Lomse library. API documentation  0.30.0
LdpExporter Class Reference

#include <lomse_ldp_exporter.h>

Detailed Description

LdpExporter is responsible for generating the LDP source format for an score. Exporting a document is a simple operation. It is just instantiating the exporter object, specifying the desired generation options and request to generate the source code. Example:

ofstream file1(path + "musicxml_export.xml", ios::out);
if (file1.good())
{
LdpExporter exporter;
ImoScore* pScore = ...
std::string source = exporter.get_source(pScore);
file1.write(source.c_str(), source.size());
file1.close();
}
else
{
std::cout << "file error write" << endl;
CHECK( false );
}

Public Member Functions

 LdpExporter ()
 
virtual ~LdpExporter ()
 
Main methods for generating the source code
std::string get_source (ImoObj *pImo)
 
Options for generating code
void set_indent_spaces (int spaces)
 
void set_remove_newlines (bool value)
 
void set_add_id (bool value)
 
Getters for current options
int get_indent_spaces ()
 
bool get_remove_newlines ()
 
bool get_add_id ()
 

Constructor & Destructor Documentation

◆ LdpExporter()

LdpExporter::LdpExporter ( )

Constructor

◆ ~LdpExporter()

virtual LdpExporter::~LdpExporter ( )
inlinevirtual

Destructor

Member Function Documentation

◆ get_add_id()

bool LdpExporter::get_add_id ( )
inline

Returns current setting: true if Ids will be generated.

◆ get_indent_spaces()

int LdpExporter::get_indent_spaces ( )
inline

Returns current setting for the number of spaces that will be generated for each indentation step.

◆ get_remove_newlines()

bool LdpExporter::get_remove_newlines ( )
inline

Returns current setting: true if neither newlines nor indentation spaces will be generated.

◆ get_source()

std::string LdpExporter::get_source ( ImoObj *  pImo)
inline

This method generates the source code for the object passed as argument. The method is oriented to generate the full source code for an score but also can be used to generate partial source code for an element. This can be useful for tests or other purposes. PLEASE take into account that not all objects can directly generate source code, and that for others the code can be incomplete.

Parameters
pImoThe object whose source code is requested.

◆ set_add_id()

void LdpExporter::set_add_id ( bool  value)
inline

This method controls generation of objects Id. When set to true the object Id will be added after each tag name, e.g "(clef#39 G)" instead of "(clef G)".

Parameters
valuetrue for generating Ids.

◆ set_indent_spaces()

void LdpExporter::set_indent_spaces ( int  spaces)
inline

This method controls the number of spaces that will be generated for each indentation step. By default, the exporter uses three spaces per step. Indentation is supressed when remove newlines is set to true. See set_remove_newlines().

Parameters
spacesThe number of spaces to use for each indentation step.

◆ set_remove_newlines()

void LdpExporter::set_remove_newlines ( bool  value)
inline

This method controls generation of newlines. When set to true maximum compactness will be achieved: no newlines and no indentation spaces will be generated. Default value is false so newlines and indentation spaces will be generated. The number of indentation spaces can be controlled with method set_indent_spaces().

Parameters
valuetrue for not generating neither newlines nor indent spaces.