Lomse library. API documentation  0.30.0
MxlExporter Class Reference

#include <lomse_mxl_exporter.h>

Detailed Description

MxlExporter is responsible for generating the MusicXML 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())
{
MxlExporter exporter(m_libraryScope);
exporter.set_remove_separator_lines(true);
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

 MxlExporter (LibraryScope &libScope)
 
virtual ~MxlExporter ()
 
Main methods for generating the source code
std::string get_source (ImoObj *pImo)
 
std::string get_source (AScore score)
 
Options for generating code
void set_indent_spaces (int spaces)
 
void set_remove_newlines (bool value)
 
void set_remove_separator_lines (bool value)
 
Getters for current options
int get_indent_spaces () const
 
bool get_remove_newlines () const
 
bool get_remove_separator_lines () const
 

Constructor & Destructor Documentation

◆ MxlExporter()

MxlExporter::MxlExporter ( LibraryScope &  libScope)

Constructor

◆ ~MxlExporter()

virtual MxlExporter::~MxlExporter ( )
virtual

Destructor

Member Function Documentation

◆ get_indent_spaces()

int MxlExporter::get_indent_spaces ( ) const
inline

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

◆ get_remove_newlines()

bool MxlExporter::get_remove_newlines ( ) const
inline

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

◆ get_remove_separator_lines()

bool MxlExporter::get_remove_separator_lines ( ) const
inline

Returns current setting: true for not generating separator lines.

◆ get_source() [1/2]

std::string MxlExporter::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.

◆ get_source() [2/2]

std::string MxlExporter::get_source ( AScore  score)

This method generates the source code for the score passed as argument.

Parameters
scoreThe score whose source code is requested.

◆ set_indent_spaces()

void MxlExporter::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 MxlExporter::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.

◆ set_remove_separator_lines()

void MxlExporter::set_remove_separator_lines ( bool  value)
inline

This method controls generation of separator lines between <measure> elements. By default, the exporter will generate separator lines.

Parameters
valuetrue for not generating separator lines.