From 02e649bd5096ff40446623293be6e61505fac876 Mon Sep 17 00:00:00 2001 From: Don Byrd Date: Mon, 12 Oct 2015 11:27:27 -0400 Subject: [PATCH 001/217] Comment out one call to LogDebug & add one (both for debugging, of course). --- src/aligner.cpp | 2 +- src/view_element.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/aligner.cpp b/src/aligner.cpp index 50c05dbc4e6..43714e7a854 100644 --- a/src/aligner.cpp +++ b/src/aligner.cpp @@ -484,7 +484,7 @@ int Alignment::SetAlignmentXPos( ArrayPtrVoid *params ) double intervalTime = (m_time - (*previousTime)); if ( intervalTime > 0.0 ) { intervalXRel = HorizontalSpaceForDuration(intervalTime, *maxActualDur); - LogDebug("SetAlignmentXPos: intervalTime=%.2f intervalXRel=%d", intervalTime, intervalXRel); + //LogDebug("SetAlignmentXPos: intervalTime=%.2f intervalXRel=%d", intervalTime, intervalXRel); } m_xRel = (*previousXRel) + (intervalXRel) * DEFINITON_FACTOR; (*previousTime) = m_time; diff --git a/src/view_element.cpp b/src/view_element.cpp index e1bc70b84b3..1f8e897641d 100644 --- a/src/view_element.cpp +++ b/src/view_element.cpp @@ -1574,6 +1574,7 @@ void View::DrawAccid( DeviceContext *dc, LayerElement *element, Layer *layer, St // Parent will be NULL if we are drawing a note @accid (see DrawNote) - the y value is already set if ( accid->m_parent ) { accid->SetDrawingY( accid->GetDrawingY() + CalculatePitchPosY( staff, accid->GetPloc(), layer->GetClefOffset( accid ), accid->GetOloc()) ); + LogDebug("DrawAccid: GetOloc()=%d", accid->GetOloc()); accid->m_drawingCueSize = accid->IsCueSize(); } From a72012a48455bdd420390337dca405a9d4a2a300 Mon Sep 17 00:00:00 2001 From: Don Byrd Date: Thu, 22 Oct 2015 15:51:59 -0400 Subject: [PATCH 002/217] Fix typos in command-line help --- tools/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/main.cpp b/tools/main.cpp index 96be357971e..0026e7ca4dc 100644 --- a/tools/main.cpp +++ b/tools/main.cpp @@ -127,11 +127,11 @@ void display_usage() { cerr << " --spacing-linear=SP Specify the linear spacing factor (default is " << DEFAULT_SPACING_LINEAR << ")" << endl; - cerr << " --spacing-non-linear=SP Specify the non linear spacing factor (default is " << DEFAULT_SPACING_NON_LINEAR << ")" << endl; + cerr << " --spacing-non-linear=SP Specify the non-linear spacing factor (default is " << DEFAULT_SPACING_NON_LINEAR << ")" << endl; - cerr << " --spacing-staff=SP Specify the spacing above each staff (in MEI vu)," << endl; + cerr << " --spacing-staff=SP Specify the spacing above each staff (in MEI vu)" << endl; - cerr << " --spacing-system=SP Specify the spacing above each system (in MEI vu)," << endl; + cerr << " --spacing-system=SP Specify the spacing above each system (in MEI vu)" << endl; // Debugging options cerr << endl << "Debugging options" << endl; From 916776e41f748b35aad7193e2ec85e52597af7a3 Mon Sep 17 00:00:00 2001 From: Don Byrd Date: Thu, 22 Oct 2015 15:53:35 -0400 Subject: [PATCH 003/217] Rewrite comments on HorizontalSpaceForDuration(); change formula for ideal space so the "linear" parameter really is linear. --- src/aligner.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/aligner.cpp b/src/aligner.cpp index c85667f69ee..195ec5bc420 100644 --- a/src/aligner.cpp +++ b/src/aligner.cpp @@ -446,7 +446,6 @@ int MeasureAligner::SetAlignmentXPos( ArrayPtrVoid *params ) // Reset the previous time position and x_rel to 0; (*previousTime) = 0.0; (*previousXRel) = 0; - return FUNCTOR_CONTINUE; } @@ -456,17 +455,23 @@ to keep consecutive symbols from overlapping or nearly overlapping: we assume sp will be increased as necessary later to avoid that. For modern notation (CMN), ideal space is a function of time interval. -The power function we currently use is isn't quite right; see _Behind Bars_, p. 39. We also -need more flexibility: for example, for some purposes, spacing propoortional to duration is -desirable. The best solution is probably to get ideal spacing from a user-definable table. */ - -int Alignment::HorizontalSpaceForDuration(double intervalTime, int maxActualDur, double spacingLinear, double spacingNonLinear) +For a discussion of the way engravers determine spacing, see Elaine Gould, _Behind Bars_, +p. 39. But we need something more flexible, because for example (1) we're interested in +music with notes of very long duration: say, music in mensural notation containing longas +or maximas; such music is usually not spaced by duration, but we support spacing by +duration if the user wishes, and standard engravers' rules would waste a lot of space; and +(2) for some purposes, spacing strictly propoortional to duration is desirable. The most +flexible solution might be to get ideal spacing from a user-definable table, but using a + formula with parameters can come close and has other advantages. */ + +int Alignment::HorizontalSpaceForDuration(double intervalTime, int maxActualDur, double spacingLinear, + double spacingNonLinear) { - /* If the longest duration interval in the score is longer than semibreve, adjust spacing so - that interval gets the space a semibreve would ordinarily get. (maxActualDur is in our - internal code format: cf. attdef.h). ??TO BE DONE */ + /* If the longest duration interval in the score is longer than semibreve, adjust spacing + so that interval gets the space a semibreve would ordinarily get. (maxActualDur is in + our internal code format: cf. attdef.h). */ if (maxActualDur < DUR_1) intervalTime /= pow(2.0, DUR_1 - maxActualDur); - int intervalXRel = pow( intervalTime, spacingNonLinear ) * pow( spacingLinear * 5.0, 2 ); + int intervalXRel = pow( intervalTime, spacingNonLinear ) * spacingLinear * 8.0; return intervalXRel; } From 42e7e56f8cb2cc995351d61c8119c2ba3afbc7ed Mon Sep 17 00:00:00 2001 From: Don Byrd Date: Thu, 12 Nov 2015 10:54:13 -0500 Subject: [PATCH 004/217] Fix typos in error messages. --- src/toolkit.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/toolkit.cpp b/src/toolkit.cpp index 7106b3fe75f..f4bd1855448 100644 --- a/src/toolkit.cpp +++ b/src/toolkit.cpp @@ -83,7 +83,7 @@ bool Toolkit::SetBorder( int border ) { // We use left margin values because for now we cannot specify different values for each margin if (border < MIN_PAGE_LEFT_MAR || border > MAX_PAGE_LEFT_MAR) { - LogError( "Border out of bounds; default is %d, minimun is %d, and maximum is %d", DEFAULT_PAGE_LEFT_MAR, MIN_PAGE_LEFT_MAR, MAX_PAGE_LEFT_MAR ); + LogError( "Border out of bounds; default is %d, minimum is %d, and maximum is %d", DEFAULT_PAGE_LEFT_MAR, MIN_PAGE_LEFT_MAR, MAX_PAGE_LEFT_MAR ); return false; } m_border = border; @@ -93,7 +93,7 @@ bool Toolkit::SetBorder( int border ) bool Toolkit::SetScale( int scale ) { if (scale < MIN_SCALE || scale > MAX_SCALE) { - LogError( "Scale out of bounds; default is %d, minimun is %d, and maximum is %d", DEFAULT_SCALE, MIN_SCALE, MAX_SCALE ); + LogError( "Scale out of bounds; default is %d, minimum is %d, and maximum is %d", DEFAULT_SCALE, MIN_SCALE, MAX_SCALE ); return false; } m_scale = scale; @@ -103,7 +103,7 @@ bool Toolkit::SetScale( int scale ) bool Toolkit::SetPageHeight( int h ) { if (h < MIN_PAGE_HEIGHT || h > MAX_PAGE_HEIGHT) { - LogError( "Page height out of bounds; default is %d, minimun is %d, and maximum is %d", DEFAULT_PAGE_HEIGHT, MIN_PAGE_HEIGHT, MAX_PAGE_HEIGHT ); + LogError( "Page height out of bounds; default is %d, minimum is %d, and maximum is %d", DEFAULT_PAGE_HEIGHT, MIN_PAGE_HEIGHT, MAX_PAGE_HEIGHT ); return false; } m_pageHeight = h; @@ -113,7 +113,7 @@ bool Toolkit::SetPageHeight( int h ) bool Toolkit::SetPageWidth( int w ) { if (w < MIN_PAGE_WIDTH || w > MAX_PAGE_WIDTH) { - LogError( "Page width out of bounds; default is %d, minimun is %d, and maximum is %d", DEFAULT_PAGE_WIDTH, MIN_PAGE_WIDTH, MAX_PAGE_WIDTH ); + LogError( "Page width out of bounds; default is %d, minimum is %d, and maximum is %d", DEFAULT_PAGE_WIDTH, MIN_PAGE_WIDTH, MAX_PAGE_WIDTH ); return false; } m_pageWidth = w; @@ -123,7 +123,7 @@ bool Toolkit::SetPageWidth( int w ) bool Toolkit::SetSpacingStaff( int spacingStaff ) { if (spacingStaff < MIN_SPACING_STAFF || spacingStaff > MAX_SPACING_STAFF) { - LogError( "Spacing staff out of bounds; default is %d, minimun is %d, and maximum is %d", DEFAULT_SPACING_STAFF, MIN_SPACING_STAFF, MAX_SPACING_STAFF ); + LogError( "Spacing staff out of bounds; default is %d, minimum is %d, and maximum is %d", DEFAULT_SPACING_STAFF, MIN_SPACING_STAFF, MAX_SPACING_STAFF ); return false; } m_spacingStaff = spacingStaff; @@ -133,7 +133,7 @@ bool Toolkit::SetSpacingStaff( int spacingStaff ) bool Toolkit::SetSpacingSystem( int spacingSystem ) { if (spacingSystem < MIN_SPACING_SYSTEM || spacingSystem > MAX_SPACING_SYSTEM) { - LogError( "Spacing system out of bounds; default is %d, minimun is %d, and maximum is %d", DEFAULT_SPACING_SYSTEM, MIN_SPACING_SYSTEM, MAX_SPACING_SYSTEM ); + LogError( "Spacing system out of bounds; default is %d, minimum is %d, and maximum is %d", DEFAULT_SPACING_SYSTEM, MIN_SPACING_SYSTEM, MAX_SPACING_SYSTEM ); return false; } m_spacingSystem = spacingSystem; @@ -143,7 +143,7 @@ bool Toolkit::SetSpacingSystem( int spacingSystem ) bool Toolkit::SetSpacingLinear( float spacingLinear ) { if (spacingLinear < MIN_SPACING_LINEAR || spacingLinear > MAX_SPACING_LINEAR) { - LogError( "Spacing (linear) out of bounds; default is %d, minimun is %d, and maximum is %d", DEFAULT_SPACING_LINEAR, MIN_SPACING_LINEAR, MAX_SPACING_LINEAR ); + LogError( "Spacing (linear) out of bounds; default is %d, minimum is %d, and maximum is %d", DEFAULT_SPACING_LINEAR, MIN_SPACING_LINEAR, MAX_SPACING_LINEAR ); return false; } m_spacingLinear = spacingLinear; @@ -153,7 +153,7 @@ bool Toolkit::SetSpacingLinear( float spacingLinear ) bool Toolkit::SetSpacingNonLinear( float spacingNonLinear ) { if (spacingNonLinear < MIN_SPACING_NON_LINEAR || spacingNonLinear > MAX_SPACING_NON_LINEAR) { - LogError( "Spacing (non linear) out of bounds; default is %d, minimun is %d, and maximum is %d", DEFAULT_SPACING_NON_LINEAR, MIN_SPACING_NON_LINEAR, MAX_SPACING_NON_LINEAR ); + LogError( "Spacing (non-linear) out of bounds; default is %d, minimum is %d, and maximum is %d", DEFAULT_SPACING_NON_LINEAR, MIN_SPACING_NON_LINEAR, MAX_SPACING_NON_LINEAR ); return false; } m_spacingNonLinear = spacingNonLinear; From 8f714160bcfc0a52b4842e5f298ef145f6bdd700 Mon Sep 17 00:00:00 2001 From: Don Byrd Date: Thu, 12 Nov 2015 11:03:40 -0500 Subject: [PATCH 005/217] Correct minor grammatical problems in comments. --- src/page.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/page.cpp b/src/page.cpp index 24ec3167db1..095bbc43eb6 100644 --- a/src/page.cpp +++ b/src/page.cpp @@ -150,7 +150,7 @@ void Page::LayOutHorizontally( ) view.DrawCurrentPage( &bb_dc, false ); // Adjust the X shift of the Alignment looking at the bounding boxes - // Look at each LayerElement and changes the m_xShift if the bouding box is overlapping + // Look at each LayerElement and change the m_xShift if the bounding box is overlapping params.clear(); int grace_min_pos = 0; params.push_back( &grace_min_pos ); @@ -167,7 +167,7 @@ void Page::LayOutHorizontally( ) this->Process( &integrateBoundingBoxGraceXShift, ¶ms ); // Adjust the X shift of the Alignment looking at the bounding boxes - // Look at each LayerElement and changes the m_xShift if the bounding box is overlapping + // Look at each LayerElement and change the m_xShift if the bounding box is overlapping params.clear(); int min_pos = 0; int measure_width = 0; @@ -232,7 +232,7 @@ void Page::LayOutVertically( ) view.DrawCurrentPage( &bb_dc, false ); // Adjust the Y shift of the StaffAlignment looking at the bounding boxes - // Look at each Staff and changes the m_yShift if the bounding box is overlapping + // Look at each Staff and change the m_yShift if the bounding box is overlapping params.clear(); int previous_height = 0; int system_height = 0; @@ -243,7 +243,7 @@ void Page::LayOutVertically( ) this->Process( &setBoundingBoxYShift, ¶ms, &setBoundingBoxYShiftEnd ); // Set the Y position of each StaffAlignment - // Adjusts the Y shift for making sure there is a minimal space (staffMargin) between each staff + // Adjust the Y shift to make sure there is a minimal space (staffMargin) between each staff params.clear(); int previousStaffHeight = 0; // 0 for the first staff, reset for each system (see System::SetAlignmentYPos) int staffMargin = doc->GetSpacingStaff() * doc->GetDrawingDoubleUnit( 100 ); // the minimal space we want to have between each staff From 8cd36d0920325dec72ef8099737039386a597afe Mon Sep 17 00:00:00 2001 From: Don Byrd Date: Thu, 12 Nov 2015 11:11:50 -0500 Subject: [PATCH 006/217] Clarify comments. --- tools/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/main.cpp b/tools/main.cpp index 0026e7ca4dc..1ab0dcfdaa8 100644 --- a/tools/main.cpp +++ b/tools/main.cpp @@ -320,7 +320,7 @@ int main(int argc, char** argv) exit(0); } - // Set the various flags + // Set the various flags in accordance with the options given toolkit.SetAdjustPageHeight(adjust_page_height); toolkit.SetNoLayout(no_layout); toolkit.SetIgnoreLayout(ignore_layout); @@ -344,7 +344,7 @@ int main(int argc, char** argv) exit(1); } - // Loaded the music font from the resource diretory + // Load the music font from the resource diretory if (!Resources::InitFonts()) { cerr << "The music font could not be loaded; please check the contents of the resource directory." << endl; exit(1); From e5f1f357633224d8f35cca6c577cd385bd45656c Mon Sep 17 00:00:00 2001 From: Don Byrd Date: Wed, 18 Nov 2015 15:58:34 -0500 Subject: [PATCH 007/217] Move #define MENSURAL_LINEWIDTH_FACTOR into style.h . --- include/vrv/style.h | 5 ++++- src/view_page.cpp | 5 +---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/vrv/style.h b/include/vrv/style.h index c82c15bd574..218ab9cb1be 100644 --- a/include/vrv/style.h +++ b/include/vrv/style.h @@ -154,6 +154,7 @@ namespace vrv { #define TEMP_STYLE_SLUR_CONTROL_POINT_FACTOR 5 // higher value means more curved at the end /* Style parameters for mensural notation */ + // Ratio of mensural notehead size to CMN notehead size for the same staff size #define MNOTEHEAD_SIZE_FACTOR 0.90 // Size of mensuration sign circle relative to space between staff lines @@ -164,7 +165,9 @@ namespace vrv { #define MSIGN_DOT_DIAM 0.5 // Relative size of figures in proportions #define PROPRT_SIZE_FACTOR 0.50 - +// Linewidth for staff lines in mensural notation, rel. to "normal" width of staff lines */ +#define MENSURAL_LINEWIDTH_FACTOR 0.5 + /** * This class contains the document default environment variables. diff --git a/src/view_page.cpp b/src/view_page.cpp index b3a68596938..9aacc3c9fd0 100644 --- a/src/view_page.cpp +++ b/src/view_page.cpp @@ -817,9 +817,6 @@ void View::DrawStaff( DeviceContext *dc, Staff *staff, Measure *measure, System } -/* Linewidth for staff lines in mensural notation, relative to the "normal" width of staff lines */ -#define MENSURAL_LINEWIDTH_FACTOR 0.5 - void View::DrawStaffLines( DeviceContext *dc, Staff *staff, Measure *measure, System *system ) { assert( dc ); @@ -847,7 +844,7 @@ void View::DrawStaffLines( DeviceContext *dc, Staff *staff, Measure *measure, Sy //dc->SetPen( m_currentColour, ToDeviceContextX( m_doc->GetDrawingStaffLineWidth(staff->m_drawingStaffSize) ), AxSOLID ); dc->SetBrush( m_currentColour , AxSOLID ); - for(j = 0;j < staff->m_drawingLines; j++) + for (j = 0;j < staff->m_drawingLines; j++) { dc->DrawLine( ToDeviceContextX (x1) , ToDeviceContextY ( yy ) , ToDeviceContextX (x2) , ToDeviceContextY ( yy ) ); // For drawing rectangles insteam of line From df26cb8b38a1176e1eb0740de1a6d841280629f8 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Tue, 1 Dec 2015 07:42:01 +0100 Subject: [PATCH 008/217] Starting version 0.9.11 --- include/vrv/vrvdef.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/vrv/vrvdef.h b/include/vrv/vrvdef.h index 0d833c2ec32..6bb01d40076 100644 --- a/include/vrv/vrvdef.h +++ b/include/vrv/vrvdef.h @@ -27,9 +27,9 @@ namespace vrv { #define VERSION_MAJOR 0 #define VERSION_MINOR 9 -#define VERSION_REVISION 10 +#define VERSION_REVISION 11 // Adds "-dev" in the version number - should be set to false for releases -#define VERSION_DEV false +#define VERSION_DEV true //---------------------------------------------------------------------------- // Typedefs From 3a71176de02f7523a1304e58676ce9daf3eb7a81 Mon Sep 17 00:00:00 2001 From: Don Byrd Date: Tue, 1 Dec 2015 14:36:13 -0500 Subject: [PATCH 009/217] Position stems on mensural notes at their horizontal centers. --- include/vrv/view.h | 4 ++- src/view_element.cpp | 59 ++++++++++++++++++++++++++++--------------- src/view_mensural.cpp | 6 ++--- 3 files changed, 43 insertions(+), 26 deletions(-) diff --git a/include/vrv/view.h b/include/vrv/view.h index d1c56972d6c..9662f4bd090 100644 --- a/include/vrv/view.h +++ b/include/vrv/view.h @@ -243,7 +243,9 @@ class View void DrawMeterSigFigures( DeviceContext *dc, int x, int y, int num, int numBase, Staff *staff); void DrawMRptPart(DeviceContext *dc, int x, wchar_t smulfCode, int num, bool line, Staff *staff, Measure *measure ); void DrawQuarterRest ( DeviceContext *dc, int x, int y, int valeur, unsigned char dots, bool cueSize, Staff *staff); - void DrawStem( DeviceContext *dc, LayerElement *object, Staff *staff, data_STEMDIRECTION dir, int radius, int xn, int originY, int heightY = 0); + void DrawStem( DeviceContext *dc, LayerElement *object, Staff *staff, bool isMensural, + data_STEMDIRECTION dir, int radius, int xn, int originY, int heightY = 0); + void DrawMensuralStem( DeviceContext *dc, LayerElement *object, Staff *staff, data_STEMDIRECTION dir, int radius, int xn, int originY, int heightY = 0); void DrawTrill(DeviceContext *dc, LayerElement *element, Staff *staff ); void DrawWholeRest ( DeviceContext *dc, int x, int y, int valeur, unsigned char dots, bool cueSize, Staff *staff); ///@} diff --git a/src/view_element.cpp b/src/view_element.cpp index 1f8e897641d..77bdcc2cc3e 100644 --- a/src/view_element.cpp +++ b/src/view_element.cpp @@ -284,11 +284,11 @@ void View::DrawNote ( DeviceContext *dc, LayerElement *element, Layer *layer, St //if the note is clustered, calculations are different if (note->m_cluster) { if (note->GetDrawingStemDir() == STEMDIRECTION_down) { - //stem down/even cluster = noteheads start on left (incorrect side) + // stem down/even cluster = noteheads start on left (incorrect side) if (note->m_cluster->size() % 2 == 0) { flippedNotehead = (note->m_clusterPosition % 2 != 0); } - //else they start on normal side + // else they start on normal side else { flippedNotehead = (note->m_clusterPosition % 2 == 0); } @@ -300,22 +300,22 @@ void View::DrawNote ( DeviceContext *dc, LayerElement *element, Layer *layer, St } } else { - //flipped noteheads start on normal side no matter what + // flipped noteheads start on normal side no matter what flippedNotehead = (note->m_clusterPosition % 2 == 0); - //if stem goes up, move ledger start to the right and expand it a full radius + // if stem goes up, move ledger start to the right and expand it a full radius if(!(note->IsClusterExtreme() && IsOnStaffLine(noteY, staff))) { xLedger += radius; doubleLengthLedger = true; } } - //positions notehead + // positions notehead if (!flippedNotehead) { xNote = xStem - radius; } else { - //if we have a flipped notehead, we need to be in a chord + // if we have a flipped notehead, we need to be in a chord assert(inChord); if (note->GetDrawingStemDir() == STEMDIRECTION_up) { xNote = xStem + radius - m_doc->GetDrawingStemWidth(staffSize); @@ -359,7 +359,7 @@ void View::DrawNote ( DeviceContext *dc, LayerElement *element, Layer *layer, St DrawSmuflCode( dc, xNote, noteY, fontNo, staff->m_drawingStaffSize, drawingCueSize ); if (!(inBeam && drawingDur > DUR_4) && !inChord) { - DrawStem(dc, note, staff, note->GetDrawingStemDir(), radius, xStem, noteY); + DrawStem(dc, note, staff, false, note->GetDrawingStemDir(), radius, xStem, noteY); } } @@ -369,7 +369,7 @@ void View::DrawNote ( DeviceContext *dc, LayerElement *element, Layer *layer, St int staffTop = staffY + m_doc->GetDrawingUnit(staffSize); int staffBot = staffY - m_doc->GetDrawingStaffSize(staffSize) - m_doc->GetDrawingUnit(staffSize); - //if the note is not in the staff + // if the note is not in the staff if (!is_in(noteY,staffTop,staffBot)) { int distance, highestNewLine, numLines; @@ -391,7 +391,7 @@ void View::DrawNote ( DeviceContext *dc, LayerElement *element, Layer *layer, St std::vector *legerLines = &inChord->m_drawingLedgerLines.at(staff); (*legerLines).at(idx) = ledgermax(numLines, (*legerLines).at(idx)); } - //we do want to go ahead and draw if it's not in a chord + // we do want to go ahead and draw if it's not in a chord else { DrawLedgerLines(dc, note, staff, aboveStaff, false, 0, numLines); } @@ -408,7 +408,7 @@ void View::DrawNote ( DeviceContext *dc, LayerElement *element, Layer *layer, St note->m_drawingAccid->SetDrawingX( xAccid ); note->m_drawingAccid->SetDrawingY( noteY ); - //postpone drawing the accidental until later if it's in a chord or if it is not an attribute + // postpone drawing the accidental until later if it's in a chord or if it is not an attribute if (!inChord && note->m_isDrawingAccidAttr) DrawAccid( dc, note->m_drawingAccid, layer, staff, measure ); } @@ -443,8 +443,14 @@ void View::DrawNote ( DeviceContext *dc, LayerElement *element, Layer *layer, St } #define STANDARD_STEMLENGTH 7 // in half staff spaces ??BUT SHOULD BE 6 IF 2-VOICE NOTATION! + +/* Draw a stem and, if needed, flags. In mensural notation, stems on the longest duration + notes -- maximas and longas -- are always aligned horizontally with the right end of the + notehead; stems on other notes -- minims and shorter, since brevis and semibrevis don't + have stems -- are always aligned with the center of the notehead. */ -void View::DrawStem( DeviceContext *dc, LayerElement *object, Staff *staff, data_STEMDIRECTION dir, int radius, int xn, int originY, int heightY) +void View::DrawStem( DeviceContext *dc, LayerElement *object, Staff *staff, bool isMensural, + data_STEMDIRECTION dir, int radius, int xn, int originY, int heightY) { assert(dynamic_cast(object)); @@ -461,22 +467,29 @@ void View::DrawStem( DeviceContext *dc, LayerElement *object, Staff *staff, data baseStem = m_doc->GetGraceSize(baseStem); flagStemHeight = m_doc->GetGraceSize(flagStemHeight); } - + nbFlags = drawingDur - DUR_8; totalFlagStemHeight = flagStemHeight * (nbFlags * 2 - 1) / 2; if (dir == STEMDIRECTION_down) { - // flip all lengths + // flip all lengths. Exception: in mensural notation, the stem will never be at left, + // so leave radius as is. baseStem = -baseStem; totalFlagStemHeight = -totalFlagStemHeight; - radius = -radius; + if (!isMensural) radius = -radius; heightY = -heightY; } - // If we have flags, add them to the height + // If we have flags, add them to the height. If duration is longa or maxima and (probably + // a redundant test) note is mensural, move stem to the right side of the notehead. int y1 = originY; int y2 = ((drawingDur>DUR_8) ? (y1 + baseStem + totalFlagStemHeight) : (y1 + baseStem)) + heightY; - int x2 = xn + radius; + int x2; + if (isMensural) { + if (drawingDurGetDrawingUnit(staffSize) / 4 : y1 - m_doc->GetDrawingUnit(staffSize) / 4; + int shortening; + if (isMensural) shortening = 0.6 * m_doc->GetDrawingUnit(staffSize); + else shortening = 0.25*m_doc->GetDrawingUnit(staffSize); + int stemY1 = (dir == STEMDIRECTION_up) ? y1 + shortening : y1 - shortening; int stemY2 = y2; if (drawingDur > DUR_4) { // if we have flags, shorten the stem to make sure we have a nice overlap with the flag glyph int shortener = (drawingCueSize) ? - m_doc->GetGraceSize(m_doc->GetDrawingUnit(staffSize)) : - m_doc->GetDrawingUnit(staffSize); + m_doc->GetGraceSize(m_doc->GetDrawingUnit(staffSize)) : + m_doc->GetDrawingUnit(staffSize); stemY2 = (dir == STEMDIRECTION_up) ? y2 - shortener : y2 + shortener; } @@ -529,7 +545,8 @@ void View::DrawStem( DeviceContext *dc, LayerElement *object, Staff *staff, data } } -//skips "skip" lines before drawing "n" ledger lines + +// skips "skip" lines before drawing "n" ledger lines void View::DrawLedgerLines ( DeviceContext *dc, LayerElement *element, Staff *staff, bool aboveStaff, bool doubleLength, int skip, int n) { //various variables @@ -1080,7 +1097,7 @@ void View::DrawChord( DeviceContext *dc, LayerElement *element, Layer *layer, St int originY = ( chord->GetDrawingStemDir() == STEMDIRECTION_down ? yMax : yMin ); int heightY = yMax - yMin; - DrawStem(dc, chord, staff, chord->GetDrawingStemDir(), radius, beamX, originY, heightY); + DrawStem(dc, chord, staff, false, chord->GetDrawingStemDir(), radius, beamX, originY, heightY); } /************ Draw children (notes) ************/ diff --git a/src/view_mensural.cpp b/src/view_mensural.cpp index 4ddd84af603..c681cce6267 100644 --- a/src/view_mensural.cpp +++ b/src/view_mensural.cpp @@ -114,7 +114,7 @@ void View::DrawMensuralNote ( DeviceContext *dc, LayerElement *element, Layer *l DrawSmuflCode( dc, xNote, noteY, charCode, pseudoStaffSize, false ); - DrawStem(dc, note, staff, note->GetDrawingStemDir(), radius, xStem, noteY); + DrawStem(dc, note, staff, true, note->GetDrawingStemDir(), radius, xStem, noteY); } /************** Ledger lines: **************/ @@ -123,8 +123,7 @@ void View::DrawMensuralNote ( DeviceContext *dc, LayerElement *element, Layer *l int staffBot = staffY - m_doc->GetDrawingStaffSize(staffSize) - m_doc->GetDrawingUnit(staffSize); //if the note is not in the staff - if (!is_in(noteY,staffTop,staffBot)) - { + if (!is_in(noteY,staffTop,staffBot)) { int distance, highestNewLine, numLines; bool aboveStaff = (noteY > staffTop); @@ -133,7 +132,6 @@ void View::DrawMensuralNote ( DeviceContext *dc, LayerElement *element, Layer *l numLines = highestNewLine / m_doc->GetDrawingDoubleUnit(staffSize); DrawLedgerLines(dc, note, staff, aboveStaff, false, 0, numLines); - } /************** dots **************/ From eea43a751b83b6e2cbc64baf2c743e337ae0ea16 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Wed, 9 Dec 2015 23:16:15 +0100 Subject: [PATCH 010/217] Update to MEI version 3.0.0 --- Verovio.xcodeproj/project.pbxproj | 22 +- emscripten/build.sh | 1 + include/vrv/att.h | 8 +- include/vrv/chord.h | 4 +- include/vrv/measure.h | 8 +- include/vrv/note.h | 4 +- include/vrv/scoredef.h | 2 + java/build.sh | 1 + libmei/att_classes.h | 34 +- libmei/atts_cmn.cpp | 310 +- libmei/atts_cmn.h | 175 +- libmei/atts_cmnornaments.h | 4 +- libmei/atts_edittrans.cpp | 26 +- libmei/atts_edittrans.h | 14 +- libmei/atts_harmony.cpp | 22 - libmei/atts_harmony.h | 11 - libmei/atts_mei.cpp | 119 + libmei/atts_mei.h | 82 + libmei/atts_mensural.h | 4 +- libmei/atts_midi.cpp | 116 + libmei/atts_midi.h | 76 + libmei/atts_neumes.h | 4 +- ...tts_linkalign.cpp => atts_performance.cpp} | 6 +- .../{atts_linkalign.h => atts_performance.h} | 8 +- libmei/atts_shared.cpp | 2964 +++++++++++------ libmei/atts_shared.h | 1654 ++++++--- libmei/atts_tablature.h | 2 +- libmei/atts_usersymbols.cpp | 97 + libmei/atts_usersymbols.h | 72 + python/setup.py | 1 + src/barline.cpp | 2 +- src/chord.cpp | 12 +- src/iomei.cpp | 16 +- src/iopae.cpp | 2 +- src/measure.cpp | 8 +- src/note.cpp | 12 +- src/scoredef.cpp | 6 + src/view_beam.cpp | 8 +- src/view_element.cpp | 6 +- src/view_page.cpp | 16 +- tools/CMakeLists.txt | 4 +- 41 files changed, 4090 insertions(+), 1853 deletions(-) create mode 100644 libmei/atts_mei.cpp create mode 100644 libmei/atts_mei.h rename libmei/{atts_linkalign.cpp => atts_performance.cpp} (92%) rename libmei/{atts_linkalign.h => atts_performance.h} (92%) create mode 100644 libmei/atts_usersymbols.cpp create mode 100644 libmei/atts_usersymbols.h diff --git a/Verovio.xcodeproj/project.pbxproj b/Verovio.xcodeproj/project.pbxproj index 2f9edee28b0..15e1c1110ee 100644 --- a/Verovio.xcodeproj/project.pbxproj +++ b/Verovio.xcodeproj/project.pbxproj @@ -86,6 +86,9 @@ 4DF28A051A754DF000BA9F7D /* floatingelement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DF28A041A754DF000BA9F7D /* floatingelement.cpp */; }; 4DF28A061A754DF000BA9F7D /* floatingelement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DF28A041A754DF000BA9F7D /* floatingelement.cpp */; }; 4DF2AF7E1A62F6A50016F869 /* drawinginterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DF2AF7D1A62F6A50016F869 /* drawinginterface.h */; }; + 4DF9D2831C18DC490069E8C8 /* atts_mei.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DF9D2811C18DC490069E8C8 /* atts_mei.cpp */; }; + 4DF9D2841C18DC490069E8C8 /* atts_mei.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DF9D2811C18DC490069E8C8 /* atts_mei.cpp */; }; + 4DF9D2851C18DC490069E8C8 /* atts_mei.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DF9D2821C18DC490069E8C8 /* atts_mei.h */; }; 8F086EE2188539540037FD8E /* aligner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F086EB6188539540037FD8E /* aligner.cpp */; }; 8F086EE4188539540037FD8E /* barline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F086EB8188539540037FD8E /* barline.cpp */; }; 8F086EE5188539540037FD8E /* bboxdevicecontext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F086EB9188539540037FD8E /* bboxdevicecontext.cpp */; }; @@ -293,8 +296,6 @@ 4DEE28FC1940BCC100C76319 /* atts_harmony.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = atts_harmony.h; path = libmei/atts_harmony.h; sourceTree = ""; }; 4DEE28FD1940BCC100C76319 /* atts_header.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atts_header.cpp; path = libmei/atts_header.cpp; sourceTree = ""; }; 4DEE28FE1940BCC100C76319 /* atts_header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = atts_header.h; path = libmei/atts_header.h; sourceTree = ""; }; - 4DEE28FF1940BCC100C76319 /* atts_linkalign.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atts_linkalign.cpp; path = libmei/atts_linkalign.cpp; sourceTree = ""; }; - 4DEE29001940BCC100C76319 /* atts_linkalign.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = atts_linkalign.h; path = libmei/atts_linkalign.h; sourceTree = ""; }; 4DEE29011940BCC100C76319 /* atts_lyrics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atts_lyrics.cpp; path = libmei/atts_lyrics.cpp; sourceTree = ""; }; 4DEE29021940BCC100C76319 /* atts_lyrics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = atts_lyrics.h; path = libmei/atts_lyrics.h; sourceTree = ""; }; 4DEE29031940BCC100C76319 /* atts_mensural.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atts_mensural.cpp; path = libmei/atts_mensural.cpp; sourceTree = ""; }; @@ -312,6 +313,12 @@ 4DF28A021A754DE400BA9F7D /* floatingelement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = floatingelement.h; path = include/vrv/floatingelement.h; sourceTree = ""; }; 4DF28A041A754DF000BA9F7D /* floatingelement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = floatingelement.cpp; path = src/floatingelement.cpp; sourceTree = ""; }; 4DF2AF7D1A62F6A50016F869 /* drawinginterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = drawinginterface.h; path = include/vrv/drawinginterface.h; sourceTree = ""; }; + 4DF9D2811C18DC490069E8C8 /* atts_mei.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atts_mei.cpp; path = libmei/atts_mei.cpp; sourceTree = ""; }; + 4DF9D2821C18DC490069E8C8 /* atts_mei.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = atts_mei.h; path = libmei/atts_mei.h; sourceTree = ""; }; + 4DF9D2861C18DE270069E8C8 /* atts_performance.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = atts_performance.cpp; path = libmei/atts_performance.cpp; sourceTree = ""; }; + 4DF9D2871C18DE270069E8C8 /* atts_performance.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = atts_performance.h; path = libmei/atts_performance.h; sourceTree = ""; }; + 4DF9D2881C18DE270069E8C8 /* atts_usersymbols.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = atts_usersymbols.cpp; path = libmei/atts_usersymbols.cpp; sourceTree = ""; }; + 4DF9D2891C18DE270069E8C8 /* atts_usersymbols.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = atts_usersymbols.h; path = libmei/atts_usersymbols.h; sourceTree = ""; }; 8F086EA9188534680037FD8E /* Verovio */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Verovio; sourceTree = BUILT_PRODUCTS_DIR; }; 8F086EB6188539540037FD8E /* aligner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = aligner.cpp; path = src/aligner.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 8F086EB8188539540037FD8E /* barline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = barline.cpp; path = src/barline.cpp; sourceTree = ""; }; @@ -485,22 +492,26 @@ 4DEE28FC1940BCC100C76319 /* atts_harmony.h */, 4DEE28FD1940BCC100C76319 /* atts_header.cpp */, 4DEE28FE1940BCC100C76319 /* atts_header.h */, - 4DEE28FF1940BCC100C76319 /* atts_linkalign.cpp */, - 4DEE29001940BCC100C76319 /* atts_linkalign.h */, 4DEE29011940BCC100C76319 /* atts_lyrics.cpp */, 4DEE29021940BCC100C76319 /* atts_lyrics.h */, + 4DF9D2811C18DC490069E8C8 /* atts_mei.cpp */, + 4DF9D2821C18DC490069E8C8 /* atts_mei.h */, 4DEE29031940BCC100C76319 /* atts_mensural.cpp */, 4DEE29041940BCC100C76319 /* atts_mensural.h */, 4DEE29051940BCC100C76319 /* atts_midi.cpp */, 4DEE29061940BCC100C76319 /* atts_midi.h */, 4D3FF8D919BADD7A00B105B5 /* atts_pagebased.cpp */, 4D3FF8DA19BADD7A00B105B5 /* atts_pagebased.h */, + 4DF9D2861C18DE270069E8C8 /* atts_performance.cpp */, + 4DF9D2871C18DE270069E8C8 /* atts_performance.h */, 4DEE29071940BCC100C76319 /* atts_neumes.cpp */, 4DEE29081940BCC100C76319 /* atts_neumes.h */, 4DEE29091940BCC100C76319 /* atts_shared.cpp */, 4DEE290A1940BCC100C76319 /* atts_shared.h */, 4DEE290B1940BCC100C76319 /* atts_tablature.cpp */, 4DEE290C1940BCC100C76319 /* atts_tablature.h */, + 4DF9D2881C18DE270069E8C8 /* atts_usersymbols.cpp */, + 4DF9D2891C18DE270069E8C8 /* atts_usersymbols.h */, ); name = libmei; sourceTree = ""; @@ -733,6 +744,7 @@ 4D9C53131B52E4AE0003C6EC /* unchecked.h in Headers */, 4DF28A031A754DE400BA9F7D /* floatingelement.h in Headers */, 8F59294D18854BF800FE51AD /* pitchinterface.h in Headers */, + 4DF9D2851C18DC490069E8C8 /* atts_mei.h in Headers */, 8F59294E18854BF800FE51AD /* positioninterface.h in Headers */, 8F59294F18854BF800FE51AD /* rest.h in Headers */, 4DF289FD1A7545CC00BA9F7D /* timeinterface.h in Headers */, @@ -917,6 +929,7 @@ 4D9A9C1E19A1DE2000028D93 /* syl.cpp in Sources */, 4DA3FCD319B61DB300CBDFE6 /* atts_cmn.cpp in Sources */, 4DF28A051A754DF000BA9F7D /* floatingelement.cpp in Sources */, + 4DF9D2831C18DC490069E8C8 /* atts_mei.cpp in Sources */, 4D3FF8DB19BADD7A00B105B5 /* atts_pagebased.cpp in Sources */, 4DC34BA819BC4A83006175CD /* accid.cpp in Sources */, 4DC34BAA19BC4A83006175CD /* custos.cpp in Sources */, @@ -947,6 +960,7 @@ 8F3DD34218854B2E0051330C /* durationinterface.cpp in Sources */, 8F3DD34418854B2E0051330C /* keysig.cpp in Sources */, 4DF28A001A7545E500BA9F7D /* timeinterface.cpp in Sources */, + 4DF9D2841C18DC490069E8C8 /* atts_mei.cpp in Sources */, 4DA60EE71B6307B9006E2DFC /* textdirinterface.cpp in Sources */, 8F3DD34618854B2E0051330C /* layerelement.cpp in Sources */, 4D798CBE1B8AEDBA007281CA /* drawinginterface.cpp in Sources */, diff --git a/emscripten/build.sh b/emscripten/build.sh index 1a8422376d6..f0f1b7be56c 100755 --- a/emscripten/build.sh +++ b/emscripten/build.sh @@ -161,6 +161,7 @@ python $EMCC $CHATTY \ $VEROVIO_ROOT/src/pugixml.cpp \ $VEROVIO_ROOT/libmei/atts_cmn.cpp \ $VEROVIO_ROOT/libmei/atts_critapp.cpp \ + $VEROVIO_ROOT/libmei/atts_mei.cpp \ $VEROVIO_ROOT/libmei/atts_mensural.cpp \ $VEROVIO_ROOT/libmei/atts_shared.cpp \ $VEROVIO_ROOT/libmei/atts_pagebased.cpp \ diff --git a/include/vrv/att.h b/include/vrv/att.h index a803c40f5d6..0b9c1f32038 100644 --- a/include/vrv/att.h +++ b/include/vrv/att.h @@ -53,14 +53,16 @@ class Att //static bool SetFigtable( Object *element, std::string attrType, std::string attrValue ); //static bool SetHarmony( Object *element, std::string attrType, std::string attrValue ); //static bool SetHeader( Object *element, std::string attrType, std::string attrValue ); - //static bool SetLinkalign( Object *element, std::string attrType, std::string attrValue ); //static bool SetLyrics( Object *element, std::string attrType, std::string attrValue ); + static bool SetMei( Object *element, std::string attrType, std::string attrValue ); static bool SetMensural( Object *element, std::string attrType, std::string attrValue ); //static bool SetMidi( Object *element, std::string attrType, std::string attrValue ); static bool SetPagebased( Object *element, std::string attrType, std::string attrValue ); + //static bool SetPerformance( Object *element, std::string attrType, std::string attrValue ); //static bool SetNeumes( Object *element, std::string attrType, std::string attrValue ); static bool SetShared( Object *element, std::string attrType, std::string attrValue ); //static bool SetTablature( Object *element, std::string attrType, std::string attrValue ); + //static bool SetUsersymbols( Object *element, std::string attrType, std::string attrValue ); /** * Idem for getting attributes as strings @@ -74,14 +76,16 @@ class Att //static void GetFigtable( Object *element, ArrayOfStrAttr *attributes ); //static void GetHarmony( Object *element, ArrayOfStrAttr *attributes ); //static void GetHeader( Object *element, ArrayOfStrAttr *attributes ); - //static void GetLinkalign( Object *element, ArrayOfStrAttr *attributes ); //static void GetLyrics( Object *element, ArrayOfStrAttr *attributes ); + static void GetMei( Object *element, ArrayOfStrAttr *attributes ); static void GetMensural( Object *element, ArrayOfStrAttr *attributes ); //static void GetMidi( Object *element, ArrayOfStrAttr *attributes ); static void GetPagebased( Object *element, ArrayOfStrAttr *attributes ); + //static void GetPerformance( Object *element, ArrayOfStrAttr *attributes ); //static void GetNeumes( Object *element, ArrayOfStrAttr *attributes ); static void GetShared( Object *element, ArrayOfStrAttr *attributes ); //static void GetTablature( Object *element, ArrayOfStrAttr *attributes ); + //static void GetUsersymbols( Object *element, ArrayOfStrAttr *attributes ); ///@} public: diff --git a/include/vrv/chord.h b/include/vrv/chord.h index 23a7b7dbc28..98d158aefcd 100644 --- a/include/vrv/chord.h +++ b/include/vrv/chord.h @@ -32,8 +32,8 @@ namespace vrv { class Chord: public LayerElement, public ObjectListInterface, public StemmedDrawingInterface, public DurationInterface, public AttCommon, - public AttStemmed, - public AttStemmedCmn, + public AttStems, + public AttStemsCmn, public AttTiepresent { public: diff --git a/include/vrv/measure.h b/include/vrv/measure.h index d8be18c4a05..025edde50d9 100644 --- a/include/vrv/measure.h +++ b/include/vrv/measure.h @@ -74,10 +74,10 @@ class Measure: public DocObject, * void SetLeftBarlineType( data_BARRENDITION type ) { m_leftBarline.SetRend(type); SetLeft(type); }; */ ///@{ - data_BARRENDITION GetLeftBarlineType() const { return m_leftBarline.GetRend(); }; - void SetLeftBarlineType( data_BARRENDITION type ) { m_leftBarline.SetRend(type); }; - data_BARRENDITION GetRightBarlineType() const { return m_rightBarline.GetRend(); }; - void SetRightBarlineType( data_BARRENDITION type ) { m_rightBarline.SetRend(type); }; + data_BARRENDITION GetLeftBarlineType() const { return m_leftBarline.GetForm(); }; + void SetLeftBarlineType( data_BARRENDITION type ) { m_leftBarline.SetForm(type); }; + data_BARRENDITION GetRightBarlineType() const { return m_rightBarline.GetForm(); }; + void SetRightBarlineType( data_BARRENDITION type ) { m_rightBarline.SetForm(type); }; ///@} /** diff --git a/include/vrv/note.h b/include/vrv/note.h index f05e5872ade..05e330ae975 100644 --- a/include/vrv/note.h +++ b/include/vrv/note.h @@ -46,8 +46,8 @@ class Note: public LayerElement, public StemmedDrawingInterface, public Duration public AttColoration, public AttGraced, public AttNoteLogMensural, - public AttStemmed, - public AttStemmedCmn, + public AttStems, + public AttStemsCmn, public AttTiepresent { public: diff --git a/include/vrv/scoredef.h b/include/vrv/scoredef.h index d48f73deeb4..5d9abad689a 100644 --- a/include/vrv/scoredef.h +++ b/include/vrv/scoredef.h @@ -206,6 +206,7 @@ class ScoreDef: public ScoreDefElement, public ObjectListInterface */ class StaffGrp: public Object, public ObjectListInterface, public AttCommon, + public AttCommonPart, public AttLabelsAddl, public AttStaffgroupingsym, public AttStaffGrpVis @@ -261,6 +262,7 @@ class StaffGrp: public Object, public ObjectListInterface, */ class StaffDef: public ScoreDefElement, public StaffDefDrawingInterface, public AttCommon, + public AttCommonPart, public AttLabelsAddl, public AttScalable, public AttStaffDefVis diff --git a/java/build.sh b/java/build.sh index 077307caeba..bb9f1b1084a 100755 --- a/java/build.sh +++ b/java/build.sh @@ -77,6 +77,7 @@ FILES="../src/accid.cpp \ ../libmei/atts_shared.cpp \ ../libmei/atts_cmn.cpp \ ../libmei/atts_critapp.cpp \ + ../libmei/atts_mei.cpp \ ../libmei/atts_mensural.cpp \ ../libmei/atts_pagebased.cpp" diff --git a/libmei/att_classes.h b/libmei/att_classes.h index d8f7a8a37cc..5a67180c7b1 100644 --- a/libmei/att_classes.h +++ b/libmei/att_classes.h @@ -21,6 +21,7 @@ namespace vrv { enum AttClassId { ATT_CLASS_min = 0, + ATT_NOTATIONTYPE, ATT_COMMONANL, ATT_HARMONICFUNCTION, ATT_INTERVALHARMONIC, @@ -36,13 +37,13 @@ enum AttClassId { ATT_BEAMINGLOG, ATT_BEAMREND, ATT_BEAMSECONDARY, + ATT_BEATRPTLOG, ATT_BEATRPTVIS, ATT_BENDGES, ATT_CUTOUT, ATT_EXPANDABLE, ATT_FTREMLOG, ATT_FERMATAVIS, - ATT_GLISSVIS, ATT_GRACED, ATT_HAIRPINLOG, ATT_HAIRPINVIS, @@ -59,7 +60,7 @@ enum AttClassId { ATT_REHEARSAL, ATT_SCOREDEFVISCMN, ATT_SLURREND, - ATT_STEMMEDCMN, + ATT_STEMSCMN, ATT_TIEREND, ATT_TREMMEASURED, ATT_TUPLETVIS, @@ -70,7 +71,7 @@ enum AttClassId { ATT_CRIT, ATT_SOURCE, ATT_AGENTIDENT, - ATT_EDIT, + ATT_EVIDENCE, ATT_EXTENT, ATT_REASONIDENT, ATT_FACSIMILE, @@ -79,7 +80,6 @@ enum AttClassId { ATT_HARMLOG, ATT_HARMVIS, ATT_REGULARMETHOD, - ATT_ALIGNMENT, ATT_VERSELOG, ATT_LIGATURELOG, ATT_MENSURVIS, @@ -93,14 +93,16 @@ enum AttClassId { ATT_MIDINUMBER, ATT_MIDITEMPO, ATT_MIDIVALUE, + ATT_MIDIVALUE2, + ATT_MIDIVELOCITY, ATT_TIMEBASE, ATT_INEUMELOG, ATT_UNEUMELOG, ATT_SURFACE, + ATT_ALIGNMENT, ATT_ACCIDLOG, ATT_ACCIDENTAL, ATT_ACCIDENTALPERFORMED, - ATT_ALTSYM, ATT_ARTICULATION, ATT_ARTICULATIONPERFORMED, ATT_AUGMENTDOTS, @@ -112,14 +114,15 @@ enum AttClassId { ATT_CALENDARED, ATT_CANONICAL, ATT_CHORDVIS, + ATT_CLASSCODEIDENT, ATT_CLEFLOG, ATT_CLEFFINGLOG, ATT_CLEFFINGVIS, ATT_CLEFSHAPE, - ATT_CODED, ATT_COLOR, ATT_COLORATION, ATT_COMMON, + ATT_COMMONPART, ATT_COORDINATED, ATT_CURVATURE, ATT_CURVEREND, @@ -135,8 +138,13 @@ enum AttClassId { ATT_DURATIONPERFORMED, ATT_DURATIONRATIO, ATT_ENCLOSINGCHARS, + ATT_ENDINGS, + ATT_EXTENDER, ATT_FERMATAPRESENT, + ATT_FILING, + ATT_GRPSYMLOG, ATT_HANDIDENT, + ATT_HEIGHT, ATT_HORIZONTALALIGN, ATT_INSTRUMENTIDENT, ATT_INTERNETMEDIA, @@ -148,11 +156,14 @@ enum AttClassId { ATT_LANG, ATT_LAYERLOG, ATT_LAYERIDENT, + ATT_LINEVIS, ATT_LINELOC, ATT_LINEREND, + ATT_LINERENDBASE, ATT_LYRICSTYLE, ATT_MEASURELOG, ATT_MEASUREMENT, + ATT_MEASURENUMBERS, ATT_MEDIABOUNDS, ATT_MEDIUM, ATT_MEIVERSION, @@ -166,18 +177,22 @@ enum AttClassId { ATT_MMTEMPO, ATT_MULTINUMMEASURES, ATT_NAME, + ATT_NOTATIONSTYLE, ATT_NOTEGES, - ATT_NOTEVIS, + ATT_NOTEHEADS, ATT_OCTAVE, ATT_OCTAVEDEFAULT, ATT_OCTAVEDISPLACEMENT, ATT_ONELINESTAFF, + ATT_OPTIMIZATION, ATT_PADLOG, + ATT_PAGES, ATT_PBVIS, ATT_PITCH, ATT_PLACEMENT, ATT_PLIST, ATT_POINTING, + ATT_QUANTITY, ATT_RELATIVESIZE, ATT_RESPONSIBILITY, ATT_SBVIS, @@ -189,6 +204,7 @@ enum AttClassId { ATT_SLASHCOUNT, ATT_SLURPRESENT, ATT_SPACEVIS, + ATT_SPACING, ATT_STAFFLOG, ATT_STAFFDEFVIS, ATT_STAFFGRPVIS, @@ -198,9 +214,10 @@ enum AttClassId { ATT_STAFFLOCPITCHED, ATT_STARTENDID, ATT_STARTID, - ATT_STEMMED, + ATT_STEMS, ATT_SYLLOG, ATT_SYLTEXT, + ATT_SYSTEMS, ATT_TEXTSTYLE, ATT_TIEPRESENT, ATT_TIMESTAMPMUSICAL, @@ -223,6 +240,7 @@ enum AttClassId { ATT_XY2, ATT_NOTEGESTABLATURE, ATT_STAFFDEFGESTABLATURE, + ATT_ALTSYM, ATT_CLASS_max }; diff --git a/libmei/atts_cmn.cpp b/libmei/atts_cmn.cpp index e286f5f718b..0d9f40dccea 100644 --- a/libmei/atts_cmn.cpp +++ b/libmei/atts_cmn.cpp @@ -125,13 +125,13 @@ AttBTremLog::~AttBTremLog() { } void AttBTremLog::ResetBTremLog() { - m_form = ""; + m_form = BEATRPT_REND_NONE; } bool AttBTremLog::ReadBTremLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("form")) { - this->SetForm(StrToStr(element.attribute("form").value())); + this->SetForm(StrToBeatrptRend(element.attribute("form").value())); element.remove_attribute("form"); hasAttribute = true; } @@ -141,7 +141,7 @@ bool AttBTremLog::ReadBTremLog( pugi::xml_node element ) { bool AttBTremLog::WriteBTremLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasForm()) { - element.append_attribute("form") = StrToStr(this->GetForm()).c_str(); + element.append_attribute("form") = BeatrptRendToStr(this->GetForm()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -149,7 +149,7 @@ bool AttBTremLog::WriteBTremLog( pugi::xml_node element ) { bool AttBTremLog::HasForm( ) { - return (m_form != ""); + return (m_form != BEATRPT_REND_NONE); } @@ -312,15 +312,15 @@ AttBeamrend::~AttBeamrend() { } void AttBeamrend::ResetBeamrend() { - m_rend = BEATRPT_REND_NONE; + m_form = BEATRPT_REND_NONE; m_slopeDbl = 0.0; } bool AttBeamrend::ReadBeamrend( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("rend")) { - this->SetRend(StrToBeatrptRend(element.attribute("rend").value())); - element.remove_attribute("rend"); + if (element.attribute("form")) { + this->SetForm(StrToBeatrptRend(element.attribute("form").value())); + element.remove_attribute("form"); hasAttribute = true; } if (element.attribute("slope")) { @@ -333,8 +333,8 @@ bool AttBeamrend::ReadBeamrend( pugi::xml_node element ) { bool AttBeamrend::WriteBeamrend( pugi::xml_node element ) { bool wroteAttribute = false; - if (this->HasRend()) { - element.append_attribute("rend") = BeatrptRendToStr(this->GetRend()).c_str(); + if (this->HasForm()) { + element.append_attribute("form") = BeatrptRendToStr(this->GetForm()).c_str(); wroteAttribute = true; } if (this->HasSlope()) { @@ -344,9 +344,9 @@ bool AttBeamrend::WriteBeamrend( pugi::xml_node element ) { return wroteAttribute; } -bool AttBeamrend::HasRend( ) +bool AttBeamrend::HasForm( ) { - return (m_rend != BEATRPT_REND_NONE); + return (m_form != BEATRPT_REND_NONE); } bool AttBeamrend::HasSlope( ) @@ -400,6 +400,49 @@ bool AttBeamsecondary::HasBreaksec( ) /* include */ +//---------------------------------------------------------------------------- +// AttBeatRptLog +//---------------------------------------------------------------------------- + +AttBeatRptLog::AttBeatRptLog(): Att() { + ResetBeatRptLog(); +} + +AttBeatRptLog::~AttBeatRptLog() { + +} + +void AttBeatRptLog::ResetBeatRptLog() { + m_beatDef = ""; +} + +bool AttBeatRptLog::ReadBeatRptLog( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("beatDef")) { + this->SetBeatDef(StrToStr(element.attribute("beatDef").value())); + element.remove_attribute("beatDef"); + hasAttribute = true; + } + return hasAttribute; +} + +bool AttBeatRptLog::WriteBeatRptLog( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasBeatDef()) { + element.append_attribute("beatDef") = StrToStr(this->GetBeatDef()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttBeatRptLog::HasBeatDef( ) +{ + return (m_beatDef != ""); +} + + +/* include */ + //---------------------------------------------------------------------------- // AttBeatRptVis //---------------------------------------------------------------------------- @@ -413,14 +456,14 @@ AttBeatRptVis::~AttBeatRptVis() { } void AttBeatRptVis::ResetBeatRptVis() { - m_rend = BEATRPT_REND_NONE; + m_form = BEATRPT_REND_NONE; } bool AttBeatRptVis::ReadBeatRptVis( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("rend")) { - this->SetRend(StrToBeatrptRend(element.attribute("rend").value())); - element.remove_attribute("rend"); + if (element.attribute("form")) { + this->SetForm(StrToBeatrptRend(element.attribute("form").value())); + element.remove_attribute("form"); hasAttribute = true; } return hasAttribute; @@ -428,20 +471,20 @@ bool AttBeatRptVis::ReadBeatRptVis( pugi::xml_node element ) { bool AttBeatRptVis::WriteBeatRptVis( pugi::xml_node element ) { bool wroteAttribute = false; - if (this->HasRend()) { - element.append_attribute("rend") = BeatrptRendToStr(this->GetRend()).c_str(); + if (this->HasForm()) { + element.append_attribute("form") = BeatrptRendToStr(this->GetForm()).c_str(); wroteAttribute = true; } return wroteAttribute; } -bool AttBeatRptVis::HasRend( ) +bool AttBeatRptVis::HasForm( ) { - return (m_rend != BEATRPT_REND_NONE); + return (m_form != BEATRPT_REND_NONE); } -/* include */ +/* include */ //---------------------------------------------------------------------------- // AttBendGes @@ -585,13 +628,13 @@ AttFTremLog::~AttFTremLog() { } void AttFTremLog::ResetFTremLog() { - m_form = ""; + m_form = BEATRPT_REND_NONE; } bool AttFTremLog::ReadFTremLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("form")) { - this->SetForm(StrToStr(element.attribute("form").value())); + this->SetForm(StrToBeatrptRend(element.attribute("form").value())); element.remove_attribute("form"); hasAttribute = true; } @@ -601,7 +644,7 @@ bool AttFTremLog::ReadFTremLog( pugi::xml_node element ) { bool AttFTremLog::WriteFTremLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasForm()) { - element.append_attribute("form") = StrToStr(this->GetForm()).c_str(); + element.append_attribute("form") = BeatrptRendToStr(this->GetForm()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -609,7 +652,7 @@ bool AttFTremLog::WriteFTremLog( pugi::xml_node element ) { bool AttFTremLog::HasForm( ) { - return (m_form != ""); + return (m_form != BEATRPT_REND_NONE); } @@ -628,14 +671,14 @@ AttFermataVis::~AttFermataVis() { } void AttFermataVis::ResetFermataVis() { - m_form = ""; + m_form = BEATRPT_REND_NONE; m_shape = ""; } bool AttFermataVis::ReadFermataVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("form")) { - this->SetForm(StrToStr(element.attribute("form").value())); + this->SetForm(StrToBeatrptRend(element.attribute("form").value())); element.remove_attribute("form"); hasAttribute = true; } @@ -650,7 +693,7 @@ bool AttFermataVis::ReadFermataVis( pugi::xml_node element ) { bool AttFermataVis::WriteFermataVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasForm()) { - element.append_attribute("form") = StrToStr(this->GetForm()).c_str(); + element.append_attribute("form") = BeatrptRendToStr(this->GetForm()).c_str(); wroteAttribute = true; } if (this->HasShape()) { @@ -662,7 +705,7 @@ bool AttFermataVis::WriteFermataVis( pugi::xml_node element ) { bool AttFermataVis::HasForm( ) { - return (m_form != ""); + return (m_form != BEATRPT_REND_NONE); } bool AttFermataVis::HasShape( ) @@ -673,49 +716,6 @@ bool AttFermataVis::HasShape( ) /* include */ -//---------------------------------------------------------------------------- -// AttGlissVis -//---------------------------------------------------------------------------- - -AttGlissVis::AttGlissVis(): Att() { - ResetGlissVis(); -} - -AttGlissVis::~AttGlissVis() { - -} - -void AttGlissVis::ResetGlissVis() { - m_text = ""; -} - -bool AttGlissVis::ReadGlissVis( pugi::xml_node element ) { - bool hasAttribute = false; - if (element.attribute("text")) { - this->SetText(StrToStr(element.attribute("text").value())); - element.remove_attribute("text"); - hasAttribute = true; - } - return hasAttribute; -} - -bool AttGlissVis::WriteGlissVis( pugi::xml_node element ) { - bool wroteAttribute = false; - if (this->HasText()) { - element.append_attribute("text") = StrToStr(this->GetText()).c_str(); - wroteAttribute = true; - } - return wroteAttribute; -} - -bool AttGlissVis::HasText( ) -{ - return (m_text != ""); -} - - -/* include */ - //---------------------------------------------------------------------------- // AttGraced //---------------------------------------------------------------------------- @@ -787,23 +787,33 @@ AttHairpinLog::~AttHairpinLog() { } void AttHairpinLog::ResetHairpinLog() { - m_form = ""; + m_form = BEATRPT_REND_NONE; + m_niente = ""; } bool AttHairpinLog::ReadHairpinLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("form")) { - this->SetForm(StrToStr(element.attribute("form").value())); + this->SetForm(StrToBeatrptRend(element.attribute("form").value())); element.remove_attribute("form"); hasAttribute = true; } + if (element.attribute("niente")) { + this->SetNiente(StrToStr(element.attribute("niente").value())); + element.remove_attribute("niente"); + hasAttribute = true; + } return hasAttribute; } bool AttHairpinLog::WriteHairpinLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasForm()) { - element.append_attribute("form") = StrToStr(this->GetForm()).c_str(); + element.append_attribute("form") = BeatrptRendToStr(this->GetForm()).c_str(); + wroteAttribute = true; + } + if (this->HasNiente()) { + element.append_attribute("niente") = StrToStr(this->GetNiente()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -811,11 +821,16 @@ bool AttHairpinLog::WriteHairpinLog( pugi::xml_node element ) { bool AttHairpinLog::HasForm( ) { - return (m_form != ""); + return (m_form != BEATRPT_REND_NONE); } +bool AttHairpinLog::HasNiente( ) +{ + return (m_niente != ""); +} -/* include */ + +/* include */ //---------------------------------------------------------------------------- // AttHairpinVis @@ -1322,14 +1337,14 @@ AttPedalVis::~AttPedalVis() { } void AttPedalVis::ResetPedalVis() { - m_style = ""; + m_form = BEATRPT_REND_NONE; } bool AttPedalVis::ReadPedalVis( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("style")) { - this->SetStyle(StrToStr(element.attribute("style").value())); - element.remove_attribute("style"); + if (element.attribute("form")) { + this->SetForm(StrToBeatrptRend(element.attribute("form").value())); + element.remove_attribute("form"); hasAttribute = true; } return hasAttribute; @@ -1337,20 +1352,20 @@ bool AttPedalVis::ReadPedalVis( pugi::xml_node element ) { bool AttPedalVis::WritePedalVis( pugi::xml_node element ) { bool wroteAttribute = false; - if (this->HasStyle()) { - element.append_attribute("style") = StrToStr(this->GetStyle()).c_str(); + if (this->HasForm()) { + element.append_attribute("form") = BeatrptRendToStr(this->GetForm()).c_str(); wroteAttribute = true; } return wroteAttribute; } -bool AttPedalVis::HasStyle( ) +bool AttPedalVis::HasForm( ) { - return (m_style != ""); + return (m_form != BEATRPT_REND_NONE); } -/* include */ +/* include */ //---------------------------------------------------------------------------- // AttPianopedals @@ -1525,29 +1540,23 @@ bool AttSlurrend::HasSlurRend( ) /* include */ //---------------------------------------------------------------------------- -// AttStemmedCmn +// AttStemsCmn //---------------------------------------------------------------------------- -AttStemmedCmn::AttStemmedCmn(): Att() { - ResetStemmedCmn(); +AttStemsCmn::AttStemsCmn(): Att() { + ResetStemsCmn(); } -AttStemmedCmn::~AttStemmedCmn() { +AttStemsCmn::~AttStemsCmn() { } -void AttStemmedCmn::ResetStemmedCmn() { - m_stemMod = STEMMODIFIER_NONE; +void AttStemsCmn::ResetStemsCmn() { m_stemWith = ""; } -bool AttStemmedCmn::ReadStemmedCmn( pugi::xml_node element ) { +bool AttStemsCmn::ReadStemsCmn( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("stem.mod")) { - this->SetStemMod(StrToStemModifier(element.attribute("stem.mod").value())); - element.remove_attribute("stem.mod"); - hasAttribute = true; - } if (element.attribute("stem.with")) { this->SetStemWith(StrToStr(element.attribute("stem.with").value())); element.remove_attribute("stem.with"); @@ -1556,12 +1565,8 @@ bool AttStemmedCmn::ReadStemmedCmn( pugi::xml_node element ) { return hasAttribute; } -bool AttStemmedCmn::WriteStemmedCmn( pugi::xml_node element ) { +bool AttStemsCmn::WriteStemsCmn( pugi::xml_node element ) { bool wroteAttribute = false; - if (this->HasStemMod()) { - element.append_attribute("stem.mod") = StemModifierToStr(this->GetStemMod()).c_str(); - wroteAttribute = true; - } if (this->HasStemWith()) { element.append_attribute("stem.with") = StrToStr(this->GetStemWith()).c_str(); wroteAttribute = true; @@ -1569,12 +1574,7 @@ bool AttStemmedCmn::WriteStemmedCmn( pugi::xml_node element ) { return wroteAttribute; } -bool AttStemmedCmn::HasStemMod( ) -{ - return (m_stemMod != STEMMODIFIER_NONE); -} - -bool AttStemmedCmn::HasStemWith( ) +bool AttStemsCmn::HasStemWith( ) { return (m_stemWith != ""); } @@ -1777,7 +1777,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttBTremLog *att = dynamic_cast(element); assert( att ); if (attrType == "form") { - att->SetForm(att->StrToStr(attrValue)); + att->SetForm(att->StrToBeatrptRend(attrValue)); return true; } } @@ -1812,8 +1812,8 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) if (element->HasAttClass( ATT_BEAMREND ) ) { AttBeamrend *att = dynamic_cast(element); assert( att ); - if (attrType == "rend") { - att->SetRend(att->StrToBeatrptRend(attrValue)); + if (attrType == "form") { + att->SetForm(att->StrToBeatrptRend(attrValue)); return true; } if (attrType == "slopeDbl") { @@ -1829,11 +1829,19 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) return true; } } + if (element->HasAttClass( ATT_BEATRPTLOG ) ) { + AttBeatRptLog *att = dynamic_cast(element); + assert( att ); + if (attrType == "beatDef") { + att->SetBeatDef(att->StrToStr(attrValue)); + return true; + } + } if (element->HasAttClass( ATT_BEATRPTVIS ) ) { AttBeatRptVis *att = dynamic_cast(element); assert( att ); - if (attrType == "rend") { - att->SetRend(att->StrToBeatrptRend(attrValue)); + if (attrType == "form") { + att->SetForm(att->StrToBeatrptRend(attrValue)); return true; } } @@ -1865,7 +1873,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttFTremLog *att = dynamic_cast(element); assert( att ); if (attrType == "form") { - att->SetForm(att->StrToStr(attrValue)); + att->SetForm(att->StrToBeatrptRend(attrValue)); return true; } } @@ -1873,7 +1881,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttFermataVis *att = dynamic_cast(element); assert( att ); if (attrType == "form") { - att->SetForm(att->StrToStr(attrValue)); + att->SetForm(att->StrToBeatrptRend(attrValue)); return true; } if (attrType == "shape") { @@ -1881,14 +1889,6 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) return true; } } - if (element->HasAttClass( ATT_GLISSVIS ) ) { - AttGlissVis *att = dynamic_cast(element); - assert( att ); - if (attrType == "text") { - att->SetText(att->StrToStr(attrValue)); - return true; - } - } if (element->HasAttClass( ATT_GRACED ) ) { AttGraced *att = dynamic_cast(element); assert( att ); @@ -1905,7 +1905,11 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttHairpinLog *att = dynamic_cast(element); assert( att ); if (attrType == "form") { - att->SetForm(att->StrToStr(attrValue)); + att->SetForm(att->StrToBeatrptRend(attrValue)); + return true; + } + if (attrType == "niente") { + att->SetNiente(att->StrToStr(attrValue)); return true; } } @@ -2012,8 +2016,8 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) if (element->HasAttClass( ATT_PEDALVIS ) ) { AttPedalVis *att = dynamic_cast(element); assert( att ); - if (attrType == "style") { - att->SetStyle(att->StrToStr(attrValue)); + if (attrType == "form") { + att->SetForm(att->StrToBeatrptRend(attrValue)); return true; } } @@ -2049,13 +2053,9 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) return true; } } - if (element->HasAttClass( ATT_STEMMEDCMN ) ) { - AttStemmedCmn *att = dynamic_cast(element); + if (element->HasAttClass( ATT_STEMSCMN ) ) { + AttStemsCmn *att = dynamic_cast(element); assert( att ); - if (attrType == "stemMod") { - att->SetStemMod(att->StrToStemModifier(attrValue)); - return true; - } if (attrType == "stemWith") { att->SetStemWith(att->StrToStr(attrValue)); return true; @@ -2120,7 +2120,7 @@ void Att::GetCmn( Object *element, ArrayOfStrAttr *attributes ) { AttBTremLog *att = dynamic_cast(element); assert( att ); if (att->HasForm()) { - attributes->push_back(std::make_pair("form", att->StrToStr(att->GetForm()))); + attributes->push_back(std::make_pair("form", att->BeatrptRendToStr(att->GetForm()))); } } if (element->HasAttClass( ATT_BEAMED ) ) { @@ -2150,8 +2150,8 @@ void Att::GetCmn( Object *element, ArrayOfStrAttr *attributes ) { if (element->HasAttClass( ATT_BEAMREND ) ) { AttBeamrend *att = dynamic_cast(element); assert( att ); - if (att->HasRend()) { - attributes->push_back(std::make_pair("rend", att->BeatrptRendToStr(att->GetRend()))); + if (att->HasForm()) { + attributes->push_back(std::make_pair("form", att->BeatrptRendToStr(att->GetForm()))); } if (att->HasSlope()) { attributes->push_back(std::make_pair("slopeDbl", att->DblToStr(att->GetSlope()))); @@ -2164,11 +2164,18 @@ void Att::GetCmn( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("breaksecInt", att->IntToStr(att->GetBreaksec()))); } } + if (element->HasAttClass( ATT_BEATRPTLOG ) ) { + AttBeatRptLog *att = dynamic_cast(element); + assert( att ); + if (att->HasBeatDef()) { + attributes->push_back(std::make_pair("beatDef", att->StrToStr(att->GetBeatDef()))); + } + } if (element->HasAttClass( ATT_BEATRPTVIS ) ) { AttBeatRptVis *att = dynamic_cast(element); assert( att ); - if (att->HasRend()) { - attributes->push_back(std::make_pair("rend", att->BeatrptRendToStr(att->GetRend()))); + if (att->HasForm()) { + attributes->push_back(std::make_pair("form", att->BeatrptRendToStr(att->GetForm()))); } } if (element->HasAttClass( ATT_BENDGES ) ) { @@ -2196,26 +2203,19 @@ void Att::GetCmn( Object *element, ArrayOfStrAttr *attributes ) { AttFTremLog *att = dynamic_cast(element); assert( att ); if (att->HasForm()) { - attributes->push_back(std::make_pair("form", att->StrToStr(att->GetForm()))); + attributes->push_back(std::make_pair("form", att->BeatrptRendToStr(att->GetForm()))); } } if (element->HasAttClass( ATT_FERMATAVIS ) ) { AttFermataVis *att = dynamic_cast(element); assert( att ); if (att->HasForm()) { - attributes->push_back(std::make_pair("form", att->StrToStr(att->GetForm()))); + attributes->push_back(std::make_pair("form", att->BeatrptRendToStr(att->GetForm()))); } if (att->HasShape()) { attributes->push_back(std::make_pair("shape", att->StrToStr(att->GetShape()))); } } - if (element->HasAttClass( ATT_GLISSVIS ) ) { - AttGlissVis *att = dynamic_cast(element); - assert( att ); - if (att->HasText()) { - attributes->push_back(std::make_pair("text", att->StrToStr(att->GetText()))); - } - } if (element->HasAttClass( ATT_GRACED ) ) { AttGraced *att = dynamic_cast(element); assert( att ); @@ -2230,7 +2230,10 @@ void Att::GetCmn( Object *element, ArrayOfStrAttr *attributes ) { AttHairpinLog *att = dynamic_cast(element); assert( att ); if (att->HasForm()) { - attributes->push_back(std::make_pair("form", att->StrToStr(att->GetForm()))); + attributes->push_back(std::make_pair("form", att->BeatrptRendToStr(att->GetForm()))); + } + if (att->HasNiente()) { + attributes->push_back(std::make_pair("niente", att->StrToStr(att->GetNiente()))); } } if (element->HasAttClass( ATT_HAIRPINVIS ) ) { @@ -2320,8 +2323,8 @@ void Att::GetCmn( Object *element, ArrayOfStrAttr *attributes ) { if (element->HasAttClass( ATT_PEDALVIS ) ) { AttPedalVis *att = dynamic_cast(element); assert( att ); - if (att->HasStyle()) { - attributes->push_back(std::make_pair("style", att->StrToStr(att->GetStyle()))); + if (att->HasForm()) { + attributes->push_back(std::make_pair("form", att->BeatrptRendToStr(att->GetForm()))); } } if (element->HasAttClass( ATT_PIANOPEDALS ) ) { @@ -2352,12 +2355,9 @@ void Att::GetCmn( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("slurRend", att->StrToStr(att->GetSlurRend()))); } } - if (element->HasAttClass( ATT_STEMMEDCMN ) ) { - AttStemmedCmn *att = dynamic_cast(element); + if (element->HasAttClass( ATT_STEMSCMN ) ) { + AttStemsCmn *att = dynamic_cast(element); assert( att ); - if (att->HasStemMod()) { - attributes->push_back(std::make_pair("stemMod", att->StemModifierToStr(att->GetStemMod()))); - } if (att->HasStemWith()) { attributes->push_back(std::make_pair("stemWith", att->StrToStr(att->GetStemWith()))); } diff --git a/libmei/atts_cmn.h b/libmei/atts_cmn.h index b365457df81..a09746e3289 100644 --- a/libmei/atts_cmn.h +++ b/libmei/atts_cmn.h @@ -126,15 +126,15 @@ class AttBTremLog: public Att * to the default value) **/ ///@{ - void SetForm(std::string form_) { m_form = form_; }; - std::string GetForm() const { return m_form; }; + void SetForm(data_BEATRPT_REND form_) { m_form = form_; }; + data_BEATRPT_REND GetForm() const { return m_form; }; bool HasForm( ); ///@} private: - /** Records the function of the dot. **/ - std::string m_form; + /** Records the appearance and usually the function of the bar line. **/ + data_BEATRPT_REND m_form; /* include */ }; @@ -295,9 +295,9 @@ class AttBeamrend: public Att * to the default value) **/ ///@{ - void SetRend(data_BEATRPT_REND rend_) { m_rend = rend_; }; - data_BEATRPT_REND GetRend() const { return m_rend; }; - bool HasRend( ); + void SetForm(data_BEATRPT_REND form_) { m_form = form_; }; + data_BEATRPT_REND GetForm() const { return m_form; }; + bool HasForm( ); // void SetSlope(double slopeDbl_) { m_slopeDbl = slopeDbl_; }; @@ -308,7 +308,7 @@ class AttBeamrend: public Att private: /** Records the appearance and usually the function of the bar line. **/ - data_BEATRPT_REND m_rend; + data_BEATRPT_REND m_form; /** Records the slope of the beam. **/ double m_slopeDbl; @@ -358,6 +358,44 @@ class AttBeamsecondary: public Att /* include */ }; +//---------------------------------------------------------------------------- +// AttBeatRptLog +//---------------------------------------------------------------------------- + +class AttBeatRptLog: public Att +{ +public: + AttBeatRptLog(); + virtual ~AttBeatRptLog(); + + /** Reset the default values for the attribute class **/ + void ResetBeatRptLog(); + + /** Read the values for the attribute class **/ + bool ReadBeatRptLog( pugi::xml_node element ); + + /** Write the values for the attribute class **/ + bool WriteBeatRptLog( pugi::xml_node element ); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetBeatDef(std::string beatDef_) { m_beatDef = beatDef_; }; + std::string GetBeatDef() const { return m_beatDef; }; + bool HasBeatDef( ); + + ///@} + +private: + /** --- **/ + std::string m_beatDef; + +/* include */ +}; + //---------------------------------------------------------------------------- // AttBeatRptVis //---------------------------------------------------------------------------- @@ -383,17 +421,17 @@ class AttBeatRptVis: public Att * to the default value) **/ ///@{ - void SetRend(data_BEATRPT_REND rend_) { m_rend = rend_; }; - data_BEATRPT_REND GetRend() const { return m_rend; }; - bool HasRend( ); + void SetForm(data_BEATRPT_REND form_) { m_form = form_; }; + data_BEATRPT_REND GetForm() const { return m_form; }; + bool HasForm( ); ///@} private: /** Records the appearance and usually the function of the bar line. **/ - data_BEATRPT_REND m_rend; + data_BEATRPT_REND m_form; -/* include */ +/* include */ }; //---------------------------------------------------------------------------- @@ -544,15 +582,15 @@ class AttFTremLog: public Att * to the default value) **/ ///@{ - void SetForm(std::string form_) { m_form = form_; }; - std::string GetForm() const { return m_form; }; + void SetForm(data_BEATRPT_REND form_) { m_form = form_; }; + data_BEATRPT_REND GetForm() const { return m_form; }; bool HasForm( ); ///@} private: - /** Records the function of the dot. **/ - std::string m_form; + /** Records the appearance and usually the function of the bar line. **/ + data_BEATRPT_REND m_form; /* include */ }; @@ -582,8 +620,8 @@ class AttFermataVis: public Att * to the default value) **/ ///@{ - void SetForm(std::string form_) { m_form = form_; }; - std::string GetForm() const { return m_form; }; + void SetForm(data_BEATRPT_REND form_) { m_form = form_; }; + data_BEATRPT_REND GetForm() const { return m_form; }; bool HasForm( ); // @@ -594,52 +632,14 @@ class AttFermataVis: public Att ///@} private: - /** Records the function of the dot. **/ - std::string m_form; + /** Records the appearance and usually the function of the bar line. **/ + data_BEATRPT_REND m_form; /** Describes a clef's shape. **/ std::string m_shape; /* include */ }; -//---------------------------------------------------------------------------- -// AttGlissVis -//---------------------------------------------------------------------------- - -class AttGlissVis: public Att -{ -public: - AttGlissVis(); - virtual ~AttGlissVis(); - - /** Reset the default values for the attribute class **/ - void ResetGlissVis(); - - /** Read the values for the attribute class **/ - bool ReadGlissVis( pugi::xml_node element ); - - /** Write the values for the attribute class **/ - bool WriteGlissVis( pugi::xml_node element ); - - /** - * @name Setters, getters and presence checker for class members. - * The checker returns true if the attribute class is set (e.g., not equal - * to the default value) - **/ - ///@{ - void SetText(std::string text_) { m_text = text_; }; - std::string GetText() const { return m_text; }; - bool HasText( ); - - ///@} - -private: - /** Records a text string, such as 'gliss', that accompanies the glissando mark. **/ - std::string m_text; - -/* include */ -}; - //---------------------------------------------------------------------------- // AttGraced //---------------------------------------------------------------------------- @@ -713,17 +713,28 @@ class AttHairpinLog: public Att * to the default value) **/ ///@{ - void SetForm(std::string form_) { m_form = form_; }; - std::string GetForm() const { return m_form; }; + void SetForm(data_BEATRPT_REND form_) { m_form = form_; }; + data_BEATRPT_REND GetForm() const { return m_form; }; bool HasForm( ); + // + void SetNiente(std::string niente_) { m_niente = niente_; }; + std::string GetNiente() const { return m_niente; }; + bool HasNiente( ); + ///@} private: - /** Records the function of the dot. **/ - std::string m_form; + /** Records the appearance and usually the function of the bar line. **/ + data_BEATRPT_REND m_form; + /** + * Indicates that the hairpin starts from or ends in silence. + * Often rendered as a small circle attached to the closed end of the hairpin. See + * Gould, p. 108. + **/ + std::string m_niente; -/* include */ +/* include */ }; //---------------------------------------------------------------------------- @@ -1161,17 +1172,17 @@ class AttPedalVis: public Att * to the default value) **/ ///@{ - void SetStyle(std::string style_) { m_style = style_; }; - std::string GetStyle() const { return m_style; }; - bool HasStyle( ); + void SetForm(data_BEATRPT_REND form_) { m_form = form_; }; + data_BEATRPT_REND GetForm() const { return m_form; }; + bool HasForm( ); ///@} private: - /** Determines whether piano pedal marks should be rendered as lines or as terms. **/ - std::string m_style; + /** Records the appearance and usually the function of the bar line. **/ + data_BEATRPT_REND m_form; -/* include */ +/* include */ }; //---------------------------------------------------------------------------- @@ -1327,23 +1338,23 @@ class AttSlurrend: public Att }; //---------------------------------------------------------------------------- -// AttStemmedCmn +// AttStemsCmn //---------------------------------------------------------------------------- -class AttStemmedCmn: public Att +class AttStemsCmn: public Att { public: - AttStemmedCmn(); - virtual ~AttStemmedCmn(); + AttStemsCmn(); + virtual ~AttStemsCmn(); /** Reset the default values for the attribute class **/ - void ResetStemmedCmn(); + void ResetStemsCmn(); /** Read the values for the attribute class **/ - bool ReadStemmedCmn( pugi::xml_node element ); + bool ReadStemsCmn( pugi::xml_node element ); /** Write the values for the attribute class **/ - bool WriteStemmedCmn( pugi::xml_node element ); + bool WriteStemsCmn( pugi::xml_node element ); /** * @name Setters, getters and presence checker for class members. @@ -1351,11 +1362,6 @@ class AttStemmedCmn: public Att * to the default value) **/ ///@{ - void SetStemMod(data_STEMMODIFIER stemMod_) { m_stemMod = stemMod_; }; - data_STEMMODIFIER GetStemMod() const { return m_stemMod; }; - bool HasStemMod( ); - - // void SetStemWith(std::string stemWith_) { m_stemWith = stemWith_; }; std::string GetStemWith() const { return m_stemWith; }; bool HasStemWith( ); @@ -1363,11 +1369,6 @@ class AttStemmedCmn: public Att ///@} private: - /** - * Encodes any stem "modifiers"; that is, symbols rendered on the stem, such as - * tremolo or Sprechstimme indicators. - **/ - data_STEMMODIFIER m_stemMod; /** * Contains an indication of which staff a note or chord that logically belongs to * the current staff should be visually placed on; that is, the one above or the diff --git a/libmei/atts_cmnornaments.h b/libmei/atts_cmnornaments.h index 0d19b82ca28..baafb5fee56 100644 --- a/libmei/atts_cmnornaments.h +++ b/libmei/atts_cmnornaments.h @@ -62,7 +62,7 @@ class AttMordentLog: public Att ///@} private: - /** Records the function of the dot. **/ + /** Records the appearance and usually the function of the bar line. **/ std::string m_form; /** * When the long attribute is set to 'yes', a double or long mordent, consisting of @@ -203,7 +203,7 @@ class AttTurnLog: public Att * See Read, p. 246. **/ std::string m_delayed; - /** Records the function of the dot. **/ + /** Records the appearance and usually the function of the bar line. **/ std::string m_form; /* include */ diff --git a/libmei/atts_edittrans.cpp b/libmei/atts_edittrans.cpp index 309363dd850..699fdb5daba 100644 --- a/libmei/atts_edittrans.cpp +++ b/libmei/atts_edittrans.cpp @@ -70,23 +70,23 @@ bool AttAgentident::HasAgent( ) /* include */ //---------------------------------------------------------------------------- -// AttEdit +// AttEvidence //---------------------------------------------------------------------------- -AttEdit::AttEdit(): Att() { - ResetEdit(); +AttEvidence::AttEvidence(): Att() { + ResetEvidence(); } -AttEdit::~AttEdit() { +AttEvidence::~AttEvidence() { } -void AttEdit::ResetEdit() { +void AttEvidence::ResetEvidence() { m_cert = ""; m_evidence = ""; } -bool AttEdit::ReadEdit( pugi::xml_node element ) { +bool AttEvidence::ReadEvidence( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("cert")) { this->SetCert(StrToStr(element.attribute("cert").value())); @@ -101,7 +101,7 @@ bool AttEdit::ReadEdit( pugi::xml_node element ) { return hasAttribute; } -bool AttEdit::WriteEdit( pugi::xml_node element ) { +bool AttEvidence::WriteEvidence( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasCert()) { element.append_attribute("cert") = StrToStr(this->GetCert()).c_str(); @@ -114,12 +114,12 @@ bool AttEdit::WriteEdit( pugi::xml_node element ) { return wroteAttribute; } -bool AttEdit::HasCert( ) +bool AttEvidence::HasCert( ) { return (m_cert != ""); } -bool AttEdit::HasEvidence( ) +bool AttEvidence::HasEvidence( ) { return (m_evidence != ""); } @@ -222,8 +222,8 @@ bool Att::SetEdittrans( Object *element, std::string attrType, std::string attrV return true; } } - if (element->HasAttClass( ATT_EDIT ) ) { - AttEdit *att = dynamic_cast(element); + if (element->HasAttClass( ATT_EVIDENCE ) ) { + AttEvidence *att = dynamic_cast(element); assert( att ); if (attrType == "cert") { att->SetCert(att->StrToStr(attrValue)); @@ -262,8 +262,8 @@ void Att::GetEdittrans( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("agent", att->StrToStr(att->GetAgent()))); } } - if (element->HasAttClass( ATT_EDIT ) ) { - AttEdit *att = dynamic_cast(element); + if (element->HasAttClass( ATT_EVIDENCE ) ) { + AttEvidence *att = dynamic_cast(element); assert( att ); if (att->HasCert()) { attributes->push_back(std::make_pair("cert", att->StrToStr(att->GetCert()))); diff --git a/libmei/atts_edittrans.h b/libmei/atts_edittrans.h index 483edee8dbe..4107457da55 100644 --- a/libmei/atts_edittrans.h +++ b/libmei/atts_edittrans.h @@ -67,23 +67,23 @@ class AttAgentident: public Att }; //---------------------------------------------------------------------------- -// AttEdit +// AttEvidence //---------------------------------------------------------------------------- -class AttEdit: public Att +class AttEvidence: public Att { public: - AttEdit(); - virtual ~AttEdit(); + AttEvidence(); + virtual ~AttEvidence(); /** Reset the default values for the attribute class **/ - void ResetEdit(); + void ResetEvidence(); /** Read the values for the attribute class **/ - bool ReadEdit( pugi::xml_node element ); + bool ReadEvidence( pugi::xml_node element ); /** Write the values for the attribute class **/ - bool WriteEdit( pugi::xml_node element ); + bool WriteEvidence( pugi::xml_node element ); /** * @name Setters, getters and presence checker for class members. diff --git a/libmei/atts_harmony.cpp b/libmei/atts_harmony.cpp index babe881857c..25a1126c5e3 100644 --- a/libmei/atts_harmony.cpp +++ b/libmei/atts_harmony.cpp @@ -125,17 +125,11 @@ AttHarmVis::~AttHarmVis() { } void AttHarmVis::ResetHarmVis() { - m_extender = ""; m_rendgrid = ""; } bool AttHarmVis::ReadHarmVis( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("extender")) { - this->SetExtender(StrToStr(element.attribute("extender").value())); - element.remove_attribute("extender"); - hasAttribute = true; - } if (element.attribute("rendgrid")) { this->SetRendgrid(StrToStr(element.attribute("rendgrid").value())); element.remove_attribute("rendgrid"); @@ -146,10 +140,6 @@ bool AttHarmVis::ReadHarmVis( pugi::xml_node element ) { bool AttHarmVis::WriteHarmVis( pugi::xml_node element ) { bool wroteAttribute = false; - if (this->HasExtender()) { - element.append_attribute("extender") = StrToStr(this->GetExtender()).c_str(); - wroteAttribute = true; - } if (this->HasRendgrid()) { element.append_attribute("rendgrid") = StrToStr(this->GetRendgrid()).c_str(); wroteAttribute = true; @@ -157,11 +147,6 @@ bool AttHarmVis::WriteHarmVis( pugi::xml_node element ) { return wroteAttribute; } -bool AttHarmVis::HasExtender( ) -{ - return (m_extender != ""); -} - bool AttHarmVis::HasRendgrid( ) { return (m_rendgrid != ""); @@ -190,10 +175,6 @@ bool Att::SetHarmony( Object *element, std::string attrType, std::string attrVal if (element->HasAttClass( ATT_HARMVIS ) ) { AttHarmVis *att = dynamic_cast(element); assert( att ); - if (attrType == "extender") { - att->SetExtender(att->StrToStr(attrValue)); - return true; - } if (attrType == "rendgrid") { att->SetRendgrid(att->StrToStr(attrValue)); return true; @@ -221,9 +202,6 @@ void Att::GetHarmony( Object *element, ArrayOfStrAttr *attributes ) { if (element->HasAttClass( ATT_HARMVIS ) ) { AttHarmVis *att = dynamic_cast(element); assert( att ); - if (att->HasExtender()) { - attributes->push_back(std::make_pair("extender", att->StrToStr(att->GetExtender()))); - } if (att->HasRendgrid()) { attributes->push_back(std::make_pair("rendgrid", att->StrToStr(att->GetRendgrid()))); } diff --git a/libmei/atts_harmony.h b/libmei/atts_harmony.h index cadb0c3e355..4986a53ad77 100644 --- a/libmei/atts_harmony.h +++ b/libmei/atts_harmony.h @@ -126,11 +126,6 @@ class AttHarmVis: public Att * to the default value) **/ ///@{ - void SetExtender(std::string extender_) { m_extender = extender_; }; - std::string GetExtender() const { return m_extender; }; - bool HasExtender( ); - - // void SetRendgrid(std::string rendgrid_) { m_rendgrid = rendgrid_; }; std::string GetRendgrid() const { return m_rendgrid; }; bool HasRendgrid( ); @@ -138,12 +133,6 @@ class AttHarmVis: public Att ///@} private: - /** - * Indicates the presence of an extension symbol, typically a dash or underscore, - * drawn from the end of the harmonic indication to the point indicated by the dur - * attribute. - **/ - std::string m_extender; /** Describes how the harmonic indication should be rendered. **/ std::string m_rendgrid; diff --git a/libmei/atts_mei.cpp b/libmei/atts_mei.cpp new file mode 100644 index 00000000000..1f03469b75a --- /dev/null +++ b/libmei/atts_mei.cpp @@ -0,0 +1,119 @@ +///////////////////////////////////////////////////////////////////////////// +// Authors: Laurent Pugin and Rodolfo Zitellini +// Created: 2014 +// Copyright (c) Authors and others. All rights reserved. +// +// Code generated using a modified version of libmei +// by Andrew Hankinson, Alastair Porter, and Others +///////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////// +// NOTE: this file was generated with the Verovio libmei version and +// should not be edited because changes will be lost. +///////////////////////////////////////////////////////////////////////////// + +#include "atts_mei.h" + +//---------------------------------------------------------------------------- + +#include + +//---------------------------------------------------------------------------- + +#include "object.h" + +/* #include_block */ + +namespace vrv { + +//---------------------------------------------------------------------------- +// AttNotationtype +//---------------------------------------------------------------------------- + +AttNotationtype::AttNotationtype(): Att() { + ResetNotationtype(); +} + +AttNotationtype::~AttNotationtype() { + +} + +void AttNotationtype::ResetNotationtype() { + m_notationtype = ""; + m_notationsubtype = ""; +} + +bool AttNotationtype::ReadNotationtype( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("notationtype")) { + this->SetNotationtype(StrToStr(element.attribute("notationtype").value())); + element.remove_attribute("notationtype"); + hasAttribute = true; + } + if (element.attribute("notationsubtype")) { + this->SetNotationsubtype(StrToStr(element.attribute("notationsubtype").value())); + element.remove_attribute("notationsubtype"); + hasAttribute = true; + } + return hasAttribute; +} + +bool AttNotationtype::WriteNotationtype( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasNotationtype()) { + element.append_attribute("notationtype") = StrToStr(this->GetNotationtype()).c_str(); + wroteAttribute = true; + } + if (this->HasNotationsubtype()) { + element.append_attribute("notationsubtype") = StrToStr(this->GetNotationsubtype()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttNotationtype::HasNotationtype( ) +{ + return (m_notationtype != ""); +} + +bool AttNotationtype::HasNotationsubtype( ) +{ + return (m_notationsubtype != ""); +} + + +/* include */ + +bool Att::SetMei( Object *element, std::string attrType, std::string attrValue ) { + if (element->HasAttClass( ATT_NOTATIONTYPE ) ) { + AttNotationtype *att = dynamic_cast(element); + assert( att ); + if (attrType == "notationtype") { + att->SetNotationtype(att->StrToStr(attrValue)); + return true; + } + if (attrType == "notationsubtype") { + att->SetNotationsubtype(att->StrToStr(attrValue)); + return true; + } + } + + return false; +} + +void Att::GetMei( Object *element, ArrayOfStrAttr *attributes ) { + if (element->HasAttClass( ATT_NOTATIONTYPE ) ) { + AttNotationtype *att = dynamic_cast(element); + assert( att ); + if (att->HasNotationtype()) { + attributes->push_back(std::make_pair("notationtype", att->StrToStr(att->GetNotationtype()))); + } + if (att->HasNotationsubtype()) { + attributes->push_back(std::make_pair("notationsubtype", att->StrToStr(att->GetNotationsubtype()))); + } + } + +} + +} // vrv namespace + diff --git a/libmei/atts_mei.h b/libmei/atts_mei.h new file mode 100644 index 00000000000..bd996c2bfe1 --- /dev/null +++ b/libmei/atts_mei.h @@ -0,0 +1,82 @@ +///////////////////////////////////////////////////////////////////////////// +// Authors: Laurent Pugin and Rodolfo Zitellini +// Created: 2014 +// Copyright (c) Authors and others. All rights reserved. +// +// Code generated using a modified version of libmei +// by Andrew Hankinson, Alastair Porter, and Others +///////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////// +// NOTE: this file was generated with the Verovio libmei version and +// should not be edited because changes will be lost. +///////////////////////////////////////////////////////////////////////////// + +#ifndef __VRV_ATTS_MEI_H__ +#define __VRV_ATTS_MEI_H__ + +#include "att.h" +#include "att_classes.h" +#include "pugixml.hpp" + +//---------------------------------------------------------------------------- + +#include + +namespace vrv { + +//---------------------------------------------------------------------------- +// AttNotationtype +//---------------------------------------------------------------------------- + +class AttNotationtype: public Att +{ +public: + AttNotationtype(); + virtual ~AttNotationtype(); + + /** Reset the default values for the attribute class **/ + void ResetNotationtype(); + + /** Read the values for the attribute class **/ + bool ReadNotationtype( pugi::xml_node element ); + + /** Write the values for the attribute class **/ + bool WriteNotationtype( pugi::xml_node element ); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetNotationtype(std::string notationtype_) { m_notationtype = notationtype_; }; + std::string GetNotationtype() const { return m_notationtype; }; + bool HasNotationtype( ); + + // + void SetNotationsubtype(std::string notationsubtype_) { m_notationsubtype = notationsubtype_; }; + std::string GetNotationsubtype() const { return m_notationsubtype; }; + bool HasNotationsubtype( ); + + ///@} + +private: + /** + * Contains classification of the notation contained or described by the element + * bearing this attribute. + **/ + std::string m_notationtype; + /** + * Provides any sub-classification of the notation contained or described by the + * element, additional to that given by its notationtype attribute. + **/ + std::string m_notationsubtype; + +/* include */ +}; + +} // vrv namespace + +#endif // __VRV_ATTS_MEI_H__ + diff --git a/libmei/atts_mensural.h b/libmei/atts_mensural.h index f121e5fe54b..88b627b4c8b 100644 --- a/libmei/atts_mensural.h +++ b/libmei/atts_mensural.h @@ -57,7 +57,7 @@ class AttLigatureLog: public Att ///@} private: - /** Records the function of the dot. **/ + /** Records the appearance and usually the function of the bar line. **/ std::string m_form; /* include */ @@ -100,7 +100,7 @@ class AttMensurVis: public Att ///@} private: - /** Records the function of the dot. **/ + /** Records the appearance and usually the function of the bar line. **/ std::string m_form; /** Describes the rotation or reflection of the base symbol. **/ data_ORIENTATION m_orient; diff --git a/libmei/atts_midi.cpp b/libmei/atts_midi.cpp index 04618f8382f..a0bb0e00977 100644 --- a/libmei/atts_midi.cpp +++ b/libmei/atts_midi.cpp @@ -331,6 +331,92 @@ bool AttMidivalue::HasVal( ) /* include */ +//---------------------------------------------------------------------------- +// AttMidivalue2 +//---------------------------------------------------------------------------- + +AttMidivalue2::AttMidivalue2(): Att() { + ResetMidivalue2(); +} + +AttMidivalue2::~AttMidivalue2() { + +} + +void AttMidivalue2::ResetMidivalue2() { + m_val2 = ""; +} + +bool AttMidivalue2::ReadMidivalue2( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("val2")) { + this->SetVal2(StrToStr(element.attribute("val2").value())); + element.remove_attribute("val2"); + hasAttribute = true; + } + return hasAttribute; +} + +bool AttMidivalue2::WriteMidivalue2( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasVal2()) { + element.append_attribute("val2") = StrToStr(this->GetVal2()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttMidivalue2::HasVal2( ) +{ + return (m_val2 != ""); +} + + +/* include */ + +//---------------------------------------------------------------------------- +// AttMidivelocity +//---------------------------------------------------------------------------- + +AttMidivelocity::AttMidivelocity(): Att() { + ResetMidivelocity(); +} + +AttMidivelocity::~AttMidivelocity() { + +} + +void AttMidivelocity::ResetMidivelocity() { + m_vel = ""; +} + +bool AttMidivelocity::ReadMidivelocity( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("vel")) { + this->SetVel(StrToStr(element.attribute("vel").value())); + element.remove_attribute("vel"); + hasAttribute = true; + } + return hasAttribute; +} + +bool AttMidivelocity::WriteMidivelocity( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasVel()) { + element.append_attribute("vel") = StrToStr(this->GetVel()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttMidivelocity::HasVel( ) +{ + return (m_vel != ""); +} + + +/* include */ + //---------------------------------------------------------------------------- // AttTimebase //---------------------------------------------------------------------------- @@ -439,6 +525,22 @@ bool Att::SetMidi( Object *element, std::string attrType, std::string attrValue return true; } } + if (element->HasAttClass( ATT_MIDIVALUE2 ) ) { + AttMidivalue2 *att = dynamic_cast(element); + assert( att ); + if (attrType == "val2") { + att->SetVal2(att->StrToStr(attrValue)); + return true; + } + } + if (element->HasAttClass( ATT_MIDIVELOCITY ) ) { + AttMidivelocity *att = dynamic_cast(element); + assert( att ); + if (attrType == "vel") { + att->SetVel(att->StrToStr(attrValue)); + return true; + } + } if (element->HasAttClass( ATT_TIMEBASE ) ) { AttTimebase *att = dynamic_cast(element); assert( att ); @@ -505,6 +607,20 @@ void Att::GetMidi( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("val", att->StrToStr(att->GetVal()))); } } + if (element->HasAttClass( ATT_MIDIVALUE2 ) ) { + AttMidivalue2 *att = dynamic_cast(element); + assert( att ); + if (att->HasVal2()) { + attributes->push_back(std::make_pair("val2", att->StrToStr(att->GetVal2()))); + } + } + if (element->HasAttClass( ATT_MIDIVELOCITY ) ) { + AttMidivelocity *att = dynamic_cast(element); + assert( att ); + if (att->HasVel()) { + attributes->push_back(std::make_pair("vel", att->StrToStr(att->GetVel()))); + } + } if (element->HasAttClass( ATT_TIMEBASE ) ) { AttTimebase *att = dynamic_cast(element); assert( att ); diff --git a/libmei/atts_midi.h b/libmei/atts_midi.h index d03c26c1479..4fd6801c466 100644 --- a/libmei/atts_midi.h +++ b/libmei/atts_midi.h @@ -266,6 +266,82 @@ class AttMidivalue: public Att /* include */ }; +//---------------------------------------------------------------------------- +// AttMidivalue2 +//---------------------------------------------------------------------------- + +class AttMidivalue2: public Att +{ +public: + AttMidivalue2(); + virtual ~AttMidivalue2(); + + /** Reset the default values for the attribute class **/ + void ResetMidivalue2(); + + /** Read the values for the attribute class **/ + bool ReadMidivalue2( pugi::xml_node element ); + + /** Write the values for the attribute class **/ + bool WriteMidivalue2( pugi::xml_node element ); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetVal2(std::string val2_) { m_val2 = val2_; }; + std::string GetVal2() const { return m_val2; }; + bool HasVal2( ); + + ///@} + +private: + /** MIDI number. **/ + std::string m_val2; + +/* include */ +}; + +//---------------------------------------------------------------------------- +// AttMidivelocity +//---------------------------------------------------------------------------- + +class AttMidivelocity: public Att +{ +public: + AttMidivelocity(); + virtual ~AttMidivelocity(); + + /** Reset the default values for the attribute class **/ + void ResetMidivelocity(); + + /** Read the values for the attribute class **/ + bool ReadMidivelocity( pugi::xml_node element ); + + /** Write the values for the attribute class **/ + bool WriteMidivelocity( pugi::xml_node element ); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetVel(std::string vel_) { m_vel = vel_; }; + std::string GetVel() const { return m_vel; }; + bool HasVel( ); + + ///@} + +private: + /** MIDI Note-on/off velocity. **/ + std::string m_vel; + +/* include */ +}; + //---------------------------------------------------------------------------- // AttTimebase //---------------------------------------------------------------------------- diff --git a/libmei/atts_neumes.h b/libmei/atts_neumes.h index 1aeb642aa21..10e8a2d1164 100644 --- a/libmei/atts_neumes.h +++ b/libmei/atts_neumes.h @@ -62,7 +62,7 @@ class AttIneumeLog: public Att ///@} private: - /** Records the function of the dot. **/ + /** Records the appearance and usually the function of the bar line. **/ std::string m_form; /** Records the name of the neume. **/ std::string m_name; @@ -107,7 +107,7 @@ class AttUneumeLog: public Att ///@} private: - /** Records the function of the dot. **/ + /** Records the appearance and usually the function of the bar line. **/ std::string m_form; /** Records the name of the neume. **/ std::string m_name; diff --git a/libmei/atts_linkalign.cpp b/libmei/atts_performance.cpp similarity index 92% rename from libmei/atts_linkalign.cpp rename to libmei/atts_performance.cpp index 012b8142b3c..33956176193 100644 --- a/libmei/atts_linkalign.cpp +++ b/libmei/atts_performance.cpp @@ -12,7 +12,7 @@ // should not be edited because changes will be lost. ///////////////////////////////////////////////////////////////////////////// -#include "atts_linkalign.h" +#include "atts_performance.h" //---------------------------------------------------------------------------- @@ -69,7 +69,7 @@ bool AttAlignment::HasWhen( ) /* include */ -bool Att::SetLinkalign( Object *element, std::string attrType, std::string attrValue ) { +bool Att::SetPerformance( Object *element, std::string attrType, std::string attrValue ) { if (element->HasAttClass( ATT_ALIGNMENT ) ) { AttAlignment *att = dynamic_cast(element); assert( att ); @@ -82,7 +82,7 @@ bool Att::SetLinkalign( Object *element, std::string attrType, std::string attrV return false; } -void Att::GetLinkalign( Object *element, ArrayOfStrAttr *attributes ) { +void Att::GetPerformance( Object *element, ArrayOfStrAttr *attributes ) { if (element->HasAttClass( ATT_ALIGNMENT ) ) { AttAlignment *att = dynamic_cast(element); assert( att ); diff --git a/libmei/atts_linkalign.h b/libmei/atts_performance.h similarity index 92% rename from libmei/atts_linkalign.h rename to libmei/atts_performance.h index ae7cd6dd6ec..994bf8e8c6a 100644 --- a/libmei/atts_linkalign.h +++ b/libmei/atts_performance.h @@ -12,8 +12,8 @@ // should not be edited because changes will be lost. ///////////////////////////////////////////////////////////////////////////// -#ifndef __VRV_ATTS_LINKALIGN_H__ -#define __VRV_ATTS_LINKALIGN_H__ +#ifndef __VRV_ATTS_PERFORMANCE_H__ +#define __VRV_ATTS_PERFORMANCE_H__ #include "att.h" #include "att_classes.h" @@ -59,7 +59,7 @@ class AttAlignment: public Att private: /** * Indicates the point of occurrence of this feature along a time line. - * Its value must be the ID of a element. + * Its value must be the ID of a **/ std::string m_when; @@ -68,5 +68,5 @@ class AttAlignment: public Att } // vrv namespace -#endif // __VRV_ATTS_LINKALIGN_H__ +#endif // __VRV_ATTS_PERFORMANCE_H__ diff --git a/libmei/atts_shared.cpp b/libmei/atts_shared.cpp index 6e6794db2d7..02e1c7c9d27 100644 --- a/libmei/atts_shared.cpp +++ b/libmei/atts_shared.cpp @@ -155,49 +155,6 @@ bool AttAccidentalPerformed::HasAccidGes( ) /* include */ -//---------------------------------------------------------------------------- -// AttAltsym -//---------------------------------------------------------------------------- - -AttAltsym::AttAltsym(): Att() { - ResetAltsym(); -} - -AttAltsym::~AttAltsym() { - -} - -void AttAltsym::ResetAltsym() { - m_altsym = ""; -} - -bool AttAltsym::ReadAltsym( pugi::xml_node element ) { - bool hasAttribute = false; - if (element.attribute("altsym")) { - this->SetAltsym(StrToStr(element.attribute("altsym").value())); - element.remove_attribute("altsym"); - hasAttribute = true; - } - return hasAttribute; -} - -bool AttAltsym::WriteAltsym( pugi::xml_node element ) { - bool wroteAttribute = false; - if (this->HasAltsym()) { - element.append_attribute("altsym") = StrToStr(this->GetAltsym()).c_str(); - wroteAttribute = true; - } - return wroteAttribute; -} - -bool AttAltsym::HasAltsym( ) -{ - return (m_altsym != ""); -} - - -/* include */ - //---------------------------------------------------------------------------- // AttArticulation //---------------------------------------------------------------------------- @@ -398,14 +355,14 @@ AttBarLineLog::~AttBarLineLog() { } void AttBarLineLog::ResetBarLineLog() { - m_rend = BARRENDITION_single; + m_form = BARRENDITION_single; } bool AttBarLineLog::ReadBarLineLog( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("rend")) { - this->SetRend(StrToBarRendition(element.attribute("rend").value())); - element.remove_attribute("rend"); + if (element.attribute("form")) { + this->SetForm(StrToBarRendition(element.attribute("form").value())); + element.remove_attribute("form"); hasAttribute = true; } return hasAttribute; @@ -413,20 +370,20 @@ bool AttBarLineLog::ReadBarLineLog( pugi::xml_node element ) { bool AttBarLineLog::WriteBarLineLog( pugi::xml_node element ) { bool wroteAttribute = false; - if (this->HasRend()) { - element.append_attribute("rend") = BarRenditionToStr(this->GetRend()).c_str(); + if (this->HasForm()) { + element.append_attribute("form") = BarRenditionToStr(this->GetForm()).c_str(); wroteAttribute = true; } return wroteAttribute; } -bool AttBarLineLog::HasRend( ) +bool AttBarLineLog::HasForm( ) { - return (m_rend != BARRENDITION_single); + return (m_form != BARRENDITION_single); } -/* include */ +/* include */ //---------------------------------------------------------------------------- // AttBarplacement @@ -658,14 +615,14 @@ AttCanonical::~AttCanonical() { } void AttCanonical::ResetCanonical() { - m_dbkey = ""; + m_codedval = ""; } bool AttCanonical::ReadCanonical( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("dbkey")) { - this->SetDbkey(StrToStr(element.attribute("dbkey").value())); - element.remove_attribute("dbkey"); + if (element.attribute("codedval")) { + this->SetCodedval(StrToStr(element.attribute("codedval").value())); + element.remove_attribute("codedval"); hasAttribute = true; } return hasAttribute; @@ -673,20 +630,20 @@ bool AttCanonical::ReadCanonical( pugi::xml_node element ) { bool AttCanonical::WriteCanonical( pugi::xml_node element ) { bool wroteAttribute = false; - if (this->HasDbkey()) { - element.append_attribute("dbkey") = StrToStr(this->GetDbkey()).c_str(); + if (this->HasCodedval()) { + element.append_attribute("codedval") = StrToStr(this->GetCodedval()).c_str(); wroteAttribute = true; } return wroteAttribute; } -bool AttCanonical::HasDbkey( ) +bool AttCanonical::HasCodedval( ) { - return (m_dbkey != ""); + return (m_codedval != ""); } -/* include */ +/* include */ //---------------------------------------------------------------------------- // AttChordVis @@ -731,6 +688,49 @@ bool AttChordVis::HasCluster( ) /* include */ +//---------------------------------------------------------------------------- +// AttClasscodeident +//---------------------------------------------------------------------------- + +AttClasscodeident::AttClasscodeident(): Att() { + ResetClasscodeident(); +} + +AttClasscodeident::~AttClasscodeident() { + +} + +void AttClasscodeident::ResetClasscodeident() { + m_classcode = ""; +} + +bool AttClasscodeident::ReadClasscodeident( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("classcode")) { + this->SetClasscode(StrToStr(element.attribute("classcode").value())); + element.remove_attribute("classcode"); + hasAttribute = true; + } + return hasAttribute; +} + +bool AttClasscodeident::WriteClasscodeident( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasClasscode()) { + element.append_attribute("classcode") = StrToStr(this->GetClasscode()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttClasscodeident::HasClasscode( ) +{ + return (m_classcode != ""); +} + + +/* include */ + //---------------------------------------------------------------------------- // AttClefLog //---------------------------------------------------------------------------- @@ -963,49 +963,6 @@ bool AttClefshape::HasShape( ) /* include */ -//---------------------------------------------------------------------------- -// AttCoded -//---------------------------------------------------------------------------- - -AttCoded::AttCoded(): Att() { - ResetCoded(); -} - -AttCoded::~AttCoded() { - -} - -void AttCoded::ResetCoded() { - m_code = ""; -} - -bool AttCoded::ReadCoded( pugi::xml_node element ) { - bool hasAttribute = false; - if (element.attribute("code")) { - this->SetCode(StrToStr(element.attribute("code").value())); - element.remove_attribute("code"); - hasAttribute = true; - } - return hasAttribute; -} - -bool AttCoded::WriteCoded( pugi::xml_node element ) { - bool wroteAttribute = false; - if (this->HasCode()) { - element.append_attribute("code") = StrToStr(this->GetCode()).c_str(); - wroteAttribute = true; - } - return wroteAttribute; -} - -bool AttCoded::HasCode( ) -{ - return (m_code != ""); -} - - -/* include */ - //---------------------------------------------------------------------------- // AttColor //---------------------------------------------------------------------------- @@ -1105,23 +1062,60 @@ AttCommon::~AttCommon() { } void AttCommon::ResetCommon() { - m_label = ""; m_n = 0; - m_base = ""; } bool AttCommon::ReadCommon( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("label")) { - this->SetLabel(StrToStr(element.attribute("label").value())); - element.remove_attribute("label"); - hasAttribute = true; - } if (element.attribute("n")) { this->SetN(StrToInt(element.attribute("n").value())); element.remove_attribute("n"); hasAttribute = true; } + return hasAttribute; +} + +bool AttCommon::WriteCommon( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasN()) { + element.append_attribute("n") = IntToStr(this->GetN()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttCommon::HasN( ) +{ + return (m_n != 0); +} + + +/* include */ + +//---------------------------------------------------------------------------- +// AttCommonPart +//---------------------------------------------------------------------------- + +AttCommonPart::AttCommonPart(): Att() { + ResetCommonPart(); +} + +AttCommonPart::~AttCommonPart() { + +} + +void AttCommonPart::ResetCommonPart() { + m_label = ""; + m_base = ""; +} + +bool AttCommonPart::ReadCommonPart( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("label")) { + this->SetLabel(StrToStr(element.attribute("label").value())); + element.remove_attribute("label"); + hasAttribute = true; + } if (element.attribute("base")) { this->SetBase(StrToStr(element.attribute("base").value())); element.remove_attribute("base"); @@ -1130,16 +1124,12 @@ bool AttCommon::ReadCommon( pugi::xml_node element ) { return hasAttribute; } -bool AttCommon::WriteCommon( pugi::xml_node element ) { +bool AttCommonPart::WriteCommonPart( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasLabel()) { element.append_attribute("label") = StrToStr(this->GetLabel()).c_str(); wroteAttribute = true; } - if (this->HasN()) { - element.append_attribute("n") = IntToStr(this->GetN()).c_str(); - wroteAttribute = true; - } if (this->HasBase()) { element.append_attribute("base") = StrToStr(this->GetBase()).c_str(); wroteAttribute = true; @@ -1147,17 +1137,12 @@ bool AttCommon::WriteCommon( pugi::xml_node element ) { return wroteAttribute; } -bool AttCommon::HasLabel( ) +bool AttCommonPart::HasLabel( ) { return (m_label != ""); } -bool AttCommon::HasN( ) -{ - return (m_n != 0); -} - -bool AttCommon::HasBase( ) +bool AttCommonPart::HasBase( ) { return (m_base != ""); } @@ -1339,14 +1324,20 @@ AttCurverend::~AttCurverend() { } void AttCurverend::ResetCurverend() { - m_rend = BARRENDITION_single; + m_lform = ""; + m_lwidth = ""; } bool AttCurverend::ReadCurverend( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("rend")) { - this->SetRend(StrToBarRendition(element.attribute("rend").value())); - element.remove_attribute("rend"); + if (element.attribute("lform")) { + this->SetLform(StrToStr(element.attribute("lform").value())); + element.remove_attribute("lform"); + hasAttribute = true; + } + if (element.attribute("lwidth")) { + this->SetLwidth(StrToStr(element.attribute("lwidth").value())); + element.remove_attribute("lwidth"); hasAttribute = true; } return hasAttribute; @@ -1354,20 +1345,29 @@ bool AttCurverend::ReadCurverend( pugi::xml_node element ) { bool AttCurverend::WriteCurverend( pugi::xml_node element ) { bool wroteAttribute = false; - if (this->HasRend()) { - element.append_attribute("rend") = BarRenditionToStr(this->GetRend()).c_str(); + if (this->HasLform()) { + element.append_attribute("lform") = StrToStr(this->GetLform()).c_str(); + wroteAttribute = true; + } + if (this->HasLwidth()) { + element.append_attribute("lwidth") = StrToStr(this->GetLwidth()).c_str(); wroteAttribute = true; } return wroteAttribute; } -bool AttCurverend::HasRend( ) +bool AttCurverend::HasLform( ) +{ + return (m_lform != ""); +} + +bool AttCurverend::HasLwidth( ) { - return (m_rend != BARRENDITION_single); + return (m_lwidth != ""); } -/* include */ +/* include */ //---------------------------------------------------------------------------- // AttCustosLog @@ -1687,13 +1687,13 @@ AttDotLog::~AttDotLog() { } void AttDotLog::ResetDotLog() { - m_form = ""; + m_form = BARRENDITION_single; } bool AttDotLog::ReadDotLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("form")) { - this->SetForm(StrToStr(element.attribute("form").value())); + this->SetForm(StrToBarRendition(element.attribute("form").value())); element.remove_attribute("form"); hasAttribute = true; } @@ -1703,7 +1703,7 @@ bool AttDotLog::ReadDotLog( pugi::xml_node element ) { bool AttDotLog::WriteDotLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasForm()) { - element.append_attribute("form") = StrToStr(this->GetForm()).c_str(); + element.append_attribute("form") = BarRenditionToStr(this->GetForm()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -1711,7 +1711,7 @@ bool AttDotLog::WriteDotLog( pugi::xml_node element ) { bool AttDotLog::HasForm( ) { - return (m_form != ""); + return (m_form != BARRENDITION_single); } @@ -2021,229 +2021,444 @@ bool AttEnclosingchars::HasEnclose( ) /* include */ //---------------------------------------------------------------------------- -// AttFermatapresent +// AttEndings //---------------------------------------------------------------------------- -AttFermatapresent::AttFermatapresent(): Att() { - ResetFermatapresent(); +AttEndings::AttEndings(): Att() { + ResetEndings(); } -AttFermatapresent::~AttFermatapresent() { +AttEndings::~AttEndings() { } -void AttFermatapresent::ResetFermatapresent() { - m_fermata = PLACE_NONE; +void AttEndings::ResetEndings() { + m_endingRend = ""; } -bool AttFermatapresent::ReadFermatapresent( pugi::xml_node element ) { +bool AttEndings::ReadEndings( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("fermata")) { - this->SetFermata(StrToPlace(element.attribute("fermata").value())); - element.remove_attribute("fermata"); + if (element.attribute("ending.rend")) { + this->SetEndingRend(StrToStr(element.attribute("ending.rend").value())); + element.remove_attribute("ending.rend"); hasAttribute = true; } return hasAttribute; } -bool AttFermatapresent::WriteFermatapresent( pugi::xml_node element ) { +bool AttEndings::WriteEndings( pugi::xml_node element ) { bool wroteAttribute = false; - if (this->HasFermata()) { - element.append_attribute("fermata") = PlaceToStr(this->GetFermata()).c_str(); + if (this->HasEndingRend()) { + element.append_attribute("ending.rend") = StrToStr(this->GetEndingRend()).c_str(); wroteAttribute = true; } return wroteAttribute; } -bool AttFermatapresent::HasFermata( ) +bool AttEndings::HasEndingRend( ) { - return (m_fermata != PLACE_NONE); + return (m_endingRend != ""); } -/* include */ +/* include */ //---------------------------------------------------------------------------- -// AttHandident +// AttExtender //---------------------------------------------------------------------------- -AttHandident::AttHandident(): Att() { - ResetHandident(); +AttExtender::AttExtender(): Att() { + ResetExtender(); } -AttHandident::~AttHandident() { +AttExtender::~AttExtender() { } -void AttHandident::ResetHandident() { - m_hand = ""; +void AttExtender::ResetExtender() { + m_extender = ""; } -bool AttHandident::ReadHandident( pugi::xml_node element ) { +bool AttExtender::ReadExtender( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("hand")) { - this->SetHand(StrToStr(element.attribute("hand").value())); - element.remove_attribute("hand"); + if (element.attribute("extender")) { + this->SetExtender(StrToStr(element.attribute("extender").value())); + element.remove_attribute("extender"); hasAttribute = true; } return hasAttribute; } -bool AttHandident::WriteHandident( pugi::xml_node element ) { +bool AttExtender::WriteExtender( pugi::xml_node element ) { bool wroteAttribute = false; - if (this->HasHand()) { - element.append_attribute("hand") = StrToStr(this->GetHand()).c_str(); + if (this->HasExtender()) { + element.append_attribute("extender") = StrToStr(this->GetExtender()).c_str(); wroteAttribute = true; } return wroteAttribute; } -bool AttHandident::HasHand( ) +bool AttExtender::HasExtender( ) { - return (m_hand != ""); + return (m_extender != ""); } -/* include */ +/* include */ //---------------------------------------------------------------------------- -// AttHorizontalalign +// AttFermatapresent //---------------------------------------------------------------------------- -AttHorizontalalign::AttHorizontalalign(): Att() { - ResetHorizontalalign(); +AttFermatapresent::AttFermatapresent(): Att() { + ResetFermatapresent(); } -AttHorizontalalign::~AttHorizontalalign() { +AttFermatapresent::~AttFermatapresent() { } -void AttHorizontalalign::ResetHorizontalalign() { - m_halign = ""; +void AttFermatapresent::ResetFermatapresent() { + m_fermata = PLACE_NONE; } -bool AttHorizontalalign::ReadHorizontalalign( pugi::xml_node element ) { +bool AttFermatapresent::ReadFermatapresent( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("halign")) { - this->SetHalign(StrToStr(element.attribute("halign").value())); - element.remove_attribute("halign"); + if (element.attribute("fermata")) { + this->SetFermata(StrToPlace(element.attribute("fermata").value())); + element.remove_attribute("fermata"); hasAttribute = true; } return hasAttribute; } -bool AttHorizontalalign::WriteHorizontalalign( pugi::xml_node element ) { +bool AttFermatapresent::WriteFermatapresent( pugi::xml_node element ) { bool wroteAttribute = false; - if (this->HasHalign()) { - element.append_attribute("halign") = StrToStr(this->GetHalign()).c_str(); + if (this->HasFermata()) { + element.append_attribute("fermata") = PlaceToStr(this->GetFermata()).c_str(); wroteAttribute = true; } return wroteAttribute; } -bool AttHorizontalalign::HasHalign( ) +bool AttFermatapresent::HasFermata( ) { - return (m_halign != ""); + return (m_fermata != PLACE_NONE); } -/* include */ +/* include */ //---------------------------------------------------------------------------- -// AttInstrumentident +// AttFiling //---------------------------------------------------------------------------- -AttInstrumentident::AttInstrumentident(): Att() { - ResetInstrumentident(); +AttFiling::AttFiling(): Att() { + ResetFiling(); } -AttInstrumentident::~AttInstrumentident() { +AttFiling::~AttFiling() { } -void AttInstrumentident::ResetInstrumentident() { - m_instr = ""; +void AttFiling::ResetFiling() { + m_nonfilingInt = 0; } -bool AttInstrumentident::ReadInstrumentident( pugi::xml_node element ) { +bool AttFiling::ReadFiling( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("instr")) { - this->SetInstr(StrToStr(element.attribute("instr").value())); - element.remove_attribute("instr"); + if (element.attribute("nonfiling")) { + this->SetNonfiling(StrToInt(element.attribute("nonfiling").value())); + element.remove_attribute("nonfiling"); hasAttribute = true; } return hasAttribute; } -bool AttInstrumentident::WriteInstrumentident( pugi::xml_node element ) { +bool AttFiling::WriteFiling( pugi::xml_node element ) { bool wroteAttribute = false; - if (this->HasInstr()) { - element.append_attribute("instr") = StrToStr(this->GetInstr()).c_str(); + if (this->HasNonfiling()) { + element.append_attribute("nonfiling") = IntToStr(this->GetNonfiling()).c_str(); wroteAttribute = true; } return wroteAttribute; } -bool AttInstrumentident::HasInstr( ) +bool AttFiling::HasNonfiling( ) { - return (m_instr != ""); + return (m_nonfilingInt != 0); } -/* include */ +/* include */ //---------------------------------------------------------------------------- -// AttInternetmedia +// AttGrpSymLog //---------------------------------------------------------------------------- -AttInternetmedia::AttInternetmedia(): Att() { - ResetInternetmedia(); +AttGrpSymLog::AttGrpSymLog(): Att() { + ResetGrpSymLog(); } -AttInternetmedia::~AttInternetmedia() { +AttGrpSymLog::~AttGrpSymLog() { } -void AttInternetmedia::ResetInternetmedia() { - m_mimetype = ""; +void AttGrpSymLog::ResetGrpSymLog() { + m_levelInt = 0; } -bool AttInternetmedia::ReadInternetmedia( pugi::xml_node element ) { +bool AttGrpSymLog::ReadGrpSymLog( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("mimetype")) { - this->SetMimetype(StrToStr(element.attribute("mimetype").value())); - element.remove_attribute("mimetype"); + if (element.attribute("level")) { + this->SetLevel(StrToInt(element.attribute("level").value())); + element.remove_attribute("level"); hasAttribute = true; } return hasAttribute; } -bool AttInternetmedia::WriteInternetmedia( pugi::xml_node element ) { +bool AttGrpSymLog::WriteGrpSymLog( pugi::xml_node element ) { bool wroteAttribute = false; - if (this->HasMimetype()) { - element.append_attribute("mimetype") = StrToStr(this->GetMimetype()).c_str(); + if (this->HasLevel()) { + element.append_attribute("level") = IntToStr(this->GetLevel()).c_str(); wroteAttribute = true; } return wroteAttribute; } -bool AttInternetmedia::HasMimetype( ) +bool AttGrpSymLog::HasLevel( ) { - return (m_mimetype != ""); + return (m_levelInt != 0); } -/* include */ +/* include */ //---------------------------------------------------------------------------- -// AttJoined +// AttHandident //---------------------------------------------------------------------------- -AttJoined::AttJoined(): Att() { - ResetJoined(); +AttHandident::AttHandident(): Att() { + ResetHandident(); } -AttJoined::~AttJoined() { +AttHandident::~AttHandident() { + +} + +void AttHandident::ResetHandident() { + m_hand = ""; +} + +bool AttHandident::ReadHandident( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("hand")) { + this->SetHand(StrToStr(element.attribute("hand").value())); + element.remove_attribute("hand"); + hasAttribute = true; + } + return hasAttribute; +} + +bool AttHandident::WriteHandident( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasHand()) { + element.append_attribute("hand") = StrToStr(this->GetHand()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttHandident::HasHand( ) +{ + return (m_hand != ""); +} + + +/* include */ + +//---------------------------------------------------------------------------- +// AttHeight +//---------------------------------------------------------------------------- + +AttHeight::AttHeight(): Att() { + ResetHeight(); +} + +AttHeight::~AttHeight() { + +} + +void AttHeight::ResetHeight() { + m_height = ""; +} + +bool AttHeight::ReadHeight( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("height")) { + this->SetHeight(StrToStr(element.attribute("height").value())); + element.remove_attribute("height"); + hasAttribute = true; + } + return hasAttribute; +} + +bool AttHeight::WriteHeight( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasHeight()) { + element.append_attribute("height") = StrToStr(this->GetHeight()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttHeight::HasHeight( ) +{ + return (m_height != ""); +} + + +/* include */ + +//---------------------------------------------------------------------------- +// AttHorizontalalign +//---------------------------------------------------------------------------- + +AttHorizontalalign::AttHorizontalalign(): Att() { + ResetHorizontalalign(); +} + +AttHorizontalalign::~AttHorizontalalign() { + +} + +void AttHorizontalalign::ResetHorizontalalign() { + m_halign = ""; +} + +bool AttHorizontalalign::ReadHorizontalalign( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("halign")) { + this->SetHalign(StrToStr(element.attribute("halign").value())); + element.remove_attribute("halign"); + hasAttribute = true; + } + return hasAttribute; +} + +bool AttHorizontalalign::WriteHorizontalalign( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasHalign()) { + element.append_attribute("halign") = StrToStr(this->GetHalign()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttHorizontalalign::HasHalign( ) +{ + return (m_halign != ""); +} + + +/* include */ + +//---------------------------------------------------------------------------- +// AttInstrumentident +//---------------------------------------------------------------------------- + +AttInstrumentident::AttInstrumentident(): Att() { + ResetInstrumentident(); +} + +AttInstrumentident::~AttInstrumentident() { + +} + +void AttInstrumentident::ResetInstrumentident() { + m_instr = ""; +} + +bool AttInstrumentident::ReadInstrumentident( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("instr")) { + this->SetInstr(StrToStr(element.attribute("instr").value())); + element.remove_attribute("instr"); + hasAttribute = true; + } + return hasAttribute; +} + +bool AttInstrumentident::WriteInstrumentident( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasInstr()) { + element.append_attribute("instr") = StrToStr(this->GetInstr()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttInstrumentident::HasInstr( ) +{ + return (m_instr != ""); +} + + +/* include */ + +//---------------------------------------------------------------------------- +// AttInternetmedia +//---------------------------------------------------------------------------- + +AttInternetmedia::AttInternetmedia(): Att() { + ResetInternetmedia(); +} + +AttInternetmedia::~AttInternetmedia() { + +} + +void AttInternetmedia::ResetInternetmedia() { + m_mimetype = ""; +} + +bool AttInternetmedia::ReadInternetmedia( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("mimetype")) { + this->SetMimetype(StrToStr(element.attribute("mimetype").value())); + element.remove_attribute("mimetype"); + hasAttribute = true; + } + return hasAttribute; +} + +bool AttInternetmedia::WriteInternetmedia( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasMimetype()) { + element.append_attribute("mimetype") = StrToStr(this->GetMimetype()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttInternetmedia::HasMimetype( ) +{ + return (m_mimetype != ""); +} + + +/* include */ + +//---------------------------------------------------------------------------- +// AttJoined +//---------------------------------------------------------------------------- + +AttJoined::AttJoined(): Att() { + ResetJoined(); +} + +AttJoined::~AttJoined() { } @@ -2539,6 +2754,7 @@ AttLang::~AttLang() { void AttLang::ResetLang() { m_lang = ""; + m_translit = ""; } bool AttLang::ReadLang( pugi::xml_node element ) { @@ -2548,6 +2764,11 @@ bool AttLang::ReadLang( pugi::xml_node element ) { element.remove_attribute("lang"); hasAttribute = true; } + if (element.attribute("translit")) { + this->SetTranslit(StrToStr(element.attribute("translit").value())); + element.remove_attribute("translit"); + hasAttribute = true; + } return hasAttribute; } @@ -2557,6 +2778,10 @@ bool AttLang::WriteLang( pugi::xml_node element ) { element.append_attribute("lang") = StrToStr(this->GetLang()).c_str(); wroteAttribute = true; } + if (this->HasTranslit()) { + element.append_attribute("translit") = StrToStr(this->GetTranslit()).c_str(); + wroteAttribute = true; + } return wroteAttribute; } @@ -2565,8 +2790,13 @@ bool AttLang::HasLang( ) return (m_lang != ""); } +bool AttLang::HasTranslit( ) +{ + return (m_translit != ""); +} -/* include */ + +/* include */ //---------------------------------------------------------------------------- // AttLayerLog @@ -2624,13 +2854,13 @@ AttLayerident::~AttLayerident() { } void AttLayerident::ResetLayerident() { - m_layer = ""; + m_layerInt = 0; } bool AttLayerident::ReadLayerident( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("layer")) { - this->SetLayer(StrToStr(element.attribute("layer").value())); + this->SetLayer(StrToInt(element.attribute("layer").value())); element.remove_attribute("layer"); hasAttribute = true; } @@ -2640,7 +2870,7 @@ bool AttLayerident::ReadLayerident( pugi::xml_node element ) { bool AttLayerident::WriteLayerident( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasLayer()) { - element.append_attribute("layer") = StrToStr(this->GetLayer()).c_str(); + element.append_attribute("layer") = IntToStr(this->GetLayer()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -2648,55 +2878,173 @@ bool AttLayerident::WriteLayerident( pugi::xml_node element ) { bool AttLayerident::HasLayer( ) { - return (m_layer != ""); + return (m_layerInt != 0); } /* include */ //---------------------------------------------------------------------------- -// AttLineloc +// AttLineVis //---------------------------------------------------------------------------- -AttLineloc::AttLineloc(): Att() { - ResetLineloc(); +AttLineVis::AttLineVis(): Att() { + ResetLineVis(); } -AttLineloc::~AttLineloc() { +AttLineVis::~AttLineVis() { } -void AttLineloc::ResetLineloc() { - m_line = 0; +void AttLineVis::ResetLineVis() { + m_form = BARRENDITION_single; + m_width = ""; + m_endsym = ""; + m_endsymsize = ""; + m_startsym = ""; + m_startsymsize = ""; } -bool AttLineloc::ReadLineloc( pugi::xml_node element ) { +bool AttLineVis::ReadLineVis( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("line")) { - this->SetLine(StrToInt(element.attribute("line").value())); - element.remove_attribute("line"); + if (element.attribute("form")) { + this->SetForm(StrToBarRendition(element.attribute("form").value())); + element.remove_attribute("form"); + hasAttribute = true; + } + if (element.attribute("width")) { + this->SetWidth(StrToStr(element.attribute("width").value())); + element.remove_attribute("width"); + hasAttribute = true; + } + if (element.attribute("endsym")) { + this->SetEndsym(StrToStr(element.attribute("endsym").value())); + element.remove_attribute("endsym"); + hasAttribute = true; + } + if (element.attribute("endsymsize")) { + this->SetEndsymsize(StrToStr(element.attribute("endsymsize").value())); + element.remove_attribute("endsymsize"); + hasAttribute = true; + } + if (element.attribute("startsym")) { + this->SetStartsym(StrToStr(element.attribute("startsym").value())); + element.remove_attribute("startsym"); + hasAttribute = true; + } + if (element.attribute("startsymsize")) { + this->SetStartsymsize(StrToStr(element.attribute("startsymsize").value())); + element.remove_attribute("startsymsize"); hasAttribute = true; } return hasAttribute; } -bool AttLineloc::WriteLineloc( pugi::xml_node element ) { +bool AttLineVis::WriteLineVis( pugi::xml_node element ) { bool wroteAttribute = false; - if (this->HasLine()) { - element.append_attribute("line") = IntToStr(this->GetLine()).c_str(); + if (this->HasForm()) { + element.append_attribute("form") = BarRenditionToStr(this->GetForm()).c_str(); + wroteAttribute = true; + } + if (this->HasWidth()) { + element.append_attribute("width") = StrToStr(this->GetWidth()).c_str(); + wroteAttribute = true; + } + if (this->HasEndsym()) { + element.append_attribute("endsym") = StrToStr(this->GetEndsym()).c_str(); + wroteAttribute = true; + } + if (this->HasEndsymsize()) { + element.append_attribute("endsymsize") = StrToStr(this->GetEndsymsize()).c_str(); + wroteAttribute = true; + } + if (this->HasStartsym()) { + element.append_attribute("startsym") = StrToStr(this->GetStartsym()).c_str(); + wroteAttribute = true; + } + if (this->HasStartsymsize()) { + element.append_attribute("startsymsize") = StrToStr(this->GetStartsymsize()).c_str(); wroteAttribute = true; } return wroteAttribute; } -bool AttLineloc::HasLine( ) +bool AttLineVis::HasForm( ) { - return (m_line != 0); + return (m_form != BARRENDITION_single); } +bool AttLineVis::HasWidth( ) +{ + return (m_width != ""); +} + +bool AttLineVis::HasEndsym( ) +{ + return (m_endsym != ""); +} + +bool AttLineVis::HasEndsymsize( ) +{ + return (m_endsymsize != ""); +} + +bool AttLineVis::HasStartsym( ) +{ + return (m_startsym != ""); +} + +bool AttLineVis::HasStartsymsize( ) +{ + return (m_startsymsize != ""); +} + + +/* include */ + +//---------------------------------------------------------------------------- +// AttLineloc +//---------------------------------------------------------------------------- + +AttLineloc::AttLineloc(): Att() { + ResetLineloc(); +} + +AttLineloc::~AttLineloc() { + +} + +void AttLineloc::ResetLineloc() { + m_line = 0; +} + +bool AttLineloc::ReadLineloc( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("line")) { + this->SetLine(StrToInt(element.attribute("line").value())); + element.remove_attribute("line"); + hasAttribute = true; + } + return hasAttribute; +} + +bool AttLineloc::WriteLineloc( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasLine()) { + element.append_attribute("line") = IntToStr(this->GetLine()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttLineloc::HasLine( ) +{ + return (m_line != 0); +} + + +/* include */ -/* include */ - //---------------------------------------------------------------------------- // AttLinerend //---------------------------------------------------------------------------- @@ -2710,14 +3058,32 @@ AttLinerend::~AttLinerend() { } void AttLinerend::ResetLinerend() { - m_rend = BARRENDITION_single; + m_lendsym = ""; + m_lendsymsize = ""; + m_lstartsym = ""; + m_lstartsymsize = ""; } bool AttLinerend::ReadLinerend( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("rend")) { - this->SetRend(StrToBarRendition(element.attribute("rend").value())); - element.remove_attribute("rend"); + if (element.attribute("lendsym")) { + this->SetLendsym(StrToStr(element.attribute("lendsym").value())); + element.remove_attribute("lendsym"); + hasAttribute = true; + } + if (element.attribute("lendsymsize")) { + this->SetLendsymsize(StrToStr(element.attribute("lendsymsize").value())); + element.remove_attribute("lendsymsize"); + hasAttribute = true; + } + if (element.attribute("lstartsym")) { + this->SetLstartsym(StrToStr(element.attribute("lstartsym").value())); + element.remove_attribute("lstartsym"); + hasAttribute = true; + } + if (element.attribute("lstartsymsize")) { + this->SetLstartsymsize(StrToStr(element.attribute("lstartsymsize").value())); + element.remove_attribute("lstartsymsize"); hasAttribute = true; } return hasAttribute; @@ -2725,20 +3091,105 @@ bool AttLinerend::ReadLinerend( pugi::xml_node element ) { bool AttLinerend::WriteLinerend( pugi::xml_node element ) { bool wroteAttribute = false; - if (this->HasRend()) { - element.append_attribute("rend") = BarRenditionToStr(this->GetRend()).c_str(); + if (this->HasLendsym()) { + element.append_attribute("lendsym") = StrToStr(this->GetLendsym()).c_str(); + wroteAttribute = true; + } + if (this->HasLendsymsize()) { + element.append_attribute("lendsymsize") = StrToStr(this->GetLendsymsize()).c_str(); + wroteAttribute = true; + } + if (this->HasLstartsym()) { + element.append_attribute("lstartsym") = StrToStr(this->GetLstartsym()).c_str(); + wroteAttribute = true; + } + if (this->HasLstartsymsize()) { + element.append_attribute("lstartsymsize") = StrToStr(this->GetLstartsymsize()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttLinerend::HasLendsym( ) +{ + return (m_lendsym != ""); +} + +bool AttLinerend::HasLendsymsize( ) +{ + return (m_lendsymsize != ""); +} + +bool AttLinerend::HasLstartsym( ) +{ + return (m_lstartsym != ""); +} + +bool AttLinerend::HasLstartsymsize( ) +{ + return (m_lstartsymsize != ""); +} + + +/* include */ + +//---------------------------------------------------------------------------- +// AttLinerendBase +//---------------------------------------------------------------------------- + +AttLinerendBase::AttLinerendBase(): Att() { + ResetLinerendBase(); +} + +AttLinerendBase::~AttLinerendBase() { + +} + +void AttLinerendBase::ResetLinerendBase() { + m_lform = ""; + m_lwidth = ""; +} + +bool AttLinerendBase::ReadLinerendBase( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("lform")) { + this->SetLform(StrToStr(element.attribute("lform").value())); + element.remove_attribute("lform"); + hasAttribute = true; + } + if (element.attribute("lwidth")) { + this->SetLwidth(StrToStr(element.attribute("lwidth").value())); + element.remove_attribute("lwidth"); + hasAttribute = true; + } + return hasAttribute; +} + +bool AttLinerendBase::WriteLinerendBase( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasLform()) { + element.append_attribute("lform") = StrToStr(this->GetLform()).c_str(); + wroteAttribute = true; + } + if (this->HasLwidth()) { + element.append_attribute("lwidth") = StrToStr(this->GetLwidth()).c_str(); wroteAttribute = true; } return wroteAttribute; } -bool AttLinerend::HasRend( ) +bool AttLinerendBase::HasLform( ) +{ + return (m_lform != ""); +} + +bool AttLinerendBase::HasLwidth( ) { - return (m_rend != BARRENDITION_single); + return (m_lwidth != ""); } -/* include */ +/* include */ //---------------------------------------------------------------------------- // AttLyricstyle @@ -2959,6 +3410,49 @@ bool AttMeasurement::HasUnit( ) /* include */ +//---------------------------------------------------------------------------- +// AttMeasurenumbers +//---------------------------------------------------------------------------- + +AttMeasurenumbers::AttMeasurenumbers(): Att() { + ResetMeasurenumbers(); +} + +AttMeasurenumbers::~AttMeasurenumbers() { + +} + +void AttMeasurenumbers::ResetMeasurenumbers() { + m_mnumVisible = ""; +} + +bool AttMeasurenumbers::ReadMeasurenumbers( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("mnum.visible")) { + this->SetMnumVisible(StrToStr(element.attribute("mnum.visible").value())); + element.remove_attribute("mnum.visible"); + hasAttribute = true; + } + return hasAttribute; +} + +bool AttMeasurenumbers::WriteMeasurenumbers( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasMnumVisible()) { + element.append_attribute("mnum.visible") = StrToStr(this->GetMnumVisible()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttMeasurenumbers::HasMnumVisible( ) +{ + return (m_mnumVisible != ""); +} + + +/* include */ + //---------------------------------------------------------------------------- // AttMediabounds //---------------------------------------------------------------------------- @@ -3089,7 +3583,6 @@ AttMeiversion::~AttMeiversion() { void AttMeiversion::ResetMeiversion() { m_meiversion = ""; - m_meiversionNum = ""; } bool AttMeiversion::ReadMeiversion( pugi::xml_node element ) { @@ -3099,11 +3592,6 @@ bool AttMeiversion::ReadMeiversion( pugi::xml_node element ) { element.remove_attribute("meiversion"); hasAttribute = true; } - if (element.attribute("meiversion.num")) { - this->SetMeiversionNum(StrToStr(element.attribute("meiversion.num").value())); - element.remove_attribute("meiversion.num"); - hasAttribute = true; - } return hasAttribute; } @@ -3113,10 +3601,6 @@ bool AttMeiversion::WriteMeiversion( pugi::xml_node element ) { element.append_attribute("meiversion") = StrToStr(this->GetMeiversion()).c_str(); wroteAttribute = true; } - if (this->HasMeiversionNum()) { - element.append_attribute("meiversion.num") = StrToStr(this->GetMeiversionNum()).c_str(); - wroteAttribute = true; - } return wroteAttribute; } @@ -3125,13 +3609,8 @@ bool AttMeiversion::HasMeiversion( ) return (m_meiversion != ""); } -bool AttMeiversion::HasMeiversionNum( ) -{ - return (m_meiversionNum != ""); -} - -/* include */ +/* include */ //---------------------------------------------------------------------------- // AttMensurLog @@ -3277,14 +3756,14 @@ AttMeterSigVis::~AttMeterSigVis() { } void AttMeterSigVis::ResetMeterSigVis() { - m_rend = BARRENDITION_single; + m_form = BARRENDITION_single; } bool AttMeterSigVis::ReadMeterSigVis( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("rend")) { - this->SetRend(StrToBarRendition(element.attribute("rend").value())); - element.remove_attribute("rend"); + if (element.attribute("form")) { + this->SetForm(StrToBarRendition(element.attribute("form").value())); + element.remove_attribute("form"); hasAttribute = true; } return hasAttribute; @@ -3292,20 +3771,20 @@ bool AttMeterSigVis::ReadMeterSigVis( pugi::xml_node element ) { bool AttMeterSigVis::WriteMeterSigVis( pugi::xml_node element ) { bool wroteAttribute = false; - if (this->HasRend()) { - element.append_attribute("rend") = BarRenditionToStr(this->GetRend()).c_str(); + if (this->HasForm()) { + element.append_attribute("form") = BarRenditionToStr(this->GetForm()).c_str(); wroteAttribute = true; } return wroteAttribute; } -bool AttMeterSigVis::HasRend( ) +bool AttMeterSigVis::HasForm( ) { - return (m_rend != BARRENDITION_single); + return (m_form != BARRENDITION_single); } -/* include */ +/* include */ //---------------------------------------------------------------------------- // AttMeterSigDefaultLog @@ -3713,6 +4192,64 @@ bool AttName::HasRole( ) /* include */ +//---------------------------------------------------------------------------- +// AttNotationstyle +//---------------------------------------------------------------------------- + +AttNotationstyle::AttNotationstyle(): Att() { + ResetNotationstyle(); +} + +AttNotationstyle::~AttNotationstyle() { + +} + +void AttNotationstyle::ResetNotationstyle() { + m_musicName = ""; + m_musicSize = ""; +} + +bool AttNotationstyle::ReadNotationstyle( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("music.name")) { + this->SetMusicName(StrToStr(element.attribute("music.name").value())); + element.remove_attribute("music.name"); + hasAttribute = true; + } + if (element.attribute("music.size")) { + this->SetMusicSize(StrToStr(element.attribute("music.size").value())); + element.remove_attribute("music.size"); + hasAttribute = true; + } + return hasAttribute; +} + +bool AttNotationstyle::WriteNotationstyle( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasMusicName()) { + element.append_attribute("music.name") = StrToStr(this->GetMusicName()).c_str(); + wroteAttribute = true; + } + if (this->HasMusicSize()) { + element.append_attribute("music.size") = StrToStr(this->GetMusicSize()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttNotationstyle::HasMusicName( ) +{ + return (m_musicName != ""); +} + +bool AttNotationstyle::HasMusicSize( ) +{ + return (m_musicSize != ""); +} + + +/* include */ + //---------------------------------------------------------------------------- // AttNoteGes //---------------------------------------------------------------------------- @@ -3787,47 +4324,137 @@ bool AttNoteGes::HasPnum( ) /* include */ //---------------------------------------------------------------------------- -// AttNoteVis +// AttNoteheads //---------------------------------------------------------------------------- -AttNoteVis::AttNoteVis(): Att() { - ResetNoteVis(); +AttNoteheads::AttNoteheads(): Att() { + ResetNoteheads(); } -AttNoteVis::~AttNoteVis() { +AttNoteheads::~AttNoteheads() { } -void AttNoteVis::ResetNoteVis() { - m_headshape = ""; +void AttNoteheads::ResetNoteheads() { + m_headColor = ""; + m_headFill = ""; + m_headFillcolor = ""; + m_headMod = ""; + m_headRotation = ""; + m_headShape = ""; + m_headVisible = ""; } -bool AttNoteVis::ReadNoteVis( pugi::xml_node element ) { +bool AttNoteheads::ReadNoteheads( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("headshape")) { - this->SetHeadshape(StrToStr(element.attribute("headshape").value())); - element.remove_attribute("headshape"); + if (element.attribute("head.color")) { + this->SetHeadColor(StrToStr(element.attribute("head.color").value())); + element.remove_attribute("head.color"); + hasAttribute = true; + } + if (element.attribute("head.fill")) { + this->SetHeadFill(StrToStr(element.attribute("head.fill").value())); + element.remove_attribute("head.fill"); + hasAttribute = true; + } + if (element.attribute("head.fillcolor")) { + this->SetHeadFillcolor(StrToStr(element.attribute("head.fillcolor").value())); + element.remove_attribute("head.fillcolor"); + hasAttribute = true; + } + if (element.attribute("head.mod")) { + this->SetHeadMod(StrToStr(element.attribute("head.mod").value())); + element.remove_attribute("head.mod"); + hasAttribute = true; + } + if (element.attribute("head.rotation")) { + this->SetHeadRotation(StrToStr(element.attribute("head.rotation").value())); + element.remove_attribute("head.rotation"); + hasAttribute = true; + } + if (element.attribute("head.shape")) { + this->SetHeadShape(StrToStr(element.attribute("head.shape").value())); + element.remove_attribute("head.shape"); + hasAttribute = true; + } + if (element.attribute("head.visible")) { + this->SetHeadVisible(StrToStr(element.attribute("head.visible").value())); + element.remove_attribute("head.visible"); hasAttribute = true; } return hasAttribute; } -bool AttNoteVis::WriteNoteVis( pugi::xml_node element ) { +bool AttNoteheads::WriteNoteheads( pugi::xml_node element ) { bool wroteAttribute = false; - if (this->HasHeadshape()) { - element.append_attribute("headshape") = StrToStr(this->GetHeadshape()).c_str(); + if (this->HasHeadColor()) { + element.append_attribute("head.color") = StrToStr(this->GetHeadColor()).c_str(); + wroteAttribute = true; + } + if (this->HasHeadFill()) { + element.append_attribute("head.fill") = StrToStr(this->GetHeadFill()).c_str(); + wroteAttribute = true; + } + if (this->HasHeadFillcolor()) { + element.append_attribute("head.fillcolor") = StrToStr(this->GetHeadFillcolor()).c_str(); + wroteAttribute = true; + } + if (this->HasHeadMod()) { + element.append_attribute("head.mod") = StrToStr(this->GetHeadMod()).c_str(); + wroteAttribute = true; + } + if (this->HasHeadRotation()) { + element.append_attribute("head.rotation") = StrToStr(this->GetHeadRotation()).c_str(); + wroteAttribute = true; + } + if (this->HasHeadShape()) { + element.append_attribute("head.shape") = StrToStr(this->GetHeadShape()).c_str(); + wroteAttribute = true; + } + if (this->HasHeadVisible()) { + element.append_attribute("head.visible") = StrToStr(this->GetHeadVisible()).c_str(); wroteAttribute = true; } return wroteAttribute; } -bool AttNoteVis::HasHeadshape( ) +bool AttNoteheads::HasHeadColor( ) +{ + return (m_headColor != ""); +} + +bool AttNoteheads::HasHeadFill( ) +{ + return (m_headFill != ""); +} + +bool AttNoteheads::HasHeadFillcolor( ) +{ + return (m_headFillcolor != ""); +} + +bool AttNoteheads::HasHeadMod( ) +{ + return (m_headMod != ""); +} + +bool AttNoteheads::HasHeadRotation( ) +{ + return (m_headRotation != ""); +} + +bool AttNoteheads::HasHeadShape( ) { - return (m_headshape != ""); + return (m_headShape != ""); } +bool AttNoteheads::HasHeadVisible( ) +{ + return (m_headVisible != ""); +} -/* include */ + +/* include */ //---------------------------------------------------------------------------- // AttOctave @@ -4017,24 +4644,67 @@ bool AttOnelinestaff::HasOntheline( ) /* include */ //---------------------------------------------------------------------------- -// AttPadLog +// AttOptimization //---------------------------------------------------------------------------- -AttPadLog::AttPadLog(): Att() { - ResetPadLog(); +AttOptimization::AttOptimization(): Att() { + ResetOptimization(); } -AttPadLog::~AttPadLog() { +AttOptimization::~AttOptimization() { } -void AttPadLog::ResetPadLog() { - m_num = -1; +void AttOptimization::ResetOptimization() { + m_optimize = ""; } -bool AttPadLog::ReadPadLog( pugi::xml_node element ) { +bool AttOptimization::ReadOptimization( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("num")) { + if (element.attribute("optimize")) { + this->SetOptimize(StrToStr(element.attribute("optimize").value())); + element.remove_attribute("optimize"); + hasAttribute = true; + } + return hasAttribute; +} + +bool AttOptimization::WriteOptimization( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasOptimize()) { + element.append_attribute("optimize") = StrToStr(this->GetOptimize()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttOptimization::HasOptimize( ) +{ + return (m_optimize != ""); +} + + +/* include */ + +//---------------------------------------------------------------------------- +// AttPadLog +//---------------------------------------------------------------------------- + +AttPadLog::AttPadLog(): Att() { + ResetPadLog(); +} + +AttPadLog::~AttPadLog() { + +} + +void AttPadLog::ResetPadLog() { + m_num = -1; +} + +bool AttPadLog::ReadPadLog( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("num")) { this->SetNum(StrToInt(element.attribute("num").value())); element.remove_attribute("num"); hasAttribute = true; @@ -4059,6 +4729,154 @@ bool AttPadLog::HasNum( ) /* include */ +//---------------------------------------------------------------------------- +// AttPages +//---------------------------------------------------------------------------- + +AttPages::AttPages(): Att() { + ResetPages(); +} + +AttPages::~AttPages() { + +} + +void AttPages::ResetPages() { + m_pageHeight = ""; + m_pageWidth = ""; + m_pageTopmar = ""; + m_pageBotmar = ""; + m_pageLeftmar = ""; + m_pageRightmar = ""; + m_pagePanels = ""; + m_pageScale = ""; +} + +bool AttPages::ReadPages( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("page.height")) { + this->SetPageHeight(StrToStr(element.attribute("page.height").value())); + element.remove_attribute("page.height"); + hasAttribute = true; + } + if (element.attribute("page.width")) { + this->SetPageWidth(StrToStr(element.attribute("page.width").value())); + element.remove_attribute("page.width"); + hasAttribute = true; + } + if (element.attribute("page.topmar")) { + this->SetPageTopmar(StrToStr(element.attribute("page.topmar").value())); + element.remove_attribute("page.topmar"); + hasAttribute = true; + } + if (element.attribute("page.botmar")) { + this->SetPageBotmar(StrToStr(element.attribute("page.botmar").value())); + element.remove_attribute("page.botmar"); + hasAttribute = true; + } + if (element.attribute("page.leftmar")) { + this->SetPageLeftmar(StrToStr(element.attribute("page.leftmar").value())); + element.remove_attribute("page.leftmar"); + hasAttribute = true; + } + if (element.attribute("page.rightmar")) { + this->SetPageRightmar(StrToStr(element.attribute("page.rightmar").value())); + element.remove_attribute("page.rightmar"); + hasAttribute = true; + } + if (element.attribute("page.panels")) { + this->SetPagePanels(StrToStr(element.attribute("page.panels").value())); + element.remove_attribute("page.panels"); + hasAttribute = true; + } + if (element.attribute("page.scale")) { + this->SetPageScale(StrToStr(element.attribute("page.scale").value())); + element.remove_attribute("page.scale"); + hasAttribute = true; + } + return hasAttribute; +} + +bool AttPages::WritePages( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasPageHeight()) { + element.append_attribute("page.height") = StrToStr(this->GetPageHeight()).c_str(); + wroteAttribute = true; + } + if (this->HasPageWidth()) { + element.append_attribute("page.width") = StrToStr(this->GetPageWidth()).c_str(); + wroteAttribute = true; + } + if (this->HasPageTopmar()) { + element.append_attribute("page.topmar") = StrToStr(this->GetPageTopmar()).c_str(); + wroteAttribute = true; + } + if (this->HasPageBotmar()) { + element.append_attribute("page.botmar") = StrToStr(this->GetPageBotmar()).c_str(); + wroteAttribute = true; + } + if (this->HasPageLeftmar()) { + element.append_attribute("page.leftmar") = StrToStr(this->GetPageLeftmar()).c_str(); + wroteAttribute = true; + } + if (this->HasPageRightmar()) { + element.append_attribute("page.rightmar") = StrToStr(this->GetPageRightmar()).c_str(); + wroteAttribute = true; + } + if (this->HasPagePanels()) { + element.append_attribute("page.panels") = StrToStr(this->GetPagePanels()).c_str(); + wroteAttribute = true; + } + if (this->HasPageScale()) { + element.append_attribute("page.scale") = StrToStr(this->GetPageScale()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttPages::HasPageHeight( ) +{ + return (m_pageHeight != ""); +} + +bool AttPages::HasPageWidth( ) +{ + return (m_pageWidth != ""); +} + +bool AttPages::HasPageTopmar( ) +{ + return (m_pageTopmar != ""); +} + +bool AttPages::HasPageBotmar( ) +{ + return (m_pageBotmar != ""); +} + +bool AttPages::HasPageLeftmar( ) +{ + return (m_pageLeftmar != ""); +} + +bool AttPages::HasPageRightmar( ) +{ + return (m_pageRightmar != ""); +} + +bool AttPages::HasPagePanels( ) +{ + return (m_pagePanels != ""); +} + +bool AttPages::HasPageScale( ) +{ + return (m_pageScale != ""); +} + + +/* include */ + //---------------------------------------------------------------------------- // AttPbVis //---------------------------------------------------------------------------- @@ -4072,14 +4890,14 @@ AttPbVis::~AttPbVis() { } void AttPbVis::ResetPbVis() { - m_func = FUNC_NONE; + m_folium = ""; } bool AttPbVis::ReadPbVis( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("func")) { - this->SetFunc(StrToFunc(element.attribute("func").value())); - element.remove_attribute("func"); + if (element.attribute("folium")) { + this->SetFolium(StrToStr(element.attribute("folium").value())); + element.remove_attribute("folium"); hasAttribute = true; } return hasAttribute; @@ -4087,20 +4905,20 @@ bool AttPbVis::ReadPbVis( pugi::xml_node element ) { bool AttPbVis::WritePbVis( pugi::xml_node element ) { bool wroteAttribute = false; - if (this->HasFunc()) { - element.append_attribute("func") = FuncToStr(this->GetFunc()).c_str(); + if (this->HasFolium()) { + element.append_attribute("folium") = StrToStr(this->GetFolium()).c_str(); wroteAttribute = true; } return wroteAttribute; } -bool AttPbVis::HasFunc( ) +bool AttPbVis::HasFolium( ) { - return (m_func != FUNC_NONE); + return (m_folium != ""); } -/* include */ +/* include */ //---------------------------------------------------------------------------- // AttPitch @@ -4364,6 +5182,49 @@ bool AttPointing::HasTitle( ) /* include */ +//---------------------------------------------------------------------------- +// AttQuantity +//---------------------------------------------------------------------------- + +AttQuantity::AttQuantity(): Att() { + ResetQuantity(); +} + +AttQuantity::~AttQuantity() { + +} + +void AttQuantity::ResetQuantity() { + m_quantityDbl = 0.0; +} + +bool AttQuantity::ReadQuantity( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("quantity")) { + this->SetQuantity(StrToDbl(element.attribute("quantity").value())); + element.remove_attribute("quantity"); + hasAttribute = true; + } + return hasAttribute; +} + +bool AttQuantity::WriteQuantity( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasQuantity()) { + element.append_attribute("quantity") = DblToStr(this->GetQuantity()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttQuantity::HasQuantity( ) +{ + return (m_quantityDbl != 0.0); +} + + +/* include */ + //---------------------------------------------------------------------------- // AttRelativesize //---------------------------------------------------------------------------- @@ -4463,14 +5324,14 @@ AttSbVis::~AttSbVis() { } void AttSbVis::ResetSbVis() { - m_rend = BARRENDITION_single; + m_form = BARRENDITION_single; } bool AttSbVis::ReadSbVis( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("rend")) { - this->SetRend(StrToBarRendition(element.attribute("rend").value())); - element.remove_attribute("rend"); + if (element.attribute("form")) { + this->SetForm(StrToBarRendition(element.attribute("form").value())); + element.remove_attribute("form"); hasAttribute = true; } return hasAttribute; @@ -4478,20 +5339,20 @@ bool AttSbVis::ReadSbVis( pugi::xml_node element ) { bool AttSbVis::WriteSbVis( pugi::xml_node element ) { bool wroteAttribute = false; - if (this->HasRend()) { - element.append_attribute("rend") = BarRenditionToStr(this->GetRend()).c_str(); + if (this->HasForm()) { + element.append_attribute("form") = BarRenditionToStr(this->GetForm()).c_str(); wroteAttribute = true; } return wroteAttribute; } -bool AttSbVis::HasRend( ) +bool AttSbVis::HasForm( ) { - return (m_rend != BARRENDITION_single); + return (m_form != BARRENDITION_single); } -/* include */ +/* include */ //---------------------------------------------------------------------------- // AttScalable @@ -4528,420 +5389,120 @@ bool AttScalable::WriteScalable( pugi::xml_node element ) { return wroteAttribute; } -bool AttScalable::HasScale( ) -{ - return (m_scale != 0); -} - - -/* include */ - -//---------------------------------------------------------------------------- -// AttScoreDefGes -//---------------------------------------------------------------------------- - -AttScoreDefGes::AttScoreDefGes(): Att() { - ResetScoreDefGes(); -} - -AttScoreDefGes::~AttScoreDefGes() { - -} - -void AttScoreDefGes::ResetScoreDefGes() { - m_tunePname = ""; - m_tuneHzDbl = 0.0; - m_tuneTemper = ""; -} - -bool AttScoreDefGes::ReadScoreDefGes( pugi::xml_node element ) { - bool hasAttribute = false; - if (element.attribute("tune.pname")) { - this->SetTunePname(StrToStr(element.attribute("tune.pname").value())); - element.remove_attribute("tune.pname"); - hasAttribute = true; - } - if (element.attribute("tune.Hz")) { - this->SetTuneHz(StrToDbl(element.attribute("tune.Hz").value())); - element.remove_attribute("tune.Hz"); - hasAttribute = true; - } - if (element.attribute("tune.temper")) { - this->SetTuneTemper(StrToStr(element.attribute("tune.temper").value())); - element.remove_attribute("tune.temper"); - hasAttribute = true; - } - return hasAttribute; -} - -bool AttScoreDefGes::WriteScoreDefGes( pugi::xml_node element ) { - bool wroteAttribute = false; - if (this->HasTunePname()) { - element.append_attribute("tune.pname") = StrToStr(this->GetTunePname()).c_str(); - wroteAttribute = true; - } - if (this->HasTuneHz()) { - element.append_attribute("tune.Hz") = DblToStr(this->GetTuneHz()).c_str(); - wroteAttribute = true; - } - if (this->HasTuneTemper()) { - element.append_attribute("tune.temper") = StrToStr(this->GetTuneTemper()).c_str(); - wroteAttribute = true; - } - return wroteAttribute; -} - -bool AttScoreDefGes::HasTunePname( ) -{ - return (m_tunePname != ""); -} - -bool AttScoreDefGes::HasTuneHz( ) -{ - return (m_tuneHzDbl != 0.0); -} - -bool AttScoreDefGes::HasTuneTemper( ) -{ - return (m_tuneTemper != ""); -} - - -/* include */ - -//---------------------------------------------------------------------------- -// AttScoreDefVis -//---------------------------------------------------------------------------- - -AttScoreDefVis::AttScoreDefVis(): Att() { - ResetScoreDefVis(); -} - -AttScoreDefVis::~AttScoreDefVis() { - -} - -void AttScoreDefVis::ResetScoreDefVis() { - m_endingRend = ""; - m_mnumVisible = ""; - m_musicName = ""; - m_musicSize = ""; - m_optimize = ""; - m_pageHeight = ""; - m_pageWidth = ""; - m_pageTopmar = ""; - m_pageBotmar = ""; - m_pageLeftmar = ""; - m_pageRightmar = ""; - m_pagePanels = ""; - m_pageScale = ""; - m_spacingPackexpDbl = 0.0; - m_spacingPackfactDbl = 0.0; - m_spacingStaff = ""; - m_spacingSystem = ""; - m_systemLeftmar = ""; - m_systemRightmar = ""; - m_systemTopmar = ""; - m_vuHeight = ""; -} - -bool AttScoreDefVis::ReadScoreDefVis( pugi::xml_node element ) { - bool hasAttribute = false; - if (element.attribute("ending.rend")) { - this->SetEndingRend(StrToStr(element.attribute("ending.rend").value())); - element.remove_attribute("ending.rend"); - hasAttribute = true; - } - if (element.attribute("mnum.visible")) { - this->SetMnumVisible(StrToStr(element.attribute("mnum.visible").value())); - element.remove_attribute("mnum.visible"); - hasAttribute = true; - } - if (element.attribute("music.name")) { - this->SetMusicName(StrToStr(element.attribute("music.name").value())); - element.remove_attribute("music.name"); - hasAttribute = true; - } - if (element.attribute("music.size")) { - this->SetMusicSize(StrToStr(element.attribute("music.size").value())); - element.remove_attribute("music.size"); - hasAttribute = true; - } - if (element.attribute("optimize")) { - this->SetOptimize(StrToStr(element.attribute("optimize").value())); - element.remove_attribute("optimize"); - hasAttribute = true; - } - if (element.attribute("page.height")) { - this->SetPageHeight(StrToStr(element.attribute("page.height").value())); - element.remove_attribute("page.height"); - hasAttribute = true; - } - if (element.attribute("page.width")) { - this->SetPageWidth(StrToStr(element.attribute("page.width").value())); - element.remove_attribute("page.width"); - hasAttribute = true; - } - if (element.attribute("page.topmar")) { - this->SetPageTopmar(StrToStr(element.attribute("page.topmar").value())); - element.remove_attribute("page.topmar"); - hasAttribute = true; - } - if (element.attribute("page.botmar")) { - this->SetPageBotmar(StrToStr(element.attribute("page.botmar").value())); - element.remove_attribute("page.botmar"); - hasAttribute = true; - } - if (element.attribute("page.leftmar")) { - this->SetPageLeftmar(StrToStr(element.attribute("page.leftmar").value())); - element.remove_attribute("page.leftmar"); - hasAttribute = true; - } - if (element.attribute("page.rightmar")) { - this->SetPageRightmar(StrToStr(element.attribute("page.rightmar").value())); - element.remove_attribute("page.rightmar"); - hasAttribute = true; - } - if (element.attribute("page.panels")) { - this->SetPagePanels(StrToStr(element.attribute("page.panels").value())); - element.remove_attribute("page.panels"); - hasAttribute = true; - } - if (element.attribute("page.scale")) { - this->SetPageScale(StrToStr(element.attribute("page.scale").value())); - element.remove_attribute("page.scale"); - hasAttribute = true; - } - if (element.attribute("spacing.packexp")) { - this->SetSpacingPackexp(StrToDbl(element.attribute("spacing.packexp").value())); - element.remove_attribute("spacing.packexp"); - hasAttribute = true; - } - if (element.attribute("spacing.packfact")) { - this->SetSpacingPackfact(StrToDbl(element.attribute("spacing.packfact").value())); - element.remove_attribute("spacing.packfact"); - hasAttribute = true; - } - if (element.attribute("spacing.staff")) { - this->SetSpacingStaff(StrToStr(element.attribute("spacing.staff").value())); - element.remove_attribute("spacing.staff"); - hasAttribute = true; - } - if (element.attribute("spacing.system")) { - this->SetSpacingSystem(StrToStr(element.attribute("spacing.system").value())); - element.remove_attribute("spacing.system"); - hasAttribute = true; - } - if (element.attribute("system.leftmar")) { - this->SetSystemLeftmar(StrToStr(element.attribute("system.leftmar").value())); - element.remove_attribute("system.leftmar"); - hasAttribute = true; - } - if (element.attribute("system.rightmar")) { - this->SetSystemRightmar(StrToStr(element.attribute("system.rightmar").value())); - element.remove_attribute("system.rightmar"); - hasAttribute = true; - } - if (element.attribute("system.topmar")) { - this->SetSystemTopmar(StrToStr(element.attribute("system.topmar").value())); - element.remove_attribute("system.topmar"); - hasAttribute = true; - } - if (element.attribute("vu.height")) { - this->SetVuHeight(StrToStr(element.attribute("vu.height").value())); - element.remove_attribute("vu.height"); - hasAttribute = true; - } - return hasAttribute; -} - -bool AttScoreDefVis::WriteScoreDefVis( pugi::xml_node element ) { - bool wroteAttribute = false; - if (this->HasEndingRend()) { - element.append_attribute("ending.rend") = StrToStr(this->GetEndingRend()).c_str(); - wroteAttribute = true; - } - if (this->HasMnumVisible()) { - element.append_attribute("mnum.visible") = StrToStr(this->GetMnumVisible()).c_str(); - wroteAttribute = true; - } - if (this->HasMusicName()) { - element.append_attribute("music.name") = StrToStr(this->GetMusicName()).c_str(); - wroteAttribute = true; - } - if (this->HasMusicSize()) { - element.append_attribute("music.size") = StrToStr(this->GetMusicSize()).c_str(); - wroteAttribute = true; - } - if (this->HasOptimize()) { - element.append_attribute("optimize") = StrToStr(this->GetOptimize()).c_str(); - wroteAttribute = true; - } - if (this->HasPageHeight()) { - element.append_attribute("page.height") = StrToStr(this->GetPageHeight()).c_str(); - wroteAttribute = true; - } - if (this->HasPageWidth()) { - element.append_attribute("page.width") = StrToStr(this->GetPageWidth()).c_str(); - wroteAttribute = true; - } - if (this->HasPageTopmar()) { - element.append_attribute("page.topmar") = StrToStr(this->GetPageTopmar()).c_str(); - wroteAttribute = true; - } - if (this->HasPageBotmar()) { - element.append_attribute("page.botmar") = StrToStr(this->GetPageBotmar()).c_str(); - wroteAttribute = true; - } - if (this->HasPageLeftmar()) { - element.append_attribute("page.leftmar") = StrToStr(this->GetPageLeftmar()).c_str(); - wroteAttribute = true; - } - if (this->HasPageRightmar()) { - element.append_attribute("page.rightmar") = StrToStr(this->GetPageRightmar()).c_str(); - wroteAttribute = true; - } - if (this->HasPagePanels()) { - element.append_attribute("page.panels") = StrToStr(this->GetPagePanels()).c_str(); - wroteAttribute = true; - } - if (this->HasPageScale()) { - element.append_attribute("page.scale") = StrToStr(this->GetPageScale()).c_str(); - wroteAttribute = true; - } - if (this->HasSpacingPackexp()) { - element.append_attribute("spacing.packexp") = DblToStr(this->GetSpacingPackexp()).c_str(); - wroteAttribute = true; - } - if (this->HasSpacingPackfact()) { - element.append_attribute("spacing.packfact") = DblToStr(this->GetSpacingPackfact()).c_str(); - wroteAttribute = true; - } - if (this->HasSpacingStaff()) { - element.append_attribute("spacing.staff") = StrToStr(this->GetSpacingStaff()).c_str(); - wroteAttribute = true; - } - if (this->HasSpacingSystem()) { - element.append_attribute("spacing.system") = StrToStr(this->GetSpacingSystem()).c_str(); - wroteAttribute = true; - } - if (this->HasSystemLeftmar()) { - element.append_attribute("system.leftmar") = StrToStr(this->GetSystemLeftmar()).c_str(); - wroteAttribute = true; - } - if (this->HasSystemRightmar()) { - element.append_attribute("system.rightmar") = StrToStr(this->GetSystemRightmar()).c_str(); - wroteAttribute = true; - } - if (this->HasSystemTopmar()) { - element.append_attribute("system.topmar") = StrToStr(this->GetSystemTopmar()).c_str(); - wroteAttribute = true; - } - if (this->HasVuHeight()) { - element.append_attribute("vu.height") = StrToStr(this->GetVuHeight()).c_str(); - wroteAttribute = true; - } - return wroteAttribute; -} - -bool AttScoreDefVis::HasEndingRend( ) -{ - return (m_endingRend != ""); -} - -bool AttScoreDefVis::HasMnumVisible( ) -{ - return (m_mnumVisible != ""); -} - -bool AttScoreDefVis::HasMusicName( ) -{ - return (m_musicName != ""); -} - -bool AttScoreDefVis::HasMusicSize( ) -{ - return (m_musicSize != ""); -} - -bool AttScoreDefVis::HasOptimize( ) -{ - return (m_optimize != ""); -} - -bool AttScoreDefVis::HasPageHeight( ) +bool AttScalable::HasScale( ) { - return (m_pageHeight != ""); + return (m_scale != 0); } -bool AttScoreDefVis::HasPageWidth( ) -{ - return (m_pageWidth != ""); -} -bool AttScoreDefVis::HasPageTopmar( ) -{ - return (m_pageTopmar != ""); +/* include */ + +//---------------------------------------------------------------------------- +// AttScoreDefGes +//---------------------------------------------------------------------------- + +AttScoreDefGes::AttScoreDefGes(): Att() { + ResetScoreDefGes(); } -bool AttScoreDefVis::HasPageBotmar( ) -{ - return (m_pageBotmar != ""); +AttScoreDefGes::~AttScoreDefGes() { + } -bool AttScoreDefVis::HasPageLeftmar( ) -{ - return (m_pageLeftmar != ""); +void AttScoreDefGes::ResetScoreDefGes() { + m_tunePname = ""; + m_tuneHzDbl = 0.0; + m_tuneTemper = ""; } -bool AttScoreDefVis::HasPageRightmar( ) -{ - return (m_pageRightmar != ""); +bool AttScoreDefGes::ReadScoreDefGes( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("tune.pname")) { + this->SetTunePname(StrToStr(element.attribute("tune.pname").value())); + element.remove_attribute("tune.pname"); + hasAttribute = true; + } + if (element.attribute("tune.Hz")) { + this->SetTuneHz(StrToDbl(element.attribute("tune.Hz").value())); + element.remove_attribute("tune.Hz"); + hasAttribute = true; + } + if (element.attribute("tune.temper")) { + this->SetTuneTemper(StrToStr(element.attribute("tune.temper").value())); + element.remove_attribute("tune.temper"); + hasAttribute = true; + } + return hasAttribute; } -bool AttScoreDefVis::HasPagePanels( ) -{ - return (m_pagePanels != ""); +bool AttScoreDefGes::WriteScoreDefGes( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasTunePname()) { + element.append_attribute("tune.pname") = StrToStr(this->GetTunePname()).c_str(); + wroteAttribute = true; + } + if (this->HasTuneHz()) { + element.append_attribute("tune.Hz") = DblToStr(this->GetTuneHz()).c_str(); + wroteAttribute = true; + } + if (this->HasTuneTemper()) { + element.append_attribute("tune.temper") = StrToStr(this->GetTuneTemper()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; } -bool AttScoreDefVis::HasPageScale( ) +bool AttScoreDefGes::HasTunePname( ) { - return (m_pageScale != ""); + return (m_tunePname != ""); } -bool AttScoreDefVis::HasSpacingPackexp( ) +bool AttScoreDefGes::HasTuneHz( ) { - return (m_spacingPackexpDbl != 0.0); + return (m_tuneHzDbl != 0.0); } -bool AttScoreDefVis::HasSpacingPackfact( ) +bool AttScoreDefGes::HasTuneTemper( ) { - return (m_spacingPackfactDbl != 0.0); + return (m_tuneTemper != ""); } -bool AttScoreDefVis::HasSpacingStaff( ) -{ - return (m_spacingStaff != ""); + +/* include */ + +//---------------------------------------------------------------------------- +// AttScoreDefVis +//---------------------------------------------------------------------------- + +AttScoreDefVis::AttScoreDefVis(): Att() { + ResetScoreDefVis(); } -bool AttScoreDefVis::HasSpacingSystem( ) -{ - return (m_spacingSystem != ""); +AttScoreDefVis::~AttScoreDefVis() { + } -bool AttScoreDefVis::HasSystemLeftmar( ) -{ - return (m_systemLeftmar != ""); +void AttScoreDefVis::ResetScoreDefVis() { + m_vuHeight = ""; } -bool AttScoreDefVis::HasSystemRightmar( ) -{ - return (m_systemRightmar != ""); +bool AttScoreDefVis::ReadScoreDefVis( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("vu.height")) { + this->SetVuHeight(StrToStr(element.attribute("vu.height").value())); + element.remove_attribute("vu.height"); + hasAttribute = true; + } + return hasAttribute; } -bool AttScoreDefVis::HasSystemTopmar( ) -{ - return (m_systemTopmar != ""); +bool AttScoreDefVis::WriteScoreDefVis( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasVuHeight()) { + element.append_attribute("vu.height") = StrToStr(this->GetVuHeight()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; } bool AttScoreDefVis::HasVuHeight( ) @@ -5167,6 +5728,94 @@ bool AttSpaceVis::HasCompressable( ) /* include */ +//---------------------------------------------------------------------------- +// AttSpacing +//---------------------------------------------------------------------------- + +AttSpacing::AttSpacing(): Att() { + ResetSpacing(); +} + +AttSpacing::~AttSpacing() { + +} + +void AttSpacing::ResetSpacing() { + m_spacingPackexpDbl = 0.0; + m_spacingPackfactDbl = 0.0; + m_spacingStaff = ""; + m_spacingSystem = ""; +} + +bool AttSpacing::ReadSpacing( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("spacing.packexp")) { + this->SetSpacingPackexp(StrToDbl(element.attribute("spacing.packexp").value())); + element.remove_attribute("spacing.packexp"); + hasAttribute = true; + } + if (element.attribute("spacing.packfact")) { + this->SetSpacingPackfact(StrToDbl(element.attribute("spacing.packfact").value())); + element.remove_attribute("spacing.packfact"); + hasAttribute = true; + } + if (element.attribute("spacing.staff")) { + this->SetSpacingStaff(StrToStr(element.attribute("spacing.staff").value())); + element.remove_attribute("spacing.staff"); + hasAttribute = true; + } + if (element.attribute("spacing.system")) { + this->SetSpacingSystem(StrToStr(element.attribute("spacing.system").value())); + element.remove_attribute("spacing.system"); + hasAttribute = true; + } + return hasAttribute; +} + +bool AttSpacing::WriteSpacing( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasSpacingPackexp()) { + element.append_attribute("spacing.packexp") = DblToStr(this->GetSpacingPackexp()).c_str(); + wroteAttribute = true; + } + if (this->HasSpacingPackfact()) { + element.append_attribute("spacing.packfact") = DblToStr(this->GetSpacingPackfact()).c_str(); + wroteAttribute = true; + } + if (this->HasSpacingStaff()) { + element.append_attribute("spacing.staff") = StrToStr(this->GetSpacingStaff()).c_str(); + wroteAttribute = true; + } + if (this->HasSpacingSystem()) { + element.append_attribute("spacing.system") = StrToStr(this->GetSpacingSystem()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttSpacing::HasSpacingPackexp( ) +{ + return (m_spacingPackexpDbl != 0.0); +} + +bool AttSpacing::HasSpacingPackfact( ) +{ + return (m_spacingPackfactDbl != 0.0); +} + +bool AttSpacing::HasSpacingStaff( ) +{ + return (m_spacingStaff != ""); +} + +bool AttSpacing::HasSpacingSystem( ) +{ + return (m_spacingSystem != ""); +} + + +/* include */ + //---------------------------------------------------------------------------- // AttStaffLog //---------------------------------------------------------------------------- @@ -5645,26 +6294,27 @@ bool AttStartid::HasStartid( ) /* include */ //---------------------------------------------------------------------------- -// AttStemmed +// AttStems //---------------------------------------------------------------------------- -AttStemmed::AttStemmed(): Att() { - ResetStemmed(); +AttStems::AttStems(): Att() { + ResetStems(); } -AttStemmed::~AttStemmed() { +AttStems::~AttStems() { } -void AttStemmed::ResetStemmed() { +void AttStems::ResetStems() { m_stemDir = STEMDIRECTION_NONE; m_stemLen = 0; + m_stemMod = STEMMODIFIER_NONE; m_stemPos = STEMPOSITION_NONE; m_stemX = 0; m_stemY = 0; } -bool AttStemmed::ReadStemmed( pugi::xml_node element ) { +bool AttStems::ReadStems( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("stem.dir")) { this->SetStemDir(StrToStemDirection(element.attribute("stem.dir").value())); @@ -5676,6 +6326,11 @@ bool AttStemmed::ReadStemmed( pugi::xml_node element ) { element.remove_attribute("stem.len"); hasAttribute = true; } + if (element.attribute("stem.mod")) { + this->SetStemMod(StrToStemModifier(element.attribute("stem.mod").value())); + element.remove_attribute("stem.mod"); + hasAttribute = true; + } if (element.attribute("stem.pos")) { this->SetStemPos(StrToStemPosition(element.attribute("stem.pos").value())); element.remove_attribute("stem.pos"); @@ -5694,7 +6349,7 @@ bool AttStemmed::ReadStemmed( pugi::xml_node element ) { return hasAttribute; } -bool AttStemmed::WriteStemmed( pugi::xml_node element ) { +bool AttStems::WriteStems( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasStemDir()) { element.append_attribute("stem.dir") = StemDirectionToStr(this->GetStemDir()).c_str(); @@ -5704,6 +6359,10 @@ bool AttStemmed::WriteStemmed( pugi::xml_node element ) { element.append_attribute("stem.len") = IntToStr(this->GetStemLen()).c_str(); wroteAttribute = true; } + if (this->HasStemMod()) { + element.append_attribute("stem.mod") = StemModifierToStr(this->GetStemMod()).c_str(); + wroteAttribute = true; + } if (this->HasStemPos()) { element.append_attribute("stem.pos") = StemPositionToStr(this->GetStemPos()).c_str(); wroteAttribute = true; @@ -5719,27 +6378,32 @@ bool AttStemmed::WriteStemmed( pugi::xml_node element ) { return wroteAttribute; } -bool AttStemmed::HasStemDir( ) +bool AttStems::HasStemDir( ) { return (m_stemDir != STEMDIRECTION_NONE); } -bool AttStemmed::HasStemLen( ) +bool AttStems::HasStemLen( ) { return (m_stemLen != 0); } -bool AttStemmed::HasStemPos( ) +bool AttStems::HasStemMod( ) +{ + return (m_stemMod != STEMMODIFIER_NONE); +} + +bool AttStems::HasStemPos( ) { return (m_stemPos != STEMPOSITION_NONE); } -bool AttStemmed::HasStemX( ) +bool AttStems::HasStemX( ) { return (m_stemX != 0); } -bool AttStemmed::HasStemY( ) +bool AttStems::HasStemY( ) { return (m_stemY != 0); } @@ -5840,13 +6504,101 @@ bool AttSyltext::WriteSyltext( pugi::xml_node element ) { return wroteAttribute; } -bool AttSyltext::HasSyl( ) +bool AttSyltext::HasSyl( ) +{ + return (m_syl != ""); +} + + +/* include */ + +//---------------------------------------------------------------------------- +// AttSystems +//---------------------------------------------------------------------------- + +AttSystems::AttSystems(): Att() { + ResetSystems(); +} + +AttSystems::~AttSystems() { + +} + +void AttSystems::ResetSystems() { + m_systemLeftline = ""; + m_systemLeftmar = ""; + m_systemRightmar = ""; + m_systemTopmar = ""; +} + +bool AttSystems::ReadSystems( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("system.leftline")) { + this->SetSystemLeftline(StrToStr(element.attribute("system.leftline").value())); + element.remove_attribute("system.leftline"); + hasAttribute = true; + } + if (element.attribute("system.leftmar")) { + this->SetSystemLeftmar(StrToStr(element.attribute("system.leftmar").value())); + element.remove_attribute("system.leftmar"); + hasAttribute = true; + } + if (element.attribute("system.rightmar")) { + this->SetSystemRightmar(StrToStr(element.attribute("system.rightmar").value())); + element.remove_attribute("system.rightmar"); + hasAttribute = true; + } + if (element.attribute("system.topmar")) { + this->SetSystemTopmar(StrToStr(element.attribute("system.topmar").value())); + element.remove_attribute("system.topmar"); + hasAttribute = true; + } + return hasAttribute; +} + +bool AttSystems::WriteSystems( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasSystemLeftline()) { + element.append_attribute("system.leftline") = StrToStr(this->GetSystemLeftline()).c_str(); + wroteAttribute = true; + } + if (this->HasSystemLeftmar()) { + element.append_attribute("system.leftmar") = StrToStr(this->GetSystemLeftmar()).c_str(); + wroteAttribute = true; + } + if (this->HasSystemRightmar()) { + element.append_attribute("system.rightmar") = StrToStr(this->GetSystemRightmar()).c_str(); + wroteAttribute = true; + } + if (this->HasSystemTopmar()) { + element.append_attribute("system.topmar") = StrToStr(this->GetSystemTopmar()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttSystems::HasSystemLeftline( ) +{ + return (m_systemLeftline != ""); +} + +bool AttSystems::HasSystemLeftmar( ) { - return (m_syl != ""); + return (m_systemLeftmar != ""); } +bool AttSystems::HasSystemRightmar( ) +{ + return (m_systemRightmar != ""); +} -/* include */ +bool AttSystems::HasSystemTopmar( ) +{ + return (m_systemTopmar != ""); +} + + +/* include */ //---------------------------------------------------------------------------- // AttTextstyle @@ -6050,14 +6802,14 @@ AttTimestampPerformed::~AttTimestampPerformed() { } void AttTimestampPerformed::ResetTimestampPerformed() { - m_tstampGesInt = 0; + m_tstampGes = ""; m_tstampReal = ""; } bool AttTimestampPerformed::ReadTimestampPerformed( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("tstamp.ges")) { - this->SetTstampGes(StrToInt(element.attribute("tstamp.ges").value())); + this->SetTstampGes(StrToStr(element.attribute("tstamp.ges").value())); element.remove_attribute("tstamp.ges"); hasAttribute = true; } @@ -6072,7 +6824,7 @@ bool AttTimestampPerformed::ReadTimestampPerformed( pugi::xml_node element ) { bool AttTimestampPerformed::WriteTimestampPerformed( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasTstampGes()) { - element.append_attribute("tstamp.ges") = IntToStr(this->GetTstampGes()).c_str(); + element.append_attribute("tstamp.ges") = StrToStr(this->GetTstampGes()).c_str(); wroteAttribute = true; } if (this->HasTstampReal()) { @@ -6084,7 +6836,7 @@ bool AttTimestampPerformed::WriteTimestampPerformed( pugi::xml_node element ) { bool AttTimestampPerformed::HasTstampGes( ) { - return (m_tstampGesInt != 0); + return (m_tstampGes != ""); } bool AttTimestampPerformed::HasTstampReal( ) @@ -6973,14 +7725,6 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } } - if (element->HasAttClass( ATT_ALTSYM ) ) { - AttAltsym *att = dynamic_cast(element); - assert( att ); - if (attrType == "altsym") { - att->SetAltsym(att->StrToStr(attrValue)); - return true; - } - } if (element->HasAttClass( ATT_ARTICULATION ) ) { AttArticulation *att = dynamic_cast(element); assert( att ); @@ -7020,8 +7764,8 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_BARLINELOG ) ) { AttBarLineLog *att = dynamic_cast(element); assert( att ); - if (attrType == "rend") { - att->SetRend(att->StrToBarRendition(attrValue)); + if (attrType == "form") { + att->SetForm(att->StrToBarRendition(attrValue)); return true; } } @@ -7072,8 +7816,8 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_CANONICAL ) ) { AttCanonical *att = dynamic_cast(element); assert( att ); - if (attrType == "dbkey") { - att->SetDbkey(att->StrToStr(attrValue)); + if (attrType == "codedval") { + att->SetCodedval(att->StrToStr(attrValue)); return true; } } @@ -7085,6 +7829,14 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } } + if (element->HasAttClass( ATT_CLASSCODEIDENT ) ) { + AttClasscodeident *att = dynamic_cast(element); + assert( att ); + if (attrType == "classcode") { + att->SetClasscode(att->StrToStr(attrValue)); + return true; + } + } if (element->HasAttClass( ATT_CLEFLOG ) ) { AttClefLog *att = dynamic_cast(element); assert( att ); @@ -7133,14 +7885,6 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } } - if (element->HasAttClass( ATT_CODED ) ) { - AttCoded *att = dynamic_cast(element); - assert( att ); - if (attrType == "code") { - att->SetCode(att->StrToStr(attrValue)); - return true; - } - } if (element->HasAttClass( ATT_COLOR ) ) { AttColor *att = dynamic_cast(element); assert( att ); @@ -7160,14 +7904,18 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_COMMON ) ) { AttCommon *att = dynamic_cast(element); assert( att ); - if (attrType == "label") { - att->SetLabel(att->StrToStr(attrValue)); - return true; - } if (attrType == "n") { att->SetN(att->StrToInt(attrValue)); return true; } + } + if (element->HasAttClass( ATT_COMMONPART ) ) { + AttCommonPart *att = dynamic_cast(element); + assert( att ); + if (attrType == "label") { + att->SetLabel(att->StrToStr(attrValue)); + return true; + } if (attrType == "base") { att->SetBase(att->StrToStr(attrValue)); return true; @@ -7212,8 +7960,12 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_CURVEREND ) ) { AttCurverend *att = dynamic_cast(element); assert( att ); - if (attrType == "rend") { - att->SetRend(att->StrToBarRendition(attrValue)); + if (attrType == "lform") { + att->SetLform(att->StrToStr(attrValue)); + return true; + } + if (attrType == "lwidth") { + att->SetLwidth(att->StrToStr(attrValue)); return true; } } @@ -7285,7 +8037,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttDotLog *att = dynamic_cast(element); assert( att ); if (attrType == "form") { - att->SetForm(att->StrToStr(attrValue)); + att->SetForm(att->StrToBarRendition(attrValue)); return true; } } @@ -7349,6 +8101,22 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } } + if (element->HasAttClass( ATT_ENDINGS ) ) { + AttEndings *att = dynamic_cast(element); + assert( att ); + if (attrType == "endingRend") { + att->SetEndingRend(att->StrToStr(attrValue)); + return true; + } + } + if (element->HasAttClass( ATT_EXTENDER ) ) { + AttExtender *att = dynamic_cast(element); + assert( att ); + if (attrType == "extender") { + att->SetExtender(att->StrToStr(attrValue)); + return true; + } + } if (element->HasAttClass( ATT_FERMATAPRESENT ) ) { AttFermatapresent *att = dynamic_cast(element); assert( att ); @@ -7357,6 +8125,22 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } } + if (element->HasAttClass( ATT_FILING ) ) { + AttFiling *att = dynamic_cast(element); + assert( att ); + if (attrType == "nonfilingInt") { + att->SetNonfiling(att->StrToInt(attrValue)); + return true; + } + } + if (element->HasAttClass( ATT_GRPSYMLOG ) ) { + AttGrpSymLog *att = dynamic_cast(element); + assert( att ); + if (attrType == "levelInt") { + att->SetLevel(att->StrToInt(attrValue)); + return true; + } + } if (element->HasAttClass( ATT_HANDIDENT ) ) { AttHandident *att = dynamic_cast(element); assert( att ); @@ -7365,6 +8149,14 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } } + if (element->HasAttClass( ATT_HEIGHT ) ) { + AttHeight *att = dynamic_cast(element); + assert( att ); + if (attrType == "height") { + att->SetHeight(att->StrToStr(attrValue)); + return true; + } + } if (element->HasAttClass( ATT_HORIZONTALALIGN ) ) { AttHorizontalalign *att = dynamic_cast(element); assert( att ); @@ -7456,6 +8248,10 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu att->SetLang(att->StrToStr(attrValue)); return true; } + if (attrType == "translit") { + att->SetTranslit(att->StrToStr(attrValue)); + return true; + } } if (element->HasAttClass( ATT_LAYERLOG ) ) { AttLayerLog *att = dynamic_cast(element); @@ -7468,8 +8264,36 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_LAYERIDENT ) ) { AttLayerident *att = dynamic_cast(element); assert( att ); - if (attrType == "layer") { - att->SetLayer(att->StrToStr(attrValue)); + if (attrType == "layerInt") { + att->SetLayer(att->StrToInt(attrValue)); + return true; + } + } + if (element->HasAttClass( ATT_LINEVIS ) ) { + AttLineVis *att = dynamic_cast(element); + assert( att ); + if (attrType == "form") { + att->SetForm(att->StrToBarRendition(attrValue)); + return true; + } + if (attrType == "width") { + att->SetWidth(att->StrToStr(attrValue)); + return true; + } + if (attrType == "endsym") { + att->SetEndsym(att->StrToStr(attrValue)); + return true; + } + if (attrType == "endsymsize") { + att->SetEndsymsize(att->StrToStr(attrValue)); + return true; + } + if (attrType == "startsym") { + att->SetStartsym(att->StrToStr(attrValue)); + return true; + } + if (attrType == "startsymsize") { + att->SetStartsymsize(att->StrToStr(attrValue)); return true; } } @@ -7484,8 +8308,32 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_LINEREND ) ) { AttLinerend *att = dynamic_cast(element); assert( att ); - if (attrType == "rend") { - att->SetRend(att->StrToBarRendition(attrValue)); + if (attrType == "lendsym") { + att->SetLendsym(att->StrToStr(attrValue)); + return true; + } + if (attrType == "lendsymsize") { + att->SetLendsymsize(att->StrToStr(attrValue)); + return true; + } + if (attrType == "lstartsym") { + att->SetLstartsym(att->StrToStr(attrValue)); + return true; + } + if (attrType == "lstartsymsize") { + att->SetLstartsymsize(att->StrToStr(attrValue)); + return true; + } + } + if (element->HasAttClass( ATT_LINERENDBASE ) ) { + AttLinerendBase *att = dynamic_cast(element); + assert( att ); + if (attrType == "lform") { + att->SetLform(att->StrToStr(attrValue)); + return true; + } + if (attrType == "lwidth") { + att->SetLwidth(att->StrToStr(attrValue)); return true; } } @@ -7537,6 +8385,14 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } } + if (element->HasAttClass( ATT_MEASURENUMBERS ) ) { + AttMeasurenumbers *att = dynamic_cast(element); + assert( att ); + if (attrType == "mnumVisible") { + att->SetMnumVisible(att->StrToStr(attrValue)); + return true; + } + } if (element->HasAttClass( ATT_MEDIABOUNDS ) ) { AttMediabounds *att = dynamic_cast(element); assert( att ); @@ -7568,10 +8424,6 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu att->SetMeiversion(att->StrToStr(attrValue)); return true; } - if (attrType == "meiversionNum") { - att->SetMeiversionNum(att->StrToStr(attrValue)); - return true; - } } if (element->HasAttClass( ATT_MENSURLOG ) ) { AttMensurLog *att = dynamic_cast(element); @@ -7604,8 +8456,8 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_METERSIGVIS ) ) { AttMeterSigVis *att = dynamic_cast(element); assert( att ); - if (attrType == "rend") { - att->SetRend(att->StrToBarRendition(attrValue)); + if (attrType == "form") { + att->SetForm(att->StrToBarRendition(attrValue)); return true; } } @@ -7693,6 +8545,18 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } } + if (element->HasAttClass( ATT_NOTATIONSTYLE ) ) { + AttNotationstyle *att = dynamic_cast(element); + assert( att ); + if (attrType == "musicName") { + att->SetMusicName(att->StrToStr(attrValue)); + return true; + } + if (attrType == "musicSize") { + att->SetMusicSize(att->StrToStr(attrValue)); + return true; + } + } if (element->HasAttClass( ATT_NOTEGES ) ) { AttNoteGes *att = dynamic_cast(element); assert( att ); @@ -7709,11 +8573,35 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } } - if (element->HasAttClass( ATT_NOTEVIS ) ) { - AttNoteVis *att = dynamic_cast(element); + if (element->HasAttClass( ATT_NOTEHEADS ) ) { + AttNoteheads *att = dynamic_cast(element); assert( att ); - if (attrType == "headshape") { - att->SetHeadshape(att->StrToStr(attrValue)); + if (attrType == "headColor") { + att->SetHeadColor(att->StrToStr(attrValue)); + return true; + } + if (attrType == "headFill") { + att->SetHeadFill(att->StrToStr(attrValue)); + return true; + } + if (attrType == "headFillcolor") { + att->SetHeadFillcolor(att->StrToStr(attrValue)); + return true; + } + if (attrType == "headMod") { + att->SetHeadMod(att->StrToStr(attrValue)); + return true; + } + if (attrType == "headRotation") { + att->SetHeadRotation(att->StrToStr(attrValue)); + return true; + } + if (attrType == "headShape") { + att->SetHeadShape(att->StrToStr(attrValue)); + return true; + } + if (attrType == "headVisible") { + att->SetHeadVisible(att->StrToStr(attrValue)); return true; } } @@ -7753,6 +8641,14 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } } + if (element->HasAttClass( ATT_OPTIMIZATION ) ) { + AttOptimization *att = dynamic_cast(element); + assert( att ); + if (attrType == "optimize") { + att->SetOptimize(att->StrToStr(attrValue)); + return true; + } + } if (element->HasAttClass( ATT_PADLOG ) ) { AttPadLog *att = dynamic_cast(element); assert( att ); @@ -7761,11 +8657,47 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } } + if (element->HasAttClass( ATT_PAGES ) ) { + AttPages *att = dynamic_cast(element); + assert( att ); + if (attrType == "pageHeight") { + att->SetPageHeight(att->StrToStr(attrValue)); + return true; + } + if (attrType == "pageWidth") { + att->SetPageWidth(att->StrToStr(attrValue)); + return true; + } + if (attrType == "pageTopmar") { + att->SetPageTopmar(att->StrToStr(attrValue)); + return true; + } + if (attrType == "pageBotmar") { + att->SetPageBotmar(att->StrToStr(attrValue)); + return true; + } + if (attrType == "pageLeftmar") { + att->SetPageLeftmar(att->StrToStr(attrValue)); + return true; + } + if (attrType == "pageRightmar") { + att->SetPageRightmar(att->StrToStr(attrValue)); + return true; + } + if (attrType == "pagePanels") { + att->SetPagePanels(att->StrToStr(attrValue)); + return true; + } + if (attrType == "pageScale") { + att->SetPageScale(att->StrToStr(attrValue)); + return true; + } + } if (element->HasAttClass( ATT_PBVIS ) ) { AttPbVis *att = dynamic_cast(element); assert( att ); - if (attrType == "func") { - att->SetFunc(att->StrToFunc(attrValue)); + if (attrType == "folium") { + att->SetFolium(att->StrToStr(attrValue)); return true; } } @@ -7825,6 +8757,14 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } } + if (element->HasAttClass( ATT_QUANTITY ) ) { + AttQuantity *att = dynamic_cast(element); + assert( att ); + if (attrType == "quantityDbl") { + att->SetQuantity(att->StrToDbl(attrValue)); + return true; + } + } if (element->HasAttClass( ATT_RELATIVESIZE ) ) { AttRelativesize *att = dynamic_cast(element); assert( att ); @@ -7844,8 +8784,8 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_SBVIS ) ) { AttSbVis *att = dynamic_cast(element); assert( att ); - if (attrType == "rend") { - att->SetRend(att->StrToBarRendition(attrValue)); + if (attrType == "form") { + att->SetForm(att->StrToBarRendition(attrValue)); return true; } } @@ -7856,106 +8796,26 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu att->SetScale(att->StrToPercent(attrValue)); return true; } - } - if (element->HasAttClass( ATT_SCOREDEFGES ) ) { - AttScoreDefGes *att = dynamic_cast(element); - assert( att ); - if (attrType == "tunePname") { - att->SetTunePname(att->StrToStr(attrValue)); - return true; - } - if (attrType == "tuneHzDbl") { - att->SetTuneHz(att->StrToDbl(attrValue)); - return true; - } - if (attrType == "tuneTemper") { - att->SetTuneTemper(att->StrToStr(attrValue)); - return true; - } - } - if (element->HasAttClass( ATT_SCOREDEFVIS ) ) { - AttScoreDefVis *att = dynamic_cast(element); - assert( att ); - if (attrType == "endingRend") { - att->SetEndingRend(att->StrToStr(attrValue)); - return true; - } - if (attrType == "mnumVisible") { - att->SetMnumVisible(att->StrToStr(attrValue)); - return true; - } - if (attrType == "musicName") { - att->SetMusicName(att->StrToStr(attrValue)); - return true; - } - if (attrType == "musicSize") { - att->SetMusicSize(att->StrToStr(attrValue)); - return true; - } - if (attrType == "optimize") { - att->SetOptimize(att->StrToStr(attrValue)); - return true; - } - if (attrType == "pageHeight") { - att->SetPageHeight(att->StrToStr(attrValue)); - return true; - } - if (attrType == "pageWidth") { - att->SetPageWidth(att->StrToStr(attrValue)); - return true; - } - if (attrType == "pageTopmar") { - att->SetPageTopmar(att->StrToStr(attrValue)); - return true; - } - if (attrType == "pageBotmar") { - att->SetPageBotmar(att->StrToStr(attrValue)); - return true; - } - if (attrType == "pageLeftmar") { - att->SetPageLeftmar(att->StrToStr(attrValue)); - return true; - } - if (attrType == "pageRightmar") { - att->SetPageRightmar(att->StrToStr(attrValue)); - return true; - } - if (attrType == "pagePanels") { - att->SetPagePanels(att->StrToStr(attrValue)); - return true; - } - if (attrType == "pageScale") { - att->SetPageScale(att->StrToStr(attrValue)); - return true; - } - if (attrType == "spacingPackexpDbl") { - att->SetSpacingPackexp(att->StrToDbl(attrValue)); - return true; - } - if (attrType == "spacingPackfactDbl") { - att->SetSpacingPackfact(att->StrToDbl(attrValue)); - return true; - } - if (attrType == "spacingStaff") { - att->SetSpacingStaff(att->StrToStr(attrValue)); - return true; - } - if (attrType == "spacingSystem") { - att->SetSpacingSystem(att->StrToStr(attrValue)); - return true; - } - if (attrType == "systemLeftmar") { - att->SetSystemLeftmar(att->StrToStr(attrValue)); + } + if (element->HasAttClass( ATT_SCOREDEFGES ) ) { + AttScoreDefGes *att = dynamic_cast(element); + assert( att ); + if (attrType == "tunePname") { + att->SetTunePname(att->StrToStr(attrValue)); return true; } - if (attrType == "systemRightmar") { - att->SetSystemRightmar(att->StrToStr(attrValue)); + if (attrType == "tuneHzDbl") { + att->SetTuneHz(att->StrToDbl(attrValue)); return true; } - if (attrType == "systemTopmar") { - att->SetSystemTopmar(att->StrToStr(attrValue)); + if (attrType == "tuneTemper") { + att->SetTuneTemper(att->StrToStr(attrValue)); return true; } + } + if (element->HasAttClass( ATT_SCOREDEFVIS ) ) { + AttScoreDefVis *att = dynamic_cast(element); + assert( att ); if (attrType == "vuHeight") { att->SetVuHeight(att->StrToStr(attrValue)); return true; @@ -8001,6 +8861,26 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } } + if (element->HasAttClass( ATT_SPACING ) ) { + AttSpacing *att = dynamic_cast(element); + assert( att ); + if (attrType == "spacingPackexpDbl") { + att->SetSpacingPackexp(att->StrToDbl(attrValue)); + return true; + } + if (attrType == "spacingPackfactDbl") { + att->SetSpacingPackfact(att->StrToDbl(attrValue)); + return true; + } + if (attrType == "spacingStaff") { + att->SetSpacingStaff(att->StrToStr(attrValue)); + return true; + } + if (attrType == "spacingSystem") { + att->SetSpacingSystem(att->StrToStr(attrValue)); + return true; + } + } if (element->HasAttClass( ATT_STAFFLOG ) ) { AttStaffLog *att = dynamic_cast(element); assert( att ); @@ -8097,8 +8977,8 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } } - if (element->HasAttClass( ATT_STEMMED ) ) { - AttStemmed *att = dynamic_cast(element); + if (element->HasAttClass( ATT_STEMS ) ) { + AttStems *att = dynamic_cast(element); assert( att ); if (attrType == "stemDir") { att->SetStemDir(att->StrToStemDirection(attrValue)); @@ -8108,6 +8988,10 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu att->SetStemLen(att->StrToInt(attrValue)); return true; } + if (attrType == "stemMod") { + att->SetStemMod(att->StrToStemModifier(attrValue)); + return true; + } if (attrType == "stemPos") { att->SetStemPos(att->StrToStemPosition(attrValue)); return true; @@ -8141,6 +9025,26 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } } + if (element->HasAttClass( ATT_SYSTEMS ) ) { + AttSystems *att = dynamic_cast(element); + assert( att ); + if (attrType == "systemLeftline") { + att->SetSystemLeftline(att->StrToStr(attrValue)); + return true; + } + if (attrType == "systemLeftmar") { + att->SetSystemLeftmar(att->StrToStr(attrValue)); + return true; + } + if (attrType == "systemRightmar") { + att->SetSystemRightmar(att->StrToStr(attrValue)); + return true; + } + if (attrType == "systemTopmar") { + att->SetSystemTopmar(att->StrToStr(attrValue)); + return true; + } + } if (element->HasAttClass( ATT_TEXTSTYLE ) ) { AttTextstyle *att = dynamic_cast(element); assert( att ); @@ -8184,8 +9088,8 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_TIMESTAMPPERFORMED ) ) { AttTimestampPerformed *att = dynamic_cast(element); assert( att ); - if (attrType == "tstampGesInt") { - att->SetTstampGes(att->StrToInt(attrValue)); + if (attrType == "tstampGes") { + att->SetTstampGes(att->StrToStr(attrValue)); return true; } if (attrType == "tstampReal") { @@ -8391,13 +9295,6 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("accidGes", att->StrToStr(att->GetAccidGes()))); } } - if (element->HasAttClass( ATT_ALTSYM ) ) { - AttAltsym *att = dynamic_cast(element); - assert( att ); - if (att->HasAltsym()) { - attributes->push_back(std::make_pair("altsym", att->StrToStr(att->GetAltsym()))); - } - } if (element->HasAttClass( ATT_ARTICULATION ) ) { AttArticulation *att = dynamic_cast(element); assert( att ); @@ -8432,8 +9329,8 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { if (element->HasAttClass( ATT_BARLINELOG ) ) { AttBarLineLog *att = dynamic_cast(element); assert( att ); - if (att->HasRend()) { - attributes->push_back(std::make_pair("rend", att->BarRenditionToStr(att->GetRend()))); + if (att->HasForm()) { + attributes->push_back(std::make_pair("form", att->BarRenditionToStr(att->GetForm()))); } } if (element->HasAttClass( ATT_BARPLACEMENT ) ) { @@ -8476,8 +9373,8 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { if (element->HasAttClass( ATT_CANONICAL ) ) { AttCanonical *att = dynamic_cast(element); assert( att ); - if (att->HasDbkey()) { - attributes->push_back(std::make_pair("dbkey", att->StrToStr(att->GetDbkey()))); + if (att->HasCodedval()) { + attributes->push_back(std::make_pair("codedval", att->StrToStr(att->GetCodedval()))); } } if (element->HasAttClass( ATT_CHORDVIS ) ) { @@ -8487,6 +9384,13 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("cluster", att->StrToStr(att->GetCluster()))); } } + if (element->HasAttClass( ATT_CLASSCODEIDENT ) ) { + AttClasscodeident *att = dynamic_cast(element); + assert( att ); + if (att->HasClasscode()) { + attributes->push_back(std::make_pair("classcode", att->StrToStr(att->GetClasscode()))); + } + } if (element->HasAttClass( ATT_CLEFLOG ) ) { AttClefLog *att = dynamic_cast(element); assert( att ); @@ -8527,13 +9431,6 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("shape", att->ClefShapeToStr(att->GetShape()))); } } - if (element->HasAttClass( ATT_CODED ) ) { - AttCoded *att = dynamic_cast(element); - assert( att ); - if (att->HasCode()) { - attributes->push_back(std::make_pair("code", att->StrToStr(att->GetCode()))); - } - } if (element->HasAttClass( ATT_COLOR ) ) { AttColor *att = dynamic_cast(element); assert( att ); @@ -8551,12 +9448,16 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { if (element->HasAttClass( ATT_COMMON ) ) { AttCommon *att = dynamic_cast(element); assert( att ); - if (att->HasLabel()) { - attributes->push_back(std::make_pair("label", att->StrToStr(att->GetLabel()))); - } if (att->HasN()) { attributes->push_back(std::make_pair("n", att->IntToStr(att->GetN()))); } + } + if (element->HasAttClass( ATT_COMMONPART ) ) { + AttCommonPart *att = dynamic_cast(element); + assert( att ); + if (att->HasLabel()) { + attributes->push_back(std::make_pair("label", att->StrToStr(att->GetLabel()))); + } if (att->HasBase()) { attributes->push_back(std::make_pair("base", att->StrToStr(att->GetBase()))); } @@ -8593,8 +9494,11 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { if (element->HasAttClass( ATT_CURVEREND ) ) { AttCurverend *att = dynamic_cast(element); assert( att ); - if (att->HasRend()) { - attributes->push_back(std::make_pair("rend", att->BarRenditionToStr(att->GetRend()))); + if (att->HasLform()) { + attributes->push_back(std::make_pair("lform", att->StrToStr(att->GetLform()))); + } + if (att->HasLwidth()) { + attributes->push_back(std::make_pair("lwidth", att->StrToStr(att->GetLwidth()))); } } if (element->HasAttClass( ATT_CUSTOSLOG ) ) { @@ -8654,7 +9558,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttDotLog *att = dynamic_cast(element); assert( att ); if (att->HasForm()) { - attributes->push_back(std::make_pair("form", att->StrToStr(att->GetForm()))); + attributes->push_back(std::make_pair("form", att->BarRenditionToStr(att->GetForm()))); } } if (element->HasAttClass( ATT_DURATIONADDITIVE ) ) { @@ -8708,6 +9612,20 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("enclose", att->StrToStr(att->GetEnclose()))); } } + if (element->HasAttClass( ATT_ENDINGS ) ) { + AttEndings *att = dynamic_cast(element); + assert( att ); + if (att->HasEndingRend()) { + attributes->push_back(std::make_pair("endingRend", att->StrToStr(att->GetEndingRend()))); + } + } + if (element->HasAttClass( ATT_EXTENDER ) ) { + AttExtender *att = dynamic_cast(element); + assert( att ); + if (att->HasExtender()) { + attributes->push_back(std::make_pair("extender", att->StrToStr(att->GetExtender()))); + } + } if (element->HasAttClass( ATT_FERMATAPRESENT ) ) { AttFermatapresent *att = dynamic_cast(element); assert( att ); @@ -8715,6 +9633,20 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("fermata", att->PlaceToStr(att->GetFermata()))); } } + if (element->HasAttClass( ATT_FILING ) ) { + AttFiling *att = dynamic_cast(element); + assert( att ); + if (att->HasNonfiling()) { + attributes->push_back(std::make_pair("nonfilingInt", att->IntToStr(att->GetNonfiling()))); + } + } + if (element->HasAttClass( ATT_GRPSYMLOG ) ) { + AttGrpSymLog *att = dynamic_cast(element); + assert( att ); + if (att->HasLevel()) { + attributes->push_back(std::make_pair("levelInt", att->IntToStr(att->GetLevel()))); + } + } if (element->HasAttClass( ATT_HANDIDENT ) ) { AttHandident *att = dynamic_cast(element); assert( att ); @@ -8722,6 +9654,13 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("hand", att->StrToStr(att->GetHand()))); } } + if (element->HasAttClass( ATT_HEIGHT ) ) { + AttHeight *att = dynamic_cast(element); + assert( att ); + if (att->HasHeight()) { + attributes->push_back(std::make_pair("height", att->StrToStr(att->GetHeight()))); + } + } if (element->HasAttClass( ATT_HORIZONTALALIGN ) ) { AttHorizontalalign *att = dynamic_cast(element); assert( att ); @@ -8799,6 +9738,9 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { if (att->HasLang()) { attributes->push_back(std::make_pair("lang", att->StrToStr(att->GetLang()))); } + if (att->HasTranslit()) { + attributes->push_back(std::make_pair("translit", att->StrToStr(att->GetTranslit()))); + } } if (element->HasAttClass( ATT_LAYERLOG ) ) { AttLayerLog *att = dynamic_cast(element); @@ -8811,7 +9753,29 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttLayerident *att = dynamic_cast(element); assert( att ); if (att->HasLayer()) { - attributes->push_back(std::make_pair("layer", att->StrToStr(att->GetLayer()))); + attributes->push_back(std::make_pair("layerInt", att->IntToStr(att->GetLayer()))); + } + } + if (element->HasAttClass( ATT_LINEVIS ) ) { + AttLineVis *att = dynamic_cast(element); + assert( att ); + if (att->HasForm()) { + attributes->push_back(std::make_pair("form", att->BarRenditionToStr(att->GetForm()))); + } + if (att->HasWidth()) { + attributes->push_back(std::make_pair("width", att->StrToStr(att->GetWidth()))); + } + if (att->HasEndsym()) { + attributes->push_back(std::make_pair("endsym", att->StrToStr(att->GetEndsym()))); + } + if (att->HasEndsymsize()) { + attributes->push_back(std::make_pair("endsymsize", att->StrToStr(att->GetEndsymsize()))); + } + if (att->HasStartsym()) { + attributes->push_back(std::make_pair("startsym", att->StrToStr(att->GetStartsym()))); + } + if (att->HasStartsymsize()) { + attributes->push_back(std::make_pair("startsymsize", att->StrToStr(att->GetStartsymsize()))); } } if (element->HasAttClass( ATT_LINELOC ) ) { @@ -8824,8 +9788,27 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { if (element->HasAttClass( ATT_LINEREND ) ) { AttLinerend *att = dynamic_cast(element); assert( att ); - if (att->HasRend()) { - attributes->push_back(std::make_pair("rend", att->BarRenditionToStr(att->GetRend()))); + if (att->HasLendsym()) { + attributes->push_back(std::make_pair("lendsym", att->StrToStr(att->GetLendsym()))); + } + if (att->HasLendsymsize()) { + attributes->push_back(std::make_pair("lendsymsize", att->StrToStr(att->GetLendsymsize()))); + } + if (att->HasLstartsym()) { + attributes->push_back(std::make_pair("lstartsym", att->StrToStr(att->GetLstartsym()))); + } + if (att->HasLstartsymsize()) { + attributes->push_back(std::make_pair("lstartsymsize", att->StrToStr(att->GetLstartsymsize()))); + } + } + if (element->HasAttClass( ATT_LINERENDBASE ) ) { + AttLinerendBase *att = dynamic_cast(element); + assert( att ); + if (att->HasLform()) { + attributes->push_back(std::make_pair("lform", att->StrToStr(att->GetLform()))); + } + if (att->HasLwidth()) { + attributes->push_back(std::make_pair("lwidth", att->StrToStr(att->GetLwidth()))); } } if (element->HasAttClass( ATT_LYRICSTYLE ) ) { @@ -8867,6 +9850,13 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("unit", att->IntToStr(att->GetUnit()))); } } + if (element->HasAttClass( ATT_MEASURENUMBERS ) ) { + AttMeasurenumbers *att = dynamic_cast(element); + assert( att ); + if (att->HasMnumVisible()) { + attributes->push_back(std::make_pair("mnumVisible", att->StrToStr(att->GetMnumVisible()))); + } + } if (element->HasAttClass( ATT_MEDIABOUNDS ) ) { AttMediabounds *att = dynamic_cast(element); assert( att ); @@ -8893,9 +9883,6 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { if (att->HasMeiversion()) { attributes->push_back(std::make_pair("meiversion", att->StrToStr(att->GetMeiversion()))); } - if (att->HasMeiversionNum()) { - attributes->push_back(std::make_pair("meiversionNum", att->StrToStr(att->GetMeiversionNum()))); - } } if (element->HasAttClass( ATT_MENSURLOG ) ) { AttMensurLog *att = dynamic_cast(element); @@ -8923,8 +9910,8 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { if (element->HasAttClass( ATT_METERSIGVIS ) ) { AttMeterSigVis *att = dynamic_cast(element); assert( att ); - if (att->HasRend()) { - attributes->push_back(std::make_pair("rend", att->BarRenditionToStr(att->GetRend()))); + if (att->HasForm()) { + attributes->push_back(std::make_pair("form", att->BarRenditionToStr(att->GetForm()))); } } if (element->HasAttClass( ATT_METERSIGDEFAULTLOG ) ) { @@ -8997,6 +9984,16 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("role", att->StrToStr(att->GetRole()))); } } + if (element->HasAttClass( ATT_NOTATIONSTYLE ) ) { + AttNotationstyle *att = dynamic_cast(element); + assert( att ); + if (att->HasMusicName()) { + attributes->push_back(std::make_pair("musicName", att->StrToStr(att->GetMusicName()))); + } + if (att->HasMusicSize()) { + attributes->push_back(std::make_pair("musicSize", att->StrToStr(att->GetMusicSize()))); + } + } if (element->HasAttClass( ATT_NOTEGES ) ) { AttNoteGes *att = dynamic_cast(element); assert( att ); @@ -9010,11 +10007,29 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("pnum", att->StrToStr(att->GetPnum()))); } } - if (element->HasAttClass( ATT_NOTEVIS ) ) { - AttNoteVis *att = dynamic_cast(element); + if (element->HasAttClass( ATT_NOTEHEADS ) ) { + AttNoteheads *att = dynamic_cast(element); assert( att ); - if (att->HasHeadshape()) { - attributes->push_back(std::make_pair("headshape", att->StrToStr(att->GetHeadshape()))); + if (att->HasHeadColor()) { + attributes->push_back(std::make_pair("headColor", att->StrToStr(att->GetHeadColor()))); + } + if (att->HasHeadFill()) { + attributes->push_back(std::make_pair("headFill", att->StrToStr(att->GetHeadFill()))); + } + if (att->HasHeadFillcolor()) { + attributes->push_back(std::make_pair("headFillcolor", att->StrToStr(att->GetHeadFillcolor()))); + } + if (att->HasHeadMod()) { + attributes->push_back(std::make_pair("headMod", att->StrToStr(att->GetHeadMod()))); + } + if (att->HasHeadRotation()) { + attributes->push_back(std::make_pair("headRotation", att->StrToStr(att->GetHeadRotation()))); + } + if (att->HasHeadShape()) { + attributes->push_back(std::make_pair("headShape", att->StrToStr(att->GetHeadShape()))); + } + if (att->HasHeadVisible()) { + attributes->push_back(std::make_pair("headVisible", att->StrToStr(att->GetHeadVisible()))); } } if (element->HasAttClass( ATT_OCTAVE ) ) { @@ -9048,6 +10063,13 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("ontheline", att->StrToStr(att->GetOntheline()))); } } + if (element->HasAttClass( ATT_OPTIMIZATION ) ) { + AttOptimization *att = dynamic_cast(element); + assert( att ); + if (att->HasOptimize()) { + attributes->push_back(std::make_pair("optimize", att->StrToStr(att->GetOptimize()))); + } + } if (element->HasAttClass( ATT_PADLOG ) ) { AttPadLog *att = dynamic_cast(element); assert( att ); @@ -9055,11 +10077,39 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("num", att->IntToStr(att->GetNum()))); } } + if (element->HasAttClass( ATT_PAGES ) ) { + AttPages *att = dynamic_cast(element); + assert( att ); + if (att->HasPageHeight()) { + attributes->push_back(std::make_pair("pageHeight", att->StrToStr(att->GetPageHeight()))); + } + if (att->HasPageWidth()) { + attributes->push_back(std::make_pair("pageWidth", att->StrToStr(att->GetPageWidth()))); + } + if (att->HasPageTopmar()) { + attributes->push_back(std::make_pair("pageTopmar", att->StrToStr(att->GetPageTopmar()))); + } + if (att->HasPageBotmar()) { + attributes->push_back(std::make_pair("pageBotmar", att->StrToStr(att->GetPageBotmar()))); + } + if (att->HasPageLeftmar()) { + attributes->push_back(std::make_pair("pageLeftmar", att->StrToStr(att->GetPageLeftmar()))); + } + if (att->HasPageRightmar()) { + attributes->push_back(std::make_pair("pageRightmar", att->StrToStr(att->GetPageRightmar()))); + } + if (att->HasPagePanels()) { + attributes->push_back(std::make_pair("pagePanels", att->StrToStr(att->GetPagePanels()))); + } + if (att->HasPageScale()) { + attributes->push_back(std::make_pair("pageScale", att->StrToStr(att->GetPageScale()))); + } + } if (element->HasAttClass( ATT_PBVIS ) ) { AttPbVis *att = dynamic_cast(element); assert( att ); - if (att->HasFunc()) { - attributes->push_back(std::make_pair("func", att->FuncToStr(att->GetFunc()))); + if (att->HasFolium()) { + attributes->push_back(std::make_pair("folium", att->StrToStr(att->GetFolium()))); } } if (element->HasAttClass( ATT_PITCH ) ) { @@ -9108,6 +10158,13 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("title", att->StrToStr(att->GetTitle()))); } } + if (element->HasAttClass( ATT_QUANTITY ) ) { + AttQuantity *att = dynamic_cast(element); + assert( att ); + if (att->HasQuantity()) { + attributes->push_back(std::make_pair("quantityDbl", att->DblToStr(att->GetQuantity()))); + } + } if (element->HasAttClass( ATT_RELATIVESIZE ) ) { AttRelativesize *att = dynamic_cast(element); assert( att ); @@ -9125,8 +10182,8 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { if (element->HasAttClass( ATT_SBVIS ) ) { AttSbVis *att = dynamic_cast(element); assert( att ); - if (att->HasRend()) { - attributes->push_back(std::make_pair("rend", att->BarRenditionToStr(att->GetRend()))); + if (att->HasForm()) { + attributes->push_back(std::make_pair("form", att->BarRenditionToStr(att->GetForm()))); } } if (element->HasAttClass( ATT_SCALABLE ) ) { @@ -9152,66 +10209,6 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { if (element->HasAttClass( ATT_SCOREDEFVIS ) ) { AttScoreDefVis *att = dynamic_cast(element); assert( att ); - if (att->HasEndingRend()) { - attributes->push_back(std::make_pair("endingRend", att->StrToStr(att->GetEndingRend()))); - } - if (att->HasMnumVisible()) { - attributes->push_back(std::make_pair("mnumVisible", att->StrToStr(att->GetMnumVisible()))); - } - if (att->HasMusicName()) { - attributes->push_back(std::make_pair("musicName", att->StrToStr(att->GetMusicName()))); - } - if (att->HasMusicSize()) { - attributes->push_back(std::make_pair("musicSize", att->StrToStr(att->GetMusicSize()))); - } - if (att->HasOptimize()) { - attributes->push_back(std::make_pair("optimize", att->StrToStr(att->GetOptimize()))); - } - if (att->HasPageHeight()) { - attributes->push_back(std::make_pair("pageHeight", att->StrToStr(att->GetPageHeight()))); - } - if (att->HasPageWidth()) { - attributes->push_back(std::make_pair("pageWidth", att->StrToStr(att->GetPageWidth()))); - } - if (att->HasPageTopmar()) { - attributes->push_back(std::make_pair("pageTopmar", att->StrToStr(att->GetPageTopmar()))); - } - if (att->HasPageBotmar()) { - attributes->push_back(std::make_pair("pageBotmar", att->StrToStr(att->GetPageBotmar()))); - } - if (att->HasPageLeftmar()) { - attributes->push_back(std::make_pair("pageLeftmar", att->StrToStr(att->GetPageLeftmar()))); - } - if (att->HasPageRightmar()) { - attributes->push_back(std::make_pair("pageRightmar", att->StrToStr(att->GetPageRightmar()))); - } - if (att->HasPagePanels()) { - attributes->push_back(std::make_pair("pagePanels", att->StrToStr(att->GetPagePanels()))); - } - if (att->HasPageScale()) { - attributes->push_back(std::make_pair("pageScale", att->StrToStr(att->GetPageScale()))); - } - if (att->HasSpacingPackexp()) { - attributes->push_back(std::make_pair("spacingPackexpDbl", att->DblToStr(att->GetSpacingPackexp()))); - } - if (att->HasSpacingPackfact()) { - attributes->push_back(std::make_pair("spacingPackfactDbl", att->DblToStr(att->GetSpacingPackfact()))); - } - if (att->HasSpacingStaff()) { - attributes->push_back(std::make_pair("spacingStaff", att->StrToStr(att->GetSpacingStaff()))); - } - if (att->HasSpacingSystem()) { - attributes->push_back(std::make_pair("spacingSystem", att->StrToStr(att->GetSpacingSystem()))); - } - if (att->HasSystemLeftmar()) { - attributes->push_back(std::make_pair("systemLeftmar", att->StrToStr(att->GetSystemLeftmar()))); - } - if (att->HasSystemRightmar()) { - attributes->push_back(std::make_pair("systemRightmar", att->StrToStr(att->GetSystemRightmar()))); - } - if (att->HasSystemTopmar()) { - attributes->push_back(std::make_pair("systemTopmar", att->StrToStr(att->GetSystemTopmar()))); - } if (att->HasVuHeight()) { attributes->push_back(std::make_pair("vuHeight", att->StrToStr(att->GetVuHeight()))); } @@ -9251,6 +10248,22 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("compressable", att->StrToStr(att->GetCompressable()))); } } + if (element->HasAttClass( ATT_SPACING ) ) { + AttSpacing *att = dynamic_cast(element); + assert( att ); + if (att->HasSpacingPackexp()) { + attributes->push_back(std::make_pair("spacingPackexpDbl", att->DblToStr(att->GetSpacingPackexp()))); + } + if (att->HasSpacingPackfact()) { + attributes->push_back(std::make_pair("spacingPackfactDbl", att->DblToStr(att->GetSpacingPackfact()))); + } + if (att->HasSpacingStaff()) { + attributes->push_back(std::make_pair("spacingStaff", att->StrToStr(att->GetSpacingStaff()))); + } + if (att->HasSpacingSystem()) { + attributes->push_back(std::make_pair("spacingSystem", att->StrToStr(att->GetSpacingSystem()))); + } + } if (element->HasAttClass( ATT_STAFFLOG ) ) { AttStaffLog *att = dynamic_cast(element); assert( att ); @@ -9332,8 +10345,8 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("startid", att->StrToStr(att->GetStartid()))); } } - if (element->HasAttClass( ATT_STEMMED ) ) { - AttStemmed *att = dynamic_cast(element); + if (element->HasAttClass( ATT_STEMS ) ) { + AttStems *att = dynamic_cast(element); assert( att ); if (att->HasStemDir()) { attributes->push_back(std::make_pair("stemDir", att->StemDirectionToStr(att->GetStemDir()))); @@ -9341,6 +10354,9 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { if (att->HasStemLen()) { attributes->push_back(std::make_pair("stemLen", att->IntToStr(att->GetStemLen()))); } + if (att->HasStemMod()) { + attributes->push_back(std::make_pair("stemMod", att->StemModifierToStr(att->GetStemMod()))); + } if (att->HasStemPos()) { attributes->push_back(std::make_pair("stemPos", att->StemPositionToStr(att->GetStemPos()))); } @@ -9368,6 +10384,22 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("syl", att->StrToStr(att->GetSyl()))); } } + if (element->HasAttClass( ATT_SYSTEMS ) ) { + AttSystems *att = dynamic_cast(element); + assert( att ); + if (att->HasSystemLeftline()) { + attributes->push_back(std::make_pair("systemLeftline", att->StrToStr(att->GetSystemLeftline()))); + } + if (att->HasSystemLeftmar()) { + attributes->push_back(std::make_pair("systemLeftmar", att->StrToStr(att->GetSystemLeftmar()))); + } + if (att->HasSystemRightmar()) { + attributes->push_back(std::make_pair("systemRightmar", att->StrToStr(att->GetSystemRightmar()))); + } + if (att->HasSystemTopmar()) { + attributes->push_back(std::make_pair("systemTopmar", att->StrToStr(att->GetSystemTopmar()))); + } + } if (element->HasAttClass( ATT_TEXTSTYLE ) ) { AttTextstyle *att = dynamic_cast(element); assert( att ); @@ -9405,7 +10437,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttTimestampPerformed *att = dynamic_cast(element); assert( att ); if (att->HasTstampGes()) { - attributes->push_back(std::make_pair("tstampGesInt", att->IntToStr(att->GetTstampGes()))); + attributes->push_back(std::make_pair("tstampGes", att->StrToStr(att->GetTstampGes()))); } if (att->HasTstampReal()) { attributes->push_back(std::make_pair("tstampReal", att->StrToStr(att->GetTstampReal()))); diff --git a/libmei/atts_shared.h b/libmei/atts_shared.h index 56368613edd..c2ea7f4acba 100644 --- a/libmei/atts_shared.h +++ b/libmei/atts_shared.h @@ -133,56 +133,12 @@ class AttAccidentalPerformed: public Att ///@} private: - /** - * Records the performed pitch inflection when it differs from the written - * accidental. - **/ + /** Records the performed pitch inflection. **/ std::string m_accidGes; /* include */ }; -//---------------------------------------------------------------------------- -// AttAltsym -//---------------------------------------------------------------------------- - -class AttAltsym: public Att -{ -public: - AttAltsym(); - virtual ~AttAltsym(); - - /** Reset the default values for the attribute class **/ - void ResetAltsym(); - - /** Read the values for the attribute class **/ - bool ReadAltsym( pugi::xml_node element ); - - /** Write the values for the attribute class **/ - bool WriteAltsym( pugi::xml_node element ); - - /** - * @name Setters, getters and presence checker for class members. - * The checker returns true if the attribute class is set (e.g., not equal - * to the default value) - **/ - ///@{ - void SetAltsym(std::string altsym_) { m_altsym = altsym_; }; - std::string GetAltsym() const { return m_altsym; }; - bool HasAltsym( ); - - ///@} - -private: - /** - * Provides a way of pointing to a user-defined symbol. - * It must contain an ID of a element elsewhere in the document. - **/ - std::string m_altsym; - -/* include */ -}; - //---------------------------------------------------------------------------- // AttArticulation //---------------------------------------------------------------------------- @@ -219,8 +175,8 @@ class AttArticulation: public Att * Encodes the written articulation(s). * Articulations are normally encoded in order from the note head outward; that is, * away from the stem. See additional notes at att.vis.note. Only articulations - * should be encoded in the artic attribute; fingerings should be encoded using the - * element. + * should be encoded in the artic attribute; for example, fingerings should be + * encoded using the element. **/ std::string m_artic; @@ -379,17 +335,17 @@ class AttBarLineLog: public Att * to the default value) **/ ///@{ - void SetRend(data_BARRENDITION rend_) { m_rend = rend_; }; - data_BARRENDITION GetRend() const { return m_rend; }; - bool HasRend( ); + void SetForm(data_BARRENDITION form_) { m_form = form_; }; + data_BARRENDITION GetForm() const { return m_form; }; + bool HasForm( ); ///@} private: /** Records the appearance and usually the function of the bar line. **/ - data_BARRENDITION m_rend; + data_BARRENDITION m_form; -/* include */ +/* include */ }; //---------------------------------------------------------------------------- @@ -605,17 +561,21 @@ class AttCanonical: public Att * to the default value) **/ ///@{ - void SetDbkey(std::string dbkey_) { m_dbkey = dbkey_; }; - std::string GetDbkey() const { return m_dbkey; }; - bool HasDbkey( ); + void SetCodedval(std::string codedval_) { m_codedval = codedval_; }; + std::string GetCodedval() const { return m_codedval; }; + bool HasCodedval( ); ///@} private: - /** Used to record a value which serves as a primary key in an external database. **/ - std::string m_dbkey; + /** + * A value that represents or identifies the element content. + * May serve as a primary key in a web-accessible database identified by the + * authURI attribute. + **/ + std::string m_codedval; -/* include */ +/* include */ }; //---------------------------------------------------------------------------- @@ -651,15 +611,58 @@ class AttChordVis: public Att private: /** - * Indicates a single alternative note head should be displayed instead of + * Indicates a single, alternative note head should be displayed instead of * individual note heads. - * See Read, p. 320-321, re: tone clusters. + * The highest and lowest notes of the chord usually indicate the upper and lower + * boundaries of the cluster note head. **/ std::string m_cluster; /* include */ }; +//---------------------------------------------------------------------------- +// AttClasscodeident +//---------------------------------------------------------------------------- + +class AttClasscodeident: public Att +{ +public: + AttClasscodeident(); + virtual ~AttClasscodeident(); + + /** Reset the default values for the attribute class **/ + void ResetClasscodeident(); + + /** Read the values for the attribute class **/ + bool ReadClasscodeident( pugi::xml_node element ); + + /** Write the values for the attribute class **/ + bool WriteClasscodeident( pugi::xml_node element ); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetClasscode(std::string classcode_) { m_classcode = classcode_; }; + std::string GetClasscode() const { return m_classcode; }; + bool HasClasscode( ); + + ///@} + +private: + /** + * Contains a reference to the controlled vocabulary from which the term is drawn. + * The value must match the value of an ID attribute on a classCode element given + * elsewhere in the document. + **/ + std::string m_classcode; + +/* include */ +}; + //---------------------------------------------------------------------------- // AttClefLog //---------------------------------------------------------------------------- @@ -847,44 +850,6 @@ class AttClefshape: public Att /* include */ }; -//---------------------------------------------------------------------------- -// AttCoded -//---------------------------------------------------------------------------- - -class AttCoded: public Att -{ -public: - AttCoded(); - virtual ~AttCoded(); - - /** Reset the default values for the attribute class **/ - void ResetCoded(); - - /** Read the values for the attribute class **/ - bool ReadCoded( pugi::xml_node element ); - - /** Write the values for the attribute class **/ - bool WriteCoded( pugi::xml_node element ); - - /** - * @name Setters, getters and presence checker for class members. - * The checker returns true if the attribute class is set (e.g., not equal - * to the default value) - **/ - ///@{ - void SetCode(std::string code_) { m_code = code_; }; - std::string GetCode() const { return m_code; }; - bool HasCode( ); - - ///@} - -private: - /** Captures one or more coded values for the textual content of this element. **/ - std::string m_code; - -/* include */ -}; - //---------------------------------------------------------------------------- // AttColor //---------------------------------------------------------------------------- @@ -996,15 +961,48 @@ class AttCommon: public Att * to the default value) **/ ///@{ - void SetLabel(std::string label_) { m_label = label_; }; - std::string GetLabel() const { return m_label; }; - bool HasLabel( ); - - // void SetN(int n_) { m_n = n_; }; int GetN() const { return m_n; }; bool HasN( ); + ///@} + +private: + /** Provides a number-like designation for an element. **/ + int m_n; + +/* include */ +}; + +//---------------------------------------------------------------------------- +// AttCommonPart +//---------------------------------------------------------------------------- + +class AttCommonPart: public Att +{ +public: + AttCommonPart(); + virtual ~AttCommonPart(); + + /** Reset the default values for the attribute class **/ + void ResetCommonPart(); + + /** Read the values for the attribute class **/ + bool ReadCommonPart( pugi::xml_node element ); + + /** Write the values for the attribute class **/ + bool WriteCommonPart( pugi::xml_node element ); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetLabel(std::string label_) { m_label = label_; }; + std::string GetLabel() const { return m_label; }; + bool HasLabel( ); + // void SetBase(std::string base_) { m_base = base_; }; std::string GetBase() const { return m_base; }; @@ -1014,15 +1012,10 @@ class AttCommon: public Att private: /** - * Provides a label for an element. + * Provides a name or label for an element. * The value may be any string. **/ std::string m_label; - /** - * Provides a name or number designation for an element. - * While the value need not be unique, it is required to be a single token. - **/ - int m_n; /** --- **/ std::string m_base; @@ -1131,15 +1124,18 @@ class AttCurvature: public Att private: /** - * Records the placement of Bezier control points as a series of space-separated xy - * coordinates, e.g., 19 45 -32 118. + * Records the placement of Bezier control points as a series of pairs of space- + * separated values; e.g., 19 45 -32 118. **/ std::string m_bezier; /** - * Describes a curve as a set of distance values above or below an imaginary line - * connecting the endpoints of the curve. - * The bulge attribute must contain one or more decimal values expressed in inter- - * line units. + * Describes a curve as one or more pairs of values with respect to an imaginary + * line connecting the starting and ending points of the curve. + * The first value of each pair represents a point along the line, expressed as a + * percentage of the line's length. The second value captures a distance to the + * left (positive value) or right (negative value) of the line, expressed in + * virtual units. N.B. An MEI virtual unit (VU) is half the distance between + * adjacent staff lines. **/ double m_bulge; /** Describes a curve with a generic term indicating the direction of curvature. **/ @@ -1173,17 +1169,24 @@ class AttCurverend: public Att * to the default value) **/ ///@{ - void SetRend(data_BARRENDITION rend_) { m_rend = rend_; }; - data_BARRENDITION GetRend() const { return m_rend; }; - bool HasRend( ); + void SetLform(std::string lform_) { m_lform = lform_; }; + std::string GetLform() const { return m_lform; }; + bool HasLform( ); + + // + void SetLwidth(std::string lwidth_) { m_lwidth = lwidth_; }; + std::string GetLwidth() const { return m_lwidth; }; + bool HasLwidth( ); ///@} private: - /** Records the appearance and usually the function of the bar line. **/ - data_BARRENDITION m_rend; + /** Describes the line style of a curve. **/ + std::string m_lform; + /** Width of a curved line. **/ + std::string m_lwidth; -/* include */ +/* include */ }; //---------------------------------------------------------------------------- @@ -1452,15 +1455,15 @@ class AttDotLog: public Att * to the default value) **/ ///@{ - void SetForm(std::string form_) { m_form = form_; }; - std::string GetForm() const { return m_form; }; + void SetForm(data_BARRENDITION form_) { m_form = form_; }; + data_BARRENDITION GetForm() const { return m_form; }; bool HasForm( ); ///@} private: - /** Records the function of the dot. **/ - std::string m_form; + /** Records the appearance and usually the function of the bar line. **/ + data_BARRENDITION m_form; /* include */ }; @@ -1498,8 +1501,8 @@ class AttDurationAdditive: public Att private: /** - * Records duration using ident dotted, relative durational values provided by the - * data.DURATION datatype. + * Records duration using optionally dotted, relative durational values provided by + * the data.DURATION datatype. * When the duration is "irrational", as is sometimes the case with tuplets, * multiple space-separated values that add up to the total duration may be used. * When dotted values are present, the dots attribute must be ignored. @@ -1604,8 +1607,8 @@ class AttDurationMusical: public Att private: /** - * Records duration using ident dotted, relative durational values provided by the - * data.DURATION datatype. + * Records duration using optionally dotted, relative durational values provided by + * the data.DURATION datatype. * When the duration is "irrational", as is sometimes the case with tuplets, * multiple space-separated values that add up to the total duration may be used. * When dotted values are present, the dots attribute must be ignored. @@ -1753,23 +1756,23 @@ class AttEnclosingchars: public Att }; //---------------------------------------------------------------------------- -// AttFermatapresent +// AttEndings //---------------------------------------------------------------------------- -class AttFermatapresent: public Att +class AttEndings: public Att { public: - AttFermatapresent(); - virtual ~AttFermatapresent(); + AttEndings(); + virtual ~AttEndings(); /** Reset the default values for the attribute class **/ - void ResetFermatapresent(); + void ResetEndings(); /** Read the values for the attribute class **/ - bool ReadFermatapresent( pugi::xml_node element ); + bool ReadEndings( pugi::xml_node element ); /** Write the values for the attribute class **/ - bool WriteFermatapresent( pugi::xml_node element ); + bool WriteEndings( pugi::xml_node element ); /** * @name Setters, getters and presence checker for class members. @@ -1777,41 +1780,37 @@ class AttFermatapresent: public Att * to the default value) **/ ///@{ - void SetFermata(data_PLACE fermata_) { m_fermata = fermata_; }; - data_PLACE GetFermata() const { return m_fermata; }; - bool HasFermata( ); + void SetEndingRend(std::string endingRend_) { m_endingRend = endingRend_; }; + std::string GetEndingRend() const { return m_endingRend; }; + bool HasEndingRend( ); ///@} private: - /** - * Indicates the attachment of a fermata to this element. - * If visual information about the fermata needs to be recorded, then a - * element should be employed instead. - **/ - data_PLACE m_fermata; + /** Describes where ending marks should be displayed. **/ + std::string m_endingRend; -/* include */ +/* include */ }; //---------------------------------------------------------------------------- -// AttHandident +// AttExtender //---------------------------------------------------------------------------- -class AttHandident: public Att +class AttExtender: public Att { public: - AttHandident(); - virtual ~AttHandident(); + AttExtender(); + virtual ~AttExtender(); /** Reset the default values for the attribute class **/ - void ResetHandident(); + void ResetExtender(); /** Read the values for the attribute class **/ - bool ReadHandident( pugi::xml_node element ); + bool ReadExtender( pugi::xml_node element ); /** Write the values for the attribute class **/ - bool WriteHandident( pugi::xml_node element ); + bool WriteExtender( pugi::xml_node element ); /** * @name Setters, getters and presence checker for class members. @@ -1819,40 +1818,37 @@ class AttHandident: public Att * to the default value) **/ ///@{ - void SetHand(std::string hand_) { m_hand = hand_; }; - std::string GetHand() const { return m_hand; }; - bool HasHand( ); + void SetExtender(std::string extender_) { m_extender = extender_; }; + std::string GetExtender() const { return m_extender; }; + bool HasExtender( ); ///@} private: - /** - * Signifies the hand responsible for an action. - * The value must be the ID of a element declared in the header. - **/ - std::string m_hand; + /** Indicates the presence of an extension symbol, typically a line. **/ + std::string m_extender; -/* include */ +/* include */ }; //---------------------------------------------------------------------------- -// AttHorizontalalign +// AttFermatapresent //---------------------------------------------------------------------------- -class AttHorizontalalign: public Att +class AttFermatapresent: public Att { public: - AttHorizontalalign(); - virtual ~AttHorizontalalign(); + AttFermatapresent(); + virtual ~AttFermatapresent(); /** Reset the default values for the attribute class **/ - void ResetHorizontalalign(); + void ResetFermatapresent(); /** Read the values for the attribute class **/ - bool ReadHorizontalalign( pugi::xml_node element ); + bool ReadFermatapresent( pugi::xml_node element ); /** Write the values for the attribute class **/ - bool WriteHorizontalalign( pugi::xml_node element ); + bool WriteFermatapresent( pugi::xml_node element ); /** * @name Setters, getters and presence checker for class members. @@ -1860,37 +1856,41 @@ class AttHorizontalalign: public Att * to the default value) **/ ///@{ - void SetHalign(std::string halign_) { m_halign = halign_; }; - std::string GetHalign() const { return m_halign; }; - bool HasHalign( ); + void SetFermata(data_PLACE fermata_) { m_fermata = fermata_; }; + data_PLACE GetFermata() const { return m_fermata; }; + bool HasFermata( ); ///@} private: - /** Records horizontal alignment. **/ - std::string m_halign; + /** + * Indicates the attachment of a fermata to this element. + * If visual information about the fermata needs to be recorded, then a + * element should be employed instead. + **/ + data_PLACE m_fermata; -/* include */ +/* include */ }; //---------------------------------------------------------------------------- -// AttInstrumentident +// AttFiling //---------------------------------------------------------------------------- -class AttInstrumentident: public Att +class AttFiling: public Att { public: - AttInstrumentident(); - virtual ~AttInstrumentident(); + AttFiling(); + virtual ~AttFiling(); /** Reset the default values for the attribute class **/ - void ResetInstrumentident(); + void ResetFiling(); /** Read the values for the attribute class **/ - bool ReadInstrumentident( pugi::xml_node element ); + bool ReadFiling( pugi::xml_node element ); /** Write the values for the attribute class **/ - bool WriteInstrumentident( pugi::xml_node element ); + bool WriteFiling( pugi::xml_node element ); /** * @name Setters, getters and presence checker for class members. @@ -1898,40 +1898,40 @@ class AttInstrumentident: public Att * to the default value) **/ ///@{ - void SetInstr(std::string instr_) { m_instr = instr_; }; - std::string GetInstr() const { return m_instr; }; - bool HasInstr( ); + void SetNonfiling(int nonfilingInt_) { m_nonfilingInt = nonfilingInt_; }; + int GetNonfiling() const { return m_nonfilingInt; }; + bool HasNonfiling( ); ///@} private: /** - * Provides a way of pointing to a MIDI instrument definition. - * It must contain the ID of an element elsewhere in the document. + * Holds the number of initial characters (such as those constituing an article or + * preposition) that should not be used for sorting a title or name. **/ - std::string m_instr; + int m_nonfilingInt; -/* include */ +/* include */ }; //---------------------------------------------------------------------------- -// AttInternetmedia +// AttGrpSymLog //---------------------------------------------------------------------------- -class AttInternetmedia: public Att +class AttGrpSymLog: public Att { public: - AttInternetmedia(); - virtual ~AttInternetmedia(); + AttGrpSymLog(); + virtual ~AttGrpSymLog(); /** Reset the default values for the attribute class **/ - void ResetInternetmedia(); + void ResetGrpSymLog(); /** Read the values for the attribute class **/ - bool ReadInternetmedia( pugi::xml_node element ); + bool ReadGrpSymLog( pugi::xml_node element ); /** Write the values for the attribute class **/ - bool WriteInternetmedia( pugi::xml_node element ); + bool WriteGrpSymLog( pugi::xml_node element ); /** * @name Setters, getters and presence checker for class members. @@ -1939,41 +1939,37 @@ class AttInternetmedia: public Att * to the default value) **/ ///@{ - void SetMimetype(std::string mimetype_) { m_mimetype = mimetype_; }; - std::string GetMimetype() const { return m_mimetype; }; - bool HasMimetype( ); + void SetLevel(int levelInt_) { m_levelInt = levelInt_; }; + int GetLevel() const { return m_levelInt; }; + bool HasLevel( ); ///@} private: - /** - * Specifies the applicable MIME (multimedia internet mail extension) type. - * The value should be a valid MIME media type defined by the Internet Engineering - * Task Force in RFC 2046. - **/ - std::string m_mimetype; + /** Indicates the nesting level of staff grouping symbols. **/ + int m_levelInt; -/* include */ +/* include */ }; //---------------------------------------------------------------------------- -// AttJoined +// AttHandident //---------------------------------------------------------------------------- -class AttJoined: public Att +class AttHandident: public Att { public: - AttJoined(); - virtual ~AttJoined(); + AttHandident(); + virtual ~AttHandident(); /** Reset the default values for the attribute class **/ - void ResetJoined(); + void ResetHandident(); /** Read the values for the attribute class **/ - bool ReadJoined( pugi::xml_node element ); + bool ReadHandident( pugi::xml_node element ); /** Write the values for the attribute class **/ - bool WriteJoined( pugi::xml_node element ); + bool WriteHandident( pugi::xml_node element ); /** * @name Setters, getters and presence checker for class members. @@ -1981,24 +1977,224 @@ class AttJoined: public Att * to the default value) **/ ///@{ - void SetJoin(std::string join_) { m_join = join_; }; - std::string GetJoin() const { return m_join; }; - bool HasJoin( ); + void SetHand(std::string hand_) { m_hand = hand_; }; + std::string GetHand() const { return m_hand; }; + bool HasHand( ); ///@} private: /** - * Used for linking visually separate entities that form a single logical entity, - * for example, multiple slurs broken across a system break that form a single - * musical phrase. - * Also used to indicate a measure which metrically completes the current one. - * Record the identifiers of the separately encoded components, excluding the one - * carrying the attribute. + * Signifies the hand responsible for an action. + * The value must be the ID of a element declared in the header. **/ - std::string m_join; + std::string m_hand; -/* include */ +/* include */ +}; + +//---------------------------------------------------------------------------- +// AttHeight +//---------------------------------------------------------------------------- + +class AttHeight: public Att +{ +public: + AttHeight(); + virtual ~AttHeight(); + + /** Reset the default values for the attribute class **/ + void ResetHeight(); + + /** Read the values for the attribute class **/ + bool ReadHeight( pugi::xml_node element ); + + /** Write the values for the attribute class **/ + bool WriteHeight( pugi::xml_node element ); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetHeight(std::string height_) { m_height = height_; }; + std::string GetHeight() const { return m_height; }; + bool HasHeight( ); + + ///@} + +private: + /** Measurement of the vertical dimension of an entity. **/ + std::string m_height; + +/* include */ +}; + +//---------------------------------------------------------------------------- +// AttHorizontalalign +//---------------------------------------------------------------------------- + +class AttHorizontalalign: public Att +{ +public: + AttHorizontalalign(); + virtual ~AttHorizontalalign(); + + /** Reset the default values for the attribute class **/ + void ResetHorizontalalign(); + + /** Read the values for the attribute class **/ + bool ReadHorizontalalign( pugi::xml_node element ); + + /** Write the values for the attribute class **/ + bool WriteHorizontalalign( pugi::xml_node element ); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetHalign(std::string halign_) { m_halign = halign_; }; + std::string GetHalign() const { return m_halign; }; + bool HasHalign( ); + + ///@} + +private: + /** Records horizontal alignment. **/ + std::string m_halign; + +/* include */ +}; + +//---------------------------------------------------------------------------- +// AttInstrumentident +//---------------------------------------------------------------------------- + +class AttInstrumentident: public Att +{ +public: + AttInstrumentident(); + virtual ~AttInstrumentident(); + + /** Reset the default values for the attribute class **/ + void ResetInstrumentident(); + + /** Read the values for the attribute class **/ + bool ReadInstrumentident( pugi::xml_node element ); + + /** Write the values for the attribute class **/ + bool WriteInstrumentident( pugi::xml_node element ); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetInstr(std::string instr_) { m_instr = instr_; }; + std::string GetInstr() const { return m_instr; }; + bool HasInstr( ); + + ///@} + +private: + /** + * Provides a way of pointing to a MIDI instrument definition. + * It must contain the ID of an element elsewhere in the document. + **/ + std::string m_instr; + +/* include */ +}; + +//---------------------------------------------------------------------------- +// AttInternetmedia +//---------------------------------------------------------------------------- + +class AttInternetmedia: public Att +{ +public: + AttInternetmedia(); + virtual ~AttInternetmedia(); + + /** Reset the default values for the attribute class **/ + void ResetInternetmedia(); + + /** Read the values for the attribute class **/ + bool ReadInternetmedia( pugi::xml_node element ); + + /** Write the values for the attribute class **/ + bool WriteInternetmedia( pugi::xml_node element ); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetMimetype(std::string mimetype_) { m_mimetype = mimetype_; }; + std::string GetMimetype() const { return m_mimetype; }; + bool HasMimetype( ); + + ///@} + +private: + /** + * Specifies the applicable MIME (multimedia internet mail extension) type. + * The value should be a valid MIME media type defined by the Internet Engineering + * Task Force in RFC 2046. + **/ + std::string m_mimetype; + +/* include */ +}; + +//---------------------------------------------------------------------------- +// AttJoined +//---------------------------------------------------------------------------- + +class AttJoined: public Att +{ +public: + AttJoined(); + virtual ~AttJoined(); + + /** Reset the default values for the attribute class **/ + void ResetJoined(); + + /** Read the values for the attribute class **/ + bool ReadJoined( pugi::xml_node element ); + + /** Write the values for the attribute class **/ + bool WriteJoined( pugi::xml_node element ); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetJoin(std::string join_) { m_join = join_; }; + std::string GetJoin() const { return m_join; }; + bool HasJoin( ); + + ///@} + +private: + /** + * Used for linking visually separate entities that form a single logical entity, + * for example, multiple slurs broken across a system break that form a single + * musical phrase. + * Also used to indicate a measure which metrically completes the current one. + * Record the identifiers of the separately encoded components, excluding the one + * carrying the attribute. + **/ + std::string m_join; + +/* include */ }; //---------------------------------------------------------------------------- @@ -2112,7 +2308,7 @@ class AttKeySigDefaultLog: public Att * be indicated by setting the key.sig attribute to 'mixed' and providing explicit * key signature information in the key.sig.mixed attribute or in the * element. It is intended that key.sig.mixed contain a series of tokens with each - * token containing pitch name, accidental, and octave, such as 'A4 Cs5 Ef5' that + * token containing pitch name, accidental, and octave, such as 'a4 c5s e5f' that * indicate what key accidentals should be rendered and where they should be * placed. **/ @@ -2236,13 +2432,20 @@ class AttLang: public Att std::string GetLang() const { return m_lang; }; bool HasLang( ); + // + void SetTranslit(std::string translit_) { m_translit = translit_; }; + std::string GetTranslit() const { return m_translit; }; + bool HasTranslit( ); + ///@} private: /** --- **/ std::string m_lang; + /** Specifies the transliteration technique used. **/ + std::string m_translit; -/* include */ +/* include */ }; //---------------------------------------------------------------------------- @@ -2308,19 +2511,92 @@ class AttLayerident: public Att * to the default value) **/ ///@{ - void SetLayer(std::string layer_) { m_layer = layer_; }; - std::string GetLayer() const { return m_layer; }; + void SetLayer(int layerInt_) { m_layerInt = layerInt_; }; + int GetLayer() const { return m_layerInt; }; bool HasLayer( ); ///@} private: /** Identifies the layer to which a feature applies. **/ - std::string m_layer; + int m_layerInt; /* include */ }; +//---------------------------------------------------------------------------- +// AttLineVis +//---------------------------------------------------------------------------- + +class AttLineVis: public Att +{ +public: + AttLineVis(); + virtual ~AttLineVis(); + + /** Reset the default values for the attribute class **/ + void ResetLineVis(); + + /** Read the values for the attribute class **/ + bool ReadLineVis( pugi::xml_node element ); + + /** Write the values for the attribute class **/ + bool WriteLineVis( pugi::xml_node element ); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetForm(data_BARRENDITION form_) { m_form = form_; }; + data_BARRENDITION GetForm() const { return m_form; }; + bool HasForm( ); + + // + void SetWidth(std::string width_) { m_width = width_; }; + std::string GetWidth() const { return m_width; }; + bool HasWidth( ); + + // + void SetEndsym(std::string endsym_) { m_endsym = endsym_; }; + std::string GetEndsym() const { return m_endsym; }; + bool HasEndsym( ); + + // + void SetEndsymsize(std::string endsymsize_) { m_endsymsize = endsymsize_; }; + std::string GetEndsymsize() const { return m_endsymsize; }; + bool HasEndsymsize( ); + + // + void SetStartsym(std::string startsym_) { m_startsym = startsym_; }; + std::string GetStartsym() const { return m_startsym; }; + bool HasStartsym( ); + + // + void SetStartsymsize(std::string startsymsize_) { m_startsymsize = startsymsize_; }; + std::string GetStartsymsize() const { return m_startsymsize; }; + bool HasStartsymsize( ); + + ///@} + +private: + /** Records the appearance and usually the function of the bar line. **/ + data_BARRENDITION m_form; + /** Width of the line. **/ + std::string m_width; + /** Symbol rendered at end of line. **/ + std::string m_endsym; + /** Holds the relative size of the line-end symbol. **/ + std::string m_endsymsize; + /** Symbol rendered at start of line. **/ + std::string m_startsym; + /** Holds the relative size of the line-start symbol. **/ + std::string m_startsymsize; + +/* include */ +}; + //---------------------------------------------------------------------------- // AttLineloc //---------------------------------------------------------------------------- @@ -2388,17 +2664,83 @@ class AttLinerend: public Att * to the default value) **/ ///@{ - void SetRend(data_BARRENDITION rend_) { m_rend = rend_; }; - data_BARRENDITION GetRend() const { return m_rend; }; - bool HasRend( ); + void SetLendsym(std::string lendsym_) { m_lendsym = lendsym_; }; + std::string GetLendsym() const { return m_lendsym; }; + bool HasLendsym( ); + + // + void SetLendsymsize(std::string lendsymsize_) { m_lendsymsize = lendsymsize_; }; + std::string GetLendsymsize() const { return m_lendsymsize; }; + bool HasLendsymsize( ); + + // + void SetLstartsym(std::string lstartsym_) { m_lstartsym = lstartsym_; }; + std::string GetLstartsym() const { return m_lstartsym; }; + bool HasLstartsym( ); + + // + void SetLstartsymsize(std::string lstartsymsize_) { m_lstartsymsize = lstartsymsize_; }; + std::string GetLstartsymsize() const { return m_lstartsymsize; }; + bool HasLstartsymsize( ); ///@} private: - /** Records the appearance and usually the function of the bar line. **/ - data_BARRENDITION m_rend; + /** Symbol rendered at end of line. **/ + std::string m_lendsym; + /** Holds the relative size of the line-end symbol. **/ + std::string m_lendsymsize; + /** Symbol rendered at start of line. **/ + std::string m_lstartsym; + /** Holds the relative size of the line-start symbol. **/ + std::string m_lstartsymsize; + +/* include */ +}; + +//---------------------------------------------------------------------------- +// AttLinerendBase +//---------------------------------------------------------------------------- -/* include */ +class AttLinerendBase: public Att +{ +public: + AttLinerendBase(); + virtual ~AttLinerendBase(); + + /** Reset the default values for the attribute class **/ + void ResetLinerendBase(); + + /** Read the values for the attribute class **/ + bool ReadLinerendBase( pugi::xml_node element ); + + /** Write the values for the attribute class **/ + bool WriteLinerendBase( pugi::xml_node element ); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetLform(std::string lform_) { m_lform = lform_; }; + std::string GetLform() const { return m_lform; }; + bool HasLform( ); + + // + void SetLwidth(std::string lwidth_) { m_lwidth = lwidth_; }; + std::string GetLwidth() const { return m_lwidth; }; + bool HasLwidth( ); + + ///@} + +private: + /** Describes the line style of a curve. **/ + std::string m_lform; + /** Width of a curved line. **/ + std::string m_lwidth; + +/* include */ }; //---------------------------------------------------------------------------- @@ -2555,12 +2897,50 @@ class AttMeasurement: public Att ///@} private: - /** Indicates the unit used for a measurement of size. **/ + /** Indicates the unit of measurement. **/ int m_unit; /* include */ }; +//---------------------------------------------------------------------------- +// AttMeasurenumbers +//---------------------------------------------------------------------------- + +class AttMeasurenumbers: public Att +{ +public: + AttMeasurenumbers(); + virtual ~AttMeasurenumbers(); + + /** Reset the default values for the attribute class **/ + void ResetMeasurenumbers(); + + /** Read the values for the attribute class **/ + bool ReadMeasurenumbers( pugi::xml_node element ); + + /** Write the values for the attribute class **/ + bool WriteMeasurenumbers( pugi::xml_node element ); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetMnumVisible(std::string mnumVisible_) { m_mnumVisible = mnumVisible_; }; + std::string GetMnumVisible() const { return m_mnumVisible; }; + bool HasMnumVisible( ); + + ///@} + +private: + /** Indicates whether measure numbers should be displayed. **/ + std::string m_mnumVisible; + +/* include */ +}; + //---------------------------------------------------------------------------- // AttMediabounds //---------------------------------------------------------------------------- @@ -2605,15 +2985,15 @@ class AttMediabounds: public Att private: /** * Specifies a point where the relevant content begins. - * A numerical value must be less and a time value must be earlier than that in the - * end attribute. + * A numerical value must be less and a time value must be earlier than that given + * by the end attribute. **/ std::string m_begin; /** * Specifies a point where the relevant content ends. * If not specified, the end of the content is assumed to be the end point. A - * numerical value must be greater and a time value must be later than that in the - * begin attribute. + * numerical value must be greater and a time value must be later than that given + * by the begin attribute. **/ std::string m_end; /** @@ -2693,20 +3073,13 @@ class AttMeiversion: public Att std::string GetMeiversion() const { return m_meiversion; }; bool HasMeiversion( ); - // - void SetMeiversionNum(std::string meiversionNum_) { m_meiversionNum = meiversionNum_; }; - std::string GetMeiversionNum() const { return m_meiversionNum; }; - bool HasMeiversionNum( ); - ///@} private: /** Specifies a generic MEI version label. **/ std::string m_meiversion; - /** Records a detailed MEI version number. **/ - std::string m_meiversionNum; -/* include */ +/* include */ }; //---------------------------------------------------------------------------- @@ -2808,7 +3181,7 @@ class AttMeterSigLog: public Att * is, 'C' for common time or 'C' with a slash for cut time. **/ data_METERSIGN m_sym; - /** Indicates the unit used for a measurement of size. **/ + /** Indicates the unit of measurement. **/ int m_unit; /* include */ @@ -2839,17 +3212,17 @@ class AttMeterSigVis: public Att * to the default value) **/ ///@{ - void SetRend(data_BARRENDITION rend_) { m_rend = rend_; }; - data_BARRENDITION GetRend() const { return m_rend; }; - bool HasRend( ); + void SetForm(data_BARRENDITION form_) { m_form = form_; }; + data_BARRENDITION GetForm() const { return m_form; }; + bool HasForm( ); ///@} private: /** Records the appearance and usually the function of the bar line. **/ - data_BARRENDITION m_rend; + data_BARRENDITION m_form; -/* include */ +/* include */ }; //---------------------------------------------------------------------------- @@ -3200,12 +3573,58 @@ class AttName: public Att /** * Used to specify further information about the entity referenced by this name, * for example, the occupation of a person or the status of a place. + * Use a standard value whenever possible. **/ std::string m_role; /* include */ }; +//---------------------------------------------------------------------------- +// AttNotationstyle +//---------------------------------------------------------------------------- + +class AttNotationstyle: public Att +{ +public: + AttNotationstyle(); + virtual ~AttNotationstyle(); + + /** Reset the default values for the attribute class **/ + void ResetNotationstyle(); + + /** Read the values for the attribute class **/ + bool ReadNotationstyle( pugi::xml_node element ); + + /** Write the values for the attribute class **/ + bool WriteNotationstyle( pugi::xml_node element ); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetMusicName(std::string musicName_) { m_musicName = musicName_; }; + std::string GetMusicName() const { return m_musicName; }; + bool HasMusicName( ); + + // + void SetMusicSize(std::string musicSize_) { m_musicSize = musicSize_; }; + std::string GetMusicSize() const { return m_musicSize; }; + bool HasMusicSize( ); + + ///@} + +private: + /** Sets the default music font name. **/ + std::string m_musicName; + /** Sets the default music font size. **/ + std::string m_musicSize; + +/* include */ +}; + //---------------------------------------------------------------------------- // AttNoteGes //---------------------------------------------------------------------------- @@ -3259,23 +3678,23 @@ class AttNoteGes: public Att }; //---------------------------------------------------------------------------- -// AttNoteVis +// AttNoteheads //---------------------------------------------------------------------------- -class AttNoteVis: public Att +class AttNoteheads: public Att { public: - AttNoteVis(); - virtual ~AttNoteVis(); + AttNoteheads(); + virtual ~AttNoteheads(); /** Reset the default values for the attribute class **/ - void ResetNoteVis(); + void ResetNoteheads(); /** Read the values for the attribute class **/ - bool ReadNoteVis( pugi::xml_node element ); + bool ReadNoteheads( pugi::xml_node element ); /** Write the values for the attribute class **/ - bool WriteNoteVis( pugi::xml_node element ); + bool WriteNoteheads( pugi::xml_node element ); /** * @name Setters, getters and presence checker for class members. @@ -3283,17 +3702,66 @@ class AttNoteVis: public Att * to the default value) **/ ///@{ - void SetHeadshape(std::string headshape_) { m_headshape = headshape_; }; - std::string GetHeadshape() const { return m_headshape; }; - bool HasHeadshape( ); + void SetHeadColor(std::string headColor_) { m_headColor = headColor_; }; + std::string GetHeadColor() const { return m_headColor; }; + bool HasHeadColor( ); + + // + void SetHeadFill(std::string headFill_) { m_headFill = headFill_; }; + std::string GetHeadFill() const { return m_headFill; }; + bool HasHeadFill( ); + + // + void SetHeadFillcolor(std::string headFillcolor_) { m_headFillcolor = headFillcolor_; }; + std::string GetHeadFillcolor() const { return m_headFillcolor; }; + bool HasHeadFillcolor( ); + + // + void SetHeadMod(std::string headMod_) { m_headMod = headMod_; }; + std::string GetHeadMod() const { return m_headMod; }; + bool HasHeadMod( ); + + // + void SetHeadRotation(std::string headRotation_) { m_headRotation = headRotation_; }; + std::string GetHeadRotation() const { return m_headRotation; }; + bool HasHeadRotation( ); + + // + void SetHeadShape(std::string headShape_) { m_headShape = headShape_; }; + std::string GetHeadShape() const { return m_headShape; }; + bool HasHeadShape( ); + + // + void SetHeadVisible(std::string headVisible_) { m_headVisible = headVisible_; }; + std::string GetHeadVisible() const { return m_headVisible; }; + bool HasHeadVisible( ); ///@} private: + /** Captures the overall color of a notehead. **/ + std::string m_headColor; + /** Describes how/if the notehead is filled. **/ + std::string m_headFill; + /** Captures the fill color of a notehead if different from the overall note color. **/ + std::string m_headFillcolor; + /** Records any additional symbols applied to the notehead. **/ + std::string m_headMod; + /** + * Describes rotation applied to the basic notehead shape. + * A positive value rotates the notehead in a counter-clockwise fashion, while + * negative values produce clockwise rotation. + **/ + std::string m_headRotation; /** Used to override the head shape normally used for the given duration. **/ - std::string m_headshape; + std::string m_headShape; + /** + * Indicates if a feature should be rendered when the notation is presented + * graphically or sounded when it is presented in an aural form. + **/ + std::string m_headVisible; -/* include */ +/* include */ }; //---------------------------------------------------------------------------- @@ -3435,10 +3903,52 @@ class AttOnelinestaff: public Att void ResetOnelinestaff(); /** Read the values for the attribute class **/ - bool ReadOnelinestaff( pugi::xml_node element ); + bool ReadOnelinestaff( pugi::xml_node element ); + + /** Write the values for the attribute class **/ + bool WriteOnelinestaff( pugi::xml_node element ); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetOntheline(std::string ontheline_) { m_ontheline = ontheline_; }; + std::string GetOntheline() const { return m_ontheline; }; + bool HasOntheline( ); + + ///@} + +private: + /** + * Determines the placement of notes on a 1-line staff. + * A value of 'true' places all notes on the line, while a value of 'false' places + * stems-up notes above the line and stems-down notes below the line. + **/ + std::string m_ontheline; + +/* include */ +}; + +//---------------------------------------------------------------------------- +// AttOptimization +//---------------------------------------------------------------------------- + +class AttOptimization: public Att +{ +public: + AttOptimization(); + virtual ~AttOptimization(); + + /** Reset the default values for the attribute class **/ + void ResetOptimization(); + + /** Read the values for the attribute class **/ + bool ReadOptimization( pugi::xml_node element ); /** Write the values for the attribute class **/ - bool WriteOnelinestaff( pugi::xml_node element ); + bool WriteOptimization( pugi::xml_node element ); /** * @name Setters, getters and presence checker for class members. @@ -3446,21 +3956,20 @@ class AttOnelinestaff: public Att * to the default value) **/ ///@{ - void SetOntheline(std::string ontheline_) { m_ontheline = ontheline_; }; - std::string GetOntheline() const { return m_ontheline; }; - bool HasOntheline( ); + void SetOptimize(std::string optimize_) { m_optimize = optimize_; }; + std::string GetOptimize() const { return m_optimize; }; + bool HasOptimize( ); ///@} private: /** - * Determines the placement of notes on a 1-line staff. - * A value of 'true' places all notes on the line, while a value of 'false' places - * stems-up notes above the line and stems-down notes below the line. + * Indicates whether staves without notes, rests, etc. + * should be displayed. When the value is 'true', empty staves are displayed. **/ - std::string m_ontheline; + std::string m_optimize; -/* include */ +/* include */ }; //---------------------------------------------------------------------------- @@ -3504,6 +4013,99 @@ class AttPadLog: public Att /* include */ }; +//---------------------------------------------------------------------------- +// AttPages +//---------------------------------------------------------------------------- + +class AttPages: public Att +{ +public: + AttPages(); + virtual ~AttPages(); + + /** Reset the default values for the attribute class **/ + void ResetPages(); + + /** Read the values for the attribute class **/ + bool ReadPages( pugi::xml_node element ); + + /** Write the values for the attribute class **/ + bool WritePages( pugi::xml_node element ); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetPageHeight(std::string pageHeight_) { m_pageHeight = pageHeight_; }; + std::string GetPageHeight() const { return m_pageHeight; }; + bool HasPageHeight( ); + + // + void SetPageWidth(std::string pageWidth_) { m_pageWidth = pageWidth_; }; + std::string GetPageWidth() const { return m_pageWidth; }; + bool HasPageWidth( ); + + // + void SetPageTopmar(std::string pageTopmar_) { m_pageTopmar = pageTopmar_; }; + std::string GetPageTopmar() const { return m_pageTopmar; }; + bool HasPageTopmar( ); + + // + void SetPageBotmar(std::string pageBotmar_) { m_pageBotmar = pageBotmar_; }; + std::string GetPageBotmar() const { return m_pageBotmar; }; + bool HasPageBotmar( ); + + // + void SetPageLeftmar(std::string pageLeftmar_) { m_pageLeftmar = pageLeftmar_; }; + std::string GetPageLeftmar() const { return m_pageLeftmar; }; + bool HasPageLeftmar( ); + + // + void SetPageRightmar(std::string pageRightmar_) { m_pageRightmar = pageRightmar_; }; + std::string GetPageRightmar() const { return m_pageRightmar; }; + bool HasPageRightmar( ); + + // + void SetPagePanels(std::string pagePanels_) { m_pagePanels = pagePanels_; }; + std::string GetPagePanels() const { return m_pagePanels; }; + bool HasPagePanels( ); + + // + void SetPageScale(std::string pageScale_) { m_pageScale = pageScale_; }; + std::string GetPageScale() const { return m_pageScale; }; + bool HasPageScale( ); + + ///@} + +private: + /** + * Specifies the height of the page; may be expressed in real-world units or staff + * steps. + **/ + std::string m_pageHeight; + /** + * Describes the width of the page; may be expressed in real-world units or staff + * steps. + **/ + std::string m_pageWidth; + /** Indicates the amount of whitespace at the top of a page. **/ + std::string m_pageTopmar; + /** Indicates the amount of whitespace at the bottom of a page. **/ + std::string m_pageBotmar; + /** Indicates the amount of whitespace at the left side of a page. **/ + std::string m_pageLeftmar; + /** Indicates the amount of whitespace at the right side of a page. **/ + std::string m_pageRightmar; + /** Indicates the number of logical pages to be rendered on a single physical page. **/ + std::string m_pagePanels; + /** Indicates how the page should be scaled when rendered. **/ + std::string m_pageScale; + +/* include */ +}; + //---------------------------------------------------------------------------- // AttPbVis //---------------------------------------------------------------------------- @@ -3529,17 +4131,20 @@ class AttPbVis: public Att * to the default value) **/ ///@{ - void SetFunc(data_FUNC func_) { m_func = func_; }; - data_FUNC GetFunc() const { return m_func; }; - bool HasFunc( ); + void SetFolium(std::string folium_) { m_folium = folium_; }; + std::string GetFolium() const { return m_folium; }; + bool HasFolium( ); ///@} private: - /** Records the function of an accidental. **/ - data_FUNC m_func; + /** + * States the side of a leaf (as in a manuscript) on which the content following + * the element occurs. + **/ + std::string m_folium; -/* include */ +/* include */ }; //---------------------------------------------------------------------------- @@ -3731,6 +4336,7 @@ class AttPointing: public Att /** * Used to specify further information about the entity referenced by this name, * for example, the occupation of a person or the status of a place. + * Use a standard value whenever possible. **/ std::string m_role; /** --- **/ @@ -3751,6 +4357,47 @@ class AttPointing: public Att /* include */ }; +//---------------------------------------------------------------------------- +// AttQuantity +//---------------------------------------------------------------------------- + +class AttQuantity: public Att +{ +public: + AttQuantity(); + virtual ~AttQuantity(); + + /** Reset the default values for the attribute class **/ + void ResetQuantity(); + + /** Read the values for the attribute class **/ + bool ReadQuantity( pugi::xml_node element ); + + /** Write the values for the attribute class **/ + bool WriteQuantity( pugi::xml_node element ); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetQuantity(double quantityDbl_) { m_quantityDbl = quantityDbl_; }; + double GetQuantity() const { return m_quantityDbl; }; + bool HasQuantity( ); + + ///@} + +private: + /** + * Numeric value capturing a measurement or count. + * Can only be interpreted in combination with the unit or currency attribute. + **/ + double m_quantityDbl; + +/* include */ +}; + //---------------------------------------------------------------------------- // AttRelativesize //---------------------------------------------------------------------------- @@ -3856,17 +4503,17 @@ class AttSbVis: public Att * to the default value) **/ ///@{ - void SetRend(data_BARRENDITION rend_) { m_rend = rend_; }; - data_BARRENDITION GetRend() const { return m_rend; }; - bool HasRend( ); + void SetForm(data_BARRENDITION form_) { m_form = form_; }; + data_BARRENDITION GetForm() const { return m_form; }; + bool HasForm( ); ///@} private: /** Records the appearance and usually the function of the bar line. **/ - data_BARRENDITION m_rend; + data_BARRENDITION m_form; -/* include */ +/* include */ }; //---------------------------------------------------------------------------- @@ -3934,156 +4581,56 @@ class AttScoreDefGes: public Att ///@{ void SetTunePname(std::string tunePname_) { m_tunePname = tunePname_; }; std::string GetTunePname() const { return m_tunePname; }; - bool HasTunePname( ); - - // - void SetTuneHz(double tuneHzDbl_) { m_tuneHzDbl = tuneHzDbl_; }; - double GetTuneHz() const { return m_tuneHzDbl; }; - bool HasTuneHz( ); - - // - void SetTuneTemper(std::string tuneTemper_) { m_tuneTemper = tuneTemper_; }; - std::string GetTuneTemper() const { return m_tuneTemper; }; - bool HasTuneTemper( ); - - ///@} - -private: - /** Holds the pitch name of a tuning reference pitch. **/ - std::string m_tunePname; - /** Holds a value for cycles per second, i.e., Hertz, for a tuning reference pitch. **/ - double m_tuneHzDbl; - /** Provides an indication of the tuning system, 'just', for example. **/ - std::string m_tuneTemper; - -/* include */ -}; - -//---------------------------------------------------------------------------- -// AttScoreDefVis -//---------------------------------------------------------------------------- - -class AttScoreDefVis: public Att -{ -public: - AttScoreDefVis(); - virtual ~AttScoreDefVis(); - - /** Reset the default values for the attribute class **/ - void ResetScoreDefVis(); - - /** Read the values for the attribute class **/ - bool ReadScoreDefVis( pugi::xml_node element ); - - /** Write the values for the attribute class **/ - bool WriteScoreDefVis( pugi::xml_node element ); - - /** - * @name Setters, getters and presence checker for class members. - * The checker returns true if the attribute class is set (e.g., not equal - * to the default value) - **/ - ///@{ - void SetEndingRend(std::string endingRend_) { m_endingRend = endingRend_; }; - std::string GetEndingRend() const { return m_endingRend; }; - bool HasEndingRend( ); - - // - void SetMnumVisible(std::string mnumVisible_) { m_mnumVisible = mnumVisible_; }; - std::string GetMnumVisible() const { return m_mnumVisible; }; - bool HasMnumVisible( ); - - // - void SetMusicName(std::string musicName_) { m_musicName = musicName_; }; - std::string GetMusicName() const { return m_musicName; }; - bool HasMusicName( ); - - // - void SetMusicSize(std::string musicSize_) { m_musicSize = musicSize_; }; - std::string GetMusicSize() const { return m_musicSize; }; - bool HasMusicSize( ); - - // - void SetOptimize(std::string optimize_) { m_optimize = optimize_; }; - std::string GetOptimize() const { return m_optimize; }; - bool HasOptimize( ); - - // - void SetPageHeight(std::string pageHeight_) { m_pageHeight = pageHeight_; }; - std::string GetPageHeight() const { return m_pageHeight; }; - bool HasPageHeight( ); - - // - void SetPageWidth(std::string pageWidth_) { m_pageWidth = pageWidth_; }; - std::string GetPageWidth() const { return m_pageWidth; }; - bool HasPageWidth( ); - - // - void SetPageTopmar(std::string pageTopmar_) { m_pageTopmar = pageTopmar_; }; - std::string GetPageTopmar() const { return m_pageTopmar; }; - bool HasPageTopmar( ); - - // - void SetPageBotmar(std::string pageBotmar_) { m_pageBotmar = pageBotmar_; }; - std::string GetPageBotmar() const { return m_pageBotmar; }; - bool HasPageBotmar( ); - - // - void SetPageLeftmar(std::string pageLeftmar_) { m_pageLeftmar = pageLeftmar_; }; - std::string GetPageLeftmar() const { return m_pageLeftmar; }; - bool HasPageLeftmar( ); - - // - void SetPageRightmar(std::string pageRightmar_) { m_pageRightmar = pageRightmar_; }; - std::string GetPageRightmar() const { return m_pageRightmar; }; - bool HasPageRightmar( ); - - // - void SetPagePanels(std::string pagePanels_) { m_pagePanels = pagePanels_; }; - std::string GetPagePanels() const { return m_pagePanels; }; - bool HasPagePanels( ); - - // - void SetPageScale(std::string pageScale_) { m_pageScale = pageScale_; }; - std::string GetPageScale() const { return m_pageScale; }; - bool HasPageScale( ); - - // - void SetSpacingPackexp(double spacingPackexpDbl_) { m_spacingPackexpDbl = spacingPackexpDbl_; }; - double GetSpacingPackexp() const { return m_spacingPackexpDbl; }; - bool HasSpacingPackexp( ); + bool HasTunePname( ); // - void SetSpacingPackfact(double spacingPackfactDbl_) { m_spacingPackfactDbl = spacingPackfactDbl_; }; - double GetSpacingPackfact() const { return m_spacingPackfactDbl; }; - bool HasSpacingPackfact( ); + void SetTuneHz(double tuneHzDbl_) { m_tuneHzDbl = tuneHzDbl_; }; + double GetTuneHz() const { return m_tuneHzDbl; }; + bool HasTuneHz( ); // - void SetSpacingStaff(std::string spacingStaff_) { m_spacingStaff = spacingStaff_; }; - std::string GetSpacingStaff() const { return m_spacingStaff; }; - bool HasSpacingStaff( ); + void SetTuneTemper(std::string tuneTemper_) { m_tuneTemper = tuneTemper_; }; + std::string GetTuneTemper() const { return m_tuneTemper; }; + bool HasTuneTemper( ); - // - void SetSpacingSystem(std::string spacingSystem_) { m_spacingSystem = spacingSystem_; }; - std::string GetSpacingSystem() const { return m_spacingSystem; }; - bool HasSpacingSystem( ); + ///@} + +private: + /** Holds the pitch name of a tuning reference pitch. **/ + std::string m_tunePname; + /** Holds a value for cycles per second, i.e., Hertz, for a tuning reference pitch. **/ + double m_tuneHzDbl; + /** Provides an indication of the tuning system, 'just', for example. **/ + std::string m_tuneTemper; + +/* include */ +}; + +//---------------------------------------------------------------------------- +// AttScoreDefVis +//---------------------------------------------------------------------------- + +class AttScoreDefVis: public Att +{ +public: + AttScoreDefVis(); + virtual ~AttScoreDefVis(); - // - void SetSystemLeftmar(std::string systemLeftmar_) { m_systemLeftmar = systemLeftmar_; }; - std::string GetSystemLeftmar() const { return m_systemLeftmar; }; - bool HasSystemLeftmar( ); + /** Reset the default values for the attribute class **/ + void ResetScoreDefVis(); - // - void SetSystemRightmar(std::string systemRightmar_) { m_systemRightmar = systemRightmar_; }; - std::string GetSystemRightmar() const { return m_systemRightmar; }; - bool HasSystemRightmar( ); + /** Read the values for the attribute class **/ + bool ReadScoreDefVis( pugi::xml_node element ); - // - void SetSystemTopmar(std::string systemTopmar_) { m_systemTopmar = systemTopmar_; }; - std::string GetSystemTopmar() const { return m_systemTopmar; }; - bool HasSystemTopmar( ); + /** Write the values for the attribute class **/ + bool WriteScoreDefVis( pugi::xml_node element ); - // + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ void SetVuHeight(std::string vuHeight_) { m_vuHeight = vuHeight_; }; std::string GetVuHeight() const { return m_vuHeight; }; bool HasVuHeight( ); @@ -4091,73 +4638,6 @@ class AttScoreDefVis: public Att ///@} private: - /** Describes where ending marks should be displayed. **/ - std::string m_endingRend; - /** Indicates whether measure numbers should be displayed. **/ - std::string m_mnumVisible; - /** Sets the default music font name. **/ - std::string m_musicName; - /** Sets the default music font size. **/ - std::string m_musicSize; - /** - * Indicates whether staves without notes, rests, etc. - * should be displayed. When the value is 'true', empty staves are displayed. - **/ - std::string m_optimize; - /** - * Specifies the height of the page; may be expressed in real-world units or staff - * steps. - **/ - std::string m_pageHeight; - /** - * Describes the width of the page; may be expressed in real-world units or staff - * steps. - **/ - std::string m_pageWidth; - /** Indicates the amount of whitespace at the top of a page. **/ - std::string m_pageTopmar; - /** Indicates the amount of whitespace at the bottom of a page. **/ - std::string m_pageBotmar; - /** Indicates the amount of whitespace at the left side of a page. **/ - std::string m_pageLeftmar; - /** Indicates the amount of whitespace at the right side of a page. **/ - std::string m_pageRightmar; - /** Indicates the number of logical pages to be rendered on a single physical page. **/ - std::string m_pagePanels; - /** Indicates how the page should be scaled when rendered. **/ - std::string m_pageScale; - /** Describes a note's spacing relative to its time value. **/ - double m_spacingPackexpDbl; - /** Describes the note spacing of output. **/ - double m_spacingPackfactDbl; - /** - * Specifies the minimum amount of space between adjacent staves in the same - * system; measured from the bottom line of the staff above to the top line of the - * staff below. - **/ - std::string m_spacingStaff; - /** - * Describes the space between adjacent systems; a pair of space-separated values - * (minimum and maximum, respectively) provides a range between which a rendering - * system-supplied value may fall, while a single value indicates a fixed amount of - * space; that is, the minimum and maximum values are equal. - **/ - std::string m_spacingSystem; - /** - * Describes the amount of whitespace at the left system margin relative to - * page.leftmar. - **/ - std::string m_systemLeftmar; - /** - * Describes the amount of whitespace at the right system margin relative to - * page.rightmar. - **/ - std::string m_systemRightmar; - /** - * Describes the distance from page's top edge to the first system; used for first - * page only. - **/ - std::string m_systemTopmar; /** * Defines the height of a "virtual unit" (vu) in terms of real-world units. * A single vu is half the distance between the vertical center point of a staff @@ -4368,6 +4848,74 @@ class AttSpaceVis: public Att /* include */ }; +//---------------------------------------------------------------------------- +// AttSpacing +//---------------------------------------------------------------------------- + +class AttSpacing: public Att +{ +public: + AttSpacing(); + virtual ~AttSpacing(); + + /** Reset the default values for the attribute class **/ + void ResetSpacing(); + + /** Read the values for the attribute class **/ + bool ReadSpacing( pugi::xml_node element ); + + /** Write the values for the attribute class **/ + bool WriteSpacing( pugi::xml_node element ); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetSpacingPackexp(double spacingPackexpDbl_) { m_spacingPackexpDbl = spacingPackexpDbl_; }; + double GetSpacingPackexp() const { return m_spacingPackexpDbl; }; + bool HasSpacingPackexp( ); + + // + void SetSpacingPackfact(double spacingPackfactDbl_) { m_spacingPackfactDbl = spacingPackfactDbl_; }; + double GetSpacingPackfact() const { return m_spacingPackfactDbl; }; + bool HasSpacingPackfact( ); + + // + void SetSpacingStaff(std::string spacingStaff_) { m_spacingStaff = spacingStaff_; }; + std::string GetSpacingStaff() const { return m_spacingStaff; }; + bool HasSpacingStaff( ); + + // + void SetSpacingSystem(std::string spacingSystem_) { m_spacingSystem = spacingSystem_; }; + std::string GetSpacingSystem() const { return m_spacingSystem; }; + bool HasSpacingSystem( ); + + ///@} + +private: + /** Describes a note's spacing relative to its time value. **/ + double m_spacingPackexpDbl; + /** Describes the note spacing of output. **/ + double m_spacingPackfactDbl; + /** + * Specifies the minimum amount of space between adjacent staves in the same + * system; measured from the bottom line of the staff above to the top line of the + * staff below. + **/ + std::string m_spacingStaff; + /** + * Describes the space between adjacent systems; a pair of space-separated values + * (minimum and maximum, respectively) provides a range between which a rendering + * system-supplied value may fall, while a single value indicates a fixed amount of + * space; that is, the minimum and maximum values are equal. + **/ + std::string m_spacingSystem; + +/* include */ +}; + //---------------------------------------------------------------------------- // AttStaffLog //---------------------------------------------------------------------------- @@ -4778,23 +5326,23 @@ class AttStartid: public Att }; //---------------------------------------------------------------------------- -// AttStemmed +// AttStems //---------------------------------------------------------------------------- -class AttStemmed: public Att +class AttStems: public Att { public: - AttStemmed(); - virtual ~AttStemmed(); + AttStems(); + virtual ~AttStems(); /** Reset the default values for the attribute class **/ - void ResetStemmed(); + void ResetStems(); /** Read the values for the attribute class **/ - bool ReadStemmed( pugi::xml_node element ); + bool ReadStems( pugi::xml_node element ); /** Write the values for the attribute class **/ - bool WriteStemmed( pugi::xml_node element ); + bool WriteStems( pugi::xml_node element ); /** * @name Setters, getters and presence checker for class members. @@ -4811,6 +5359,11 @@ class AttStemmed: public Att int GetStemLen() const { return m_stemLen; }; bool HasStemLen( ); + // + void SetStemMod(data_STEMMODIFIER stemMod_) { m_stemMod = stemMod_; }; + data_STEMMODIFIER GetStemMod() const { return m_stemMod; }; + bool HasStemMod( ); + // void SetStemPos(data_STEMPOSITION stemPos_) { m_stemPos = stemPos_; }; data_STEMPOSITION GetStemPos() const { return m_stemPos; }; @@ -4833,6 +5386,11 @@ class AttStemmed: public Att data_STEMDIRECTION m_stemDir; /** Encodes the stem length. **/ int m_stemLen; + /** + * Encodes any stem "modifiers"; that is, symbols rendered on the stem, such as + * tremolo or Sprechstimme indicators. + **/ + data_STEMMODIFIER m_stemMod; /** Records the position of the stem in relation to the note head(s). **/ data_STEMPOSITION m_stemPos; /** Records the output x coordinate of the stem's attachment point. **/ @@ -4929,6 +5487,78 @@ class AttSyltext: public Att /* include */ }; +//---------------------------------------------------------------------------- +// AttSystems +//---------------------------------------------------------------------------- + +class AttSystems: public Att +{ +public: + AttSystems(); + virtual ~AttSystems(); + + /** Reset the default values for the attribute class **/ + void ResetSystems(); + + /** Read the values for the attribute class **/ + bool ReadSystems( pugi::xml_node element ); + + /** Write the values for the attribute class **/ + bool WriteSystems( pugi::xml_node element ); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetSystemLeftline(std::string systemLeftline_) { m_systemLeftline = systemLeftline_; }; + std::string GetSystemLeftline() const { return m_systemLeftline; }; + bool HasSystemLeftline( ); + + // + void SetSystemLeftmar(std::string systemLeftmar_) { m_systemLeftmar = systemLeftmar_; }; + std::string GetSystemLeftmar() const { return m_systemLeftmar; }; + bool HasSystemLeftmar( ); + + // + void SetSystemRightmar(std::string systemRightmar_) { m_systemRightmar = systemRightmar_; }; + std::string GetSystemRightmar() const { return m_systemRightmar; }; + bool HasSystemRightmar( ); + + // + void SetSystemTopmar(std::string systemTopmar_) { m_systemTopmar = systemTopmar_; }; + std::string GetSystemTopmar() const { return m_systemTopmar; }; + bool HasSystemTopmar( ); + + ///@} + +private: + /** + * Indicates whether the staves are joined at the left by a continuous line. + * The default value is "true". Do not confuse this with the heavy vertical line + * used as a grouping symbol. + **/ + std::string m_systemLeftline; + /** + * Describes the amount of whitespace at the left system margin relative to + * page.leftmar. + **/ + std::string m_systemLeftmar; + /** + * Describes the amount of whitespace at the right system margin relative to + * page.rightmar. + **/ + std::string m_systemRightmar; + /** + * Describes the distance from page's top edge to the first system; used for first + * page only. + **/ + std::string m_systemTopmar; + +/* include */ +}; + //---------------------------------------------------------------------------- // AttTextstyle //---------------------------------------------------------------------------- @@ -5118,8 +5748,8 @@ class AttTimestampPerformed: public Att * to the default value) **/ ///@{ - void SetTstampGes(int tstampGesInt_) { m_tstampGesInt = tstampGesInt_; }; - int GetTstampGes() const { return m_tstampGesInt; }; + void SetTstampGes(std::string tstampGes_) { m_tstampGes = tstampGes_; }; + std::string GetTstampGes() const { return m_tstampGes; }; bool HasTstampGes( ); // @@ -5131,11 +5761,12 @@ class AttTimestampPerformed: public Att private: /** - * Used to record the onset time in pulses per quarter note (ppq, MusicXML - * divisions, or MIDI clicks) since the start of the file. + * Captures performed onset time in several forms; that is, ppq (MIDI clicks and + * MusicXML 'divisions'), Humdrum **recip values, beats, seconds, or mensural + * duration values. **/ - int m_tstampGesInt; - /** Used to record the onset time in terms of ISO time since the start of the file. **/ + std::string m_tstampGes; + /** Used to record the onset time in terms of ISO time. **/ std::string m_tstampReal; /* include */ @@ -5781,12 +6412,7 @@ class AttWidth: public Att ///@} private: - /** - * Measurement of the horizontal dimension of an entity. - * The width attribute may be used to capture measure width data for interchange - * with music printing systems that utilize this information for printing. On - * the width attribute captures the width of the preceding measure. - **/ + /** Width of the line. **/ std::string m_width; /* include */ diff --git a/libmei/atts_tablature.h b/libmei/atts_tablature.h index 591299c79fa..a36386296cf 100644 --- a/libmei/atts_tablature.h +++ b/libmei/atts_tablature.h @@ -102,7 +102,7 @@ class AttStaffDefGesTablature: public Att ///@} private: - /** Provides a *written* pitch and octave for each open string. **/ + /** Provides a *written* pitch and octave for each open string or course of strings. **/ std::string m_tabStrings; /* include */ diff --git a/libmei/atts_usersymbols.cpp b/libmei/atts_usersymbols.cpp new file mode 100644 index 00000000000..3ab259d1adb --- /dev/null +++ b/libmei/atts_usersymbols.cpp @@ -0,0 +1,97 @@ +///////////////////////////////////////////////////////////////////////////// +// Authors: Laurent Pugin and Rodolfo Zitellini +// Created: 2014 +// Copyright (c) Authors and others. All rights reserved. +// +// Code generated using a modified version of libmei +// by Andrew Hankinson, Alastair Porter, and Others +///////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////// +// NOTE: this file was generated with the Verovio libmei version and +// should not be edited because changes will be lost. +///////////////////////////////////////////////////////////////////////////// + +#include "atts_usersymbols.h" + +//---------------------------------------------------------------------------- + +#include + +//---------------------------------------------------------------------------- + +#include "object.h" + +/* #include_block */ + +namespace vrv { + +//---------------------------------------------------------------------------- +// AttAltsym +//---------------------------------------------------------------------------- + +AttAltsym::AttAltsym(): Att() { + ResetAltsym(); +} + +AttAltsym::~AttAltsym() { + +} + +void AttAltsym::ResetAltsym() { + m_altsym = ""; +} + +bool AttAltsym::ReadAltsym( pugi::xml_node element ) { + bool hasAttribute = false; + if (element.attribute("altsym")) { + this->SetAltsym(StrToStr(element.attribute("altsym").value())); + element.remove_attribute("altsym"); + hasAttribute = true; + } + return hasAttribute; +} + +bool AttAltsym::WriteAltsym( pugi::xml_node element ) { + bool wroteAttribute = false; + if (this->HasAltsym()) { + element.append_attribute("altsym") = StrToStr(this->GetAltsym()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttAltsym::HasAltsym( ) +{ + return (m_altsym != ""); +} + + +/* include */ + +bool Att::SetUsersymbols( Object *element, std::string attrType, std::string attrValue ) { + if (element->HasAttClass( ATT_ALTSYM ) ) { + AttAltsym *att = dynamic_cast(element); + assert( att ); + if (attrType == "altsym") { + att->SetAltsym(att->StrToStr(attrValue)); + return true; + } + } + + return false; +} + +void Att::GetUsersymbols( Object *element, ArrayOfStrAttr *attributes ) { + if (element->HasAttClass( ATT_ALTSYM ) ) { + AttAltsym *att = dynamic_cast(element); + assert( att ); + if (att->HasAltsym()) { + attributes->push_back(std::make_pair("altsym", att->StrToStr(att->GetAltsym()))); + } + } + +} + +} // vrv namespace + diff --git a/libmei/atts_usersymbols.h b/libmei/atts_usersymbols.h new file mode 100644 index 00000000000..ad2b56d568d --- /dev/null +++ b/libmei/atts_usersymbols.h @@ -0,0 +1,72 @@ +///////////////////////////////////////////////////////////////////////////// +// Authors: Laurent Pugin and Rodolfo Zitellini +// Created: 2014 +// Copyright (c) Authors and others. All rights reserved. +// +// Code generated using a modified version of libmei +// by Andrew Hankinson, Alastair Porter, and Others +///////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////// +// NOTE: this file was generated with the Verovio libmei version and +// should not be edited because changes will be lost. +///////////////////////////////////////////////////////////////////////////// + +#ifndef __VRV_ATTS_USERSYMBOLS_H__ +#define __VRV_ATTS_USERSYMBOLS_H__ + +#include "att.h" +#include "att_classes.h" +#include "pugixml.hpp" + +//---------------------------------------------------------------------------- + +#include + +namespace vrv { + +//---------------------------------------------------------------------------- +// AttAltsym +//---------------------------------------------------------------------------- + +class AttAltsym: public Att +{ +public: + AttAltsym(); + virtual ~AttAltsym(); + + /** Reset the default values for the attribute class **/ + void ResetAltsym(); + + /** Read the values for the attribute class **/ + bool ReadAltsym( pugi::xml_node element ); + + /** Write the values for the attribute class **/ + bool WriteAltsym( pugi::xml_node element ); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetAltsym(std::string altsym_) { m_altsym = altsym_; }; + std::string GetAltsym() const { return m_altsym; }; + bool HasAltsym( ); + + ///@} + +private: + /** + * Provides a way of pointing to a user-defined symbol. + * It must contain an ID of a element elsewhere in the document. + **/ + std::string m_altsym; + +/* include */ +}; + +} // vrv namespace + +#endif // __VRV_ATTS_USERSYMBOLS_H__ + diff --git a/python/setup.py b/python/setup.py index 86b5f285d7b..f5c7613affc 100755 --- a/python/setup.py +++ b/python/setup.py @@ -81,6 +81,7 @@ '../libmei/atts_shared.cpp', '../libmei/atts_cmn.cpp', '../libmei/atts_critapp.cpp', + '../libmei/atts_mei.cpp', '../libmei/atts_mensural.cpp', '../libmei/atts_pagebased.cpp', 'verovio.i'], diff --git a/src/barline.cpp b/src/barline.cpp index e283c984472..542c247c653 100644 --- a/src/barline.cpp +++ b/src/barline.cpp @@ -34,7 +34,7 @@ void Barline::Reset() bool Barline::HasRepetitionDots() { - if (GetRend() == BARRENDITION_rptstart || GetRend() == BARRENDITION_rptend || GetRend() == BARRENDITION_rptboth) { + if (GetForm() == BARRENDITION_rptstart || GetForm() == BARRENDITION_rptend || GetForm() == BARRENDITION_rptboth) { return true; } return false; diff --git a/src/chord.cpp b/src/chord.cpp index f093c786aec..1ec627c9a43 100644 --- a/src/chord.cpp +++ b/src/chord.cpp @@ -25,13 +25,13 @@ namespace vrv { Chord::Chord( ): LayerElement("chord-"), StemmedDrawingInterface(), ObjectListInterface(), DurationInterface(), AttCommon(), - AttStemmed(), - AttStemmedCmn(), + AttStems(), + AttStemsCmn(), AttTiepresent() { RegisterAttClass(ATT_COMMON); - RegisterAttClass(ATT_STEMMED); - RegisterAttClass(ATT_STEMMEDCMN); + RegisterAttClass(ATT_STEMS); + RegisterAttClass(ATT_STEMSCMN); RegisterAttClass(ATT_TIEPRESENT); RegisterInterface( DurationInterface::GetAttClasses(), DurationInterface::IsInterface() ); @@ -54,8 +54,8 @@ void Chord::Reset() StemmedDrawingInterface::Reset(); DurationInterface::Reset(); ResetCommon(); - ResetStemmed(); - ResetStemmedCmn(); + ResetStems(); + ResetStemsCmn(); ResetTiepresent(); } diff --git a/src/iomei.cpp b/src/iomei.cpp index e33d6dc2278..6cb459f9af9 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -617,8 +617,8 @@ void MeiOutput::WriteMeiChord( pugi::xml_node currentNode, Chord *chord ) WriteLayerElement( currentNode, chord ); WriteDurationInterface( currentNode, chord); chord->WriteCommon(currentNode); - chord->WriteStemmed(currentNode); - chord->WriteStemmedCmn(currentNode); + chord->WriteStems(currentNode); + chord->WriteStemsCmn(currentNode); chord->WriteTiepresent(currentNode); return; @@ -741,8 +741,8 @@ void MeiOutput::WriteMeiNote( pugi::xml_node currentNode, Note *note ) note->WriteColoration(currentNode); note->WriteGraced(currentNode); note->WriteNoteLogMensural(currentNode); - note->WriteStemmed(currentNode); - note->WriteStemmedCmn(currentNode); + note->WriteStems(currentNode); + note->WriteStemsCmn(currentNode); note->WriteTiepresent(currentNode); return; @@ -1812,8 +1812,8 @@ bool MeiInput::ReadMeiChord( Object *parent, pugi::xml_node chord) ReadDurationInterface(chord, vrvChord); vrvChord->ReadCommon(chord); - vrvChord->ReadStemmed(chord); - vrvChord->ReadStemmedCmn(chord); + vrvChord->ReadStems(chord); + vrvChord->ReadStemsCmn(chord); vrvChord->ReadTiepresent(chord); AddLayerElement(parent, vrvChord); @@ -1970,8 +1970,8 @@ bool MeiInput::ReadMeiNote( Object *parent, pugi::xml_node note ) vrvNote->ReadColoration(note); vrvNote->ReadGraced(note); vrvNote->ReadNoteLogMensural(note); - vrvNote->ReadStemmed(note); - vrvNote->ReadStemmedCmn(note); + vrvNote->ReadStems(note); + vrvNote->ReadStemsCmn(note); vrvNote->ReadTiepresent(note); AddLayerElement(parent, vrvNote); diff --git a/src/iopae.cpp b/src/iopae.cpp index 8c0dbaf4863..5696d3cc0d8 100644 --- a/src/iopae.cpp +++ b/src/iopae.cpp @@ -1150,7 +1150,7 @@ void PaeInput::convertMeasure(pae::Measure *measure ) { // Set barLine // FIXME use flags for proper barLine identification Barline *bline = m_measure->GetRightBarline(); - bline->SetRend( measure->barLine ); + bline->SetForm( measure->barLine ); } diff --git a/src/measure.cpp b/src/measure.cpp index a1bb1a1bc43..586aaa638bb 100644 --- a/src/measure.cpp +++ b/src/measure.cpp @@ -59,8 +59,8 @@ void Measure::Reset() m_drawingX = 0; // by default, we have a single barLine on the right (none on the left) - m_rightBarline.SetRend( this->GetRight() ); - m_leftBarline.SetRend( this->GetLeft() ); + m_rightBarline.SetForm( this->GetRight() ); + m_leftBarline.SetForm( this->GetLeft() ); if ( !m_measuredMusic ) { m_xAbs = 0; @@ -157,11 +157,11 @@ int Measure::AlignHorizontally( ArrayPtrVoid *params ) // point to it (*measureAligner) = &m_measureAligner; - if ( m_leftBarline.GetRend() != BARRENDITION_NONE ) { + if ( m_leftBarline.GetForm() != BARRENDITION_NONE ) { m_leftBarline.SetAlignment( m_measureAligner.GetLeftAlignment() ); } - if ( m_rightBarline.GetRend() != BARRENDITION_NONE ) { + if ( m_rightBarline.GetForm() != BARRENDITION_NONE ) { m_rightBarline.SetAlignment( m_measureAligner.GetRightAlignment() ); } diff --git a/src/note.cpp b/src/note.cpp index 68e8b7ab68c..b85aae295cf 100644 --- a/src/note.cpp +++ b/src/note.cpp @@ -31,15 +31,15 @@ Note::Note(): AttColoration(), AttGraced(), AttNoteLogMensural(), - AttStemmed(), - AttStemmedCmn(), + AttStems(), + AttStemsCmn(), AttTiepresent() { RegisterAttClass(ATT_COLORATION); RegisterAttClass(ATT_GRACED); RegisterAttClass(ATT_NOTELOGMENSURAL); - RegisterAttClass(ATT_STEMMED); - RegisterAttClass(ATT_STEMMEDCMN); + RegisterAttClass(ATT_STEMS); + RegisterAttClass(ATT_STEMSCMN); RegisterAttClass(ATT_TIEPRESENT); RegisterInterface( DurationInterface::GetAttClasses(), DurationInterface::IsInterface() ); @@ -76,8 +76,8 @@ void Note::Reset() ResetColoration(); ResetGraced(); ResetNoteLogMensural(); - ResetStemmed(); - ResetStemmedCmn(); + ResetStems(); + ResetStemsCmn(); ResetTiepresent(); // TO BE REMOVED diff --git a/src/scoredef.cpp b/src/scoredef.cpp index 5c87fa50483..a82d39cf3b5 100644 --- a/src/scoredef.cpp +++ b/src/scoredef.cpp @@ -350,11 +350,13 @@ void ScoreDef::SetDrawingWidth(int drawingWidth) StaffGrp::StaffGrp() : Object(), ObjectListInterface(), AttCommon(), + AttCommonPart(), AttLabelsAddl(), AttStaffgroupingsym(), AttStaffGrpVis() { RegisterAttClass(ATT_COMMON); + RegisterAttClass(ATT_COMMONPART); RegisterAttClass(ATT_LABELSADDL); RegisterAttClass(ATT_STAFFGROUPINGSYM); RegisterAttClass(ATT_STAFFGRPVIS); @@ -369,6 +371,7 @@ void StaffGrp::Reset() { Object::Reset(); ResetCommon(); + ResetCommonPart(); ResetLabelsAddl(); ResetStaffgroupingsym(); ResetStaffGrpVis(); @@ -411,11 +414,13 @@ void StaffGrp::FilterList( ListOfObjects *childList ) StaffDef::StaffDef() : ScoreDefElement("staffdef-"), AttCommon(), + AttCommonPart(), AttLabelsAddl(), AttScalable(), AttStaffDefVis() { RegisterAttClass(ATT_COMMON); + RegisterAttClass(ATT_COMMONPART); RegisterAttClass(ATT_LABELSADDL); RegisterAttClass(ATT_SCALABLE); RegisterAttClass(ATT_STAFFDEFVIS); @@ -430,6 +435,7 @@ void StaffDef::Reset() { ScoreDefElement::Reset(); ResetCommon(); + ResetCommonPart(); ResetLabelsAddl(); ResetScalable(); ResetStaffDefVis(); diff --git a/src/view_beam.cpp b/src/view_beam.cpp index 10e846db43b..8af17690c26 100644 --- a/src/view_beam.cpp +++ b/src/view_beam.cpp @@ -126,8 +126,8 @@ void View::DrawBeam( DeviceContext *dc, LayerElement *element, Layer *layer, Sta if ( (current->Is() == NOTE) || (current->Is() == CHORD) ) { // look at the stemDir to see if we have multiple stem Dir if (!params.m_hasMultipleStemDir) { - assert( dynamic_cast(current) ); - currentStemDir = dynamic_cast(current)->GetStemDir(); + assert( dynamic_cast(current) ); + currentStemDir = dynamic_cast(current)->GetStemDir(); if (currentStemDir != STEMDIRECTION_NONE) { if ((params.m_stemDir != STEMDIRECTION_NONE) && (params.m_stemDir != currentStemDir)) { params.m_hasMultipleStemDir = ON; @@ -415,8 +415,8 @@ void View::DrawFTrem(DeviceContext *dc, LayerElement *element, Layer *layer, Sta } // For now look at the stemDir only on the first note - assert( dynamic_cast(firstElement.m_element) ); - params.m_stemDir = dynamic_cast(firstElement.m_element)->GetStemDir(); + assert( dynamic_cast(firstElement.m_element) ); + params.m_stemDir = dynamic_cast(firstElement.m_element)->GetStemDir(); // We look only at the first note for checking if cuesized. Somehow arbitrarily params.m_cueSize = firstElement.m_element->IsCueSize(); diff --git a/src/view_element.cpp b/src/view_element.cpp index 9204e14eb40..c114f49ebb3 100644 --- a/src/view_element.cpp +++ b/src/view_element.cpp @@ -248,7 +248,7 @@ void View::DrawBarline( DeviceContext *dc, LayerElement *element, Layer *layer, Barline *barLine = dynamic_cast(element); assert( barLine ); - if (barLine->GetRend() == BARRENDITION_invis) { + if (barLine->GetForm() == BARRENDITION_invis) { barLine->SetEmptyBB(); return; } @@ -279,12 +279,12 @@ void View::DrawBeatRpt(DeviceContext *dc, LayerElement *element, Layer *layer, S int y = element->GetDrawingY(); y -= staff->m_drawingLines / 2 * m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize); - if (beatRpt->GetRend() == BEATRPT_REND_mixed) { + if (beatRpt->GetForm() == BEATRPT_REND_mixed) { DrawSmuflCode( dc, xSymbol, y, SMUFL_E501_repeat2Bars, staff->m_drawingStaffSize, false ); } else { DrawSmuflCode( dc, xSymbol, y, SMUFL_E101_noteheadSlashHorizontalEnds, staff->m_drawingStaffSize, false ); - int additionalSlash = beatRpt->GetRend() - BEATRPT_REND_8; + int additionalSlash = beatRpt->GetForm() - BEATRPT_REND_8; int halfWidth = m_doc->GetGlyphWidth(SMUFL_E101_noteheadSlashHorizontalEnds, staff->m_drawingStaffSize, false) / 2; int i; for (i = 0; i < additionalSlash; i++) { diff --git a/src/view_page.cpp b/src/view_page.cpp index b3a68596938..84f223b73f0 100644 --- a/src/view_page.cpp +++ b/src/view_page.cpp @@ -635,34 +635,34 @@ void View::DrawBarline( DeviceContext *dc, int y_top, int y_bottom, Barline *bar int x1 = x - m_doc->GetDrawingBeamWidth(100, false) - barLineWidth; int x2 = x + m_doc->GetDrawingBeamWidth(100, false) + barLineWidth; - if (barLine->GetRend() == BARRENDITION_single) + if (barLine->GetForm() == BARRENDITION_single) { DrawVerticalLine( dc , y_top, y_bottom, x, barLineWidth); } - else if (barLine->GetRend() == BARRENDITION_rptboth) + else if (barLine->GetForm() == BARRENDITION_rptboth) { DrawVerticalLine( dc , y_top, y_bottom, x1, barLineWidth); DrawVerticalLine( dc , y_top, y_bottom, x, m_doc->GetDrawingBeamWidth(100, false)); DrawVerticalLine( dc , y_top, y_bottom, x2, barLineWidth); } - else if (barLine->GetRend() == BARRENDITION_rptstart) + else if (barLine->GetForm() == BARRENDITION_rptstart) { DrawVerticalLine( dc , y_top, y_bottom, x, m_doc->GetDrawingBeamWidth(100, false)); DrawVerticalLine( dc , y_top, y_bottom, x2, barLineWidth); } - else if (barLine->GetRend() == BARRENDITION_rptend) + else if (barLine->GetForm() == BARRENDITION_rptend) { DrawVerticalLine( dc , y_top, y_bottom, x1, barLineWidth); DrawVerticalLine( dc , y_top, y_bottom, x, m_doc->GetDrawingBeamWidth(100, false)); } - else if (barLine->GetRend() == BARRENDITION_dbl) + else if (barLine->GetForm() == BARRENDITION_dbl) { // Narrow the bars a little bit - should be centered? x1 += barLineWidth; DrawVerticalLine( dc , y_top, y_bottom, x, barLineWidth); DrawVerticalLine( dc , y_top, y_bottom, x1, barLineWidth); } - else if (barLine->GetRend() == BARRENDITION_end) + else if (barLine->GetForm() == BARRENDITION_end) { DrawVerticalLine( dc , y_top, y_bottom, x1, barLineWidth); DrawVerticalLine( dc , y_top, y_bottom, x, m_doc->GetDrawingBeamWidth(100, false)); @@ -687,13 +687,13 @@ void View::DrawBarlineDots ( DeviceContext *dc, StaffDef *staffDef, Staff *staff int y_bottom = staff->GetDrawingY() - staffDef->GetLines() * m_doc->GetDrawingUnit(staff->m_drawingStaffSize); int y_top = y_bottom + m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize); - if ((barLine->GetRend() == BARRENDITION_rptstart) || (barLine->GetRend() == BARRENDITION_rptboth)) + if ((barLine->GetForm() == BARRENDITION_rptstart) || (barLine->GetForm() == BARRENDITION_rptboth)) { DrawDot(dc, x2, y_bottom, staff->m_drawingStaffSize); DrawDot(dc, x2, y_top, staff->m_drawingStaffSize); } - if ((barLine->GetRend() == BARRENDITION_rptend) || (barLine->GetRend() == BARRENDITION_rptboth)) + if ((barLine->GetForm() == BARRENDITION_rptend) || (barLine->GetForm() == BARRENDITION_rptboth)) { DrawDot(dc, x1, y_bottom, staff->m_drawingStaffSize); DrawDot(dc, x1, y_top, staff->m_drawingStaffSize); diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index be6cdbe991b..8d53fc12410 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -95,11 +95,13 @@ add_executable (verovio ../libmei/atts_critapp.cpp #../libmei/atts_facsimile.cpp #../libmei/atts_harmony.cpp - #../libmei/atts_linkalign.cpp + ../libmei/atts_mei.cpp ../libmei/atts_mensural.cpp ../libmei/atts_pagebased.cpp + #../libmei/atts_performance.cpp #../libmei/atts_neumes.cpp #../libmei/atts_tablature.cpp + #../libmei/atts_usersymbols.cpp ) install (TARGETS verovio DESTINATION /usr/local/bin) From d4a662cd34bb7dbad059f8b8ac9c8226ec11801a Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 11 Dec 2015 16:04:43 +0100 Subject: [PATCH 011/217] Updating libmei code generation --- Verovio.xcodeproj/project.pbxproj | 20 +- include/vrv/att.h | 101 +- include/vrv/attdef.h | 341 +-- include/vrv/object.h | 2 +- include/vrv/vrvdef.h | 1 - libmei/atts_analysis.cpp | 76 +- libmei/atts_analysis.h | 26 +- libmei/atts_cmn.cpp | 620 ++-- libmei/atts_cmn.h | 236 +- libmei/atts_cmnornaments.cpp | 100 +- libmei/atts_cmnornaments.h | 46 +- libmei/atts_critapp.cpp | 8 +- libmei/atts_critapp.h | 2 +- libmei/atts_edittrans.cpp | 28 +- libmei/atts_edittrans.h | 8 +- libmei/atts_facsimile.cpp | 16 +- libmei/atts_facsimile.h | 10 +- libmei/atts_figtable.cpp | 20 +- libmei/atts_figtable.h | 14 +- libmei/atts_harmony.cpp | 36 +- libmei/atts_harmony.h | 14 +- libmei/atts_header.cpp | 16 +- libmei/atts_header.h | 10 +- libmei/atts_lyrics.cpp | 16 +- libmei/atts_lyrics.h | 8 +- libmei/atts_mei.cpp | 16 +- libmei/atts_mei.h | 8 +- libmei/atts_mensural.cpp | 136 +- libmei/atts_mensural.h | 56 +- libmei/atts_midi.cpp | 188 +- libmei/atts_midi.h | 88 +- libmei/atts_neumes.cpp | 56 +- libmei/atts_neumes.h | 28 +- libmei/atts_pagebased.cpp | 4 +- libmei/atts_pagebased.h | 2 +- libmei/atts_performance.cpp | 4 +- libmei/atts_performance.h | 2 +- libmei/atts_shared.cpp | 1800 ++++++------ libmei/atts_shared.h | 572 ++-- libmei/atts_tablature.cpp | 32 +- libmei/atts_tablature.h | 14 +- libmei/atts_usersymbols.cpp | 4 +- libmei/atts_usersymbols.h | 2 +- libmei/{att_classes.h => libmei_classes.h} | 0 libmei/libmei_converter.cpp | 3063 ++++++++++++++++++++ libmei/libmei_converter.h | 307 ++ libmei/libmei_def.h | 1276 ++++++++ src/att.cpp | 831 +----- src/iomusxml.cpp | 28 +- src/syl.cpp | 8 +- src/view_element.cpp | 4 +- src/view_floating.cpp | 8 +- src/view_mensural.cpp | 2 +- src/view_page.cpp | 8 +- 54 files changed, 6971 insertions(+), 3351 deletions(-) rename libmei/{att_classes.h => libmei_classes.h} (100%) create mode 100644 libmei/libmei_converter.cpp create mode 100644 libmei/libmei_converter.h create mode 100644 libmei/libmei_def.h diff --git a/Verovio.xcodeproj/project.pbxproj b/Verovio.xcodeproj/project.pbxproj index 15e1c1110ee..60069691d94 100644 --- a/Verovio.xcodeproj/project.pbxproj +++ b/Verovio.xcodeproj/project.pbxproj @@ -89,6 +89,11 @@ 4DF9D2831C18DC490069E8C8 /* atts_mei.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DF9D2811C18DC490069E8C8 /* atts_mei.cpp */; }; 4DF9D2841C18DC490069E8C8 /* atts_mei.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DF9D2811C18DC490069E8C8 /* atts_mei.cpp */; }; 4DF9D2851C18DC490069E8C8 /* atts_mei.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DF9D2821C18DC490069E8C8 /* atts_mei.h */; }; + 4DF9D28E1C19C4A10069E8C8 /* libmei_classes.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DF9D28C1C19C4A10069E8C8 /* libmei_classes.h */; }; + 4DF9D28F1C19C4A10069E8C8 /* libmei_def.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DF9D28D1C19C4A10069E8C8 /* libmei_def.h */; }; + 4DF9D2921C1ADCC80069E8C8 /* libmei_converter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DF9D2901C1ADCC80069E8C8 /* libmei_converter.cpp */; }; + 4DF9D2931C1ADCC80069E8C8 /* libmei_converter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DF9D2901C1ADCC80069E8C8 /* libmei_converter.cpp */; }; + 4DF9D2941C1ADCC80069E8C8 /* libmei_converter.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DF9D2911C1ADCC80069E8C8 /* libmei_converter.h */; }; 8F086EE2188539540037FD8E /* aligner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F086EB6188539540037FD8E /* aligner.cpp */; }; 8F086EE4188539540037FD8E /* barline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F086EB8188539540037FD8E /* barline.cpp */; }; 8F086EE5188539540037FD8E /* bboxdevicecontext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F086EB9188539540037FD8E /* bboxdevicecontext.cpp */; }; @@ -242,7 +247,6 @@ 4D422103199805F700963292 /* att.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = att.cpp; path = src/att.cpp; sourceTree = ""; }; 4D43C30B1A9BB22A00EA28F3 /* view_mensural.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = view_mensural.cpp; path = src/view_mensural.cpp; sourceTree = ""; }; 4D543E211B80AACF004B823C /* view_floating.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = view_floating.cpp; path = src/view_floating.cpp; sourceTree = ""; }; - 4D5B522F1B7DE3FE00179688 /* att_classes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = att_classes.h; path = libmei/att_classes.h; sourceTree = ""; }; 4D763EC51987D04D003FCAB5 /* metersig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = metersig.cpp; path = src/metersig.cpp; sourceTree = ""; }; 4D763EC81987D067003FCAB5 /* metersig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = metersig.h; path = include/vrv/metersig.h; sourceTree = ""; }; 4D797B041A67C55F007637BD /* devicecontextbase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = devicecontextbase.h; path = include/vrv/devicecontextbase.h; sourceTree = ""; }; @@ -319,6 +323,10 @@ 4DF9D2871C18DE270069E8C8 /* atts_performance.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = atts_performance.h; path = libmei/atts_performance.h; sourceTree = ""; }; 4DF9D2881C18DE270069E8C8 /* atts_usersymbols.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = atts_usersymbols.cpp; path = libmei/atts_usersymbols.cpp; sourceTree = ""; }; 4DF9D2891C18DE270069E8C8 /* atts_usersymbols.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = atts_usersymbols.h; path = libmei/atts_usersymbols.h; sourceTree = ""; }; + 4DF9D28C1C19C4A10069E8C8 /* libmei_classes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = libmei_classes.h; path = libmei/libmei_classes.h; sourceTree = ""; }; + 4DF9D28D1C19C4A10069E8C8 /* libmei_def.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = libmei_def.h; path = libmei/libmei_def.h; sourceTree = ""; }; + 4DF9D2901C1ADCC80069E8C8 /* libmei_converter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = libmei_converter.cpp; path = libmei/libmei_converter.cpp; sourceTree = ""; }; + 4DF9D2911C1ADCC80069E8C8 /* libmei_converter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = libmei_converter.h; path = libmei/libmei_converter.h; sourceTree = ""; }; 8F086EA9188534680037FD8E /* Verovio */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Verovio; sourceTree = BUILT_PRODUCTS_DIR; }; 8F086EB6188539540037FD8E /* aligner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = aligner.cpp; path = src/aligner.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 8F086EB8188539540037FD8E /* barline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = barline.cpp; path = src/barline.cpp; sourceTree = ""; }; @@ -473,7 +481,6 @@ 4DEE28EC1940BCA100C76319 /* libmei */ = { isa = PBXGroup; children = ( - 4D5B522F1B7DE3FE00179688 /* att_classes.h */, 4DEE28ED1940BCC100C76319 /* atts_analysis.cpp */, 4DEE28EE1940BCC100C76319 /* atts_analysis.h */, 4DEE28EF1940BCC100C76319 /* atts_cmn.cpp */, @@ -512,6 +519,10 @@ 4DEE290C1940BCC100C76319 /* atts_tablature.h */, 4DF9D2881C18DE270069E8C8 /* atts_usersymbols.cpp */, 4DF9D2891C18DE270069E8C8 /* atts_usersymbols.h */, + 4DF9D28C1C19C4A10069E8C8 /* libmei_classes.h */, + 4DF9D2901C1ADCC80069E8C8 /* libmei_converter.cpp */, + 4DF9D2911C1ADCC80069E8C8 /* libmei_converter.h */, + 4DF9D28D1C19C4A10069E8C8 /* libmei_def.h */, ); name = libmei; sourceTree = ""; @@ -721,6 +732,7 @@ 4D1D733E1A1D08CD001E08F6 /* glyph.h in Headers */, 8F59293A18854BF800FE51AD /* devicecontext.h in Headers */, 8F59293B18854BF800FE51AD /* doc.h in Headers */, + 4DF9D2941C1ADCC80069E8C8 /* libmei_converter.h in Headers */, 8F59293C18854BF800FE51AD /* durationinterface.h in Headers */, 8F59293D18854BF800FE51AD /* toolkit.h in Headers */, 4D1D733C1A1D0390001E08F6 /* smufl.h in Headers */, @@ -748,10 +760,12 @@ 8F59294E18854BF800FE51AD /* positioninterface.h in Headers */, 8F59294F18854BF800FE51AD /* rest.h in Headers */, 4DF289FD1A7545CC00BA9F7D /* timeinterface.h in Headers */, + 4DF9D28E1C19C4A10069E8C8 /* libmei_classes.h in Headers */, 8F59295018854BF800FE51AD /* scoredef.h in Headers */, 4DB726C31B8B9F540040231B /* rpt.h in Headers */, 8F59295118854BF800FE51AD /* slur.h in Headers */, 8F59295218854BF800FE51AD /* staff.h in Headers */, + 4DF9D28F1C19C4A10069E8C8 /* libmei_def.h in Headers */, 8F59295318854BF800FE51AD /* svgdevicecontext.h in Headers */, 8F59295518854BF800FE51AD /* system.h in Headers */, 8F59295618854BF800FE51AD /* tie.h in Headers */, @@ -900,6 +914,7 @@ 8F086EFF188539540037FD8E /* slur.cpp in Sources */, 8F086F00188539540037FD8E /* staff.cpp in Sources */, 8F086F01188539540037FD8E /* svgdevicecontext.cpp in Sources */, + 4DF9D2921C1ADCC80069E8C8 /* libmei_converter.cpp in Sources */, 4DA80D961A6ACF5D0089802D /* style.cpp in Sources */, 8F086F03188539540037FD8E /* system.cpp in Sources */, 4D20B5EC1B873A1300EA9EC3 /* scoredefinterface.cpp in Sources */, @@ -966,6 +981,7 @@ 4D798CBE1B8AEDBA007281CA /* drawinginterface.cpp in Sources */, 8F3DD34818854B2E0051330C /* mensur.cpp in Sources */, 8F3DD34A18854B2E0051330C /* multirest.cpp in Sources */, + 4DF9D2931C1ADCC80069E8C8 /* libmei_converter.cpp in Sources */, 8F3DD34C18854B2E0051330C /* note.cpp in Sources */, 4D8CD8A71B4E927300F0756F /* atts_critapp.cpp in Sources */, 8F3DD34E18854B2E0051330C /* pitchinterface.cpp in Sources */, diff --git a/include/vrv/att.h b/include/vrv/att.h index 0b9c1f32038..9f6778c0390 100644 --- a/include/vrv/att.h +++ b/include/vrv/att.h @@ -13,6 +13,7 @@ //---------------------------------------------------------------------------- #include "vrvdef.h" +#include "libmei_converter.h" namespace vrv { @@ -27,7 +28,7 @@ class Object; * It is not an abstract class but it should not be instanciated directly. * The att classes are generated with the libmei parser for Verovio. */ -class Att +class Att: public LibmeiConverter { public: /** @name Constructors and destructor */ @@ -105,119 +106,45 @@ class Att /** @name Converters for writing and reading */ ///@{ - std::string AccidentalExplicitToStr(data_ACCIDENTAL_EXPLICIT data); - data_ACCIDENTAL_EXPLICIT StrToAccidentalExplicit(std::string value); - - std::string AccidentalImplicitToStr(data_ACCIDENTAL_IMPLICIT data); - data_ACCIDENTAL_IMPLICIT StrToAccidentalImplicit(std::string value); - - std::string BarRenditionToStr(data_BARRENDITION data); - data_BARRENDITION StrToBarRendition(std::string value); std::string BeatrptRendToStr(data_BEATRPT_REND data); data_BEATRPT_REND StrToBeatrptRend(std::string value); - std::string BoolToStr(data_BOOLEAN data); - data_BOOLEAN StrToBool(std::string value); - - std::string ClefShapeToStr(data_CLEFSHAPE data); - data_CLEFSHAPE StrToClefShape(std::string value); - - std::string ConToStr(data_CON data); - data_CON StrToCon(std::string value); - - std::string CurvedirToStr(data_CURVEDIR data); - data_CURVEDIR StrToCurvedir(std::string value); - - std::string DurToStr(data_DURATION data); - data_DURATION StrToDur(std::string value); - - std::string FontstyleToStr(data_FONTSTYLE data); - data_FONTSTYLE StrToFontstyle(std::string value); - - std::string FontweightToStr(data_FONTWEIGHT data); - data_FONTWEIGHT StrToFontweight(std::string value); - - std::string FuncToStr(data_FUNC data); - data_FUNC StrToFunc(std::string value); - - std::string GraceToStr(data_GRACE data); - data_GRACE StrToGrace(std::string value); + std::string DurationToStr(data_DURATION data); + data_DURATION StrToDuration(std::string value); - std::string KeySignatureToStr(data_KEYSIGNATURE data); - data_KEYSIGNATURE StrToKeySignature(std::string value); - - std::string LayerschemeToStr(data_LAYERSCHEME data); - data_LAYERSCHEME StrToLayerscheme(std::string value); - - std::string LigatureToStr(data_LIGATURE data); - data_LIGATURE StrToLigature(std::string value); + std::string KeysignatureToStr(data_KEYSIGNATURE data); + data_KEYSIGNATURE StrToKeysignature(std::string value); - std::string MensurationSignToStr(data_MENSURATIONSIGN data); - data_MENSURATIONSIGN StrToMensurationSign(std::string value); - - std::string MeterSignToStr(data_METERSIGN data); - data_METERSIGN StrToMeterSign(std::string value); - - std::string ModeToStr(data_MODE data); - data_MODE StrToMode(std::string value); + std::string MeasurebeatToStr(data_MEASUREBEAT data); + data_MEASUREBEAT StrToMeasurebeat(std::string value); std::string ModusmaiorToStr(data_MODUSMAIOR data); data_MODUSMAIOR StrToModusmaior(std::string value); std::string ModusminorToStr(data_MODUSMINOR data); data_MODUSMINOR StrToModusminor(std::string value); - - std::string NumformatToStr(data_NUMFORMAT data); - data_NUMFORMAT StrToNumformat(std::string value); - - std::string PercentToStr(data_PERCENT data); - data_PERCENT StrToPercent(std::string value); std::string OctaveDisToStr(data_OCTAVE_DIS data); data_OCTAVE_DIS StrToOctaveDis(std::string value); - + std::string OrientationToStr(data_ORIENTATION data); data_ORIENTATION StrToOrientation(std::string value); - std::string PitchNameToStr(data_PITCHNAME data); - data_PITCHNAME StrToPitchName(std::string value); - - std::string PlaceToStr(data_PLACE data); - data_PLACE StrToPlace(std::string value); + std::string PitchnameToStr(data_PITCHNAME data); + data_PITCHNAME StrToPitchname(std::string value); std::string ProlatioToStr(data_PROLATIO data); data_PROLATIO StrToProlatio(std::string value); - - std::string StaffRelToStr(data_STAFFREL data); - data_STAFFREL StrToStaffRel(std::string value); - - std::string StemDirectionToStr(data_STEMDIRECTION data); - data_STEMDIRECTION StrToStemDirection(std::string value); - - std::string StemModifierToStr(data_STEMMODIFIER data); - data_STEMMODIFIER StrToStemModifier(std::string value); - - std::string StemPositionToStr(data_STEMPOSITION data); - data_STEMPOSITION StrToStemPosition(std::string value); - - std::string SymbolToStr(data_SYMBOL data); - data_SYMBOL StrToSymbol(std::string value); + std::string StemdirectionToStr(data_STEMDIRECTION data); + data_STEMDIRECTION StrToStemdirection(std::string value); + std::string TempusToStr(data_TEMPUS data); data_TEMPUS StrToTempus(std::string value); std::string TieToStr(data_TIE data); data_TIE StrToTie(std::string value); - - std::string Tstamp2ToStr(typedef_TSTAMP2 data); - typedef_TSTAMP2 StrToTstamp2(std::string value); - - std::string WordPosToStr(data_WORDPOS data); - data_WORDPOS StrToWordPos(std::string value); - - ///@} - }; //---------------------------------------------------------------------------- diff --git a/include/vrv/attdef.h b/include/vrv/attdef.h index 8c213e43bf6..e9f2e71bccd 100644 --- a/include/vrv/attdef.h +++ b/include/vrv/attdef.h @@ -15,6 +15,11 @@ //---------------------------------------------------------------------------- +#include "libmei_classes.h" +#include "libmei_def.h" + +//---------------------------------------------------------------------------- + namespace vrv { typedef std::vector > ArrayOfStrAttr; @@ -52,64 +57,6 @@ typedef std::vector > ArrayOfStrAttr; //---------------------------------------------------------------------------- // MEI data defines //---------------------------------------------------------------------------- - -/** - * MEI data.ACCIDENTAL.EXPLICIT - */ -enum data_ACCIDENTAL_EXPLICIT { - ACCIDENTAL_EXPLICIT_NONE = 0, - ACCIDENTAL_EXPLICIT_s, - ACCIDENTAL_EXPLICIT_f, - ACCIDENTAL_EXPLICIT_ss, - ACCIDENTAL_EXPLICIT_x, - ACCIDENTAL_EXPLICIT_ff, - ACCIDENTAL_EXPLICIT_xs, - ACCIDENTAL_EXPLICIT_ts, - ACCIDENTAL_EXPLICIT_tf, - ACCIDENTAL_EXPLICIT_n, - ACCIDENTAL_EXPLICIT_nf, - ACCIDENTAL_EXPLICIT_ns, - ACCIDENTAL_EXPLICIT_su, - ACCIDENTAL_EXPLICIT_sd, - ACCIDENTAL_EXPLICIT_fu, - ACCIDENTAL_EXPLICIT_fd, - ACCIDENTAL_EXPLICIT_nu, - ACCIDENTAL_EXPLICIT_nd -}; - -/** - * MEI data.ACCIDENTAL.IMPLICIT - */ -enum data_ACCIDENTAL_IMPLICIT { - ACCIDENTAL_IMPLICIT_NONE = 0, - ACCIDENTAL_IMPLICIT_s, - ACCIDENTAL_IMPLICIT_f, - ACCIDENTAL_IMPLICIT_ss, - ACCIDENTAL_IMPLICIT_ff, - ACCIDENTAL_IMPLICIT_n, - ACCIDENTAL_IMPLICIT_su, - ACCIDENTAL_IMPLICIT_sd, - ACCIDENTAL_IMPLICIT_fu, - ACCIDENTAL_IMPLICIT_fd -}; - -/** - * MEI data.BARRENDITION - */ -enum data_BARRENDITION { - BARRENDITION_NONE = 0, - BARRENDITION_dashed, - BARRENDITION_dotted, - BARRENDITION_dbl, - BARRENDITION_dbldashed, - BARRENDITION_dbldotted, - BARRENDITION_end, - BARRENDITION_invis, - BARRENDITION_rptstart, - BARRENDITION_rptboth, - BARRENDITION_rptend, - BARRENDITION_single -}; /** * MEI data.BEATRPT_REND @@ -125,52 +72,6 @@ enum data_BEATRPT_REND { BEATRPT_REND_mixed }; -/** - * MEI data.BOOEAN - */ -enum data_BOOLEAN { - BOOLEAN_NONE = 0, - BOOLEAN_true, - BOOLEAN_false -}; - -/** - * MEI data.CLEFSHAPE - */ -enum data_CLEFSHAPE { - CLEFSHAPE_NONE = 0, - CLEFSHAPE_G, - CLEFSHAPE_GG, - CLEFSHAPE_F, - CLEFSHAPE_C, - CLEFSHAPE_perc, - CLEFSHAPE_TAB -}; - -/** - * MEI values for @con (no datatype in MEI) - */ -enum data_CON { - CON_NONE = 0, - CON_s, - CON_d, - CON_u, - CON_t, - CON_c, - CON_v, - CON_i, - CON_b -}; - -/** - * MEI values for @curvedir (no datatype in MEI) - */ -enum data_CURVEDIR { - CURVEDIR_NONE = 0, - CURVEDIR_above, - CURVEDIR_below -}; - /** * MEI data.DURATION */ @@ -199,46 +100,7 @@ enum data_DURATION { DURATION_fusa, DURATION_semifusa }; - -/** - * MEI data.FONTSTYLE - */ -enum data_FONTSTYLE { - FONTSTYLE_NONE = 0, - FONTSTYLE_italic, - FONTSTYLE_normal, - FONTSTYLE_oblique -}; - -/** - * MEI data.FONTWEIGHT - */ -enum data_FONTWEIGHT { - FONTWEIGHT_NONE = 0, - FONTWEIGHT_bold, - FONTWEIGHT_normal -}; - -/** - * MEI data.GRACE - */ -enum data_GRACE { - GRACE_NONE = 0, - GRACE_acc, - GRACE_unacc, - GRACE_unknown -}; - - -/** - * MEI values for @func (no datatype in MEI) - */ -enum data_FUNC { - FUNC_NONE = 0, - FUNC_caution, - FUNC_edit -}; - + /** * MEI data.KEYSIGNATURE * The maximum is 255 (unsigned char) @@ -264,60 +126,9 @@ enum data_KEYSIGNATURE { KEYSIGNATURE_7s, KEYSIGNATURE_mixed }; - -/** - * MEI data.LAYERSCHEME - */ -enum data_LAYERSCHEME { - LAYERSCHEME_NONE = 0, - LAYERSCHEME_1, - LAYERSCHEME_2o, - LAYERSCHEME_2f, - LAYERSCHEME_3o, - LAYERSCHEME_3f -}; - -/** - * MEI values for @lig (no datatype in MEI) - */ -enum data_LIGATURE { - LIGATURE_NONE = 0, - LIGATURE_recta, - LIGATURE_obliqua -}; -/** - * MEI data.METERSIGN - */ -enum data_METERSIGN { - METERSIGN_NONE = 0, - METERSIGN_common, - METERSIGN_cut -}; - -/** - * MEI data.MENSURATIONSIGN - */ -enum data_MENSURATIONSIGN { - MENSURATIONSIGN_NONE = 0, - MENSURATIONSIGN_C, - MENSURATIONSIGN_O -}; - -/** - * MEI data.MODE - */ -enum data_MODE { - MODE_NONE = 0, - MODE_major, - MODE_minor, - MODE_dorian, - MODE_phrygian, - MODE_lydian, - MODE_mixolydian, - MODE_aeolian, - MODE_locrian -}; + +typedef std::pair data_MEASUREBEAT; /** * MEI data.MODUSMAIOR @@ -338,16 +149,7 @@ enum data_MODUSMINOR { MODUSMINOR_2 = 2, MODUSMINOR_3 }; - -/** - * MEI values for @num.format (no datatype in MEI) - */ -enum data_NUMFORMAT { - NUMFORMAT_NONE = 0, - NUMFORMAT_count, - NUMFORMAT_ratio, -}; - + /** * MEI data.OCTAVE.DIS */ @@ -359,9 +161,14 @@ enum data_OCTAVE_DIS { }; /** - * MEI value for @scale (no datatype in MEI) + * MEI data.ORIENTATION */ -typedef int data_PERCENT; +enum data_ORIENTATION { + ORIENTATION_NONE = 0, + ORIENTATION_reversed, + ORIENTATION_90CW, + ORIENTATION_90CCW +}; /** * MEI data.PITCHNAME @@ -377,6 +184,21 @@ enum data_PITCHNAME { PITCHNAME_b, }; +/** + * MEI data.PITCHNAME.GES + */ +enum data_PITCHNAME_GES { + PITCHNAME_GES_NONE = 0, + PITCHNAME_GES_c, + PITCHNAME_GES_d, + PITCHNAME_GES_e, + PITCHNAME_GES_f, + PITCHNAME_GES_g, + PITCHNAME_GES_a, + PITCHNAME_GES_b, + PITCHNAME_GES_none +}; + /** * MEI data.PROLATIO * NONE is -3 for perfect value (abs) by default @@ -386,90 +208,22 @@ enum data_PROLATIO { PROLATIO_2 = 2, PROLATIO_3 }; - -/** - * MEI data.ORIENTATION - */ -enum data_ORIENTATION { - ORIENTATION_NONE = 0, - ORIENTATION_reversed, - ORIENTATION_90CW, - ORIENTATION_90CCW -}; -/** - * MEI data.PLACE - */ -enum data_PLACE { - PLACE_NONE = 0, - PLACE_above, - PLACE_below -}; - -/** - * MEI values for @symbol (no datatype in MEI) - */ -enum data_SYMBOL { - SYMBOL_NONE = 0, - SYMBOL_brace, - SYMBOL_bracket, - SYMBOL_line -}; - -/** - * MEI data.STAFFREL - */ -enum data_STAFFREL { - STAFFREL_NONE = 0, - STAFFREL_above, - STAFFREL_below, - STAFFREL_within -}; - /** * MEI data.STEMDIRECTION */ enum data_STEMDIRECTION { STEMDIRECTION_NONE = 0, STEMDIRECTION_up, - STEMDIRECTION_down -}; - -/** - * MEI data.STEMPOSITION - */ -enum data_STEMPOSITION { - STEMPOSITION_NONE = 0, - STEMPOSITION_left, - STEMPOSITION_right, - STEMPOSITION_center -}; - -/** - * MEI data.STEMPOSITION - */ -enum data_STEMMODIFIER { - STEMMODIFIER_NONE = 0, - STEMMODIFIER_1slash, - STEMMODIFIER_2slash, - STEMMODIFIER_3slash, - STEMMODIFIER_4slash, - STEMMODIFIER_5slash, - STEMMODIFIER_6slash, - STEMMODIFIER_sprech, - STEMMODIFIER_z, -}; - -/** - * MEI data.TEMPUS - * NONE is -3 for perfect value (abs) by default - */ -enum data_TEMPUS { - TEMPUS_NONE = -3, - TEMPUS_2 = 2, - TEMPUS_3 + STEMDIRECTION_down, + STEMDIRECTION_left, + STEMDIRECTION_right, + STEMDIRECTION_ne, + STEMDIRECTION_se, + STEMDIRECTION_nw, + STEMDIRECTION_sw, }; - + /** * MEI data.TIE */ @@ -479,18 +233,17 @@ enum data_TIE { TIE_m, TIE_t }; - + /** - * MEI values for @wordpos (no datatype in MEI) + * MEI data.TEMPUS + * NONE is -3 for perfect value (abs) by default */ -enum data_WORDPOS { - WORDPOS_NONE = 0, - WORDPOS_i, - WORDPOS_m, - WORDPOS_t +enum data_TEMPUS { + TEMPUS_NONE = -3, + TEMPUS_2 = 2, + TEMPUS_3 }; - -typedef std::pair typedef_TSTAMP2; + } // namespace vrv diff --git a/include/vrv/object.h b/include/vrv/object.h index 22a916d9fe8..966f660075f 100644 --- a/include/vrv/object.h +++ b/include/vrv/object.h @@ -15,7 +15,7 @@ //---------------------------------------------------------------------------- -#include "att_classes.h" +#include "libmei_classes.h" #include "vrvdef.h" namespace vrv { diff --git a/include/vrv/vrvdef.h b/include/vrv/vrvdef.h index 6bb01d40076..404abb6a44b 100644 --- a/include/vrv/vrvdef.h +++ b/include/vrv/vrvdef.h @@ -16,7 +16,6 @@ //---------------------------------------------------------------------------- -#include "att_classes.h" #include "attdef.h" namespace vrv { diff --git a/libmei/atts_analysis.cpp b/libmei/atts_analysis.cpp index 146a8c18e16..9683295204c 100644 --- a/libmei/atts_analysis.cpp +++ b/libmei/atts_analysis.cpp @@ -47,7 +47,7 @@ void AttCommonAnl::ResetCommonAnl() { m_synch = ""; } -bool AttCommonAnl::ReadCommonAnl( pugi::xml_node element ) { +bool AttCommonAnl::ReadCommonAnl( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("copyof")) { this->SetCopyof(StrToStr(element.attribute("copyof").value())); @@ -82,7 +82,7 @@ bool AttCommonAnl::ReadCommonAnl( pugi::xml_node element ) { return hasAttribute; } -bool AttCommonAnl::WriteCommonAnl( pugi::xml_node element ) { +bool AttCommonAnl::WriteCommonAnl( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasCopyof()) { element.append_attribute("copyof") = StrToStr(this->GetCopyof()).c_str(); @@ -157,23 +157,23 @@ AttHarmonicfunction::~AttHarmonicfunction() { } void AttHarmonicfunction::ResetHarmonicfunction() { - m_deg = ""; + m_deg = SCALEDEGREE_NONE; } -bool AttHarmonicfunction::ReadHarmonicfunction( pugi::xml_node element ) { +bool AttHarmonicfunction::ReadHarmonicfunction( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("deg")) { - this->SetDeg(StrToStr(element.attribute("deg").value())); + this->SetDeg(StrToScaledegree(element.attribute("deg").value())); element.remove_attribute("deg"); hasAttribute = true; } return hasAttribute; } -bool AttHarmonicfunction::WriteHarmonicfunction( pugi::xml_node element ) { +bool AttHarmonicfunction::WriteHarmonicfunction( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasDeg()) { - element.append_attribute("deg") = StrToStr(this->GetDeg()).c_str(); + element.append_attribute("deg") = ScaledegreeToStr(this->GetDeg()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -181,7 +181,7 @@ bool AttHarmonicfunction::WriteHarmonicfunction( pugi::xml_node element ) { bool AttHarmonicfunction::HasDeg( ) { - return (m_deg != ""); + return (m_deg != SCALEDEGREE_NONE); } @@ -203,7 +203,7 @@ void AttIntervalharmonic::ResetIntervalharmonic() { m_inth = ""; } -bool AttIntervalharmonic::ReadIntervalharmonic( pugi::xml_node element ) { +bool AttIntervalharmonic::ReadIntervalharmonic( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("inth")) { this->SetInth(StrToStr(element.attribute("inth").value())); @@ -213,7 +213,7 @@ bool AttIntervalharmonic::ReadIntervalharmonic( pugi::xml_node element ) { return hasAttribute; } -bool AttIntervalharmonic::WriteIntervalharmonic( pugi::xml_node element ) { +bool AttIntervalharmonic::WriteIntervalharmonic( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasInth()) { element.append_attribute("inth") = StrToStr(this->GetInth()).c_str(); @@ -243,23 +243,23 @@ AttIntervallicdesc::~AttIntervallicdesc() { } void AttIntervallicdesc::ResetIntervallicdesc() { - m_intm = ""; + m_intm = INTERVAL_AMOUNT_NONE; } -bool AttIntervallicdesc::ReadIntervallicdesc( pugi::xml_node element ) { +bool AttIntervallicdesc::ReadIntervallicdesc( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("intm")) { - this->SetIntm(StrToStr(element.attribute("intm").value())); + this->SetIntm(StrToIntervalAmount(element.attribute("intm").value())); element.remove_attribute("intm"); hasAttribute = true; } return hasAttribute; } -bool AttIntervallicdesc::WriteIntervallicdesc( pugi::xml_node element ) { +bool AttIntervallicdesc::WriteIntervallicdesc( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasIntm()) { - element.append_attribute("intm") = StrToStr(this->GetIntm()).c_str(); + element.append_attribute("intm") = IntervalAmountToStr(this->GetIntm()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -267,7 +267,7 @@ bool AttIntervallicdesc::WriteIntervallicdesc( pugi::xml_node element ) { bool AttIntervallicdesc::HasIntm( ) { - return (m_intm != ""); + return (m_intm != INTERVAL_AMOUNT_NONE); } @@ -286,23 +286,23 @@ AttMelodicfunction::~AttMelodicfunction() { } void AttMelodicfunction::ResetMelodicfunction() { - m_mfunc = ""; + m_mfunc = MELODICFUNCTION_NONE; } -bool AttMelodicfunction::ReadMelodicfunction( pugi::xml_node element ) { +bool AttMelodicfunction::ReadMelodicfunction( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("mfunc")) { - this->SetMfunc(StrToStr(element.attribute("mfunc").value())); + this->SetMfunc(StrToMelodicfunction(element.attribute("mfunc").value())); element.remove_attribute("mfunc"); hasAttribute = true; } return hasAttribute; } -bool AttMelodicfunction::WriteMelodicfunction( pugi::xml_node element ) { +bool AttMelodicfunction::WriteMelodicfunction( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasMfunc()) { - element.append_attribute("mfunc") = StrToStr(this->GetMfunc()).c_str(); + element.append_attribute("mfunc") = MelodicfunctionToStr(this->GetMfunc()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -310,7 +310,7 @@ bool AttMelodicfunction::WriteMelodicfunction( pugi::xml_node element ) { bool AttMelodicfunction::HasMfunc( ) { - return (m_mfunc != ""); + return (m_mfunc != MELODICFUNCTION_NONE); } @@ -329,23 +329,23 @@ AttPitchclass::~AttPitchclass() { } void AttPitchclass::ResetPitchclass() { - m_pclass = ""; + m_pclass = PITCHCLASS_NONE; } -bool AttPitchclass::ReadPitchclass( pugi::xml_node element ) { +bool AttPitchclass::ReadPitchclass( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("pclass")) { - this->SetPclass(StrToStr(element.attribute("pclass").value())); + this->SetPclass(StrToPitchclass(element.attribute("pclass").value())); element.remove_attribute("pclass"); hasAttribute = true; } return hasAttribute; } -bool AttPitchclass::WritePitchclass( pugi::xml_node element ) { +bool AttPitchclass::WritePitchclass( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasPclass()) { - element.append_attribute("pclass") = StrToStr(this->GetPclass()).c_str(); + element.append_attribute("pclass") = PitchclassToStr(this->GetPclass()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -353,7 +353,7 @@ bool AttPitchclass::WritePitchclass( pugi::xml_node element ) { bool AttPitchclass::HasPclass( ) { - return (m_pclass != ""); + return (m_pclass != PITCHCLASS_NONE); } @@ -375,7 +375,7 @@ void AttSolfa::ResetSolfa() { m_psolfa = ""; } -bool AttSolfa::ReadSolfa( pugi::xml_node element ) { +bool AttSolfa::ReadSolfa( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("psolfa")) { this->SetPsolfa(StrToStr(element.attribute("psolfa").value())); @@ -385,7 +385,7 @@ bool AttSolfa::ReadSolfa( pugi::xml_node element ) { return hasAttribute; } -bool AttSolfa::WriteSolfa( pugi::xml_node element ) { +bool AttSolfa::WriteSolfa( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasPsolfa()) { element.append_attribute("psolfa") = StrToStr(this->GetPsolfa()).c_str(); @@ -435,7 +435,7 @@ bool Att::SetAnalysis( Object *element, std::string attrType, std::string attrVa AttHarmonicfunction *att = dynamic_cast(element); assert( att ); if (attrType == "deg") { - att->SetDeg(att->StrToStr(attrValue)); + att->SetDeg(att->StrToScaledegree(attrValue)); return true; } } @@ -451,7 +451,7 @@ bool Att::SetAnalysis( Object *element, std::string attrType, std::string attrVa AttIntervallicdesc *att = dynamic_cast(element); assert( att ); if (attrType == "intm") { - att->SetIntm(att->StrToStr(attrValue)); + att->SetIntm(att->StrToIntervalAmount(attrValue)); return true; } } @@ -459,7 +459,7 @@ bool Att::SetAnalysis( Object *element, std::string attrType, std::string attrVa AttMelodicfunction *att = dynamic_cast(element); assert( att ); if (attrType == "mfunc") { - att->SetMfunc(att->StrToStr(attrValue)); + att->SetMfunc(att->StrToMelodicfunction(attrValue)); return true; } } @@ -467,7 +467,7 @@ bool Att::SetAnalysis( Object *element, std::string attrType, std::string attrVa AttPitchclass *att = dynamic_cast(element); assert( att ); if (attrType == "pclass") { - att->SetPclass(att->StrToStr(attrValue)); + att->SetPclass(att->StrToPitchclass(attrValue)); return true; } } @@ -510,7 +510,7 @@ void Att::GetAnalysis( Object *element, ArrayOfStrAttr *attributes ) { AttHarmonicfunction *att = dynamic_cast(element); assert( att ); if (att->HasDeg()) { - attributes->push_back(std::make_pair("deg", att->StrToStr(att->GetDeg()))); + attributes->push_back(std::make_pair("deg", att->ScaledegreeToStr(att->GetDeg()))); } } if (element->HasAttClass( ATT_INTERVALHARMONIC ) ) { @@ -524,21 +524,21 @@ void Att::GetAnalysis( Object *element, ArrayOfStrAttr *attributes ) { AttIntervallicdesc *att = dynamic_cast(element); assert( att ); if (att->HasIntm()) { - attributes->push_back(std::make_pair("intm", att->StrToStr(att->GetIntm()))); + attributes->push_back(std::make_pair("intm", att->IntervalAmountToStr(att->GetIntm()))); } } if (element->HasAttClass( ATT_MELODICFUNCTION ) ) { AttMelodicfunction *att = dynamic_cast(element); assert( att ); if (att->HasMfunc()) { - attributes->push_back(std::make_pair("mfunc", att->StrToStr(att->GetMfunc()))); + attributes->push_back(std::make_pair("mfunc", att->MelodicfunctionToStr(att->GetMfunc()))); } } if (element->HasAttClass( ATT_PITCHCLASS ) ) { AttPitchclass *att = dynamic_cast(element); assert( att ); if (att->HasPclass()) { - attributes->push_back(std::make_pair("pclass", att->StrToStr(att->GetPclass()))); + attributes->push_back(std::make_pair("pclass", att->PitchclassToStr(att->GetPclass()))); } } if (element->HasAttClass( ATT_SOLFA ) ) { diff --git a/libmei/atts_analysis.h b/libmei/atts_analysis.h index cbefc6b340e..e2aaa1c0d6f 100644 --- a/libmei/atts_analysis.h +++ b/libmei/atts_analysis.h @@ -16,7 +16,7 @@ #define __VRV_ATTS_ANALYSIS_H__ #include "att.h" -#include "att_classes.h" +#include "attdef.h" #include "pugixml.hpp" //---------------------------------------------------------------------------- @@ -129,8 +129,8 @@ class AttHarmonicfunction: public Att * to the default value) **/ ///@{ - void SetDeg(std::string deg_) { m_deg = deg_; }; - std::string GetDeg() const { return m_deg; }; + void SetDeg(data_SCALEDEGREE deg_) { m_deg = deg_; }; + data_SCALEDEGREE GetDeg() const { return m_deg; }; bool HasDeg( ); ///@} @@ -143,7 +143,7 @@ class AttHarmonicfunction: public Att * 7 = leading tone), and an optional indication of chromatic alteration. The * amount of chromatic alternation is not indicated. **/ - std::string m_deg; + data_SCALEDEGREE m_deg; /* include */ }; @@ -214,8 +214,8 @@ class AttIntervallicdesc: public Att * to the default value) **/ ///@{ - void SetIntm(std::string intm_) { m_intm = intm_; }; - std::string GetIntm() const { return m_intm; }; + void SetIntm(data_INTERVAL_AMOUNT intm_) { m_intm = intm_; }; + data_INTERVAL_AMOUNT GetIntm() const { return m_intm; }; bool HasIntm( ); ///@} @@ -227,7 +227,7 @@ class AttIntervallicdesc: public Att * diatonic interval direction, quality, and size, or a precise numeric value in * half steps. **/ - std::string m_intm; + data_INTERVAL_AMOUNT m_intm; /* include */ }; @@ -257,15 +257,15 @@ class AttMelodicfunction: public Att * to the default value) **/ ///@{ - void SetMfunc(std::string mfunc_) { m_mfunc = mfunc_; }; - std::string GetMfunc() const { return m_mfunc; }; + void SetMfunc(data_MELODICFUNCTION mfunc_) { m_mfunc = mfunc_; }; + data_MELODICFUNCTION GetMfunc() const { return m_mfunc; }; bool HasMfunc( ); ///@} private: /** Describes melodic function using Humdrum **embel syntax. **/ - std::string m_mfunc; + data_MELODICFUNCTION m_mfunc; /* include */ }; @@ -295,15 +295,15 @@ class AttPitchclass: public Att * to the default value) **/ ///@{ - void SetPclass(std::string pclass_) { m_pclass = pclass_; }; - std::string GetPclass() const { return m_pclass; }; + void SetPclass(data_PITCHCLASS pclass_) { m_pclass = pclass_; }; + data_PITCHCLASS GetPclass() const { return m_pclass; }; bool HasPclass( ); ///@} private: /** Holds pitch class information. **/ - std::string m_pclass; + data_PITCHCLASS m_pclass; /* include */ }; diff --git a/libmei/atts_cmn.cpp b/libmei/atts_cmn.cpp index 0d9f40dccea..8d194ad6116 100644 --- a/libmei/atts_cmn.cpp +++ b/libmei/atts_cmn.cpp @@ -39,23 +39,23 @@ AttArpegLog::~AttArpegLog() { } void AttArpegLog::ResetArpegLog() { - m_order = ""; + m_order = arpegLog_ORDER_NONE; } -bool AttArpegLog::ReadArpegLog( pugi::xml_node element ) { +bool AttArpegLog::ReadArpegLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("order")) { - this->SetOrder(StrToStr(element.attribute("order").value())); + this->SetOrder(StrToArpegLogOrder(element.attribute("order").value())); element.remove_attribute("order"); hasAttribute = true; } return hasAttribute; } -bool AttArpegLog::WriteArpegLog( pugi::xml_node element ) { +bool AttArpegLog::WriteArpegLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasOrder()) { - element.append_attribute("order") = StrToStr(this->GetOrder()).c_str(); + element.append_attribute("order") = ArpegLogOrderToStr(this->GetOrder()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -63,7 +63,7 @@ bool AttArpegLog::WriteArpegLog( pugi::xml_node element ) { bool AttArpegLog::HasOrder( ) { - return (m_order != ""); + return (m_order != arpegLog_ORDER_NONE); } @@ -82,23 +82,23 @@ AttArpegVis::~AttArpegVis() { } void AttArpegVis::ResetArpegVis() { - m_arrow = ""; + m_arrow = BOOLEAN_NONE; } -bool AttArpegVis::ReadArpegVis( pugi::xml_node element ) { +bool AttArpegVis::ReadArpegVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("arrow")) { - this->SetArrow(StrToStr(element.attribute("arrow").value())); + this->SetArrow(StrToBoolean(element.attribute("arrow").value())); element.remove_attribute("arrow"); hasAttribute = true; } return hasAttribute; } -bool AttArpegVis::WriteArpegVis( pugi::xml_node element ) { +bool AttArpegVis::WriteArpegVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasArrow()) { - element.append_attribute("arrow") = StrToStr(this->GetArrow()).c_str(); + element.append_attribute("arrow") = BooleanToStr(this->GetArrow()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -106,7 +106,7 @@ bool AttArpegVis::WriteArpegVis( pugi::xml_node element ) { bool AttArpegVis::HasArrow( ) { - return (m_arrow != ""); + return (m_arrow != BOOLEAN_NONE); } @@ -125,23 +125,23 @@ AttBTremLog::~AttBTremLog() { } void AttBTremLog::ResetBTremLog() { - m_form = BEATRPT_REND_NONE; + m_form = bTremLog_FORM_NONE; } -bool AttBTremLog::ReadBTremLog( pugi::xml_node element ) { +bool AttBTremLog::ReadBTremLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("form")) { - this->SetForm(StrToBeatrptRend(element.attribute("form").value())); + this->SetForm(StrToBTremLogForm(element.attribute("form").value())); element.remove_attribute("form"); hasAttribute = true; } return hasAttribute; } -bool AttBTremLog::WriteBTremLog( pugi::xml_node element ) { +bool AttBTremLog::WriteBTremLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasForm()) { - element.append_attribute("form") = BeatrptRendToStr(this->GetForm()).c_str(); + element.append_attribute("form") = BTremLogFormToStr(this->GetForm()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -149,7 +149,7 @@ bool AttBTremLog::WriteBTremLog( pugi::xml_node element ) { bool AttBTremLog::HasForm( ) { - return (m_form != BEATRPT_REND_NONE); + return (m_form != bTremLog_FORM_NONE); } @@ -171,7 +171,7 @@ void AttBeamed::ResetBeamed() { m_beam = ""; } -bool AttBeamed::ReadBeamed( pugi::xml_node element ) { +bool AttBeamed::ReadBeamed( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("beam")) { this->SetBeam(StrToStr(element.attribute("beam").value())); @@ -181,7 +181,7 @@ bool AttBeamed::ReadBeamed( pugi::xml_node element ) { return hasAttribute; } -bool AttBeamed::WriteBeamed( pugi::xml_node element ) { +bool AttBeamed::WriteBeamed( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasBeam()) { element.append_attribute("beam") = StrToStr(this->GetBeam()).c_str(); @@ -211,23 +211,23 @@ AttBeamedwith::~AttBeamedwith() { } void AttBeamedwith::ResetBeamedwith() { - m_beamWith = ""; + m_beamWith = OTHERSTAFF_NONE; } -bool AttBeamedwith::ReadBeamedwith( pugi::xml_node element ) { +bool AttBeamedwith::ReadBeamedwith( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("beam.with")) { - this->SetBeamWith(StrToStr(element.attribute("beam.with").value())); + this->SetBeamWith(StrToOtherstaff(element.attribute("beam.with").value())); element.remove_attribute("beam.with"); hasAttribute = true; } return hasAttribute; } -bool AttBeamedwith::WriteBeamedwith( pugi::xml_node element ) { +bool AttBeamedwith::WriteBeamedwith( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasBeamWith()) { - element.append_attribute("beam.with") = StrToStr(this->GetBeamWith()).c_str(); + element.append_attribute("beam.with") = OtherstaffToStr(this->GetBeamWith()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -235,7 +235,7 @@ bool AttBeamedwith::WriteBeamedwith( pugi::xml_node element ) { bool AttBeamedwith::HasBeamWith( ) { - return (m_beamWith != ""); + return (m_beamWith != OTHERSTAFF_NONE); } @@ -255,10 +255,10 @@ AttBeamingLog::~AttBeamingLog() { void AttBeamingLog::ResetBeamingLog() { m_beamGroup = ""; - m_beamRests = ""; + m_beamRests = BOOLEAN_NONE; } -bool AttBeamingLog::ReadBeamingLog( pugi::xml_node element ) { +bool AttBeamingLog::ReadBeamingLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("beam.group")) { this->SetBeamGroup(StrToStr(element.attribute("beam.group").value())); @@ -266,21 +266,21 @@ bool AttBeamingLog::ReadBeamingLog( pugi::xml_node element ) { hasAttribute = true; } if (element.attribute("beam.rests")) { - this->SetBeamRests(StrToStr(element.attribute("beam.rests").value())); + this->SetBeamRests(StrToBoolean(element.attribute("beam.rests").value())); element.remove_attribute("beam.rests"); hasAttribute = true; } return hasAttribute; } -bool AttBeamingLog::WriteBeamingLog( pugi::xml_node element ) { +bool AttBeamingLog::WriteBeamingLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasBeamGroup()) { element.append_attribute("beam.group") = StrToStr(this->GetBeamGroup()).c_str(); wroteAttribute = true; } if (this->HasBeamRests()) { - element.append_attribute("beam.rests") = StrToStr(this->GetBeamRests()).c_str(); + element.append_attribute("beam.rests") = BooleanToStr(this->GetBeamRests()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -293,7 +293,7 @@ bool AttBeamingLog::HasBeamGroup( ) bool AttBeamingLog::HasBeamRests( ) { - return (m_beamRests != ""); + return (m_beamRests != BOOLEAN_NONE); } @@ -312,14 +312,14 @@ AttBeamrend::~AttBeamrend() { } void AttBeamrend::ResetBeamrend() { - m_form = BEATRPT_REND_NONE; - m_slopeDbl = 0.0; + m_form = beamrend_FORM_NONE; + m_slope = 0.0; } -bool AttBeamrend::ReadBeamrend( pugi::xml_node element ) { +bool AttBeamrend::ReadBeamrend( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("form")) { - this->SetForm(StrToBeatrptRend(element.attribute("form").value())); + this->SetForm(StrToBeamrendForm(element.attribute("form").value())); element.remove_attribute("form"); hasAttribute = true; } @@ -331,10 +331,10 @@ bool AttBeamrend::ReadBeamrend( pugi::xml_node element ) { return hasAttribute; } -bool AttBeamrend::WriteBeamrend( pugi::xml_node element ) { +bool AttBeamrend::WriteBeamrend( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasForm()) { - element.append_attribute("form") = BeatrptRendToStr(this->GetForm()).c_str(); + element.append_attribute("form") = BeamrendFormToStr(this->GetForm()).c_str(); wroteAttribute = true; } if (this->HasSlope()) { @@ -346,12 +346,12 @@ bool AttBeamrend::WriteBeamrend( pugi::xml_node element ) { bool AttBeamrend::HasForm( ) { - return (m_form != BEATRPT_REND_NONE); + return (m_form != beamrend_FORM_NONE); } bool AttBeamrend::HasSlope( ) { - return (m_slopeDbl != 0.0); + return (m_slope != 0.0); } @@ -370,10 +370,10 @@ AttBeamsecondary::~AttBeamsecondary() { } void AttBeamsecondary::ResetBeamsecondary() { - m_breaksecInt = 0; + m_breaksec = 0; } -bool AttBeamsecondary::ReadBeamsecondary( pugi::xml_node element ) { +bool AttBeamsecondary::ReadBeamsecondary( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("breaksec")) { this->SetBreaksec(StrToInt(element.attribute("breaksec").value())); @@ -383,7 +383,7 @@ bool AttBeamsecondary::ReadBeamsecondary( pugi::xml_node element ) { return hasAttribute; } -bool AttBeamsecondary::WriteBeamsecondary( pugi::xml_node element ) { +bool AttBeamsecondary::WriteBeamsecondary( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasBreaksec()) { element.append_attribute("breaksec") = IntToStr(this->GetBreaksec()).c_str(); @@ -394,7 +394,7 @@ bool AttBeamsecondary::WriteBeamsecondary( pugi::xml_node element ) { bool AttBeamsecondary::HasBreaksec( ) { - return (m_breaksecInt != 0); + return (m_breaksec != 0); } @@ -413,23 +413,23 @@ AttBeatRptLog::~AttBeatRptLog() { } void AttBeatRptLog::ResetBeatRptLog() { - m_beatDef = ""; + m_beatDef = DURATION_NONE; } -bool AttBeatRptLog::ReadBeatRptLog( pugi::xml_node element ) { +bool AttBeatRptLog::ReadBeatRptLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("beatDef")) { - this->SetBeatDef(StrToStr(element.attribute("beatDef").value())); + this->SetBeatDef(StrToDuration(element.attribute("beatDef").value())); element.remove_attribute("beatDef"); hasAttribute = true; } return hasAttribute; } -bool AttBeatRptLog::WriteBeatRptLog( pugi::xml_node element ) { +bool AttBeatRptLog::WriteBeatRptLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasBeatDef()) { - element.append_attribute("beatDef") = StrToStr(this->GetBeatDef()).c_str(); + element.append_attribute("beatDef") = DurationToStr(this->GetBeatDef()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -437,7 +437,7 @@ bool AttBeatRptLog::WriteBeatRptLog( pugi::xml_node element ) { bool AttBeatRptLog::HasBeatDef( ) { - return (m_beatDef != ""); + return (m_beatDef != DURATION_NONE); } @@ -459,7 +459,7 @@ void AttBeatRptVis::ResetBeatRptVis() { m_form = BEATRPT_REND_NONE; } -bool AttBeatRptVis::ReadBeatRptVis( pugi::xml_node element ) { +bool AttBeatRptVis::ReadBeatRptVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("form")) { this->SetForm(StrToBeatrptRend(element.attribute("form").value())); @@ -469,7 +469,7 @@ bool AttBeatRptVis::ReadBeatRptVis( pugi::xml_node element ) { return hasAttribute; } -bool AttBeatRptVis::WriteBeatRptVis( pugi::xml_node element ) { +bool AttBeatRptVis::WriteBeatRptVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasForm()) { element.append_attribute("form") = BeatrptRendToStr(this->GetForm()).c_str(); @@ -502,7 +502,7 @@ void AttBendGes::ResetBendGes() { m_amount = ""; } -bool AttBendGes::ReadBendGes( pugi::xml_node element ) { +bool AttBendGes::ReadBendGes( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("amount")) { this->SetAmount(StrToStr(element.attribute("amount").value())); @@ -512,7 +512,7 @@ bool AttBendGes::ReadBendGes( pugi::xml_node element ) { return hasAttribute; } -bool AttBendGes::WriteBendGes( pugi::xml_node element ) { +bool AttBendGes::WriteBendGes( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasAmount()) { element.append_attribute("amount") = StrToStr(this->GetAmount()).c_str(); @@ -542,23 +542,23 @@ AttCutout::~AttCutout() { } void AttCutout::ResetCutout() { - m_cutout = ""; + m_cutout = cutout_CUTOUT_NONE; } -bool AttCutout::ReadCutout( pugi::xml_node element ) { +bool AttCutout::ReadCutout( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("cutout")) { - this->SetCutout(StrToStr(element.attribute("cutout").value())); + this->SetCutout(StrToCutoutCutout(element.attribute("cutout").value())); element.remove_attribute("cutout"); hasAttribute = true; } return hasAttribute; } -bool AttCutout::WriteCutout( pugi::xml_node element ) { +bool AttCutout::WriteCutout( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasCutout()) { - element.append_attribute("cutout") = StrToStr(this->GetCutout()).c_str(); + element.append_attribute("cutout") = CutoutCutoutToStr(this->GetCutout()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -566,7 +566,7 @@ bool AttCutout::WriteCutout( pugi::xml_node element ) { bool AttCutout::HasCutout( ) { - return (m_cutout != ""); + return (m_cutout != cutout_CUTOUT_NONE); } @@ -585,23 +585,23 @@ AttExpandable::~AttExpandable() { } void AttExpandable::ResetExpandable() { - m_expand = ""; + m_expand = BOOLEAN_NONE; } -bool AttExpandable::ReadExpandable( pugi::xml_node element ) { +bool AttExpandable::ReadExpandable( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("expand")) { - this->SetExpand(StrToStr(element.attribute("expand").value())); + this->SetExpand(StrToBoolean(element.attribute("expand").value())); element.remove_attribute("expand"); hasAttribute = true; } return hasAttribute; } -bool AttExpandable::WriteExpandable( pugi::xml_node element ) { +bool AttExpandable::WriteExpandable( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasExpand()) { - element.append_attribute("expand") = StrToStr(this->GetExpand()).c_str(); + element.append_attribute("expand") = BooleanToStr(this->GetExpand()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -609,7 +609,7 @@ bool AttExpandable::WriteExpandable( pugi::xml_node element ) { bool AttExpandable::HasExpand( ) { - return (m_expand != ""); + return (m_expand != BOOLEAN_NONE); } @@ -628,23 +628,23 @@ AttFTremLog::~AttFTremLog() { } void AttFTremLog::ResetFTremLog() { - m_form = BEATRPT_REND_NONE; + m_form = fTremLog_FORM_NONE; } -bool AttFTremLog::ReadFTremLog( pugi::xml_node element ) { +bool AttFTremLog::ReadFTremLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("form")) { - this->SetForm(StrToBeatrptRend(element.attribute("form").value())); + this->SetForm(StrToFTremLogForm(element.attribute("form").value())); element.remove_attribute("form"); hasAttribute = true; } return hasAttribute; } -bool AttFTremLog::WriteFTremLog( pugi::xml_node element ) { +bool AttFTremLog::WriteFTremLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasForm()) { - element.append_attribute("form") = BeatrptRendToStr(this->GetForm()).c_str(); + element.append_attribute("form") = FTremLogFormToStr(this->GetForm()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -652,7 +652,7 @@ bool AttFTremLog::WriteFTremLog( pugi::xml_node element ) { bool AttFTremLog::HasForm( ) { - return (m_form != BEATRPT_REND_NONE); + return (m_form != fTremLog_FORM_NONE); } @@ -671,33 +671,33 @@ AttFermataVis::~AttFermataVis() { } void AttFermataVis::ResetFermataVis() { - m_form = BEATRPT_REND_NONE; - m_shape = ""; + m_form = fermataVis_FORM_NONE; + m_shape = fermataVis_SHAPE_NONE; } -bool AttFermataVis::ReadFermataVis( pugi::xml_node element ) { +bool AttFermataVis::ReadFermataVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("form")) { - this->SetForm(StrToBeatrptRend(element.attribute("form").value())); + this->SetForm(StrToFermataVisForm(element.attribute("form").value())); element.remove_attribute("form"); hasAttribute = true; } if (element.attribute("shape")) { - this->SetShape(StrToStr(element.attribute("shape").value())); + this->SetShape(StrToFermataVisShape(element.attribute("shape").value())); element.remove_attribute("shape"); hasAttribute = true; } return hasAttribute; } -bool AttFermataVis::WriteFermataVis( pugi::xml_node element ) { +bool AttFermataVis::WriteFermataVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasForm()) { - element.append_attribute("form") = BeatrptRendToStr(this->GetForm()).c_str(); + element.append_attribute("form") = FermataVisFormToStr(this->GetForm()).c_str(); wroteAttribute = true; } if (this->HasShape()) { - element.append_attribute("shape") = StrToStr(this->GetShape()).c_str(); + element.append_attribute("shape") = FermataVisShapeToStr(this->GetShape()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -705,12 +705,12 @@ bool AttFermataVis::WriteFermataVis( pugi::xml_node element ) { bool AttFermataVis::HasForm( ) { - return (m_form != BEATRPT_REND_NONE); + return (m_form != fermataVis_FORM_NONE); } bool AttFermataVis::HasShape( ) { - return (m_shape != ""); + return (m_shape != fermataVis_SHAPE_NONE); } @@ -730,10 +730,10 @@ AttGraced::~AttGraced() { void AttGraced::ResetGraced() { m_grace = GRACE_NONE; - m_graceTime = ""; + m_graceTime = 0; } -bool AttGraced::ReadGraced( pugi::xml_node element ) { +bool AttGraced::ReadGraced( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("grace")) { this->SetGrace(StrToGrace(element.attribute("grace").value())); @@ -741,21 +741,21 @@ bool AttGraced::ReadGraced( pugi::xml_node element ) { hasAttribute = true; } if (element.attribute("grace.time")) { - this->SetGraceTime(StrToStr(element.attribute("grace.time").value())); + this->SetGraceTime(StrToInt(element.attribute("grace.time").value())); element.remove_attribute("grace.time"); hasAttribute = true; } return hasAttribute; } -bool AttGraced::WriteGraced( pugi::xml_node element ) { +bool AttGraced::WriteGraced( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasGrace()) { element.append_attribute("grace") = GraceToStr(this->GetGrace()).c_str(); wroteAttribute = true; } if (this->HasGraceTime()) { - element.append_attribute("grace.time") = StrToStr(this->GetGraceTime()).c_str(); + element.append_attribute("grace.time") = IntToStr(this->GetGraceTime()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -768,7 +768,7 @@ bool AttGraced::HasGrace( ) bool AttGraced::HasGraceTime( ) { - return (m_graceTime != ""); + return (m_graceTime != 0); } @@ -787,33 +787,33 @@ AttHairpinLog::~AttHairpinLog() { } void AttHairpinLog::ResetHairpinLog() { - m_form = BEATRPT_REND_NONE; - m_niente = ""; + m_form = hairpinLog_FORM_NONE; + m_niente = BOOLEAN_NONE; } -bool AttHairpinLog::ReadHairpinLog( pugi::xml_node element ) { +bool AttHairpinLog::ReadHairpinLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("form")) { - this->SetForm(StrToBeatrptRend(element.attribute("form").value())); + this->SetForm(StrToHairpinLogForm(element.attribute("form").value())); element.remove_attribute("form"); hasAttribute = true; } if (element.attribute("niente")) { - this->SetNiente(StrToStr(element.attribute("niente").value())); + this->SetNiente(StrToBoolean(element.attribute("niente").value())); element.remove_attribute("niente"); hasAttribute = true; } return hasAttribute; } -bool AttHairpinLog::WriteHairpinLog( pugi::xml_node element ) { +bool AttHairpinLog::WriteHairpinLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasForm()) { - element.append_attribute("form") = BeatrptRendToStr(this->GetForm()).c_str(); + element.append_attribute("form") = HairpinLogFormToStr(this->GetForm()).c_str(); wroteAttribute = true; } if (this->HasNiente()) { - element.append_attribute("niente") = StrToStr(this->GetNiente()).c_str(); + element.append_attribute("niente") = BooleanToStr(this->GetNiente()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -821,12 +821,12 @@ bool AttHairpinLog::WriteHairpinLog( pugi::xml_node element ) { bool AttHairpinLog::HasForm( ) { - return (m_form != BEATRPT_REND_NONE); + return (m_form != hairpinLog_FORM_NONE); } bool AttHairpinLog::HasNiente( ) { - return (m_niente != ""); + return (m_niente != BOOLEAN_NONE); } @@ -848,7 +848,7 @@ void AttHairpinVis::ResetHairpinVis() { m_opening = ""; } -bool AttHairpinVis::ReadHairpinVis( pugi::xml_node element ) { +bool AttHairpinVis::ReadHairpinVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("opening")) { this->SetOpening(StrToStr(element.attribute("opening").value())); @@ -858,7 +858,7 @@ bool AttHairpinVis::ReadHairpinVis( pugi::xml_node element ) { return hasAttribute; } -bool AttHairpinVis::WriteHairpinVis( pugi::xml_node element ) { +bool AttHairpinVis::WriteHairpinVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasOpening()) { element.append_attribute("opening") = StrToStr(this->GetOpening()).c_str(); @@ -888,83 +888,83 @@ AttHarpPedalLog::~AttHarpPedalLog() { } void AttHarpPedalLog::ResetHarpPedalLog() { - m_c = ""; - m_d = ""; - m_e = ""; - m_f = ""; - m_g = ""; - m_a = ""; - m_b = ""; + m_c = harpPedalLog_C_NONE; + m_d = harpPedalLog_D_NONE; + m_e = harpPedalLog_E_NONE; + m_f = harpPedalLog_F_NONE; + m_g = harpPedalLog_G_NONE; + m_a = harpPedalLog_A_NONE; + m_b = harpPedalLog_B_NONE; } -bool AttHarpPedalLog::ReadHarpPedalLog( pugi::xml_node element ) { +bool AttHarpPedalLog::ReadHarpPedalLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("c")) { - this->SetC(StrToStr(element.attribute("c").value())); + this->SetC(StrToHarpPedalLogC(element.attribute("c").value())); element.remove_attribute("c"); hasAttribute = true; } if (element.attribute("d")) { - this->SetD(StrToStr(element.attribute("d").value())); + this->SetD(StrToHarpPedalLogD(element.attribute("d").value())); element.remove_attribute("d"); hasAttribute = true; } if (element.attribute("e")) { - this->SetE(StrToStr(element.attribute("e").value())); + this->SetE(StrToHarpPedalLogE(element.attribute("e").value())); element.remove_attribute("e"); hasAttribute = true; } if (element.attribute("f")) { - this->SetF(StrToStr(element.attribute("f").value())); + this->SetF(StrToHarpPedalLogF(element.attribute("f").value())); element.remove_attribute("f"); hasAttribute = true; } if (element.attribute("g")) { - this->SetG(StrToStr(element.attribute("g").value())); + this->SetG(StrToHarpPedalLogG(element.attribute("g").value())); element.remove_attribute("g"); hasAttribute = true; } if (element.attribute("a")) { - this->SetA(StrToStr(element.attribute("a").value())); + this->SetA(StrToHarpPedalLogA(element.attribute("a").value())); element.remove_attribute("a"); hasAttribute = true; } if (element.attribute("b")) { - this->SetB(StrToStr(element.attribute("b").value())); + this->SetB(StrToHarpPedalLogB(element.attribute("b").value())); element.remove_attribute("b"); hasAttribute = true; } return hasAttribute; } -bool AttHarpPedalLog::WriteHarpPedalLog( pugi::xml_node element ) { +bool AttHarpPedalLog::WriteHarpPedalLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasC()) { - element.append_attribute("c") = StrToStr(this->GetC()).c_str(); + element.append_attribute("c") = HarpPedalLogCToStr(this->GetC()).c_str(); wroteAttribute = true; } if (this->HasD()) { - element.append_attribute("d") = StrToStr(this->GetD()).c_str(); + element.append_attribute("d") = HarpPedalLogDToStr(this->GetD()).c_str(); wroteAttribute = true; } if (this->HasE()) { - element.append_attribute("e") = StrToStr(this->GetE()).c_str(); + element.append_attribute("e") = HarpPedalLogEToStr(this->GetE()).c_str(); wroteAttribute = true; } if (this->HasF()) { - element.append_attribute("f") = StrToStr(this->GetF()).c_str(); + element.append_attribute("f") = HarpPedalLogFToStr(this->GetF()).c_str(); wroteAttribute = true; } if (this->HasG()) { - element.append_attribute("g") = StrToStr(this->GetG()).c_str(); + element.append_attribute("g") = HarpPedalLogGToStr(this->GetG()).c_str(); wroteAttribute = true; } if (this->HasA()) { - element.append_attribute("a") = StrToStr(this->GetA()).c_str(); + element.append_attribute("a") = HarpPedalLogAToStr(this->GetA()).c_str(); wroteAttribute = true; } if (this->HasB()) { - element.append_attribute("b") = StrToStr(this->GetB()).c_str(); + element.append_attribute("b") = HarpPedalLogBToStr(this->GetB()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -972,37 +972,37 @@ bool AttHarpPedalLog::WriteHarpPedalLog( pugi::xml_node element ) { bool AttHarpPedalLog::HasC( ) { - return (m_c != ""); + return (m_c != harpPedalLog_C_NONE); } bool AttHarpPedalLog::HasD( ) { - return (m_d != ""); + return (m_d != harpPedalLog_D_NONE); } bool AttHarpPedalLog::HasE( ) { - return (m_e != ""); + return (m_e != harpPedalLog_E_NONE); } bool AttHarpPedalLog::HasF( ) { - return (m_f != ""); + return (m_f != harpPedalLog_F_NONE); } bool AttHarpPedalLog::HasG( ) { - return (m_g != ""); + return (m_g != harpPedalLog_G_NONE); } bool AttHarpPedalLog::HasA( ) { - return (m_a != ""); + return (m_a != harpPedalLog_A_NONE); } bool AttHarpPedalLog::HasB( ) { - return (m_b != ""); + return (m_b != harpPedalLog_B_NONE); } @@ -1021,23 +1021,23 @@ AttLvpresent::~AttLvpresent() { } void AttLvpresent::ResetLvpresent() { - m_lv = ""; + m_lv = BOOLEAN_NONE; } -bool AttLvpresent::ReadLvpresent( pugi::xml_node element ) { +bool AttLvpresent::ReadLvpresent( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("lv")) { - this->SetLv(StrToStr(element.attribute("lv").value())); + this->SetLv(StrToBoolean(element.attribute("lv").value())); element.remove_attribute("lv"); hasAttribute = true; } return hasAttribute; } -bool AttLvpresent::WriteLvpresent( pugi::xml_node element ) { +bool AttLvpresent::WriteLvpresent( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasLv()) { - element.append_attribute("lv") = StrToStr(this->GetLv()).c_str(); + element.append_attribute("lv") = BooleanToStr(this->GetLv()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -1045,7 +1045,7 @@ bool AttLvpresent::WriteLvpresent( pugi::xml_node element ) { bool AttLvpresent::HasLv( ) { - return (m_lv != ""); + return (m_lv != BOOLEAN_NONE); } @@ -1064,23 +1064,23 @@ AttMultiRestVis::~AttMultiRestVis() { } void AttMultiRestVis::ResetMultiRestVis() { - m_block = ""; + m_block = BOOLEAN_NONE; } -bool AttMultiRestVis::ReadMultiRestVis( pugi::xml_node element ) { +bool AttMultiRestVis::ReadMultiRestVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("block")) { - this->SetBlock(StrToStr(element.attribute("block").value())); + this->SetBlock(StrToBoolean(element.attribute("block").value())); element.remove_attribute("block"); hasAttribute = true; } return hasAttribute; } -bool AttMultiRestVis::WriteMultiRestVis( pugi::xml_node element ) { +bool AttMultiRestVis::WriteMultiRestVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasBlock()) { - element.append_attribute("block") = StrToStr(this->GetBlock()).c_str(); + element.append_attribute("block") = BooleanToStr(this->GetBlock()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -1088,7 +1088,7 @@ bool AttMultiRestVis::WriteMultiRestVis( pugi::xml_node element ) { bool AttMultiRestVis::HasBlock( ) { - return (m_block != ""); + return (m_block != BOOLEAN_NONE); } @@ -1107,23 +1107,23 @@ AttNoteGesCmn::~AttNoteGesCmn() { } void AttNoteGesCmn::ResetNoteGesCmn() { - m_gliss = ""; + m_gliss = GLISSANDO_NONE; } -bool AttNoteGesCmn::ReadNoteGesCmn( pugi::xml_node element ) { +bool AttNoteGesCmn::ReadNoteGesCmn( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("gliss")) { - this->SetGliss(StrToStr(element.attribute("gliss").value())); + this->SetGliss(StrToGlissando(element.attribute("gliss").value())); element.remove_attribute("gliss"); hasAttribute = true; } return hasAttribute; } -bool AttNoteGesCmn::WriteNoteGesCmn( pugi::xml_node element ) { +bool AttNoteGesCmn::WriteNoteGesCmn( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasGliss()) { - element.append_attribute("gliss") = StrToStr(this->GetGliss()).c_str(); + element.append_attribute("gliss") = GlissandoToStr(this->GetGliss()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -1131,7 +1131,7 @@ bool AttNoteGesCmn::WriteNoteGesCmn( pugi::xml_node element ) { bool AttNoteGesCmn::HasGliss( ) { - return (m_gliss != ""); + return (m_gliss != GLISSANDO_NONE); } @@ -1150,10 +1150,10 @@ AttNumbered::~AttNumbered() { } void AttNumbered::ResetNumbered() { - m_numInt = 0; + m_num = 0; } -bool AttNumbered::ReadNumbered( pugi::xml_node element ) { +bool AttNumbered::ReadNumbered( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("num")) { this->SetNum(StrToInt(element.attribute("num").value())); @@ -1163,7 +1163,7 @@ bool AttNumbered::ReadNumbered( pugi::xml_node element ) { return hasAttribute; } -bool AttNumbered::WriteNumbered( pugi::xml_node element ) { +bool AttNumbered::WriteNumbered( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasNum()) { element.append_attribute("num") = IntToStr(this->GetNum()).c_str(); @@ -1174,7 +1174,7 @@ bool AttNumbered::WriteNumbered( pugi::xml_node element ) { bool AttNumbered::HasNum( ) { - return (m_numInt != 0); + return (m_num != 0); } @@ -1197,7 +1197,7 @@ void AttNumberplacement::ResetNumberplacement() { m_numVisible = BOOLEAN_NONE; } -bool AttNumberplacement::ReadNumberplacement( pugi::xml_node element ) { +bool AttNumberplacement::ReadNumberplacement( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("num.place")) { this->SetNumPlace(StrToPlace(element.attribute("num.place").value())); @@ -1205,21 +1205,21 @@ bool AttNumberplacement::ReadNumberplacement( pugi::xml_node element ) { hasAttribute = true; } if (element.attribute("num.visible")) { - this->SetNumVisible(StrToBool(element.attribute("num.visible").value())); + this->SetNumVisible(StrToBoolean(element.attribute("num.visible").value())); element.remove_attribute("num.visible"); hasAttribute = true; } return hasAttribute; } -bool AttNumberplacement::WriteNumberplacement( pugi::xml_node element ) { +bool AttNumberplacement::WriteNumberplacement( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasNumPlace()) { element.append_attribute("num.place") = PlaceToStr(this->GetNumPlace()).c_str(); wroteAttribute = true; } if (this->HasNumVisible()) { - element.append_attribute("num.visible") = BoolToStr(this->GetNumVisible()).c_str(); + element.append_attribute("num.visible") = BooleanToStr(this->GetNumVisible()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -1251,23 +1251,23 @@ AttOctaveLog::~AttOctaveLog() { } void AttOctaveLog::ResetOctaveLog() { - m_coll = ""; + m_coll = octaveLog_COLL_NONE; } -bool AttOctaveLog::ReadOctaveLog( pugi::xml_node element ) { +bool AttOctaveLog::ReadOctaveLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("coll")) { - this->SetColl(StrToStr(element.attribute("coll").value())); + this->SetColl(StrToOctaveLogColl(element.attribute("coll").value())); element.remove_attribute("coll"); hasAttribute = true; } return hasAttribute; } -bool AttOctaveLog::WriteOctaveLog( pugi::xml_node element ) { +bool AttOctaveLog::WriteOctaveLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasColl()) { - element.append_attribute("coll") = StrToStr(this->GetColl()).c_str(); + element.append_attribute("coll") = OctaveLogCollToStr(this->GetColl()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -1275,7 +1275,7 @@ bool AttOctaveLog::WriteOctaveLog( pugi::xml_node element ) { bool AttOctaveLog::HasColl( ) { - return (m_coll != ""); + return (m_coll != octaveLog_COLL_NONE); } @@ -1294,23 +1294,23 @@ AttPedalLog::~AttPedalLog() { } void AttPedalLog::ResetPedalLog() { - m_dir = ""; + m_dir = pedalLog_DIR_NONE; } -bool AttPedalLog::ReadPedalLog( pugi::xml_node element ) { +bool AttPedalLog::ReadPedalLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("dir")) { - this->SetDir(StrToStr(element.attribute("dir").value())); + this->SetDir(StrToPedalLogDir(element.attribute("dir").value())); element.remove_attribute("dir"); hasAttribute = true; } return hasAttribute; } -bool AttPedalLog::WritePedalLog( pugi::xml_node element ) { +bool AttPedalLog::WritePedalLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasDir()) { - element.append_attribute("dir") = StrToStr(this->GetDir()).c_str(); + element.append_attribute("dir") = PedalLogDirToStr(this->GetDir()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -1318,7 +1318,7 @@ bool AttPedalLog::WritePedalLog( pugi::xml_node element ) { bool AttPedalLog::HasDir( ) { - return (m_dir != ""); + return (m_dir != pedalLog_DIR_NONE); } @@ -1337,23 +1337,23 @@ AttPedalVis::~AttPedalVis() { } void AttPedalVis::ResetPedalVis() { - m_form = BEATRPT_REND_NONE; + m_form = pedalVis_FORM_NONE; } -bool AttPedalVis::ReadPedalVis( pugi::xml_node element ) { +bool AttPedalVis::ReadPedalVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("form")) { - this->SetForm(StrToBeatrptRend(element.attribute("form").value())); + this->SetForm(StrToPedalVisForm(element.attribute("form").value())); element.remove_attribute("form"); hasAttribute = true; } return hasAttribute; } -bool AttPedalVis::WritePedalVis( pugi::xml_node element ) { +bool AttPedalVis::WritePedalVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasForm()) { - element.append_attribute("form") = BeatrptRendToStr(this->GetForm()).c_str(); + element.append_attribute("form") = PedalVisFormToStr(this->GetForm()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -1361,7 +1361,7 @@ bool AttPedalVis::WritePedalVis( pugi::xml_node element ) { bool AttPedalVis::HasForm( ) { - return (m_form != BEATRPT_REND_NONE); + return (m_form != pedalVis_FORM_NONE); } @@ -1380,23 +1380,23 @@ AttPianopedals::~AttPianopedals() { } void AttPianopedals::ResetPianopedals() { - m_pedalStyle = ""; + m_pedalStyle = pianopedals_PEDALSTYLE_NONE; } -bool AttPianopedals::ReadPianopedals( pugi::xml_node element ) { +bool AttPianopedals::ReadPianopedals( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("pedal.style")) { - this->SetPedalStyle(StrToStr(element.attribute("pedal.style").value())); + this->SetPedalStyle(StrToPianopedalsPedalstyle(element.attribute("pedal.style").value())); element.remove_attribute("pedal.style"); hasAttribute = true; } return hasAttribute; } -bool AttPianopedals::WritePianopedals( pugi::xml_node element ) { +bool AttPianopedals::WritePianopedals( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasPedalStyle()) { - element.append_attribute("pedal.style") = StrToStr(this->GetPedalStyle()).c_str(); + element.append_attribute("pedal.style") = PianopedalsPedalstyleToStr(this->GetPedalStyle()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -1404,7 +1404,7 @@ bool AttPianopedals::WritePianopedals( pugi::xml_node element ) { bool AttPianopedals::HasPedalStyle( ) { - return (m_pedalStyle != ""); + return (m_pedalStyle != pianopedals_PEDALSTYLE_NONE); } @@ -1423,23 +1423,23 @@ AttRehearsal::~AttRehearsal() { } void AttRehearsal::ResetRehearsal() { - m_rehEnclose = ""; + m_rehEnclose = rehearsal_REHENCLOSE_NONE; } -bool AttRehearsal::ReadRehearsal( pugi::xml_node element ) { +bool AttRehearsal::ReadRehearsal( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("reh.enclose")) { - this->SetRehEnclose(StrToStr(element.attribute("reh.enclose").value())); + this->SetRehEnclose(StrToRehearsalRehenclose(element.attribute("reh.enclose").value())); element.remove_attribute("reh.enclose"); hasAttribute = true; } return hasAttribute; } -bool AttRehearsal::WriteRehearsal( pugi::xml_node element ) { +bool AttRehearsal::WriteRehearsal( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasRehEnclose()) { - element.append_attribute("reh.enclose") = StrToStr(this->GetRehEnclose()).c_str(); + element.append_attribute("reh.enclose") = RehearsalRehencloseToStr(this->GetRehEnclose()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -1447,7 +1447,7 @@ bool AttRehearsal::WriteRehearsal( pugi::xml_node element ) { bool AttRehearsal::HasRehEnclose( ) { - return (m_rehEnclose != ""); + return (m_rehEnclose != rehearsal_REHENCLOSE_NONE); } @@ -1466,23 +1466,23 @@ AttScoreDefVisCmn::~AttScoreDefVisCmn() { } void AttScoreDefVisCmn::ResetScoreDefVisCmn() { - m_gridShow = ""; + m_gridShow = BOOLEAN_NONE; } -bool AttScoreDefVisCmn::ReadScoreDefVisCmn( pugi::xml_node element ) { +bool AttScoreDefVisCmn::ReadScoreDefVisCmn( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("grid.show")) { - this->SetGridShow(StrToStr(element.attribute("grid.show").value())); + this->SetGridShow(StrToBoolean(element.attribute("grid.show").value())); element.remove_attribute("grid.show"); hasAttribute = true; } return hasAttribute; } -bool AttScoreDefVisCmn::WriteScoreDefVisCmn( pugi::xml_node element ) { +bool AttScoreDefVisCmn::WriteScoreDefVisCmn( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasGridShow()) { - element.append_attribute("grid.show") = StrToStr(this->GetGridShow()).c_str(); + element.append_attribute("grid.show") = BooleanToStr(this->GetGridShow()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -1490,7 +1490,7 @@ bool AttScoreDefVisCmn::WriteScoreDefVisCmn( pugi::xml_node element ) { bool AttScoreDefVisCmn::HasGridShow( ) { - return (m_gridShow != ""); + return (m_gridShow != BOOLEAN_NONE); } @@ -1509,23 +1509,23 @@ AttSlurrend::~AttSlurrend() { } void AttSlurrend::ResetSlurrend() { - m_slurRend = ""; + m_slurRend = CURVERENDITION_NONE; } -bool AttSlurrend::ReadSlurrend( pugi::xml_node element ) { +bool AttSlurrend::ReadSlurrend( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("slur.rend")) { - this->SetSlurRend(StrToStr(element.attribute("slur.rend").value())); + this->SetSlurRend(StrToCurverendition(element.attribute("slur.rend").value())); element.remove_attribute("slur.rend"); hasAttribute = true; } return hasAttribute; } -bool AttSlurrend::WriteSlurrend( pugi::xml_node element ) { +bool AttSlurrend::WriteSlurrend( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasSlurRend()) { - element.append_attribute("slur.rend") = StrToStr(this->GetSlurRend()).c_str(); + element.append_attribute("slur.rend") = CurverenditionToStr(this->GetSlurRend()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -1533,7 +1533,7 @@ bool AttSlurrend::WriteSlurrend( pugi::xml_node element ) { bool AttSlurrend::HasSlurRend( ) { - return (m_slurRend != ""); + return (m_slurRend != CURVERENDITION_NONE); } @@ -1552,23 +1552,23 @@ AttStemsCmn::~AttStemsCmn() { } void AttStemsCmn::ResetStemsCmn() { - m_stemWith = ""; + m_stemWith = OTHERSTAFF_NONE; } -bool AttStemsCmn::ReadStemsCmn( pugi::xml_node element ) { +bool AttStemsCmn::ReadStemsCmn( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("stem.with")) { - this->SetStemWith(StrToStr(element.attribute("stem.with").value())); + this->SetStemWith(StrToOtherstaff(element.attribute("stem.with").value())); element.remove_attribute("stem.with"); hasAttribute = true; } return hasAttribute; } -bool AttStemsCmn::WriteStemsCmn( pugi::xml_node element ) { +bool AttStemsCmn::WriteStemsCmn( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasStemWith()) { - element.append_attribute("stem.with") = StrToStr(this->GetStemWith()).c_str(); + element.append_attribute("stem.with") = OtherstaffToStr(this->GetStemWith()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -1576,7 +1576,7 @@ bool AttStemsCmn::WriteStemsCmn( pugi::xml_node element ) { bool AttStemsCmn::HasStemWith( ) { - return (m_stemWith != ""); + return (m_stemWith != OTHERSTAFF_NONE); } @@ -1595,23 +1595,23 @@ AttTierend::~AttTierend() { } void AttTierend::ResetTierend() { - m_tieRend = ""; + m_tieRend = CURVERENDITION_NONE; } -bool AttTierend::ReadTierend( pugi::xml_node element ) { +bool AttTierend::ReadTierend( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("tie.rend")) { - this->SetTieRend(StrToStr(element.attribute("tie.rend").value())); + this->SetTieRend(StrToCurverendition(element.attribute("tie.rend").value())); element.remove_attribute("tie.rend"); hasAttribute = true; } return hasAttribute; } -bool AttTierend::WriteTierend( pugi::xml_node element ) { +bool AttTierend::WriteTierend( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasTieRend()) { - element.append_attribute("tie.rend") = StrToStr(this->GetTieRend()).c_str(); + element.append_attribute("tie.rend") = CurverenditionToStr(this->GetTieRend()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -1619,7 +1619,7 @@ bool AttTierend::WriteTierend( pugi::xml_node element ) { bool AttTierend::HasTieRend( ) { - return (m_tieRend != ""); + return (m_tieRend != CURVERENDITION_NONE); } @@ -1638,23 +1638,23 @@ AttTremmeasured::~AttTremmeasured() { } void AttTremmeasured::ResetTremmeasured() { - m_measperf = ""; + m_measperf = DURATION_NONE; } -bool AttTremmeasured::ReadTremmeasured( pugi::xml_node element ) { +bool AttTremmeasured::ReadTremmeasured( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("measperf")) { - this->SetMeasperf(StrToStr(element.attribute("measperf").value())); + this->SetMeasperf(StrToDuration(element.attribute("measperf").value())); element.remove_attribute("measperf"); hasAttribute = true; } return hasAttribute; } -bool AttTremmeasured::WriteTremmeasured( pugi::xml_node element ) { +bool AttTremmeasured::WriteTremmeasured( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasMeasperf()) { - element.append_attribute("measperf") = StrToStr(this->GetMeasperf()).c_str(); + element.append_attribute("measperf") = DurationToStr(this->GetMeasperf()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -1662,7 +1662,7 @@ bool AttTremmeasured::WriteTremmeasured( pugi::xml_node element ) { bool AttTremmeasured::HasMeasperf( ) { - return (m_measperf != ""); + return (m_measperf != DURATION_NONE); } @@ -1684,10 +1684,10 @@ void AttTupletVis::ResetTupletVis() { m_bracketPlace = PLACE_NONE; m_bracketVisible = BOOLEAN_NONE; m_durVisible = BOOLEAN_NONE; - m_numFormat = NUMFORMAT_NONE; + m_numFormat = tupletVis_NUMFORMAT_NONE; } -bool AttTupletVis::ReadTupletVis( pugi::xml_node element ) { +bool AttTupletVis::ReadTupletVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("bracket.place")) { this->SetBracketPlace(StrToPlace(element.attribute("bracket.place").value())); @@ -1695,39 +1695,39 @@ bool AttTupletVis::ReadTupletVis( pugi::xml_node element ) { hasAttribute = true; } if (element.attribute("bracket.visible")) { - this->SetBracketVisible(StrToBool(element.attribute("bracket.visible").value())); + this->SetBracketVisible(StrToBoolean(element.attribute("bracket.visible").value())); element.remove_attribute("bracket.visible"); hasAttribute = true; } if (element.attribute("dur.visible")) { - this->SetDurVisible(StrToBool(element.attribute("dur.visible").value())); + this->SetDurVisible(StrToBoolean(element.attribute("dur.visible").value())); element.remove_attribute("dur.visible"); hasAttribute = true; } if (element.attribute("num.format")) { - this->SetNumFormat(StrToNumformat(element.attribute("num.format").value())); + this->SetNumFormat(StrToTupletVisNumformat(element.attribute("num.format").value())); element.remove_attribute("num.format"); hasAttribute = true; } return hasAttribute; } -bool AttTupletVis::WriteTupletVis( pugi::xml_node element ) { +bool AttTupletVis::WriteTupletVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasBracketPlace()) { element.append_attribute("bracket.place") = PlaceToStr(this->GetBracketPlace()).c_str(); wroteAttribute = true; } if (this->HasBracketVisible()) { - element.append_attribute("bracket.visible") = BoolToStr(this->GetBracketVisible()).c_str(); + element.append_attribute("bracket.visible") = BooleanToStr(this->GetBracketVisible()).c_str(); wroteAttribute = true; } if (this->HasDurVisible()) { - element.append_attribute("dur.visible") = BoolToStr(this->GetDurVisible()).c_str(); + element.append_attribute("dur.visible") = BooleanToStr(this->GetDurVisible()).c_str(); wroteAttribute = true; } if (this->HasNumFormat()) { - element.append_attribute("num.format") = NumformatToStr(this->GetNumFormat()).c_str(); + element.append_attribute("num.format") = TupletVisNumformatToStr(this->GetNumFormat()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -1750,7 +1750,7 @@ bool AttTupletVis::HasDurVisible( ) bool AttTupletVis::HasNumFormat( ) { - return (m_numFormat != NUMFORMAT_NONE); + return (m_numFormat != tupletVis_NUMFORMAT_NONE); } @@ -1761,7 +1761,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttArpegLog *att = dynamic_cast(element); assert( att ); if (attrType == "order") { - att->SetOrder(att->StrToStr(attrValue)); + att->SetOrder(att->StrToArpegLogOrder(attrValue)); return true; } } @@ -1769,7 +1769,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttArpegVis *att = dynamic_cast(element); assert( att ); if (attrType == "arrow") { - att->SetArrow(att->StrToStr(attrValue)); + att->SetArrow(att->StrToBoolean(attrValue)); return true; } } @@ -1777,7 +1777,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttBTremLog *att = dynamic_cast(element); assert( att ); if (attrType == "form") { - att->SetForm(att->StrToBeatrptRend(attrValue)); + att->SetForm(att->StrToBTremLogForm(attrValue)); return true; } } @@ -1793,7 +1793,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttBeamedwith *att = dynamic_cast(element); assert( att ); if (attrType == "beamWith") { - att->SetBeamWith(att->StrToStr(attrValue)); + att->SetBeamWith(att->StrToOtherstaff(attrValue)); return true; } } @@ -1805,7 +1805,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) return true; } if (attrType == "beamRests") { - att->SetBeamRests(att->StrToStr(attrValue)); + att->SetBeamRests(att->StrToBoolean(attrValue)); return true; } } @@ -1813,10 +1813,10 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttBeamrend *att = dynamic_cast(element); assert( att ); if (attrType == "form") { - att->SetForm(att->StrToBeatrptRend(attrValue)); + att->SetForm(att->StrToBeamrendForm(attrValue)); return true; } - if (attrType == "slopeDbl") { + if (attrType == "slope") { att->SetSlope(att->StrToDbl(attrValue)); return true; } @@ -1824,7 +1824,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) if (element->HasAttClass( ATT_BEAMSECONDARY ) ) { AttBeamsecondary *att = dynamic_cast(element); assert( att ); - if (attrType == "breaksecInt") { + if (attrType == "breaksec") { att->SetBreaksec(att->StrToInt(attrValue)); return true; } @@ -1833,7 +1833,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttBeatRptLog *att = dynamic_cast(element); assert( att ); if (attrType == "beatDef") { - att->SetBeatDef(att->StrToStr(attrValue)); + att->SetBeatDef(att->StrToDuration(attrValue)); return true; } } @@ -1857,7 +1857,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttCutout *att = dynamic_cast(element); assert( att ); if (attrType == "cutout") { - att->SetCutout(att->StrToStr(attrValue)); + att->SetCutout(att->StrToCutoutCutout(attrValue)); return true; } } @@ -1865,7 +1865,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttExpandable *att = dynamic_cast(element); assert( att ); if (attrType == "expand") { - att->SetExpand(att->StrToStr(attrValue)); + att->SetExpand(att->StrToBoolean(attrValue)); return true; } } @@ -1873,7 +1873,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttFTremLog *att = dynamic_cast(element); assert( att ); if (attrType == "form") { - att->SetForm(att->StrToBeatrptRend(attrValue)); + att->SetForm(att->StrToFTremLogForm(attrValue)); return true; } } @@ -1881,11 +1881,11 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttFermataVis *att = dynamic_cast(element); assert( att ); if (attrType == "form") { - att->SetForm(att->StrToBeatrptRend(attrValue)); + att->SetForm(att->StrToFermataVisForm(attrValue)); return true; } if (attrType == "shape") { - att->SetShape(att->StrToStr(attrValue)); + att->SetShape(att->StrToFermataVisShape(attrValue)); return true; } } @@ -1897,7 +1897,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) return true; } if (attrType == "graceTime") { - att->SetGraceTime(att->StrToStr(attrValue)); + att->SetGraceTime(att->StrToInt(attrValue)); return true; } } @@ -1905,11 +1905,11 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttHairpinLog *att = dynamic_cast(element); assert( att ); if (attrType == "form") { - att->SetForm(att->StrToBeatrptRend(attrValue)); + att->SetForm(att->StrToHairpinLogForm(attrValue)); return true; } if (attrType == "niente") { - att->SetNiente(att->StrToStr(attrValue)); + att->SetNiente(att->StrToBoolean(attrValue)); return true; } } @@ -1925,31 +1925,31 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttHarpPedalLog *att = dynamic_cast(element); assert( att ); if (attrType == "c") { - att->SetC(att->StrToStr(attrValue)); + att->SetC(att->StrToHarpPedalLogC(attrValue)); return true; } if (attrType == "d") { - att->SetD(att->StrToStr(attrValue)); + att->SetD(att->StrToHarpPedalLogD(attrValue)); return true; } if (attrType == "e") { - att->SetE(att->StrToStr(attrValue)); + att->SetE(att->StrToHarpPedalLogE(attrValue)); return true; } if (attrType == "f") { - att->SetF(att->StrToStr(attrValue)); + att->SetF(att->StrToHarpPedalLogF(attrValue)); return true; } if (attrType == "g") { - att->SetG(att->StrToStr(attrValue)); + att->SetG(att->StrToHarpPedalLogG(attrValue)); return true; } if (attrType == "a") { - att->SetA(att->StrToStr(attrValue)); + att->SetA(att->StrToHarpPedalLogA(attrValue)); return true; } if (attrType == "b") { - att->SetB(att->StrToStr(attrValue)); + att->SetB(att->StrToHarpPedalLogB(attrValue)); return true; } } @@ -1957,7 +1957,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttLvpresent *att = dynamic_cast(element); assert( att ); if (attrType == "lv") { - att->SetLv(att->StrToStr(attrValue)); + att->SetLv(att->StrToBoolean(attrValue)); return true; } } @@ -1965,7 +1965,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttMultiRestVis *att = dynamic_cast(element); assert( att ); if (attrType == "block") { - att->SetBlock(att->StrToStr(attrValue)); + att->SetBlock(att->StrToBoolean(attrValue)); return true; } } @@ -1973,14 +1973,14 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttNoteGesCmn *att = dynamic_cast(element); assert( att ); if (attrType == "gliss") { - att->SetGliss(att->StrToStr(attrValue)); + att->SetGliss(att->StrToGlissando(attrValue)); return true; } } if (element->HasAttClass( ATT_NUMBERED ) ) { AttNumbered *att = dynamic_cast(element); assert( att ); - if (attrType == "numInt") { + if (attrType == "num") { att->SetNum(att->StrToInt(attrValue)); return true; } @@ -1993,7 +1993,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) return true; } if (attrType == "numVisible") { - att->SetNumVisible(att->StrToBool(attrValue)); + att->SetNumVisible(att->StrToBoolean(attrValue)); return true; } } @@ -2001,7 +2001,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttOctaveLog *att = dynamic_cast(element); assert( att ); if (attrType == "coll") { - att->SetColl(att->StrToStr(attrValue)); + att->SetColl(att->StrToOctaveLogColl(attrValue)); return true; } } @@ -2009,7 +2009,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttPedalLog *att = dynamic_cast(element); assert( att ); if (attrType == "dir") { - att->SetDir(att->StrToStr(attrValue)); + att->SetDir(att->StrToPedalLogDir(attrValue)); return true; } } @@ -2017,7 +2017,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttPedalVis *att = dynamic_cast(element); assert( att ); if (attrType == "form") { - att->SetForm(att->StrToBeatrptRend(attrValue)); + att->SetForm(att->StrToPedalVisForm(attrValue)); return true; } } @@ -2025,7 +2025,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttPianopedals *att = dynamic_cast(element); assert( att ); if (attrType == "pedalStyle") { - att->SetPedalStyle(att->StrToStr(attrValue)); + att->SetPedalStyle(att->StrToPianopedalsPedalstyle(attrValue)); return true; } } @@ -2033,7 +2033,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttRehearsal *att = dynamic_cast(element); assert( att ); if (attrType == "rehEnclose") { - att->SetRehEnclose(att->StrToStr(attrValue)); + att->SetRehEnclose(att->StrToRehearsalRehenclose(attrValue)); return true; } } @@ -2041,7 +2041,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttScoreDefVisCmn *att = dynamic_cast(element); assert( att ); if (attrType == "gridShow") { - att->SetGridShow(att->StrToStr(attrValue)); + att->SetGridShow(att->StrToBoolean(attrValue)); return true; } } @@ -2049,7 +2049,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttSlurrend *att = dynamic_cast(element); assert( att ); if (attrType == "slurRend") { - att->SetSlurRend(att->StrToStr(attrValue)); + att->SetSlurRend(att->StrToCurverendition(attrValue)); return true; } } @@ -2057,7 +2057,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttStemsCmn *att = dynamic_cast(element); assert( att ); if (attrType == "stemWith") { - att->SetStemWith(att->StrToStr(attrValue)); + att->SetStemWith(att->StrToOtherstaff(attrValue)); return true; } } @@ -2065,7 +2065,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttTierend *att = dynamic_cast(element); assert( att ); if (attrType == "tieRend") { - att->SetTieRend(att->StrToStr(attrValue)); + att->SetTieRend(att->StrToCurverendition(attrValue)); return true; } } @@ -2073,7 +2073,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) AttTremmeasured *att = dynamic_cast(element); assert( att ); if (attrType == "measperf") { - att->SetMeasperf(att->StrToStr(attrValue)); + att->SetMeasperf(att->StrToDuration(attrValue)); return true; } } @@ -2085,15 +2085,15 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) return true; } if (attrType == "bracketVisible") { - att->SetBracketVisible(att->StrToBool(attrValue)); + att->SetBracketVisible(att->StrToBoolean(attrValue)); return true; } if (attrType == "durVisible") { - att->SetDurVisible(att->StrToBool(attrValue)); + att->SetDurVisible(att->StrToBoolean(attrValue)); return true; } if (attrType == "numFormat") { - att->SetNumFormat(att->StrToNumformat(attrValue)); + att->SetNumFormat(att->StrToTupletVisNumformat(attrValue)); return true; } } @@ -2106,21 +2106,21 @@ void Att::GetCmn( Object *element, ArrayOfStrAttr *attributes ) { AttArpegLog *att = dynamic_cast(element); assert( att ); if (att->HasOrder()) { - attributes->push_back(std::make_pair("order", att->StrToStr(att->GetOrder()))); + attributes->push_back(std::make_pair("order", att->ArpegLogOrderToStr(att->GetOrder()))); } } if (element->HasAttClass( ATT_ARPEGVIS ) ) { AttArpegVis *att = dynamic_cast(element); assert( att ); if (att->HasArrow()) { - attributes->push_back(std::make_pair("arrow", att->StrToStr(att->GetArrow()))); + attributes->push_back(std::make_pair("arrow", att->BooleanToStr(att->GetArrow()))); } } if (element->HasAttClass( ATT_BTREMLOG ) ) { AttBTremLog *att = dynamic_cast(element); assert( att ); if (att->HasForm()) { - attributes->push_back(std::make_pair("form", att->BeatrptRendToStr(att->GetForm()))); + attributes->push_back(std::make_pair("form", att->BTremLogFormToStr(att->GetForm()))); } } if (element->HasAttClass( ATT_BEAMED ) ) { @@ -2134,7 +2134,7 @@ void Att::GetCmn( Object *element, ArrayOfStrAttr *attributes ) { AttBeamedwith *att = dynamic_cast(element); assert( att ); if (att->HasBeamWith()) { - attributes->push_back(std::make_pair("beamWith", att->StrToStr(att->GetBeamWith()))); + attributes->push_back(std::make_pair("beamWith", att->OtherstaffToStr(att->GetBeamWith()))); } } if (element->HasAttClass( ATT_BEAMINGLOG ) ) { @@ -2144,31 +2144,31 @@ void Att::GetCmn( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("beamGroup", att->StrToStr(att->GetBeamGroup()))); } if (att->HasBeamRests()) { - attributes->push_back(std::make_pair("beamRests", att->StrToStr(att->GetBeamRests()))); + attributes->push_back(std::make_pair("beamRests", att->BooleanToStr(att->GetBeamRests()))); } } if (element->HasAttClass( ATT_BEAMREND ) ) { AttBeamrend *att = dynamic_cast(element); assert( att ); if (att->HasForm()) { - attributes->push_back(std::make_pair("form", att->BeatrptRendToStr(att->GetForm()))); + attributes->push_back(std::make_pair("form", att->BeamrendFormToStr(att->GetForm()))); } if (att->HasSlope()) { - attributes->push_back(std::make_pair("slopeDbl", att->DblToStr(att->GetSlope()))); + attributes->push_back(std::make_pair("slope", att->DblToStr(att->GetSlope()))); } } if (element->HasAttClass( ATT_BEAMSECONDARY ) ) { AttBeamsecondary *att = dynamic_cast(element); assert( att ); if (att->HasBreaksec()) { - attributes->push_back(std::make_pair("breaksecInt", att->IntToStr(att->GetBreaksec()))); + attributes->push_back(std::make_pair("breaksec", att->IntToStr(att->GetBreaksec()))); } } if (element->HasAttClass( ATT_BEATRPTLOG ) ) { AttBeatRptLog *att = dynamic_cast(element); assert( att ); if (att->HasBeatDef()) { - attributes->push_back(std::make_pair("beatDef", att->StrToStr(att->GetBeatDef()))); + attributes->push_back(std::make_pair("beatDef", att->DurationToStr(att->GetBeatDef()))); } } if (element->HasAttClass( ATT_BEATRPTVIS ) ) { @@ -2189,31 +2189,31 @@ void Att::GetCmn( Object *element, ArrayOfStrAttr *attributes ) { AttCutout *att = dynamic_cast(element); assert( att ); if (att->HasCutout()) { - attributes->push_back(std::make_pair("cutout", att->StrToStr(att->GetCutout()))); + attributes->push_back(std::make_pair("cutout", att->CutoutCutoutToStr(att->GetCutout()))); } } if (element->HasAttClass( ATT_EXPANDABLE ) ) { AttExpandable *att = dynamic_cast(element); assert( att ); if (att->HasExpand()) { - attributes->push_back(std::make_pair("expand", att->StrToStr(att->GetExpand()))); + attributes->push_back(std::make_pair("expand", att->BooleanToStr(att->GetExpand()))); } } if (element->HasAttClass( ATT_FTREMLOG ) ) { AttFTremLog *att = dynamic_cast(element); assert( att ); if (att->HasForm()) { - attributes->push_back(std::make_pair("form", att->BeatrptRendToStr(att->GetForm()))); + attributes->push_back(std::make_pair("form", att->FTremLogFormToStr(att->GetForm()))); } } if (element->HasAttClass( ATT_FERMATAVIS ) ) { AttFermataVis *att = dynamic_cast(element); assert( att ); if (att->HasForm()) { - attributes->push_back(std::make_pair("form", att->BeatrptRendToStr(att->GetForm()))); + attributes->push_back(std::make_pair("form", att->FermataVisFormToStr(att->GetForm()))); } if (att->HasShape()) { - attributes->push_back(std::make_pair("shape", att->StrToStr(att->GetShape()))); + attributes->push_back(std::make_pair("shape", att->FermataVisShapeToStr(att->GetShape()))); } } if (element->HasAttClass( ATT_GRACED ) ) { @@ -2223,17 +2223,17 @@ void Att::GetCmn( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("grace", att->GraceToStr(att->GetGrace()))); } if (att->HasGraceTime()) { - attributes->push_back(std::make_pair("graceTime", att->StrToStr(att->GetGraceTime()))); + attributes->push_back(std::make_pair("graceTime", att->IntToStr(att->GetGraceTime()))); } } if (element->HasAttClass( ATT_HAIRPINLOG ) ) { AttHairpinLog *att = dynamic_cast(element); assert( att ); if (att->HasForm()) { - attributes->push_back(std::make_pair("form", att->BeatrptRendToStr(att->GetForm()))); + attributes->push_back(std::make_pair("form", att->HairpinLogFormToStr(att->GetForm()))); } if (att->HasNiente()) { - attributes->push_back(std::make_pair("niente", att->StrToStr(att->GetNiente()))); + attributes->push_back(std::make_pair("niente", att->BooleanToStr(att->GetNiente()))); } } if (element->HasAttClass( ATT_HAIRPINVIS ) ) { @@ -2247,53 +2247,53 @@ void Att::GetCmn( Object *element, ArrayOfStrAttr *attributes ) { AttHarpPedalLog *att = dynamic_cast(element); assert( att ); if (att->HasC()) { - attributes->push_back(std::make_pair("c", att->StrToStr(att->GetC()))); + attributes->push_back(std::make_pair("c", att->HarpPedalLogCToStr(att->GetC()))); } if (att->HasD()) { - attributes->push_back(std::make_pair("d", att->StrToStr(att->GetD()))); + attributes->push_back(std::make_pair("d", att->HarpPedalLogDToStr(att->GetD()))); } if (att->HasE()) { - attributes->push_back(std::make_pair("e", att->StrToStr(att->GetE()))); + attributes->push_back(std::make_pair("e", att->HarpPedalLogEToStr(att->GetE()))); } if (att->HasF()) { - attributes->push_back(std::make_pair("f", att->StrToStr(att->GetF()))); + attributes->push_back(std::make_pair("f", att->HarpPedalLogFToStr(att->GetF()))); } if (att->HasG()) { - attributes->push_back(std::make_pair("g", att->StrToStr(att->GetG()))); + attributes->push_back(std::make_pair("g", att->HarpPedalLogGToStr(att->GetG()))); } if (att->HasA()) { - attributes->push_back(std::make_pair("a", att->StrToStr(att->GetA()))); + attributes->push_back(std::make_pair("a", att->HarpPedalLogAToStr(att->GetA()))); } if (att->HasB()) { - attributes->push_back(std::make_pair("b", att->StrToStr(att->GetB()))); + attributes->push_back(std::make_pair("b", att->HarpPedalLogBToStr(att->GetB()))); } } if (element->HasAttClass( ATT_LVPRESENT ) ) { AttLvpresent *att = dynamic_cast(element); assert( att ); if (att->HasLv()) { - attributes->push_back(std::make_pair("lv", att->StrToStr(att->GetLv()))); + attributes->push_back(std::make_pair("lv", att->BooleanToStr(att->GetLv()))); } } if (element->HasAttClass( ATT_MULTIRESTVIS ) ) { AttMultiRestVis *att = dynamic_cast(element); assert( att ); if (att->HasBlock()) { - attributes->push_back(std::make_pair("block", att->StrToStr(att->GetBlock()))); + attributes->push_back(std::make_pair("block", att->BooleanToStr(att->GetBlock()))); } } if (element->HasAttClass( ATT_NOTEGESCMN ) ) { AttNoteGesCmn *att = dynamic_cast(element); assert( att ); if (att->HasGliss()) { - attributes->push_back(std::make_pair("gliss", att->StrToStr(att->GetGliss()))); + attributes->push_back(std::make_pair("gliss", att->GlissandoToStr(att->GetGliss()))); } } if (element->HasAttClass( ATT_NUMBERED ) ) { AttNumbered *att = dynamic_cast(element); assert( att ); if (att->HasNum()) { - attributes->push_back(std::make_pair("numInt", att->IntToStr(att->GetNum()))); + attributes->push_back(std::make_pair("num", att->IntToStr(att->GetNum()))); } } if (element->HasAttClass( ATT_NUMBERPLACEMENT ) ) { @@ -2303,77 +2303,77 @@ void Att::GetCmn( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("numPlace", att->PlaceToStr(att->GetNumPlace()))); } if (att->HasNumVisible()) { - attributes->push_back(std::make_pair("numVisible", att->BoolToStr(att->GetNumVisible()))); + attributes->push_back(std::make_pair("numVisible", att->BooleanToStr(att->GetNumVisible()))); } } if (element->HasAttClass( ATT_OCTAVELOG ) ) { AttOctaveLog *att = dynamic_cast(element); assert( att ); if (att->HasColl()) { - attributes->push_back(std::make_pair("coll", att->StrToStr(att->GetColl()))); + attributes->push_back(std::make_pair("coll", att->OctaveLogCollToStr(att->GetColl()))); } } if (element->HasAttClass( ATT_PEDALLOG ) ) { AttPedalLog *att = dynamic_cast(element); assert( att ); if (att->HasDir()) { - attributes->push_back(std::make_pair("dir", att->StrToStr(att->GetDir()))); + attributes->push_back(std::make_pair("dir", att->PedalLogDirToStr(att->GetDir()))); } } if (element->HasAttClass( ATT_PEDALVIS ) ) { AttPedalVis *att = dynamic_cast(element); assert( att ); if (att->HasForm()) { - attributes->push_back(std::make_pair("form", att->BeatrptRendToStr(att->GetForm()))); + attributes->push_back(std::make_pair("form", att->PedalVisFormToStr(att->GetForm()))); } } if (element->HasAttClass( ATT_PIANOPEDALS ) ) { AttPianopedals *att = dynamic_cast(element); assert( att ); if (att->HasPedalStyle()) { - attributes->push_back(std::make_pair("pedalStyle", att->StrToStr(att->GetPedalStyle()))); + attributes->push_back(std::make_pair("pedalStyle", att->PianopedalsPedalstyleToStr(att->GetPedalStyle()))); } } if (element->HasAttClass( ATT_REHEARSAL ) ) { AttRehearsal *att = dynamic_cast(element); assert( att ); if (att->HasRehEnclose()) { - attributes->push_back(std::make_pair("rehEnclose", att->StrToStr(att->GetRehEnclose()))); + attributes->push_back(std::make_pair("rehEnclose", att->RehearsalRehencloseToStr(att->GetRehEnclose()))); } } if (element->HasAttClass( ATT_SCOREDEFVISCMN ) ) { AttScoreDefVisCmn *att = dynamic_cast(element); assert( att ); if (att->HasGridShow()) { - attributes->push_back(std::make_pair("gridShow", att->StrToStr(att->GetGridShow()))); + attributes->push_back(std::make_pair("gridShow", att->BooleanToStr(att->GetGridShow()))); } } if (element->HasAttClass( ATT_SLURREND ) ) { AttSlurrend *att = dynamic_cast(element); assert( att ); if (att->HasSlurRend()) { - attributes->push_back(std::make_pair("slurRend", att->StrToStr(att->GetSlurRend()))); + attributes->push_back(std::make_pair("slurRend", att->CurverenditionToStr(att->GetSlurRend()))); } } if (element->HasAttClass( ATT_STEMSCMN ) ) { AttStemsCmn *att = dynamic_cast(element); assert( att ); if (att->HasStemWith()) { - attributes->push_back(std::make_pair("stemWith", att->StrToStr(att->GetStemWith()))); + attributes->push_back(std::make_pair("stemWith", att->OtherstaffToStr(att->GetStemWith()))); } } if (element->HasAttClass( ATT_TIEREND ) ) { AttTierend *att = dynamic_cast(element); assert( att ); if (att->HasTieRend()) { - attributes->push_back(std::make_pair("tieRend", att->StrToStr(att->GetTieRend()))); + attributes->push_back(std::make_pair("tieRend", att->CurverenditionToStr(att->GetTieRend()))); } } if (element->HasAttClass( ATT_TREMMEASURED ) ) { AttTremmeasured *att = dynamic_cast(element); assert( att ); if (att->HasMeasperf()) { - attributes->push_back(std::make_pair("measperf", att->StrToStr(att->GetMeasperf()))); + attributes->push_back(std::make_pair("measperf", att->DurationToStr(att->GetMeasperf()))); } } if (element->HasAttClass( ATT_TUPLETVIS ) ) { @@ -2383,13 +2383,13 @@ void Att::GetCmn( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("bracketPlace", att->PlaceToStr(att->GetBracketPlace()))); } if (att->HasBracketVisible()) { - attributes->push_back(std::make_pair("bracketVisible", att->BoolToStr(att->GetBracketVisible()))); + attributes->push_back(std::make_pair("bracketVisible", att->BooleanToStr(att->GetBracketVisible()))); } if (att->HasDurVisible()) { - attributes->push_back(std::make_pair("durVisible", att->BoolToStr(att->GetDurVisible()))); + attributes->push_back(std::make_pair("durVisible", att->BooleanToStr(att->GetDurVisible()))); } if (att->HasNumFormat()) { - attributes->push_back(std::make_pair("numFormat", att->NumformatToStr(att->GetNumFormat()))); + attributes->push_back(std::make_pair("numFormat", att->TupletVisNumformatToStr(att->GetNumFormat()))); } } diff --git a/libmei/atts_cmn.h b/libmei/atts_cmn.h index a09746e3289..ad26a0e2344 100644 --- a/libmei/atts_cmn.h +++ b/libmei/atts_cmn.h @@ -16,7 +16,7 @@ #define __VRV_ATTS_CMN_H__ #include "att.h" -#include "att_classes.h" +#include "attdef.h" #include "pugixml.hpp" //---------------------------------------------------------------------------- @@ -50,15 +50,15 @@ class AttArpegLog: public Att * to the default value) **/ ///@{ - void SetOrder(std::string order_) { m_order = order_; }; - std::string GetOrder() const { return m_order; }; + void SetOrder(arpegLog_ORDER order_) { m_order = order_; }; + arpegLog_ORDER GetOrder() const { return m_order; }; bool HasOrder( ); ///@} private: /** Describes the direction in which an arpeggio is to be performed. **/ - std::string m_order; + arpegLog_ORDER m_order; /* include */ }; @@ -88,15 +88,15 @@ class AttArpegVis: public Att * to the default value) **/ ///@{ - void SetArrow(std::string arrow_) { m_arrow = arrow_; }; - std::string GetArrow() const { return m_arrow; }; + void SetArrow(data_BOOLEAN arrow_) { m_arrow = arrow_; }; + data_BOOLEAN GetArrow() const { return m_arrow; }; bool HasArrow( ); ///@} private: /** Indicates if an arrowhead is to be drawn as part of the arpeggiation symbol. **/ - std::string m_arrow; + data_BOOLEAN m_arrow; /* include */ }; @@ -126,15 +126,15 @@ class AttBTremLog: public Att * to the default value) **/ ///@{ - void SetForm(data_BEATRPT_REND form_) { m_form = form_; }; - data_BEATRPT_REND GetForm() const { return m_form; }; + void SetForm(bTremLog_FORM form_) { m_form = form_; }; + bTremLog_FORM GetForm() const { return m_form; }; bool HasForm( ); ///@} private: /** Records the appearance and usually the function of the bar line. **/ - data_BEATRPT_REND m_form; + bTremLog_FORM m_form; /* include */ }; @@ -202,8 +202,8 @@ class AttBeamedwith: public Att * to the default value) **/ ///@{ - void SetBeamWith(std::string beamWith_) { m_beamWith = beamWith_; }; - std::string GetBeamWith() const { return m_beamWith; }; + void SetBeamWith(data_OTHERSTAFF beamWith_) { m_beamWith = beamWith_; }; + data_OTHERSTAFF GetBeamWith() const { return m_beamWith; }; bool HasBeamWith( ); ///@} @@ -214,7 +214,7 @@ class AttBeamedwith: public Att * which staff the beam is connected to; that is, the staff above or the staff * below. **/ - std::string m_beamWith; + data_OTHERSTAFF m_beamWith; /* include */ }; @@ -249,8 +249,8 @@ class AttBeamingLog: public Att bool HasBeamGroup( ); // - void SetBeamRests(std::string beamRests_) { m_beamRests = beamRests_; }; - std::string GetBeamRests() const { return m_beamRests; }; + void SetBeamRests(data_BOOLEAN beamRests_) { m_beamRests = beamRests_; }; + data_BOOLEAN GetBeamRests() const { return m_beamRests; }; bool HasBeamRests( ); ///@} @@ -265,7 +265,7 @@ class AttBeamingLog: public Att * Indicates whether automatically-drawn beams should include rests shorter than a * quarter note duration. **/ - std::string m_beamRests; + data_BOOLEAN m_beamRests; /* include */ }; @@ -295,22 +295,22 @@ class AttBeamrend: public Att * to the default value) **/ ///@{ - void SetForm(data_BEATRPT_REND form_) { m_form = form_; }; - data_BEATRPT_REND GetForm() const { return m_form; }; + void SetForm(beamrend_FORM form_) { m_form = form_; }; + beamrend_FORM GetForm() const { return m_form; }; bool HasForm( ); // - void SetSlope(double slopeDbl_) { m_slopeDbl = slopeDbl_; }; - double GetSlope() const { return m_slopeDbl; }; + void SetSlope(double slope_) { m_slope = slope_; }; + double GetSlope() const { return m_slope; }; bool HasSlope( ); ///@} private: /** Records the appearance and usually the function of the bar line. **/ - data_BEATRPT_REND m_form; + beamrend_FORM m_form; /** Records the slope of the beam. **/ - double m_slopeDbl; + double m_slope; /* include */ }; @@ -340,8 +340,8 @@ class AttBeamsecondary: public Att * to the default value) **/ ///@{ - void SetBreaksec(int breaksecInt_) { m_breaksecInt = breaksecInt_; }; - int GetBreaksec() const { return m_breaksecInt; }; + void SetBreaksec(int breaksec_) { m_breaksec = breaksec_; }; + int GetBreaksec() const { return m_breaksec; }; bool HasBreaksec( ); ///@} @@ -353,7 +353,7 @@ class AttBeamsecondary: public Att * The value of the attribute records the number of beams which should remain * unbroken. **/ - int m_breaksecInt; + int m_breaksec; /* include */ }; @@ -383,15 +383,15 @@ class AttBeatRptLog: public Att * to the default value) **/ ///@{ - void SetBeatDef(std::string beatDef_) { m_beatDef = beatDef_; }; - std::string GetBeatDef() const { return m_beatDef; }; + void SetBeatDef(data_DURATION beatDef_) { m_beatDef = beatDef_; }; + data_DURATION GetBeatDef() const { return m_beatDef; }; bool HasBeatDef( ); ///@} private: /** --- **/ - std::string m_beatDef; + data_DURATION m_beatDef; /* include */ }; @@ -501,15 +501,15 @@ class AttCutout: public Att * to the default value) **/ ///@{ - void SetCutout(std::string cutout_) { m_cutout = cutout_; }; - std::string GetCutout() const { return m_cutout; }; + void SetCutout(cutout_CUTOUT cutout_) { m_cutout = cutout_; }; + cutout_CUTOUT GetCutout() const { return m_cutout; }; bool HasCutout( ); ///@} private: /** "Cut-out" style indicated for this measure. **/ - std::string m_cutout; + cutout_CUTOUT m_cutout; /* include */ }; @@ -539,8 +539,8 @@ class AttExpandable: public Att * to the default value) **/ ///@{ - void SetExpand(std::string expand_) { m_expand = expand_; }; - std::string GetExpand() const { return m_expand; }; + void SetExpand(data_BOOLEAN expand_) { m_expand = expand_; }; + data_BOOLEAN GetExpand() const { return m_expand; }; bool HasExpand( ); ///@} @@ -552,7 +552,7 @@ class AttExpandable: public Att * A value of 'true' renders the source material, while 'false' displays the repeat * symbol. **/ - std::string m_expand; + data_BOOLEAN m_expand; /* include */ }; @@ -582,15 +582,15 @@ class AttFTremLog: public Att * to the default value) **/ ///@{ - void SetForm(data_BEATRPT_REND form_) { m_form = form_; }; - data_BEATRPT_REND GetForm() const { return m_form; }; + void SetForm(fTremLog_FORM form_) { m_form = form_; }; + fTremLog_FORM GetForm() const { return m_form; }; bool HasForm( ); ///@} private: /** Records the appearance and usually the function of the bar line. **/ - data_BEATRPT_REND m_form; + fTremLog_FORM m_form; /* include */ }; @@ -620,22 +620,22 @@ class AttFermataVis: public Att * to the default value) **/ ///@{ - void SetForm(data_BEATRPT_REND form_) { m_form = form_; }; - data_BEATRPT_REND GetForm() const { return m_form; }; + void SetForm(fermataVis_FORM form_) { m_form = form_; }; + fermataVis_FORM GetForm() const { return m_form; }; bool HasForm( ); // - void SetShape(std::string shape_) { m_shape = shape_; }; - std::string GetShape() const { return m_shape; }; + void SetShape(fermataVis_SHAPE shape_) { m_shape = shape_; }; + fermataVis_SHAPE GetShape() const { return m_shape; }; bool HasShape( ); ///@} private: /** Records the appearance and usually the function of the bar line. **/ - data_BEATRPT_REND m_form; + fermataVis_FORM m_form; /** Describes a clef's shape. **/ - std::string m_shape; + fermataVis_SHAPE m_shape; /* include */ }; @@ -670,8 +670,8 @@ class AttGraced: public Att bool HasGrace( ); // - void SetGraceTime(std::string graceTime_) { m_graceTime = graceTime_; }; - std::string GetGraceTime() const { return m_graceTime; }; + void SetGraceTime(int graceTime_) { m_graceTime = graceTime_; }; + int GetGraceTime() const { return m_graceTime; }; bool HasGraceTime( ); ///@} @@ -683,7 +683,7 @@ class AttGraced: public Att **/ data_GRACE m_grace; /** Records the amount of time to be "stolen" from a non-grace note/chord. **/ - std::string m_graceTime; + int m_graceTime; /* include */ }; @@ -713,26 +713,26 @@ class AttHairpinLog: public Att * to the default value) **/ ///@{ - void SetForm(data_BEATRPT_REND form_) { m_form = form_; }; - data_BEATRPT_REND GetForm() const { return m_form; }; + void SetForm(hairpinLog_FORM form_) { m_form = form_; }; + hairpinLog_FORM GetForm() const { return m_form; }; bool HasForm( ); // - void SetNiente(std::string niente_) { m_niente = niente_; }; - std::string GetNiente() const { return m_niente; }; + void SetNiente(data_BOOLEAN niente_) { m_niente = niente_; }; + data_BOOLEAN GetNiente() const { return m_niente; }; bool HasNiente( ); ///@} private: /** Records the appearance and usually the function of the bar line. **/ - data_BEATRPT_REND m_form; + hairpinLog_FORM m_form; /** * Indicates that the hairpin starts from or ends in silence. * Often rendered as a small circle attached to the closed end of the hairpin. See * Gould, p. 108. **/ - std::string m_niente; + data_BOOLEAN m_niente; /* include */ }; @@ -803,57 +803,57 @@ class AttHarpPedalLog: public Att * to the default value) **/ ///@{ - void SetC(std::string c_) { m_c = c_; }; - std::string GetC() const { return m_c; }; + void SetC(harpPedalLog_C c_) { m_c = c_; }; + harpPedalLog_C GetC() const { return m_c; }; bool HasC( ); // - void SetD(std::string d_) { m_d = d_; }; - std::string GetD() const { return m_d; }; + void SetD(harpPedalLog_D d_) { m_d = d_; }; + harpPedalLog_D GetD() const { return m_d; }; bool HasD( ); // - void SetE(std::string e_) { m_e = e_; }; - std::string GetE() const { return m_e; }; + void SetE(harpPedalLog_E e_) { m_e = e_; }; + harpPedalLog_E GetE() const { return m_e; }; bool HasE( ); // - void SetF(std::string f_) { m_f = f_; }; - std::string GetF() const { return m_f; }; + void SetF(harpPedalLog_F f_) { m_f = f_; }; + harpPedalLog_F GetF() const { return m_f; }; bool HasF( ); // - void SetG(std::string g_) { m_g = g_; }; - std::string GetG() const { return m_g; }; + void SetG(harpPedalLog_G g_) { m_g = g_; }; + harpPedalLog_G GetG() const { return m_g; }; bool HasG( ); // - void SetA(std::string a_) { m_a = a_; }; - std::string GetA() const { return m_a; }; + void SetA(harpPedalLog_A a_) { m_a = a_; }; + harpPedalLog_A GetA() const { return m_a; }; bool HasA( ); // - void SetB(std::string b_) { m_b = b_; }; - std::string GetB() const { return m_b; }; + void SetB(harpPedalLog_B b_) { m_b = b_; }; + harpPedalLog_B GetB() const { return m_b; }; bool HasB( ); ///@} private: /** Indicates the pedal setting for the harp's C strings. **/ - std::string m_c; + harpPedalLog_C m_c; /** Indicates the pedal setting for the harp's D strings. **/ - std::string m_d; + harpPedalLog_D m_d; /** Indicates the pedal setting for the harp's E strings. **/ - std::string m_e; + harpPedalLog_E m_e; /** Indicates the pedal setting for the harp's F strings. **/ - std::string m_f; + harpPedalLog_F m_f; /** Indicates the pedal setting for the harp's G strings. **/ - std::string m_g; + harpPedalLog_G m_g; /** Indicates the pedal setting for the harp's A strings. **/ - std::string m_a; + harpPedalLog_A m_a; /** Indicates the pedal setting for the harp's B strings. **/ - std::string m_b; + harpPedalLog_B m_b; /* include */ }; @@ -883,8 +883,8 @@ class AttLvpresent: public Att * to the default value) **/ ///@{ - void SetLv(std::string lv_) { m_lv = lv_; }; - std::string GetLv() const { return m_lv; }; + void SetLv(data_BOOLEAN lv_) { m_lv = lv_; }; + data_BOOLEAN GetLv() const { return m_lv; }; bool HasLv( ); ///@} @@ -894,7 +894,7 @@ class AttLvpresent: public Att * Indicates the attachment of an l.v. * (laissez vibrer) sign to this element. **/ - std::string m_lv; + data_BOOLEAN m_lv; /* include */ }; @@ -924,8 +924,8 @@ class AttMultiRestVis: public Att * to the default value) **/ ///@{ - void SetBlock(std::string block_) { m_block = block_; }; - std::string GetBlock() const { return m_block; }; + void SetBlock(data_BOOLEAN block_) { m_block = block_; }; + data_BOOLEAN GetBlock() const { return m_block; }; bool HasBlock( ); ///@} @@ -936,7 +936,7 @@ class AttMultiRestVis: public Att * forms (Read, p. * 104) should be rendered instead of the modern form or an alternative symbol. **/ - std::string m_block; + data_BOOLEAN m_block; /* include */ }; @@ -966,15 +966,15 @@ class AttNoteGesCmn: public Att * to the default value) **/ ///@{ - void SetGliss(std::string gliss_) { m_gliss = gliss_; }; - std::string GetGliss() const { return m_gliss; }; + void SetGliss(data_GLISSANDO gliss_) { m_gliss = gliss_; }; + data_GLISSANDO GetGliss() const { return m_gliss; }; bool HasGliss( ); ///@} private: /** Indicates that this element participates in a glissando. **/ - std::string m_gliss; + data_GLISSANDO m_gliss; /* include */ }; @@ -1004,8 +1004,8 @@ class AttNumbered: public Att * to the default value) **/ ///@{ - void SetNum(int numInt_) { m_numInt = numInt_; }; - int GetNum() const { return m_numInt; }; + void SetNum(int num_) { m_num = num_; }; + int GetNum() const { return m_num; }; bool HasNum( ); ///@} @@ -1015,7 +1015,7 @@ class AttNumbered: public Att * Along with numbase, describes duration as a ratio. * num is the first value in the ratio, while numbase is the second. **/ - int m_numInt; + int m_num; /* include */ }; @@ -1090,8 +1090,8 @@ class AttOctaveLog: public Att * to the default value) **/ ///@{ - void SetColl(std::string coll_) { m_coll = coll_; }; - std::string GetColl() const { return m_coll; }; + void SetColl(octaveLog_COLL coll_) { m_coll = coll_; }; + octaveLog_COLL GetColl() const { return m_coll; }; bool HasColl( ); ///@} @@ -1104,7 +1104,7 @@ class AttOctaveLog: public Att * typically uses an unbroken line or a series of longer broken lines, ending with * a short vertical stroke. See Read, p. 47-48. **/ - std::string m_coll; + octaveLog_COLL m_coll; /* include */ }; @@ -1134,15 +1134,15 @@ class AttPedalLog: public Att * to the default value) **/ ///@{ - void SetDir(std::string dir_) { m_dir = dir_; }; - std::string GetDir() const { return m_dir; }; + void SetDir(pedalLog_DIR dir_) { m_dir = dir_; }; + pedalLog_DIR GetDir() const { return m_dir; }; bool HasDir( ); ///@} private: /** Records the position of the piano damper pedal. **/ - std::string m_dir; + pedalLog_DIR m_dir; /* include */ }; @@ -1172,15 +1172,15 @@ class AttPedalVis: public Att * to the default value) **/ ///@{ - void SetForm(data_BEATRPT_REND form_) { m_form = form_; }; - data_BEATRPT_REND GetForm() const { return m_form; }; + void SetForm(pedalVis_FORM form_) { m_form = form_; }; + pedalVis_FORM GetForm() const { return m_form; }; bool HasForm( ); ///@} private: /** Records the appearance and usually the function of the bar line. **/ - data_BEATRPT_REND m_form; + pedalVis_FORM m_form; /* include */ }; @@ -1210,15 +1210,15 @@ class AttPianopedals: public Att * to the default value) **/ ///@{ - void SetPedalStyle(std::string pedalStyle_) { m_pedalStyle = pedalStyle_; }; - std::string GetPedalStyle() const { return m_pedalStyle; }; + void SetPedalStyle(pianopedals_PEDALSTYLE pedalStyle_) { m_pedalStyle = pedalStyle_; }; + pianopedals_PEDALSTYLE GetPedalStyle() const { return m_pedalStyle; }; bool HasPedalStyle( ); ///@} private: /** Determines whether piano pedal marks should be rendered as lines or as terms. **/ - std::string m_pedalStyle; + pianopedals_PEDALSTYLE m_pedalStyle; /* include */ }; @@ -1248,15 +1248,15 @@ class AttRehearsal: public Att * to the default value) **/ ///@{ - void SetRehEnclose(std::string rehEnclose_) { m_rehEnclose = rehEnclose_; }; - std::string GetRehEnclose() const { return m_rehEnclose; }; + void SetRehEnclose(rehearsal_REHENCLOSE rehEnclose_) { m_rehEnclose = rehEnclose_; }; + rehearsal_REHENCLOSE GetRehEnclose() const { return m_rehEnclose; }; bool HasRehEnclose( ); ///@} private: /** Describes the enclosing shape for rehearsal marks. **/ - std::string m_rehEnclose; + rehearsal_REHENCLOSE m_rehEnclose; /* include */ }; @@ -1286,15 +1286,15 @@ class AttScoreDefVisCmn: public Att * to the default value) **/ ///@{ - void SetGridShow(std::string gridShow_) { m_gridShow = gridShow_; }; - std::string GetGridShow() const { return m_gridShow; }; + void SetGridShow(data_BOOLEAN gridShow_) { m_gridShow = gridShow_; }; + data_BOOLEAN GetGridShow() const { return m_gridShow; }; bool HasGridShow( ); ///@} private: /** Determines whether to display guitar chord grids. **/ - std::string m_gridShow; + data_BOOLEAN m_gridShow; /* include */ }; @@ -1324,15 +1324,15 @@ class AttSlurrend: public Att * to the default value) **/ ///@{ - void SetSlurRend(std::string slurRend_) { m_slurRend = slurRend_; }; - std::string GetSlurRend() const { return m_slurRend; }; + void SetSlurRend(data_CURVERENDITION slurRend_) { m_slurRend = slurRend_; }; + data_CURVERENDITION GetSlurRend() const { return m_slurRend; }; bool HasSlurRend( ); ///@} private: /** Describes the line style of the slur. **/ - std::string m_slurRend; + data_CURVERENDITION m_slurRend; /* include */ }; @@ -1362,8 +1362,8 @@ class AttStemsCmn: public Att * to the default value) **/ ///@{ - void SetStemWith(std::string stemWith_) { m_stemWith = stemWith_; }; - std::string GetStemWith() const { return m_stemWith; }; + void SetStemWith(data_OTHERSTAFF stemWith_) { m_stemWith = stemWith_; }; + data_OTHERSTAFF GetStemWith() const { return m_stemWith; }; bool HasStemWith( ); ///@} @@ -1374,7 +1374,7 @@ class AttStemsCmn: public Att * the current staff should be visually placed on; that is, the one above or the * one below. **/ - std::string m_stemWith; + data_OTHERSTAFF m_stemWith; /* include */ }; @@ -1404,15 +1404,15 @@ class AttTierend: public Att * to the default value) **/ ///@{ - void SetTieRend(std::string tieRend_) { m_tieRend = tieRend_; }; - std::string GetTieRend() const { return m_tieRend; }; + void SetTieRend(data_CURVERENDITION tieRend_) { m_tieRend = tieRend_; }; + data_CURVERENDITION GetTieRend() const { return m_tieRend; }; bool HasTieRend( ); ///@} private: /** Describes the line style of the tie. **/ - std::string m_tieRend; + data_CURVERENDITION m_tieRend; /* include */ }; @@ -1442,15 +1442,15 @@ class AttTremmeasured: public Att * to the default value) **/ ///@{ - void SetMeasperf(std::string measperf_) { m_measperf = measperf_; }; - std::string GetMeasperf() const { return m_measperf; }; + void SetMeasperf(data_DURATION measperf_) { m_measperf = measperf_; }; + data_DURATION GetMeasperf() const { return m_measperf; }; bool HasMeasperf( ); ///@} private: /** The performed duration of an individual note in a measured tremolo. **/ - std::string m_measperf; + data_DURATION m_measperf; /* include */ }; @@ -1495,8 +1495,8 @@ class AttTupletVis: public Att bool HasDurVisible( ); // - void SetNumFormat(data_NUMFORMAT numFormat_) { m_numFormat = numFormat_; }; - data_NUMFORMAT GetNumFormat() const { return m_numFormat; }; + void SetNumFormat(tupletVis_NUMFORMAT numFormat_) { m_numFormat = numFormat_; }; + tupletVis_NUMFORMAT GetNumFormat() const { return m_numFormat; }; bool HasNumFormat( ); ///@} @@ -1512,7 +1512,7 @@ class AttTupletVis: public Att /** Determines if the tuplet duration is visible. **/ data_BOOLEAN m_durVisible; /** Controls how the num:numbase ratio is to be displayed. **/ - data_NUMFORMAT m_numFormat; + tupletVis_NUMFORMAT m_numFormat; /* include */ }; diff --git a/libmei/atts_cmnornaments.cpp b/libmei/atts_cmnornaments.cpp index 3296cf5892c..999ef5e4fc6 100644 --- a/libmei/atts_cmnornaments.cpp +++ b/libmei/atts_cmnornaments.cpp @@ -39,33 +39,33 @@ AttMordentLog::~AttMordentLog() { } void AttMordentLog::ResetMordentLog() { - m_form = ""; - m_long = ""; + m_form = mordentLog_FORM_NONE; + m_long = BOOLEAN_NONE; } -bool AttMordentLog::ReadMordentLog( pugi::xml_node element ) { +bool AttMordentLog::ReadMordentLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("form")) { - this->SetForm(StrToStr(element.attribute("form").value())); + this->SetForm(StrToMordentLogForm(element.attribute("form").value())); element.remove_attribute("form"); hasAttribute = true; } if (element.attribute("long")) { - this->SetLong(StrToStr(element.attribute("long").value())); + this->SetLong(StrToBoolean(element.attribute("long").value())); element.remove_attribute("long"); hasAttribute = true; } return hasAttribute; } -bool AttMordentLog::WriteMordentLog( pugi::xml_node element ) { +bool AttMordentLog::WriteMordentLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasForm()) { - element.append_attribute("form") = StrToStr(this->GetForm()).c_str(); + element.append_attribute("form") = MordentLogFormToStr(this->GetForm()).c_str(); wroteAttribute = true; } if (this->HasLong()) { - element.append_attribute("long") = StrToStr(this->GetLong()).c_str(); + element.append_attribute("long") = BooleanToStr(this->GetLong()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -73,12 +73,12 @@ bool AttMordentLog::WriteMordentLog( pugi::xml_node element ) { bool AttMordentLog::HasForm( ) { - return (m_form != ""); + return (m_form != mordentLog_FORM_NONE); } bool AttMordentLog::HasLong( ) { - return (m_long != ""); + return (m_long != BOOLEAN_NONE); } @@ -97,23 +97,23 @@ AttOrnam::~AttOrnam() { } void AttOrnam::ResetOrnam() { - m_ornam = ""; + m_ornam = ORNAM_cmn_NONE; } -bool AttOrnam::ReadOrnam( pugi::xml_node element ) { +bool AttOrnam::ReadOrnam( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("ornam")) { - this->SetOrnam(StrToStr(element.attribute("ornam").value())); + this->SetOrnam(StrToOrnamCmn(element.attribute("ornam").value())); element.remove_attribute("ornam"); hasAttribute = true; } return hasAttribute; } -bool AttOrnam::WriteOrnam( pugi::xml_node element ) { +bool AttOrnam::WriteOrnam( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasOrnam()) { - element.append_attribute("ornam") = StrToStr(this->GetOrnam()).c_str(); + element.append_attribute("ornam") = OrnamCmnToStr(this->GetOrnam()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -121,7 +121,7 @@ bool AttOrnam::WriteOrnam( pugi::xml_node element ) { bool AttOrnam::HasOrnam( ) { - return (m_ornam != ""); + return (m_ornam != ORNAM_cmn_NONE); } @@ -140,33 +140,33 @@ AttOrnamentaccid::~AttOrnamentaccid() { } void AttOrnamentaccid::ResetOrnamentaccid() { - m_accidupper = ""; - m_accidlower = ""; + m_accidupper = ACCIDENTAL_EXPLICIT_NONE; + m_accidlower = ACCIDENTAL_EXPLICIT_NONE; } -bool AttOrnamentaccid::ReadOrnamentaccid( pugi::xml_node element ) { +bool AttOrnamentaccid::ReadOrnamentaccid( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("accidupper")) { - this->SetAccidupper(StrToStr(element.attribute("accidupper").value())); + this->SetAccidupper(StrToAccidentalExplicit(element.attribute("accidupper").value())); element.remove_attribute("accidupper"); hasAttribute = true; } if (element.attribute("accidlower")) { - this->SetAccidlower(StrToStr(element.attribute("accidlower").value())); + this->SetAccidlower(StrToAccidentalExplicit(element.attribute("accidlower").value())); element.remove_attribute("accidlower"); hasAttribute = true; } return hasAttribute; } -bool AttOrnamentaccid::WriteOrnamentaccid( pugi::xml_node element ) { +bool AttOrnamentaccid::WriteOrnamentaccid( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasAccidupper()) { - element.append_attribute("accidupper") = StrToStr(this->GetAccidupper()).c_str(); + element.append_attribute("accidupper") = AccidentalExplicitToStr(this->GetAccidupper()).c_str(); wroteAttribute = true; } if (this->HasAccidlower()) { - element.append_attribute("accidlower") = StrToStr(this->GetAccidlower()).c_str(); + element.append_attribute("accidlower") = AccidentalExplicitToStr(this->GetAccidlower()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -174,12 +174,12 @@ bool AttOrnamentaccid::WriteOrnamentaccid( pugi::xml_node element ) { bool AttOrnamentaccid::HasAccidupper( ) { - return (m_accidupper != ""); + return (m_accidupper != ACCIDENTAL_EXPLICIT_NONE); } bool AttOrnamentaccid::HasAccidlower( ) { - return (m_accidlower != ""); + return (m_accidlower != ACCIDENTAL_EXPLICIT_NONE); } @@ -198,33 +198,33 @@ AttTurnLog::~AttTurnLog() { } void AttTurnLog::ResetTurnLog() { - m_delayed = ""; - m_form = ""; + m_delayed = BOOLEAN_NONE; + m_form = turnLog_FORM_NONE; } -bool AttTurnLog::ReadTurnLog( pugi::xml_node element ) { +bool AttTurnLog::ReadTurnLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("delayed")) { - this->SetDelayed(StrToStr(element.attribute("delayed").value())); + this->SetDelayed(StrToBoolean(element.attribute("delayed").value())); element.remove_attribute("delayed"); hasAttribute = true; } if (element.attribute("form")) { - this->SetForm(StrToStr(element.attribute("form").value())); + this->SetForm(StrToTurnLogForm(element.attribute("form").value())); element.remove_attribute("form"); hasAttribute = true; } return hasAttribute; } -bool AttTurnLog::WriteTurnLog( pugi::xml_node element ) { +bool AttTurnLog::WriteTurnLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasDelayed()) { - element.append_attribute("delayed") = StrToStr(this->GetDelayed()).c_str(); + element.append_attribute("delayed") = BooleanToStr(this->GetDelayed()).c_str(); wroteAttribute = true; } if (this->HasForm()) { - element.append_attribute("form") = StrToStr(this->GetForm()).c_str(); + element.append_attribute("form") = TurnLogFormToStr(this->GetForm()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -232,12 +232,12 @@ bool AttTurnLog::WriteTurnLog( pugi::xml_node element ) { bool AttTurnLog::HasDelayed( ) { - return (m_delayed != ""); + return (m_delayed != BOOLEAN_NONE); } bool AttTurnLog::HasForm( ) { - return (m_form != ""); + return (m_form != turnLog_FORM_NONE); } @@ -248,11 +248,11 @@ bool Att::SetCmnornaments( Object *element, std::string attrType, std::string at AttMordentLog *att = dynamic_cast(element); assert( att ); if (attrType == "form") { - att->SetForm(att->StrToStr(attrValue)); + att->SetForm(att->StrToMordentLogForm(attrValue)); return true; } if (attrType == "long") { - att->SetLong(att->StrToStr(attrValue)); + att->SetLong(att->StrToBoolean(attrValue)); return true; } } @@ -260,7 +260,7 @@ bool Att::SetCmnornaments( Object *element, std::string attrType, std::string at AttOrnam *att = dynamic_cast(element); assert( att ); if (attrType == "ornam") { - att->SetOrnam(att->StrToStr(attrValue)); + att->SetOrnam(att->StrToOrnamCmn(attrValue)); return true; } } @@ -268,11 +268,11 @@ bool Att::SetCmnornaments( Object *element, std::string attrType, std::string at AttOrnamentaccid *att = dynamic_cast(element); assert( att ); if (attrType == "accidupper") { - att->SetAccidupper(att->StrToStr(attrValue)); + att->SetAccidupper(att->StrToAccidentalExplicit(attrValue)); return true; } if (attrType == "accidlower") { - att->SetAccidlower(att->StrToStr(attrValue)); + att->SetAccidlower(att->StrToAccidentalExplicit(attrValue)); return true; } } @@ -280,11 +280,11 @@ bool Att::SetCmnornaments( Object *element, std::string attrType, std::string at AttTurnLog *att = dynamic_cast(element); assert( att ); if (attrType == "delayed") { - att->SetDelayed(att->StrToStr(attrValue)); + att->SetDelayed(att->StrToBoolean(attrValue)); return true; } if (attrType == "form") { - att->SetForm(att->StrToStr(attrValue)); + att->SetForm(att->StrToTurnLogForm(attrValue)); return true; } } @@ -297,37 +297,37 @@ void Att::GetCmnornaments( Object *element, ArrayOfStrAttr *attributes ) { AttMordentLog *att = dynamic_cast(element); assert( att ); if (att->HasForm()) { - attributes->push_back(std::make_pair("form", att->StrToStr(att->GetForm()))); + attributes->push_back(std::make_pair("form", att->MordentLogFormToStr(att->GetForm()))); } if (att->HasLong()) { - attributes->push_back(std::make_pair("long", att->StrToStr(att->GetLong()))); + attributes->push_back(std::make_pair("long", att->BooleanToStr(att->GetLong()))); } } if (element->HasAttClass( ATT_ORNAM ) ) { AttOrnam *att = dynamic_cast(element); assert( att ); if (att->HasOrnam()) { - attributes->push_back(std::make_pair("ornam", att->StrToStr(att->GetOrnam()))); + attributes->push_back(std::make_pair("ornam", att->OrnamCmnToStr(att->GetOrnam()))); } } if (element->HasAttClass( ATT_ORNAMENTACCID ) ) { AttOrnamentaccid *att = dynamic_cast(element); assert( att ); if (att->HasAccidupper()) { - attributes->push_back(std::make_pair("accidupper", att->StrToStr(att->GetAccidupper()))); + attributes->push_back(std::make_pair("accidupper", att->AccidentalExplicitToStr(att->GetAccidupper()))); } if (att->HasAccidlower()) { - attributes->push_back(std::make_pair("accidlower", att->StrToStr(att->GetAccidlower()))); + attributes->push_back(std::make_pair("accidlower", att->AccidentalExplicitToStr(att->GetAccidlower()))); } } if (element->HasAttClass( ATT_TURNLOG ) ) { AttTurnLog *att = dynamic_cast(element); assert( att ); if (att->HasDelayed()) { - attributes->push_back(std::make_pair("delayed", att->StrToStr(att->GetDelayed()))); + attributes->push_back(std::make_pair("delayed", att->BooleanToStr(att->GetDelayed()))); } if (att->HasForm()) { - attributes->push_back(std::make_pair("form", att->StrToStr(att->GetForm()))); + attributes->push_back(std::make_pair("form", att->TurnLogFormToStr(att->GetForm()))); } } diff --git a/libmei/atts_cmnornaments.h b/libmei/atts_cmnornaments.h index baafb5fee56..36acc5783fd 100644 --- a/libmei/atts_cmnornaments.h +++ b/libmei/atts_cmnornaments.h @@ -16,12 +16,12 @@ #define __VRV_ATTS_CMNORNAMENTS_H__ #include "att.h" -#include "att_classes.h" +#include "attdef.h" #include "pugixml.hpp" //---------------------------------------------------------------------------- -#include + namespace vrv { @@ -50,25 +50,25 @@ class AttMordentLog: public Att * to the default value) **/ ///@{ - void SetForm(std::string form_) { m_form = form_; }; - std::string GetForm() const { return m_form; }; + void SetForm(mordentLog_FORM form_) { m_form = form_; }; + mordentLog_FORM GetForm() const { return m_form; }; bool HasForm( ); // - void SetLong(std::string long_) { m_long = long_; }; - std::string GetLong() const { return m_long; }; + void SetLong(data_BOOLEAN long_) { m_long = long_; }; + data_BOOLEAN GetLong() const { return m_long; }; bool HasLong( ); ///@} private: /** Records the appearance and usually the function of the bar line. **/ - std::string m_form; + mordentLog_FORM m_form; /** * When the long attribute is set to 'yes', a double or long mordent, consisting of * 5 notes, is indicated. **/ - std::string m_long; + data_BOOLEAN m_long; /* include */ }; @@ -98,8 +98,8 @@ class AttOrnam: public Att * to the default value) **/ ///@{ - void SetOrnam(std::string ornam_) { m_ornam = ornam_; }; - std::string GetOrnam() const { return m_ornam; }; + void SetOrnam(data_ORNAM_cmn ornam_) { m_ornam = ornam_; }; + data_ORNAM_cmn GetOrnam() const { return m_ornam; }; bool HasOrnam( ); ///@} @@ -110,7 +110,7 @@ class AttOrnam: public Att * If visual information about the ornament is needed, then one of the elements * that represents an ornament (mordent, trill, or turn) should be employed. **/ - std::string m_ornam; + data_ORNAM_cmn m_ornam; /* include */ }; @@ -140,22 +140,22 @@ class AttOrnamentaccid: public Att * to the default value) **/ ///@{ - void SetAccidupper(std::string accidupper_) { m_accidupper = accidupper_; }; - std::string GetAccidupper() const { return m_accidupper; }; + void SetAccidupper(data_ACCIDENTAL_EXPLICIT accidupper_) { m_accidupper = accidupper_; }; + data_ACCIDENTAL_EXPLICIT GetAccidupper() const { return m_accidupper; }; bool HasAccidupper( ); // - void SetAccidlower(std::string accidlower_) { m_accidlower = accidlower_; }; - std::string GetAccidlower() const { return m_accidlower; }; + void SetAccidlower(data_ACCIDENTAL_EXPLICIT accidlower_) { m_accidlower = accidlower_; }; + data_ACCIDENTAL_EXPLICIT GetAccidlower() const { return m_accidlower; }; bool HasAccidlower( ); ///@} private: /** Records the written accidental associated with an upper neighboring note. **/ - std::string m_accidupper; + data_ACCIDENTAL_EXPLICIT m_accidupper; /** Records the written accidental associated with a lower neighboring note. **/ - std::string m_accidlower; + data_ACCIDENTAL_EXPLICIT m_accidlower; /* include */ }; @@ -185,13 +185,13 @@ class AttTurnLog: public Att * to the default value) **/ ///@{ - void SetDelayed(std::string delayed_) { m_delayed = delayed_; }; - std::string GetDelayed() const { return m_delayed; }; + void SetDelayed(data_BOOLEAN delayed_) { m_delayed = delayed_; }; + data_BOOLEAN GetDelayed() const { return m_delayed; }; bool HasDelayed( ); // - void SetForm(std::string form_) { m_form = form_; }; - std::string GetForm() const { return m_form; }; + void SetForm(turnLog_FORM form_) { m_form = form_; }; + turnLog_FORM GetForm() const { return m_form; }; bool HasForm( ); ///@} @@ -202,9 +202,9 @@ class AttTurnLog: public Att * of the beat. * See Read, p. 246. **/ - std::string m_delayed; + data_BOOLEAN m_delayed; /** Records the appearance and usually the function of the bar line. **/ - std::string m_form; + turnLog_FORM m_form; /* include */ }; diff --git a/libmei/atts_critapp.cpp b/libmei/atts_critapp.cpp index 3a9afc8da86..ce89eb9a8a8 100644 --- a/libmei/atts_critapp.cpp +++ b/libmei/atts_critapp.cpp @@ -42,7 +42,7 @@ void AttCrit::ResetCrit() { m_cause = ""; } -bool AttCrit::ReadCrit( pugi::xml_node element ) { +bool AttCrit::ReadCrit( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("cause")) { this->SetCause(StrToStr(element.attribute("cause").value())); @@ -52,7 +52,7 @@ bool AttCrit::ReadCrit( pugi::xml_node element ) { return hasAttribute; } -bool AttCrit::WriteCrit( pugi::xml_node element ) { +bool AttCrit::WriteCrit( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasCause()) { element.append_attribute("cause") = StrToStr(this->GetCause()).c_str(); @@ -85,7 +85,7 @@ void AttSource::ResetSource() { m_source = ""; } -bool AttSource::ReadSource( pugi::xml_node element ) { +bool AttSource::ReadSource( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("source")) { this->SetSource(StrToStr(element.attribute("source").value())); @@ -95,7 +95,7 @@ bool AttSource::ReadSource( pugi::xml_node element ) { return hasAttribute; } -bool AttSource::WriteSource( pugi::xml_node element ) { +bool AttSource::WriteSource( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasSource()) { element.append_attribute("source") = StrToStr(this->GetSource()).c_str(); diff --git a/libmei/atts_critapp.h b/libmei/atts_critapp.h index 3b1d043e915..a9225153df4 100644 --- a/libmei/atts_critapp.h +++ b/libmei/atts_critapp.h @@ -16,7 +16,7 @@ #define __VRV_ATTS_CRITAPP_H__ #include "att.h" -#include "att_classes.h" +#include "attdef.h" #include "pugixml.hpp" //---------------------------------------------------------------------------- diff --git a/libmei/atts_edittrans.cpp b/libmei/atts_edittrans.cpp index 699fdb5daba..60eb56d1a46 100644 --- a/libmei/atts_edittrans.cpp +++ b/libmei/atts_edittrans.cpp @@ -42,7 +42,7 @@ void AttAgentident::ResetAgentident() { m_agent = ""; } -bool AttAgentident::ReadAgentident( pugi::xml_node element ) { +bool AttAgentident::ReadAgentident( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("agent")) { this->SetAgent(StrToStr(element.attribute("agent").value())); @@ -52,7 +52,7 @@ bool AttAgentident::ReadAgentident( pugi::xml_node element ) { return hasAttribute; } -bool AttAgentident::WriteAgentident( pugi::xml_node element ) { +bool AttAgentident::WriteAgentident( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasAgent()) { element.append_attribute("agent") = StrToStr(this->GetAgent()).c_str(); @@ -82,14 +82,14 @@ AttEvidence::~AttEvidence() { } void AttEvidence::ResetEvidence() { - m_cert = ""; + m_cert = CERTAINTY_NONE; m_evidence = ""; } -bool AttEvidence::ReadEvidence( pugi::xml_node element ) { +bool AttEvidence::ReadEvidence( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("cert")) { - this->SetCert(StrToStr(element.attribute("cert").value())); + this->SetCert(StrToCertainty(element.attribute("cert").value())); element.remove_attribute("cert"); hasAttribute = true; } @@ -101,10 +101,10 @@ bool AttEvidence::ReadEvidence( pugi::xml_node element ) { return hasAttribute; } -bool AttEvidence::WriteEvidence( pugi::xml_node element ) { +bool AttEvidence::WriteEvidence( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasCert()) { - element.append_attribute("cert") = StrToStr(this->GetCert()).c_str(); + element.append_attribute("cert") = CertaintyToStr(this->GetCert()).c_str(); wroteAttribute = true; } if (this->HasEvidence()) { @@ -116,7 +116,7 @@ bool AttEvidence::WriteEvidence( pugi::xml_node element ) { bool AttEvidence::HasCert( ) { - return (m_cert != ""); + return (m_cert != CERTAINTY_NONE); } bool AttEvidence::HasEvidence( ) @@ -143,7 +143,7 @@ void AttExtent::ResetExtent() { m_extent = ""; } -bool AttExtent::ReadExtent( pugi::xml_node element ) { +bool AttExtent::ReadExtent( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("extent")) { this->SetExtent(StrToStr(element.attribute("extent").value())); @@ -153,7 +153,7 @@ bool AttExtent::ReadExtent( pugi::xml_node element ) { return hasAttribute; } -bool AttExtent::WriteExtent( pugi::xml_node element ) { +bool AttExtent::WriteExtent( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasExtent()) { element.append_attribute("extent") = StrToStr(this->GetExtent()).c_str(); @@ -186,7 +186,7 @@ void AttReasonident::ResetReasonident() { m_reason = ""; } -bool AttReasonident::ReadReasonident( pugi::xml_node element ) { +bool AttReasonident::ReadReasonident( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("reason")) { this->SetReason(StrToStr(element.attribute("reason").value())); @@ -196,7 +196,7 @@ bool AttReasonident::ReadReasonident( pugi::xml_node element ) { return hasAttribute; } -bool AttReasonident::WriteReasonident( pugi::xml_node element ) { +bool AttReasonident::WriteReasonident( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasReason()) { element.append_attribute("reason") = StrToStr(this->GetReason()).c_str(); @@ -226,7 +226,7 @@ bool Att::SetEdittrans( Object *element, std::string attrType, std::string attrV AttEvidence *att = dynamic_cast(element); assert( att ); if (attrType == "cert") { - att->SetCert(att->StrToStr(attrValue)); + att->SetCert(att->StrToCertainty(attrValue)); return true; } if (attrType == "evidence") { @@ -266,7 +266,7 @@ void Att::GetEdittrans( Object *element, ArrayOfStrAttr *attributes ) { AttEvidence *att = dynamic_cast(element); assert( att ); if (att->HasCert()) { - attributes->push_back(std::make_pair("cert", att->StrToStr(att->GetCert()))); + attributes->push_back(std::make_pair("cert", att->CertaintyToStr(att->GetCert()))); } if (att->HasEvidence()) { attributes->push_back(std::make_pair("evidence", att->StrToStr(att->GetEvidence()))); diff --git a/libmei/atts_edittrans.h b/libmei/atts_edittrans.h index 4107457da55..4ff1b6ae7eb 100644 --- a/libmei/atts_edittrans.h +++ b/libmei/atts_edittrans.h @@ -16,7 +16,7 @@ #define __VRV_ATTS_EDITTRANS_H__ #include "att.h" -#include "att_classes.h" +#include "attdef.h" #include "pugixml.hpp" //---------------------------------------------------------------------------- @@ -91,8 +91,8 @@ class AttEvidence: public Att * to the default value) **/ ///@{ - void SetCert(std::string cert_) { m_cert = cert_; }; - std::string GetCert() const { return m_cert; }; + void SetCert(data_CERTAINTY cert_) { m_cert = cert_; }; + data_CERTAINTY GetCert() const { return m_cert; }; bool HasCert( ); // @@ -104,7 +104,7 @@ class AttEvidence: public Att private: /** Signifies the degree of certainty or precision associated with a feature. **/ - std::string m_cert; + data_CERTAINTY m_cert; /** * Indicates the nature of the evidence supporting the reliability or accuracy of * the intervention or interpretation. diff --git a/libmei/atts_facsimile.cpp b/libmei/atts_facsimile.cpp index f7147eba268..edc0ede7ac0 100644 --- a/libmei/atts_facsimile.cpp +++ b/libmei/atts_facsimile.cpp @@ -39,23 +39,23 @@ AttFacsimile::~AttFacsimile() { } void AttFacsimile::ResetFacsimile() { - m_facs = ""; + m_facs = URIS_NONE; } -bool AttFacsimile::ReadFacsimile( pugi::xml_node element ) { +bool AttFacsimile::ReadFacsimile( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("facs")) { - this->SetFacs(StrToStr(element.attribute("facs").value())); + this->SetFacs(StrToUris(element.attribute("facs").value())); element.remove_attribute("facs"); hasAttribute = true; } return hasAttribute; } -bool AttFacsimile::WriteFacsimile( pugi::xml_node element ) { +bool AttFacsimile::WriteFacsimile( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasFacs()) { - element.append_attribute("facs") = StrToStr(this->GetFacs()).c_str(); + element.append_attribute("facs") = UrisToStr(this->GetFacs()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -63,7 +63,7 @@ bool AttFacsimile::WriteFacsimile( pugi::xml_node element ) { bool AttFacsimile::HasFacs( ) { - return (m_facs != ""); + return (m_facs != URIS_NONE); } @@ -76,7 +76,7 @@ bool Att::SetFacsimile( Object *element, std::string attrType, std::string attrV AttFacsimile *att = dynamic_cast(element); assert( att ); if (attrType == "facs") { - att->SetFacs(att->StrToStr(attrValue)); + att->SetFacs(att->StrToUris(attrValue)); return true; } } @@ -89,7 +89,7 @@ void Att::GetFacsimile( Object *element, ArrayOfStrAttr *attributes ) { AttFacsimile *att = dynamic_cast(element); assert( att ); if (att->HasFacs()) { - attributes->push_back(std::make_pair("facs", att->StrToStr(att->GetFacs()))); + attributes->push_back(std::make_pair("facs", att->UrisToStr(att->GetFacs()))); } } diff --git a/libmei/atts_facsimile.h b/libmei/atts_facsimile.h index f8435d5ec91..d056f667ee6 100644 --- a/libmei/atts_facsimile.h +++ b/libmei/atts_facsimile.h @@ -16,12 +16,12 @@ #define __VRV_ATTS_FACSIMILE_H__ #include "att.h" -#include "att_classes.h" +#include "attdef.h" #include "pugixml.hpp" //---------------------------------------------------------------------------- -#include + namespace vrv { @@ -50,8 +50,8 @@ class AttFacsimile: public Att * to the default value) **/ ///@{ - void SetFacs(std::string facs_) { m_facs = facs_; }; - std::string GetFacs() const { return m_facs; }; + void SetFacs(data_URIS facs_) { m_facs = facs_; }; + data_URIS GetFacs() const { return m_facs; }; bool HasFacs( ); ///@} @@ -61,7 +61,7 @@ class AttFacsimile: public Att * Permits the current element to reference a facsimile image or image zone which * corresponds to it. **/ - std::string m_facs; + data_URIS m_facs; /** * Test diff --git a/libmei/atts_figtable.cpp b/libmei/atts_figtable.cpp index 301966496cb..357fa206678 100644 --- a/libmei/atts_figtable.cpp +++ b/libmei/atts_figtable.cpp @@ -39,11 +39,11 @@ AttTabular::~AttTabular() { } void AttTabular::ResetTabular() { - m_colspanInt = 0; - m_rowspanInt = 0; + m_colspan = 0; + m_rowspan = 0; } -bool AttTabular::ReadTabular( pugi::xml_node element ) { +bool AttTabular::ReadTabular( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("colspan")) { this->SetColspan(StrToInt(element.attribute("colspan").value())); @@ -58,7 +58,7 @@ bool AttTabular::ReadTabular( pugi::xml_node element ) { return hasAttribute; } -bool AttTabular::WriteTabular( pugi::xml_node element ) { +bool AttTabular::WriteTabular( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasColspan()) { element.append_attribute("colspan") = IntToStr(this->GetColspan()).c_str(); @@ -73,12 +73,12 @@ bool AttTabular::WriteTabular( pugi::xml_node element ) { bool AttTabular::HasColspan( ) { - return (m_colspanInt != 0); + return (m_colspan != 0); } bool AttTabular::HasRowspan( ) { - return (m_rowspanInt != 0); + return (m_rowspan != 0); } @@ -88,11 +88,11 @@ bool Att::SetFigtable( Object *element, std::string attrType, std::string attrVa if (element->HasAttClass( ATT_TABULAR ) ) { AttTabular *att = dynamic_cast(element); assert( att ); - if (attrType == "colspanInt") { + if (attrType == "colspan") { att->SetColspan(att->StrToInt(attrValue)); return true; } - if (attrType == "rowspanInt") { + if (attrType == "rowspan") { att->SetRowspan(att->StrToInt(attrValue)); return true; } @@ -106,10 +106,10 @@ void Att::GetFigtable( Object *element, ArrayOfStrAttr *attributes ) { AttTabular *att = dynamic_cast(element); assert( att ); if (att->HasColspan()) { - attributes->push_back(std::make_pair("colspanInt", att->IntToStr(att->GetColspan()))); + attributes->push_back(std::make_pair("colspan", att->IntToStr(att->GetColspan()))); } if (att->HasRowspan()) { - attributes->push_back(std::make_pair("rowspanInt", att->IntToStr(att->GetRowspan()))); + attributes->push_back(std::make_pair("rowspan", att->IntToStr(att->GetRowspan()))); } } diff --git a/libmei/atts_figtable.h b/libmei/atts_figtable.h index 89dff3b3e74..04f6083d56a 100644 --- a/libmei/atts_figtable.h +++ b/libmei/atts_figtable.h @@ -16,7 +16,7 @@ #define __VRV_ATTS_FIGTABLE_H__ #include "att.h" -#include "att_classes.h" +#include "attdef.h" #include "pugixml.hpp" //---------------------------------------------------------------------------- @@ -50,22 +50,22 @@ class AttTabular: public Att * to the default value) **/ ///@{ - void SetColspan(int colspanInt_) { m_colspanInt = colspanInt_; }; - int GetColspan() const { return m_colspanInt; }; + void SetColspan(int colspan_) { m_colspan = colspan_; }; + int GetColspan() const { return m_colspan; }; bool HasColspan( ); // - void SetRowspan(int rowspanInt_) { m_rowspanInt = rowspanInt_; }; - int GetRowspan() const { return m_rowspanInt; }; + void SetRowspan(int rowspan_) { m_rowspan = rowspan_; }; + int GetRowspan() const { return m_rowspan; }; bool HasRowspan( ); ///@} private: /** The number of columns spanned by this cell. **/ - int m_colspanInt; + int m_colspan; /** The number of rows spanned by this cell. **/ - int m_rowspanInt; + int m_rowspan; /* include */ }; diff --git a/libmei/atts_harmony.cpp b/libmei/atts_harmony.cpp index 25a1126c5e3..b0e30b2ffd8 100644 --- a/libmei/atts_harmony.cpp +++ b/libmei/atts_harmony.cpp @@ -39,23 +39,23 @@ AttFretlocation::~AttFretlocation() { } void AttFretlocation::ResetFretlocation() { - m_fret = ""; + m_fret = FRET_NONE; } -bool AttFretlocation::ReadFretlocation( pugi::xml_node element ) { +bool AttFretlocation::ReadFretlocation( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("fret")) { - this->SetFret(StrToStr(element.attribute("fret").value())); + this->SetFret(StrToFret(element.attribute("fret").value())); element.remove_attribute("fret"); hasAttribute = true; } return hasAttribute; } -bool AttFretlocation::WriteFretlocation( pugi::xml_node element ) { +bool AttFretlocation::WriteFretlocation( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasFret()) { - element.append_attribute("fret") = StrToStr(this->GetFret()).c_str(); + element.append_attribute("fret") = FretToStr(this->GetFret()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -63,7 +63,7 @@ bool AttFretlocation::WriteFretlocation( pugi::xml_node element ) { bool AttFretlocation::HasFret( ) { - return (m_fret != ""); + return (m_fret != FRET_NONE); } @@ -85,7 +85,7 @@ void AttHarmLog::ResetHarmLog() { m_chordref = ""; } -bool AttHarmLog::ReadHarmLog( pugi::xml_node element ) { +bool AttHarmLog::ReadHarmLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("chordref")) { this->SetChordref(StrToStr(element.attribute("chordref").value())); @@ -95,7 +95,7 @@ bool AttHarmLog::ReadHarmLog( pugi::xml_node element ) { return hasAttribute; } -bool AttHarmLog::WriteHarmLog( pugi::xml_node element ) { +bool AttHarmLog::WriteHarmLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasChordref()) { element.append_attribute("chordref") = StrToStr(this->GetChordref()).c_str(); @@ -125,23 +125,23 @@ AttHarmVis::~AttHarmVis() { } void AttHarmVis::ResetHarmVis() { - m_rendgrid = ""; + m_rendgrid = harmVis_RENDGRID_NONE; } -bool AttHarmVis::ReadHarmVis( pugi::xml_node element ) { +bool AttHarmVis::ReadHarmVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("rendgrid")) { - this->SetRendgrid(StrToStr(element.attribute("rendgrid").value())); + this->SetRendgrid(StrToHarmVisRendgrid(element.attribute("rendgrid").value())); element.remove_attribute("rendgrid"); hasAttribute = true; } return hasAttribute; } -bool AttHarmVis::WriteHarmVis( pugi::xml_node element ) { +bool AttHarmVis::WriteHarmVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasRendgrid()) { - element.append_attribute("rendgrid") = StrToStr(this->GetRendgrid()).c_str(); + element.append_attribute("rendgrid") = HarmVisRendgridToStr(this->GetRendgrid()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -149,7 +149,7 @@ bool AttHarmVis::WriteHarmVis( pugi::xml_node element ) { bool AttHarmVis::HasRendgrid( ) { - return (m_rendgrid != ""); + return (m_rendgrid != harmVis_RENDGRID_NONE); } @@ -160,7 +160,7 @@ bool Att::SetHarmony( Object *element, std::string attrType, std::string attrVal AttFretlocation *att = dynamic_cast(element); assert( att ); if (attrType == "fret") { - att->SetFret(att->StrToStr(attrValue)); + att->SetFret(att->StrToFret(attrValue)); return true; } } @@ -176,7 +176,7 @@ bool Att::SetHarmony( Object *element, std::string attrType, std::string attrVal AttHarmVis *att = dynamic_cast(element); assert( att ); if (attrType == "rendgrid") { - att->SetRendgrid(att->StrToStr(attrValue)); + att->SetRendgrid(att->StrToHarmVisRendgrid(attrValue)); return true; } } @@ -189,7 +189,7 @@ void Att::GetHarmony( Object *element, ArrayOfStrAttr *attributes ) { AttFretlocation *att = dynamic_cast(element); assert( att ); if (att->HasFret()) { - attributes->push_back(std::make_pair("fret", att->StrToStr(att->GetFret()))); + attributes->push_back(std::make_pair("fret", att->FretToStr(att->GetFret()))); } } if (element->HasAttClass( ATT_HARMLOG ) ) { @@ -203,7 +203,7 @@ void Att::GetHarmony( Object *element, ArrayOfStrAttr *attributes ) { AttHarmVis *att = dynamic_cast(element); assert( att ); if (att->HasRendgrid()) { - attributes->push_back(std::make_pair("rendgrid", att->StrToStr(att->GetRendgrid()))); + attributes->push_back(std::make_pair("rendgrid", att->HarmVisRendgridToStr(att->GetRendgrid()))); } } diff --git a/libmei/atts_harmony.h b/libmei/atts_harmony.h index 4986a53ad77..ef47fb6e408 100644 --- a/libmei/atts_harmony.h +++ b/libmei/atts_harmony.h @@ -16,7 +16,7 @@ #define __VRV_ATTS_HARMONY_H__ #include "att.h" -#include "att_classes.h" +#include "attdef.h" #include "pugixml.hpp" //---------------------------------------------------------------------------- @@ -50,15 +50,15 @@ class AttFretlocation: public Att * to the default value) **/ ///@{ - void SetFret(std::string fret_) { m_fret = fret_; }; - std::string GetFret() const { return m_fret; }; + void SetFret(data_FRET fret_) { m_fret = fret_; }; + data_FRET GetFret() const { return m_fret; }; bool HasFret( ); ///@} private: /** Records the location at which a string should be stopped against a fret. **/ - std::string m_fret; + data_FRET m_fret; /* include */ }; @@ -126,15 +126,15 @@ class AttHarmVis: public Att * to the default value) **/ ///@{ - void SetRendgrid(std::string rendgrid_) { m_rendgrid = rendgrid_; }; - std::string GetRendgrid() const { return m_rendgrid; }; + void SetRendgrid(harmVis_RENDGRID rendgrid_) { m_rendgrid = rendgrid_; }; + harmVis_RENDGRID GetRendgrid() const { return m_rendgrid; }; bool HasRendgrid( ); ///@} private: /** Describes how the harmonic indication should be rendered. **/ - std::string m_rendgrid; + harmVis_RENDGRID m_rendgrid; /* include */ }; diff --git a/libmei/atts_header.cpp b/libmei/atts_header.cpp index a710e453c4a..8a29ebdc851 100644 --- a/libmei/atts_header.cpp +++ b/libmei/atts_header.cpp @@ -39,23 +39,23 @@ AttRegularmethod::~AttRegularmethod() { } void AttRegularmethod::ResetRegularmethod() { - m_method = ""; + m_method = regularmethod_METHOD_NONE; } -bool AttRegularmethod::ReadRegularmethod( pugi::xml_node element ) { +bool AttRegularmethod::ReadRegularmethod( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("method")) { - this->SetMethod(StrToStr(element.attribute("method").value())); + this->SetMethod(StrToRegularmethodMethod(element.attribute("method").value())); element.remove_attribute("method"); hasAttribute = true; } return hasAttribute; } -bool AttRegularmethod::WriteRegularmethod( pugi::xml_node element ) { +bool AttRegularmethod::WriteRegularmethod( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasMethod()) { - element.append_attribute("method") = StrToStr(this->GetMethod()).c_str(); + element.append_attribute("method") = RegularmethodMethodToStr(this->GetMethod()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -63,7 +63,7 @@ bool AttRegularmethod::WriteRegularmethod( pugi::xml_node element ) { bool AttRegularmethod::HasMethod( ) { - return (m_method != ""); + return (m_method != regularmethod_METHOD_NONE); } @@ -74,7 +74,7 @@ bool Att::SetHeader( Object *element, std::string attrType, std::string attrValu AttRegularmethod *att = dynamic_cast(element); assert( att ); if (attrType == "method") { - att->SetMethod(att->StrToStr(attrValue)); + att->SetMethod(att->StrToRegularmethodMethod(attrValue)); return true; } } @@ -87,7 +87,7 @@ void Att::GetHeader( Object *element, ArrayOfStrAttr *attributes ) { AttRegularmethod *att = dynamic_cast(element); assert( att ); if (att->HasMethod()) { - attributes->push_back(std::make_pair("method", att->StrToStr(att->GetMethod()))); + attributes->push_back(std::make_pair("method", att->RegularmethodMethodToStr(att->GetMethod()))); } } diff --git a/libmei/atts_header.h b/libmei/atts_header.h index 95ca2abdfac..cc1e5840860 100644 --- a/libmei/atts_header.h +++ b/libmei/atts_header.h @@ -16,12 +16,12 @@ #define __VRV_ATTS_HEADER_H__ #include "att.h" -#include "att_classes.h" +#include "attdef.h" #include "pugixml.hpp" //---------------------------------------------------------------------------- -#include + namespace vrv { @@ -50,15 +50,15 @@ class AttRegularmethod: public Att * to the default value) **/ ///@{ - void SetMethod(std::string method_) { m_method = method_; }; - std::string GetMethod() const { return m_method; }; + void SetMethod(regularmethod_METHOD method_) { m_method = method_; }; + regularmethod_METHOD GetMethod() const { return m_method; }; bool HasMethod( ); ///@} private: /** Indicates the method employed to mark corrections and normalizations. **/ - std::string m_method; + regularmethod_METHOD m_method; /* include */ }; diff --git a/libmei/atts_lyrics.cpp b/libmei/atts_lyrics.cpp index 62172baafaa..3429835ba93 100644 --- a/libmei/atts_lyrics.cpp +++ b/libmei/atts_lyrics.cpp @@ -39,14 +39,14 @@ AttVerseLog::~AttVerseLog() { } void AttVerseLog::ResetVerseLog() { - m_refrain = ""; + m_refrain = BOOLEAN_NONE; m_rhythm = ""; } -bool AttVerseLog::ReadVerseLog( pugi::xml_node element ) { +bool AttVerseLog::ReadVerseLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("refrain")) { - this->SetRefrain(StrToStr(element.attribute("refrain").value())); + this->SetRefrain(StrToBoolean(element.attribute("refrain").value())); element.remove_attribute("refrain"); hasAttribute = true; } @@ -58,10 +58,10 @@ bool AttVerseLog::ReadVerseLog( pugi::xml_node element ) { return hasAttribute; } -bool AttVerseLog::WriteVerseLog( pugi::xml_node element ) { +bool AttVerseLog::WriteVerseLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasRefrain()) { - element.append_attribute("refrain") = StrToStr(this->GetRefrain()).c_str(); + element.append_attribute("refrain") = BooleanToStr(this->GetRefrain()).c_str(); wroteAttribute = true; } if (this->HasRhythm()) { @@ -73,7 +73,7 @@ bool AttVerseLog::WriteVerseLog( pugi::xml_node element ) { bool AttVerseLog::HasRefrain( ) { - return (m_refrain != ""); + return (m_refrain != BOOLEAN_NONE); } bool AttVerseLog::HasRhythm( ) @@ -89,7 +89,7 @@ bool Att::SetLyrics( Object *element, std::string attrType, std::string attrValu AttVerseLog *att = dynamic_cast(element); assert( att ); if (attrType == "refrain") { - att->SetRefrain(att->StrToStr(attrValue)); + att->SetRefrain(att->StrToBoolean(attrValue)); return true; } if (attrType == "rhythm") { @@ -106,7 +106,7 @@ void Att::GetLyrics( Object *element, ArrayOfStrAttr *attributes ) { AttVerseLog *att = dynamic_cast(element); assert( att ); if (att->HasRefrain()) { - attributes->push_back(std::make_pair("refrain", att->StrToStr(att->GetRefrain()))); + attributes->push_back(std::make_pair("refrain", att->BooleanToStr(att->GetRefrain()))); } if (att->HasRhythm()) { attributes->push_back(std::make_pair("rhythm", att->StrToStr(att->GetRhythm()))); diff --git a/libmei/atts_lyrics.h b/libmei/atts_lyrics.h index 38fd739f1f8..fb56cce5d44 100644 --- a/libmei/atts_lyrics.h +++ b/libmei/atts_lyrics.h @@ -16,7 +16,7 @@ #define __VRV_ATTS_LYRICS_H__ #include "att.h" -#include "att_classes.h" +#include "attdef.h" #include "pugixml.hpp" //---------------------------------------------------------------------------- @@ -50,8 +50,8 @@ class AttVerseLog: public Att * to the default value) **/ ///@{ - void SetRefrain(std::string refrain_) { m_refrain = refrain_; }; - std::string GetRefrain() const { return m_refrain; }; + void SetRefrain(data_BOOLEAN refrain_) { m_refrain = refrain_; }; + data_BOOLEAN GetRefrain() const { return m_refrain; }; bool HasRefrain( ); // @@ -66,7 +66,7 @@ class AttVerseLog: public Att * Used to indicate a common, usually centered, refrain (Mup User's Guide, p. * 44). **/ - std::string m_refrain; + data_BOOLEAN m_refrain; /** * Used to specify a rhythm for the lyric syllables that differs from that of the * notes on the staff, e.g. diff --git a/libmei/atts_mei.cpp b/libmei/atts_mei.cpp index 1f03469b75a..8667933f231 100644 --- a/libmei/atts_mei.cpp +++ b/libmei/atts_mei.cpp @@ -39,14 +39,14 @@ AttNotationtype::~AttNotationtype() { } void AttNotationtype::ResetNotationtype() { - m_notationtype = ""; + m_notationtype = NOTATIONTYPE_NONE; m_notationsubtype = ""; } -bool AttNotationtype::ReadNotationtype( pugi::xml_node element ) { +bool AttNotationtype::ReadNotationtype( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("notationtype")) { - this->SetNotationtype(StrToStr(element.attribute("notationtype").value())); + this->SetNotationtype(StrToNotationtype(element.attribute("notationtype").value())); element.remove_attribute("notationtype"); hasAttribute = true; } @@ -58,10 +58,10 @@ bool AttNotationtype::ReadNotationtype( pugi::xml_node element ) { return hasAttribute; } -bool AttNotationtype::WriteNotationtype( pugi::xml_node element ) { +bool AttNotationtype::WriteNotationtype( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasNotationtype()) { - element.append_attribute("notationtype") = StrToStr(this->GetNotationtype()).c_str(); + element.append_attribute("notationtype") = NotationtypeToStr(this->GetNotationtype()).c_str(); wroteAttribute = true; } if (this->HasNotationsubtype()) { @@ -73,7 +73,7 @@ bool AttNotationtype::WriteNotationtype( pugi::xml_node element ) { bool AttNotationtype::HasNotationtype( ) { - return (m_notationtype != ""); + return (m_notationtype != NOTATIONTYPE_NONE); } bool AttNotationtype::HasNotationsubtype( ) @@ -89,7 +89,7 @@ bool Att::SetMei( Object *element, std::string attrType, std::string attrValue ) AttNotationtype *att = dynamic_cast(element); assert( att ); if (attrType == "notationtype") { - att->SetNotationtype(att->StrToStr(attrValue)); + att->SetNotationtype(att->StrToNotationtype(attrValue)); return true; } if (attrType == "notationsubtype") { @@ -106,7 +106,7 @@ void Att::GetMei( Object *element, ArrayOfStrAttr *attributes ) { AttNotationtype *att = dynamic_cast(element); assert( att ); if (att->HasNotationtype()) { - attributes->push_back(std::make_pair("notationtype", att->StrToStr(att->GetNotationtype()))); + attributes->push_back(std::make_pair("notationtype", att->NotationtypeToStr(att->GetNotationtype()))); } if (att->HasNotationsubtype()) { attributes->push_back(std::make_pair("notationsubtype", att->StrToStr(att->GetNotationsubtype()))); diff --git a/libmei/atts_mei.h b/libmei/atts_mei.h index bd996c2bfe1..90cb2713b7f 100644 --- a/libmei/atts_mei.h +++ b/libmei/atts_mei.h @@ -16,7 +16,7 @@ #define __VRV_ATTS_MEI_H__ #include "att.h" -#include "att_classes.h" +#include "attdef.h" #include "pugixml.hpp" //---------------------------------------------------------------------------- @@ -50,8 +50,8 @@ class AttNotationtype: public Att * to the default value) **/ ///@{ - void SetNotationtype(std::string notationtype_) { m_notationtype = notationtype_; }; - std::string GetNotationtype() const { return m_notationtype; }; + void SetNotationtype(data_NOTATIONTYPE notationtype_) { m_notationtype = notationtype_; }; + data_NOTATIONTYPE GetNotationtype() const { return m_notationtype; }; bool HasNotationtype( ); // @@ -66,7 +66,7 @@ class AttNotationtype: public Att * Contains classification of the notation contained or described by the element * bearing this attribute. **/ - std::string m_notationtype; + data_NOTATIONTYPE m_notationtype; /** * Provides any sub-classification of the notation contained or described by the * element, additional to that given by its notationtype attribute. diff --git a/libmei/atts_mensural.cpp b/libmei/atts_mensural.cpp index f5c6aa11609..8275885422a 100644 --- a/libmei/atts_mensural.cpp +++ b/libmei/atts_mensural.cpp @@ -39,23 +39,23 @@ AttLigatureLog::~AttLigatureLog() { } void AttLigatureLog::ResetLigatureLog() { - m_form = ""; + m_form = LIGATUREFORM_NONE; } -bool AttLigatureLog::ReadLigatureLog( pugi::xml_node element ) { +bool AttLigatureLog::ReadLigatureLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("form")) { - this->SetForm(StrToStr(element.attribute("form").value())); + this->SetForm(StrToLigatureform(element.attribute("form").value())); element.remove_attribute("form"); hasAttribute = true; } return hasAttribute; } -bool AttLigatureLog::WriteLigatureLog( pugi::xml_node element ) { +bool AttLigatureLog::WriteLigatureLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasForm()) { - element.append_attribute("form") = StrToStr(this->GetForm()).c_str(); + element.append_attribute("form") = LigatureformToStr(this->GetForm()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -63,7 +63,7 @@ bool AttLigatureLog::WriteLigatureLog( pugi::xml_node element ) { bool AttLigatureLog::HasForm( ) { - return (m_form != ""); + return (m_form != LIGATUREFORM_NONE); } @@ -82,14 +82,14 @@ AttMensurVis::~AttMensurVis() { } void AttMensurVis::ResetMensurVis() { - m_form = ""; + m_form = mensurVis_FORM_NONE; m_orient = ORIENTATION_NONE; } -bool AttMensurVis::ReadMensurVis( pugi::xml_node element ) { +bool AttMensurVis::ReadMensurVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("form")) { - this->SetForm(StrToStr(element.attribute("form").value())); + this->SetForm(StrToMensurVisForm(element.attribute("form").value())); element.remove_attribute("form"); hasAttribute = true; } @@ -101,10 +101,10 @@ bool AttMensurVis::ReadMensurVis( pugi::xml_node element ) { return hasAttribute; } -bool AttMensurVis::WriteMensurVis( pugi::xml_node element ) { +bool AttMensurVis::WriteMensurVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasForm()) { - element.append_attribute("form") = StrToStr(this->GetForm()).c_str(); + element.append_attribute("form") = MensurVisFormToStr(this->GetForm()).c_str(); wroteAttribute = true; } if (this->HasOrient()) { @@ -116,7 +116,7 @@ bool AttMensurVis::WriteMensurVis( pugi::xml_node element ) { bool AttMensurVis::HasForm( ) { - return (m_form != ""); + return (m_form != mensurVis_FORM_NONE); } bool AttMensurVis::HasOrient( ) @@ -147,15 +147,15 @@ void AttMensuralLog::ResetMensuralLog() { m_proportNumbase = -1; } -bool AttMensuralLog::ReadMensuralLog( pugi::xml_node element ) { +bool AttMensuralLog::ReadMensuralLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("mensur.dot")) { - this->SetMensurDot(StrToBool(element.attribute("mensur.dot").value())); + this->SetMensurDot(StrToBoolean(element.attribute("mensur.dot").value())); element.remove_attribute("mensur.dot"); hasAttribute = true; } if (element.attribute("mensur.sign")) { - this->SetMensurSign(StrToMensurationSign(element.attribute("mensur.sign").value())); + this->SetMensurSign(StrToMensurationsign(element.attribute("mensur.sign").value())); element.remove_attribute("mensur.sign"); hasAttribute = true; } @@ -177,14 +177,14 @@ bool AttMensuralLog::ReadMensuralLog( pugi::xml_node element ) { return hasAttribute; } -bool AttMensuralLog::WriteMensuralLog( pugi::xml_node element ) { +bool AttMensuralLog::WriteMensuralLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasMensurDot()) { - element.append_attribute("mensur.dot") = BoolToStr(this->GetMensurDot()).c_str(); + element.append_attribute("mensur.dot") = BooleanToStr(this->GetMensurDot()).c_str(); wroteAttribute = true; } if (this->HasMensurSign()) { - element.append_attribute("mensur.sign") = MensurationSignToStr(this->GetMensurSign()).c_str(); + element.append_attribute("mensur.sign") = MensurationsignToStr(this->GetMensurSign()).c_str(); wroteAttribute = true; } if (this->HasMensurSlash()) { @@ -249,7 +249,7 @@ void AttMensuralShared::ResetMensuralShared() { m_tempus = TEMPUS_NONE; } -bool AttMensuralShared::ReadMensuralShared( pugi::xml_node element ) { +bool AttMensuralShared::ReadMensuralShared( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("modusmaior")) { this->SetModusmaior(StrToModusmaior(element.attribute("modusmaior").value())); @@ -274,7 +274,7 @@ bool AttMensuralShared::ReadMensuralShared( pugi::xml_node element ) { return hasAttribute; } -bool AttMensuralShared::WriteMensuralShared( pugi::xml_node element ) { +bool AttMensuralShared::WriteMensuralShared( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasModusmaior()) { element.append_attribute("modusmaior") = ModusmaiorToStr(this->GetModusmaior()).c_str(); @@ -332,13 +332,13 @@ AttMensuralVis::~AttMensuralVis() { void AttMensuralVis::ResetMensuralVis() { m_mensurColor = ""; - m_mensurForm = ""; - m_mensurLoc = ""; - m_mensurOrient = ""; - m_mensurSize = ""; + m_mensurForm = mensuralVis_MENSURFORM_NONE; + m_mensurLoc = 0; + m_mensurOrient = ORIENTATION_NONE; + m_mensurSize = SIZE_NONE; } -bool AttMensuralVis::ReadMensuralVis( pugi::xml_node element ) { +bool AttMensuralVis::ReadMensuralVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("mensur.color")) { this->SetMensurColor(StrToStr(element.attribute("mensur.color").value())); @@ -346,48 +346,48 @@ bool AttMensuralVis::ReadMensuralVis( pugi::xml_node element ) { hasAttribute = true; } if (element.attribute("mensur.form")) { - this->SetMensurForm(StrToStr(element.attribute("mensur.form").value())); + this->SetMensurForm(StrToMensuralVisMensurform(element.attribute("mensur.form").value())); element.remove_attribute("mensur.form"); hasAttribute = true; } if (element.attribute("mensur.loc")) { - this->SetMensurLoc(StrToStr(element.attribute("mensur.loc").value())); + this->SetMensurLoc(StrToInt(element.attribute("mensur.loc").value())); element.remove_attribute("mensur.loc"); hasAttribute = true; } if (element.attribute("mensur.orient")) { - this->SetMensurOrient(StrToStr(element.attribute("mensur.orient").value())); + this->SetMensurOrient(StrToOrientation(element.attribute("mensur.orient").value())); element.remove_attribute("mensur.orient"); hasAttribute = true; } if (element.attribute("mensur.size")) { - this->SetMensurSize(StrToStr(element.attribute("mensur.size").value())); + this->SetMensurSize(StrToSize(element.attribute("mensur.size").value())); element.remove_attribute("mensur.size"); hasAttribute = true; } return hasAttribute; } -bool AttMensuralVis::WriteMensuralVis( pugi::xml_node element ) { +bool AttMensuralVis::WriteMensuralVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasMensurColor()) { element.append_attribute("mensur.color") = StrToStr(this->GetMensurColor()).c_str(); wroteAttribute = true; } if (this->HasMensurForm()) { - element.append_attribute("mensur.form") = StrToStr(this->GetMensurForm()).c_str(); + element.append_attribute("mensur.form") = MensuralVisMensurformToStr(this->GetMensurForm()).c_str(); wroteAttribute = true; } if (this->HasMensurLoc()) { - element.append_attribute("mensur.loc") = StrToStr(this->GetMensurLoc()).c_str(); + element.append_attribute("mensur.loc") = IntToStr(this->GetMensurLoc()).c_str(); wroteAttribute = true; } if (this->HasMensurOrient()) { - element.append_attribute("mensur.orient") = StrToStr(this->GetMensurOrient()).c_str(); + element.append_attribute("mensur.orient") = OrientationToStr(this->GetMensurOrient()).c_str(); wroteAttribute = true; } if (this->HasMensurSize()) { - element.append_attribute("mensur.size") = StrToStr(this->GetMensurSize()).c_str(); + element.append_attribute("mensur.size") = SizeToStr(this->GetMensurSize()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -400,22 +400,22 @@ bool AttMensuralVis::HasMensurColor( ) bool AttMensuralVis::HasMensurForm( ) { - return (m_mensurForm != ""); + return (m_mensurForm != mensuralVis_MENSURFORM_NONE); } bool AttMensuralVis::HasMensurLoc( ) { - return (m_mensurLoc != ""); + return (m_mensurLoc != 0); } bool AttMensuralVis::HasMensurOrient( ) { - return (m_mensurOrient != ""); + return (m_mensurOrient != ORIENTATION_NONE); } bool AttMensuralVis::HasMensurSize( ) { - return (m_mensurSize != ""); + return (m_mensurSize != SIZE_NONE); } @@ -434,23 +434,23 @@ AttNoteLogMensural::~AttNoteLogMensural() { } void AttNoteLogMensural::ResetNoteLogMensural() { - m_lig = LIGATURE_NONE; + m_lig = noteLogMensural_LIG_NONE; } -bool AttNoteLogMensural::ReadNoteLogMensural( pugi::xml_node element ) { +bool AttNoteLogMensural::ReadNoteLogMensural( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("lig")) { - this->SetLig(StrToLigature(element.attribute("lig").value())); + this->SetLig(StrToNoteLogMensuralLig(element.attribute("lig").value())); element.remove_attribute("lig"); hasAttribute = true; } return hasAttribute; } -bool AttNoteLogMensural::WriteNoteLogMensural( pugi::xml_node element ) { +bool AttNoteLogMensural::WriteNoteLogMensural( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasLig()) { - element.append_attribute("lig") = LigatureToStr(this->GetLig()).c_str(); + element.append_attribute("lig") = NoteLogMensuralLigToStr(this->GetLig()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -458,7 +458,7 @@ bool AttNoteLogMensural::WriteNoteLogMensural( pugi::xml_node element ) { bool AttNoteLogMensural::HasLig( ) { - return (m_lig != LIGATURE_NONE); + return (m_lig != noteLogMensural_LIG_NONE); } @@ -477,10 +477,10 @@ AttRestVisMensural::~AttRestVisMensural() { } void AttRestVisMensural::ResetRestVisMensural() { - m_spacesInt = 0; + m_spaces = 0; } -bool AttRestVisMensural::ReadRestVisMensural( pugi::xml_node element ) { +bool AttRestVisMensural::ReadRestVisMensural( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("spaces")) { this->SetSpaces(StrToInt(element.attribute("spaces").value())); @@ -490,7 +490,7 @@ bool AttRestVisMensural::ReadRestVisMensural( pugi::xml_node element ) { return hasAttribute; } -bool AttRestVisMensural::WriteRestVisMensural( pugi::xml_node element ) { +bool AttRestVisMensural::WriteRestVisMensural( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasSpaces()) { element.append_attribute("spaces") = IntToStr(this->GetSpaces()).c_str(); @@ -501,7 +501,7 @@ bool AttRestVisMensural::WriteRestVisMensural( pugi::xml_node element ) { bool AttRestVisMensural::HasSpaces( ) { - return (m_spacesInt != 0); + return (m_spaces != 0); } @@ -512,7 +512,7 @@ bool Att::SetMensural( Object *element, std::string attrType, std::string attrVa AttLigatureLog *att = dynamic_cast(element); assert( att ); if (attrType == "form") { - att->SetForm(att->StrToStr(attrValue)); + att->SetForm(att->StrToLigatureform(attrValue)); return true; } } @@ -520,7 +520,7 @@ bool Att::SetMensural( Object *element, std::string attrType, std::string attrVa AttMensurVis *att = dynamic_cast(element); assert( att ); if (attrType == "form") { - att->SetForm(att->StrToStr(attrValue)); + att->SetForm(att->StrToMensurVisForm(attrValue)); return true; } if (attrType == "orient") { @@ -532,11 +532,11 @@ bool Att::SetMensural( Object *element, std::string attrType, std::string attrVa AttMensuralLog *att = dynamic_cast(element); assert( att ); if (attrType == "mensurDot") { - att->SetMensurDot(att->StrToBool(attrValue)); + att->SetMensurDot(att->StrToBoolean(attrValue)); return true; } if (attrType == "mensurSign") { - att->SetMensurSign(att->StrToMensurationSign(attrValue)); + att->SetMensurSign(att->StrToMensurationsign(attrValue)); return true; } if (attrType == "mensurSlash") { @@ -580,19 +580,19 @@ bool Att::SetMensural( Object *element, std::string attrType, std::string attrVa return true; } if (attrType == "mensurForm") { - att->SetMensurForm(att->StrToStr(attrValue)); + att->SetMensurForm(att->StrToMensuralVisMensurform(attrValue)); return true; } if (attrType == "mensurLoc") { - att->SetMensurLoc(att->StrToStr(attrValue)); + att->SetMensurLoc(att->StrToInt(attrValue)); return true; } if (attrType == "mensurOrient") { - att->SetMensurOrient(att->StrToStr(attrValue)); + att->SetMensurOrient(att->StrToOrientation(attrValue)); return true; } if (attrType == "mensurSize") { - att->SetMensurSize(att->StrToStr(attrValue)); + att->SetMensurSize(att->StrToSize(attrValue)); return true; } } @@ -600,14 +600,14 @@ bool Att::SetMensural( Object *element, std::string attrType, std::string attrVa AttNoteLogMensural *att = dynamic_cast(element); assert( att ); if (attrType == "lig") { - att->SetLig(att->StrToLigature(attrValue)); + att->SetLig(att->StrToNoteLogMensuralLig(attrValue)); return true; } } if (element->HasAttClass( ATT_RESTVISMENSURAL ) ) { AttRestVisMensural *att = dynamic_cast(element); assert( att ); - if (attrType == "spacesInt") { + if (attrType == "spaces") { att->SetSpaces(att->StrToInt(attrValue)); return true; } @@ -621,14 +621,14 @@ void Att::GetMensural( Object *element, ArrayOfStrAttr *attributes ) { AttLigatureLog *att = dynamic_cast(element); assert( att ); if (att->HasForm()) { - attributes->push_back(std::make_pair("form", att->StrToStr(att->GetForm()))); + attributes->push_back(std::make_pair("form", att->LigatureformToStr(att->GetForm()))); } } if (element->HasAttClass( ATT_MENSURVIS ) ) { AttMensurVis *att = dynamic_cast(element); assert( att ); if (att->HasForm()) { - attributes->push_back(std::make_pair("form", att->StrToStr(att->GetForm()))); + attributes->push_back(std::make_pair("form", att->MensurVisFormToStr(att->GetForm()))); } if (att->HasOrient()) { attributes->push_back(std::make_pair("orient", att->OrientationToStr(att->GetOrient()))); @@ -638,10 +638,10 @@ void Att::GetMensural( Object *element, ArrayOfStrAttr *attributes ) { AttMensuralLog *att = dynamic_cast(element); assert( att ); if (att->HasMensurDot()) { - attributes->push_back(std::make_pair("mensurDot", att->BoolToStr(att->GetMensurDot()))); + attributes->push_back(std::make_pair("mensurDot", att->BooleanToStr(att->GetMensurDot()))); } if (att->HasMensurSign()) { - attributes->push_back(std::make_pair("mensurSign", att->MensurationSignToStr(att->GetMensurSign()))); + attributes->push_back(std::make_pair("mensurSign", att->MensurationsignToStr(att->GetMensurSign()))); } if (att->HasMensurSlash()) { attributes->push_back(std::make_pair("mensurSlash", att->IntToStr(att->GetMensurSlash()))); @@ -676,30 +676,30 @@ void Att::GetMensural( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("mensurColor", att->StrToStr(att->GetMensurColor()))); } if (att->HasMensurForm()) { - attributes->push_back(std::make_pair("mensurForm", att->StrToStr(att->GetMensurForm()))); + attributes->push_back(std::make_pair("mensurForm", att->MensuralVisMensurformToStr(att->GetMensurForm()))); } if (att->HasMensurLoc()) { - attributes->push_back(std::make_pair("mensurLoc", att->StrToStr(att->GetMensurLoc()))); + attributes->push_back(std::make_pair("mensurLoc", att->IntToStr(att->GetMensurLoc()))); } if (att->HasMensurOrient()) { - attributes->push_back(std::make_pair("mensurOrient", att->StrToStr(att->GetMensurOrient()))); + attributes->push_back(std::make_pair("mensurOrient", att->OrientationToStr(att->GetMensurOrient()))); } if (att->HasMensurSize()) { - attributes->push_back(std::make_pair("mensurSize", att->StrToStr(att->GetMensurSize()))); + attributes->push_back(std::make_pair("mensurSize", att->SizeToStr(att->GetMensurSize()))); } } if (element->HasAttClass( ATT_NOTELOGMENSURAL ) ) { AttNoteLogMensural *att = dynamic_cast(element); assert( att ); if (att->HasLig()) { - attributes->push_back(std::make_pair("lig", att->LigatureToStr(att->GetLig()))); + attributes->push_back(std::make_pair("lig", att->NoteLogMensuralLigToStr(att->GetLig()))); } } if (element->HasAttClass( ATT_RESTVISMENSURAL ) ) { AttRestVisMensural *att = dynamic_cast(element); assert( att ); if (att->HasSpaces()) { - attributes->push_back(std::make_pair("spacesInt", att->IntToStr(att->GetSpaces()))); + attributes->push_back(std::make_pair("spaces", att->IntToStr(att->GetSpaces()))); } } diff --git a/libmei/atts_mensural.h b/libmei/atts_mensural.h index 88b627b4c8b..ca346f3d976 100644 --- a/libmei/atts_mensural.h +++ b/libmei/atts_mensural.h @@ -16,7 +16,7 @@ #define __VRV_ATTS_MENSURAL_H__ #include "att.h" -#include "att_classes.h" +#include "attdef.h" #include "pugixml.hpp" //---------------------------------------------------------------------------- @@ -50,15 +50,15 @@ class AttLigatureLog: public Att * to the default value) **/ ///@{ - void SetForm(std::string form_) { m_form = form_; }; - std::string GetForm() const { return m_form; }; + void SetForm(data_LIGATUREFORM form_) { m_form = form_; }; + data_LIGATUREFORM GetForm() const { return m_form; }; bool HasForm( ); ///@} private: /** Records the appearance and usually the function of the bar line. **/ - std::string m_form; + data_LIGATUREFORM m_form; /* include */ }; @@ -88,8 +88,8 @@ class AttMensurVis: public Att * to the default value) **/ ///@{ - void SetForm(std::string form_) { m_form = form_; }; - std::string GetForm() const { return m_form; }; + void SetForm(mensurVis_FORM form_) { m_form = form_; }; + mensurVis_FORM GetForm() const { return m_form; }; bool HasForm( ); // @@ -101,7 +101,7 @@ class AttMensurVis: public Att private: /** Records the appearance and usually the function of the bar line. **/ - std::string m_form; + mensurVis_FORM m_form; /** Describes the rotation or reflection of the base symbol. **/ data_ORIENTATION m_orient; @@ -143,8 +143,8 @@ class AttMensuralLog: public Att bool HasMensurSign( ); // - void SetMensurSlash(char mensurSlash_) { m_mensurSlash = mensurSlash_; }; - char GetMensurSlash() const { return m_mensurSlash; }; + void SetMensurSlash(int mensurSlash_) { m_mensurSlash = mensurSlash_; }; + int GetMensurSlash() const { return m_mensurSlash; }; bool HasMensurSlash( ); // @@ -168,7 +168,7 @@ class AttMensuralLog: public Att * Indicates the number lines added to the mensuration sign. * For example, one slash is added for what we now call 'alla breve'. **/ - char m_mensurSlash; + int m_mensurSlash; /** * Together, proport.num and proport.numbase specify a proportional change as a * ratio, e.g., 1:3. @@ -274,23 +274,23 @@ class AttMensuralVis: public Att bool HasMensurColor( ); // - void SetMensurForm(std::string mensurForm_) { m_mensurForm = mensurForm_; }; - std::string GetMensurForm() const { return m_mensurForm; }; + void SetMensurForm(mensuralVis_MENSURFORM mensurForm_) { m_mensurForm = mensurForm_; }; + mensuralVis_MENSURFORM GetMensurForm() const { return m_mensurForm; }; bool HasMensurForm( ); // - void SetMensurLoc(std::string mensurLoc_) { m_mensurLoc = mensurLoc_; }; - std::string GetMensurLoc() const { return m_mensurLoc; }; + void SetMensurLoc(int mensurLoc_) { m_mensurLoc = mensurLoc_; }; + int GetMensurLoc() const { return m_mensurLoc; }; bool HasMensurLoc( ); // - void SetMensurOrient(std::string mensurOrient_) { m_mensurOrient = mensurOrient_; }; - std::string GetMensurOrient() const { return m_mensurOrient; }; + void SetMensurOrient(data_ORIENTATION mensurOrient_) { m_mensurOrient = mensurOrient_; }; + data_ORIENTATION GetMensurOrient() const { return m_mensurOrient; }; bool HasMensurOrient( ); // - void SetMensurSize(std::string mensurSize_) { m_mensurSize = mensurSize_; }; - std::string GetMensurSize() const { return m_mensurSize; }; + void SetMensurSize(data_SIZE mensurSize_) { m_mensurSize = mensurSize_; }; + data_SIZE GetMensurSize() const { return m_mensurSize; }; bool HasMensurSize( ); ///@} @@ -302,13 +302,13 @@ class AttMensuralVis: public Att **/ std::string m_mensurColor; /** Indicates whether the base symbol is written vertically or horizontally. **/ - std::string m_mensurForm; + mensuralVis_MENSURFORM m_mensurForm; /** Holds the staff location of the mensuration sign. **/ - std::string m_mensurLoc; + int m_mensurLoc; /** Describes the rotation or reflection of the base symbol. **/ - std::string m_mensurOrient; + data_ORIENTATION m_mensurOrient; /** Describes the relative size of the mensuration sign. **/ - std::string m_mensurSize; + data_SIZE m_mensurSize; /* include */ }; @@ -338,15 +338,15 @@ class AttNoteLogMensural: public Att * to the default value) **/ ///@{ - void SetLig(data_LIGATURE lig_) { m_lig = lig_; }; - data_LIGATURE GetLig() const { return m_lig; }; + void SetLig(noteLogMensural_LIG lig_) { m_lig = lig_; }; + noteLogMensural_LIG GetLig() const { return m_lig; }; bool HasLig( ); ///@} private: /** Indicates this element's participation in a ligature. **/ - data_LIGATURE m_lig; + noteLogMensural_LIG m_lig; /* include */ }; @@ -376,15 +376,15 @@ class AttRestVisMensural: public Att * to the default value) **/ ///@{ - void SetSpaces(int spacesInt_) { m_spacesInt = spacesInt_; }; - int GetSpaces() const { return m_spacesInt; }; + void SetSpaces(int spaces_) { m_spaces = spaces_; }; + int GetSpaces() const { return m_spaces; }; bool HasSpaces( ); ///@} private: /** States how many spaces are covered by the rest. **/ - int m_spacesInt; + int m_spaces; /* include */ }; diff --git a/libmei/atts_midi.cpp b/libmei/atts_midi.cpp index a0bb0e00977..be061bf25ea 100644 --- a/libmei/atts_midi.cpp +++ b/libmei/atts_midi.cpp @@ -39,26 +39,26 @@ AttChannelized::~AttChannelized() { } void AttChannelized::ResetChannelized() { - m_midiChannel = ""; - m_midiDuty = ""; - m_midiPort = ""; - m_midiTrackInt = 0; + m_midiChannel = MIDICHANNEL_NONE; + m_midiDuty = 0; + m_midiPort = MIDIVALUE_NONE; + m_midiTrack = 0; } -bool AttChannelized::ReadChannelized( pugi::xml_node element ) { +bool AttChannelized::ReadChannelized( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("midi.channel")) { - this->SetMidiChannel(StrToStr(element.attribute("midi.channel").value())); + this->SetMidiChannel(StrToMidichannel(element.attribute("midi.channel").value())); element.remove_attribute("midi.channel"); hasAttribute = true; } if (element.attribute("midi.duty")) { - this->SetMidiDuty(StrToStr(element.attribute("midi.duty").value())); + this->SetMidiDuty(StrToInt(element.attribute("midi.duty").value())); element.remove_attribute("midi.duty"); hasAttribute = true; } if (element.attribute("midi.port")) { - this->SetMidiPort(StrToStr(element.attribute("midi.port").value())); + this->SetMidiPort(StrToMidivalue(element.attribute("midi.port").value())); element.remove_attribute("midi.port"); hasAttribute = true; } @@ -70,18 +70,18 @@ bool AttChannelized::ReadChannelized( pugi::xml_node element ) { return hasAttribute; } -bool AttChannelized::WriteChannelized( pugi::xml_node element ) { +bool AttChannelized::WriteChannelized( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasMidiChannel()) { - element.append_attribute("midi.channel") = StrToStr(this->GetMidiChannel()).c_str(); + element.append_attribute("midi.channel") = MidichannelToStr(this->GetMidiChannel()).c_str(); wroteAttribute = true; } if (this->HasMidiDuty()) { - element.append_attribute("midi.duty") = StrToStr(this->GetMidiDuty()).c_str(); + element.append_attribute("midi.duty") = IntToStr(this->GetMidiDuty()).c_str(); wroteAttribute = true; } if (this->HasMidiPort()) { - element.append_attribute("midi.port") = StrToStr(this->GetMidiPort()).c_str(); + element.append_attribute("midi.port") = MidivalueToStr(this->GetMidiPort()).c_str(); wroteAttribute = true; } if (this->HasMidiTrack()) { @@ -93,22 +93,22 @@ bool AttChannelized::WriteChannelized( pugi::xml_node element ) { bool AttChannelized::HasMidiChannel( ) { - return (m_midiChannel != ""); + return (m_midiChannel != MIDICHANNEL_NONE); } bool AttChannelized::HasMidiDuty( ) { - return (m_midiDuty != ""); + return (m_midiDuty != 0); } bool AttChannelized::HasMidiPort( ) { - return (m_midiPort != ""); + return (m_midiPort != MIDIVALUE_NONE); } bool AttChannelized::HasMidiTrack( ) { - return (m_midiTrackInt != 0); + return (m_midiTrack != 0); } @@ -127,53 +127,53 @@ AttMidiinstrument::~AttMidiinstrument() { } void AttMidiinstrument::ResetMidiinstrument() { - m_midiInstrnum = ""; - m_midiInstrname = ""; - m_midiPan = ""; - m_midiVolume = ""; + m_midiInstrnum = MIDIVALUE_NONE; + m_midiInstrname = MIDINAMES_NONE; + m_midiPan = MIDIVALUE_NONE; + m_midiVolume = MIDIVALUE_NONE; } -bool AttMidiinstrument::ReadMidiinstrument( pugi::xml_node element ) { +bool AttMidiinstrument::ReadMidiinstrument( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("midi.instrnum")) { - this->SetMidiInstrnum(StrToStr(element.attribute("midi.instrnum").value())); + this->SetMidiInstrnum(StrToMidivalue(element.attribute("midi.instrnum").value())); element.remove_attribute("midi.instrnum"); hasAttribute = true; } if (element.attribute("midi.instrname")) { - this->SetMidiInstrname(StrToStr(element.attribute("midi.instrname").value())); + this->SetMidiInstrname(StrToMidinames(element.attribute("midi.instrname").value())); element.remove_attribute("midi.instrname"); hasAttribute = true; } if (element.attribute("midi.pan")) { - this->SetMidiPan(StrToStr(element.attribute("midi.pan").value())); + this->SetMidiPan(StrToMidivalue(element.attribute("midi.pan").value())); element.remove_attribute("midi.pan"); hasAttribute = true; } if (element.attribute("midi.volume")) { - this->SetMidiVolume(StrToStr(element.attribute("midi.volume").value())); + this->SetMidiVolume(StrToMidivalue(element.attribute("midi.volume").value())); element.remove_attribute("midi.volume"); hasAttribute = true; } return hasAttribute; } -bool AttMidiinstrument::WriteMidiinstrument( pugi::xml_node element ) { +bool AttMidiinstrument::WriteMidiinstrument( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasMidiInstrnum()) { - element.append_attribute("midi.instrnum") = StrToStr(this->GetMidiInstrnum()).c_str(); + element.append_attribute("midi.instrnum") = MidivalueToStr(this->GetMidiInstrnum()).c_str(); wroteAttribute = true; } if (this->HasMidiInstrname()) { - element.append_attribute("midi.instrname") = StrToStr(this->GetMidiInstrname()).c_str(); + element.append_attribute("midi.instrname") = MidinamesToStr(this->GetMidiInstrname()).c_str(); wroteAttribute = true; } if (this->HasMidiPan()) { - element.append_attribute("midi.pan") = StrToStr(this->GetMidiPan()).c_str(); + element.append_attribute("midi.pan") = MidivalueToStr(this->GetMidiPan()).c_str(); wroteAttribute = true; } if (this->HasMidiVolume()) { - element.append_attribute("midi.volume") = StrToStr(this->GetMidiVolume()).c_str(); + element.append_attribute("midi.volume") = MidivalueToStr(this->GetMidiVolume()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -181,22 +181,22 @@ bool AttMidiinstrument::WriteMidiinstrument( pugi::xml_node element ) { bool AttMidiinstrument::HasMidiInstrnum( ) { - return (m_midiInstrnum != ""); + return (m_midiInstrnum != MIDIVALUE_NONE); } bool AttMidiinstrument::HasMidiInstrname( ) { - return (m_midiInstrname != ""); + return (m_midiInstrname != MIDINAMES_NONE); } bool AttMidiinstrument::HasMidiPan( ) { - return (m_midiPan != ""); + return (m_midiPan != MIDIVALUE_NONE); } bool AttMidiinstrument::HasMidiVolume( ) { - return (m_midiVolume != ""); + return (m_midiVolume != MIDIVALUE_NONE); } @@ -215,10 +215,10 @@ AttMidinumber::~AttMidinumber() { } void AttMidinumber::ResetMidinumber() { - m_numInt = 0; + m_num = 0; } -bool AttMidinumber::ReadMidinumber( pugi::xml_node element ) { +bool AttMidinumber::ReadMidinumber( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("num")) { this->SetNum(StrToInt(element.attribute("num").value())); @@ -228,7 +228,7 @@ bool AttMidinumber::ReadMidinumber( pugi::xml_node element ) { return hasAttribute; } -bool AttMidinumber::WriteMidinumber( pugi::xml_node element ) { +bool AttMidinumber::WriteMidinumber( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasNum()) { element.append_attribute("num") = IntToStr(this->GetNum()).c_str(); @@ -239,7 +239,7 @@ bool AttMidinumber::WriteMidinumber( pugi::xml_node element ) { bool AttMidinumber::HasNum( ) { - return (m_numInt != 0); + return (m_num != 0); } @@ -258,23 +258,23 @@ AttMiditempo::~AttMiditempo() { } void AttMiditempo::ResetMiditempo() { - m_midiTempo = ""; + m_midiTempo = MIDITEMPO_NONE; } -bool AttMiditempo::ReadMiditempo( pugi::xml_node element ) { +bool AttMiditempo::ReadMiditempo( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("midi.tempo")) { - this->SetMidiTempo(StrToStr(element.attribute("midi.tempo").value())); + this->SetMidiTempo(StrToMiditempo(element.attribute("midi.tempo").value())); element.remove_attribute("midi.tempo"); hasAttribute = true; } return hasAttribute; } -bool AttMiditempo::WriteMiditempo( pugi::xml_node element ) { +bool AttMiditempo::WriteMiditempo( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasMidiTempo()) { - element.append_attribute("midi.tempo") = StrToStr(this->GetMidiTempo()).c_str(); + element.append_attribute("midi.tempo") = MiditempoToStr(this->GetMidiTempo()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -282,7 +282,7 @@ bool AttMiditempo::WriteMiditempo( pugi::xml_node element ) { bool AttMiditempo::HasMidiTempo( ) { - return (m_midiTempo != ""); + return (m_midiTempo != MIDITEMPO_NONE); } @@ -301,23 +301,23 @@ AttMidivalue::~AttMidivalue() { } void AttMidivalue::ResetMidivalue() { - m_val = ""; + m_val = MIDIVALUE_NONE; } -bool AttMidivalue::ReadMidivalue( pugi::xml_node element ) { +bool AttMidivalue::ReadMidivalue( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("val")) { - this->SetVal(StrToStr(element.attribute("val").value())); + this->SetVal(StrToMidivalue(element.attribute("val").value())); element.remove_attribute("val"); hasAttribute = true; } return hasAttribute; } -bool AttMidivalue::WriteMidivalue( pugi::xml_node element ) { +bool AttMidivalue::WriteMidivalue( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasVal()) { - element.append_attribute("val") = StrToStr(this->GetVal()).c_str(); + element.append_attribute("val") = MidivalueToStr(this->GetVal()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -325,7 +325,7 @@ bool AttMidivalue::WriteMidivalue( pugi::xml_node element ) { bool AttMidivalue::HasVal( ) { - return (m_val != ""); + return (m_val != MIDIVALUE_NONE); } @@ -344,23 +344,23 @@ AttMidivalue2::~AttMidivalue2() { } void AttMidivalue2::ResetMidivalue2() { - m_val2 = ""; + m_val2 = MIDIVALUE_NONE; } -bool AttMidivalue2::ReadMidivalue2( pugi::xml_node element ) { +bool AttMidivalue2::ReadMidivalue2( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("val2")) { - this->SetVal2(StrToStr(element.attribute("val2").value())); + this->SetVal2(StrToMidivalue(element.attribute("val2").value())); element.remove_attribute("val2"); hasAttribute = true; } return hasAttribute; } -bool AttMidivalue2::WriteMidivalue2( pugi::xml_node element ) { +bool AttMidivalue2::WriteMidivalue2( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasVal2()) { - element.append_attribute("val2") = StrToStr(this->GetVal2()).c_str(); + element.append_attribute("val2") = MidivalueToStr(this->GetVal2()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -368,7 +368,7 @@ bool AttMidivalue2::WriteMidivalue2( pugi::xml_node element ) { bool AttMidivalue2::HasVal2( ) { - return (m_val2 != ""); + return (m_val2 != MIDIVALUE_NONE); } @@ -387,23 +387,23 @@ AttMidivelocity::~AttMidivelocity() { } void AttMidivelocity::ResetMidivelocity() { - m_vel = ""; + m_vel = MIDIVALUE_NONE; } -bool AttMidivelocity::ReadMidivelocity( pugi::xml_node element ) { +bool AttMidivelocity::ReadMidivelocity( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("vel")) { - this->SetVel(StrToStr(element.attribute("vel").value())); + this->SetVel(StrToMidivalue(element.attribute("vel").value())); element.remove_attribute("vel"); hasAttribute = true; } return hasAttribute; } -bool AttMidivelocity::WriteMidivelocity( pugi::xml_node element ) { +bool AttMidivelocity::WriteMidivelocity( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasVel()) { - element.append_attribute("vel") = StrToStr(this->GetVel()).c_str(); + element.append_attribute("vel") = MidivalueToStr(this->GetVel()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -411,7 +411,7 @@ bool AttMidivelocity::WriteMidivelocity( pugi::xml_node element ) { bool AttMidivelocity::HasVel( ) { - return (m_vel != ""); + return (m_vel != MIDIVALUE_NONE); } @@ -430,10 +430,10 @@ AttTimebase::~AttTimebase() { } void AttTimebase::ResetTimebase() { - m_ppqInt = 0; + m_ppq = 0; } -bool AttTimebase::ReadTimebase( pugi::xml_node element ) { +bool AttTimebase::ReadTimebase( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("ppq")) { this->SetPpq(StrToInt(element.attribute("ppq").value())); @@ -443,7 +443,7 @@ bool AttTimebase::ReadTimebase( pugi::xml_node element ) { return hasAttribute; } -bool AttTimebase::WriteTimebase( pugi::xml_node element ) { +bool AttTimebase::WriteTimebase( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasPpq()) { element.append_attribute("ppq") = IntToStr(this->GetPpq()).c_str(); @@ -454,7 +454,7 @@ bool AttTimebase::WriteTimebase( pugi::xml_node element ) { bool AttTimebase::HasPpq( ) { - return (m_ppqInt != 0); + return (m_ppq != 0); } @@ -465,18 +465,18 @@ bool Att::SetMidi( Object *element, std::string attrType, std::string attrValue AttChannelized *att = dynamic_cast(element); assert( att ); if (attrType == "midiChannel") { - att->SetMidiChannel(att->StrToStr(attrValue)); + att->SetMidiChannel(att->StrToMidichannel(attrValue)); return true; } if (attrType == "midiDuty") { - att->SetMidiDuty(att->StrToStr(attrValue)); + att->SetMidiDuty(att->StrToInt(attrValue)); return true; } if (attrType == "midiPort") { - att->SetMidiPort(att->StrToStr(attrValue)); + att->SetMidiPort(att->StrToMidivalue(attrValue)); return true; } - if (attrType == "midiTrackInt") { + if (attrType == "midiTrack") { att->SetMidiTrack(att->StrToInt(attrValue)); return true; } @@ -485,26 +485,26 @@ bool Att::SetMidi( Object *element, std::string attrType, std::string attrValue AttMidiinstrument *att = dynamic_cast(element); assert( att ); if (attrType == "midiInstrnum") { - att->SetMidiInstrnum(att->StrToStr(attrValue)); + att->SetMidiInstrnum(att->StrToMidivalue(attrValue)); return true; } if (attrType == "midiInstrname") { - att->SetMidiInstrname(att->StrToStr(attrValue)); + att->SetMidiInstrname(att->StrToMidinames(attrValue)); return true; } if (attrType == "midiPan") { - att->SetMidiPan(att->StrToStr(attrValue)); + att->SetMidiPan(att->StrToMidivalue(attrValue)); return true; } if (attrType == "midiVolume") { - att->SetMidiVolume(att->StrToStr(attrValue)); + att->SetMidiVolume(att->StrToMidivalue(attrValue)); return true; } } if (element->HasAttClass( ATT_MIDINUMBER ) ) { AttMidinumber *att = dynamic_cast(element); assert( att ); - if (attrType == "numInt") { + if (attrType == "num") { att->SetNum(att->StrToInt(attrValue)); return true; } @@ -513,7 +513,7 @@ bool Att::SetMidi( Object *element, std::string attrType, std::string attrValue AttMiditempo *att = dynamic_cast(element); assert( att ); if (attrType == "midiTempo") { - att->SetMidiTempo(att->StrToStr(attrValue)); + att->SetMidiTempo(att->StrToMiditempo(attrValue)); return true; } } @@ -521,7 +521,7 @@ bool Att::SetMidi( Object *element, std::string attrType, std::string attrValue AttMidivalue *att = dynamic_cast(element); assert( att ); if (attrType == "val") { - att->SetVal(att->StrToStr(attrValue)); + att->SetVal(att->StrToMidivalue(attrValue)); return true; } } @@ -529,7 +529,7 @@ bool Att::SetMidi( Object *element, std::string attrType, std::string attrValue AttMidivalue2 *att = dynamic_cast(element); assert( att ); if (attrType == "val2") { - att->SetVal2(att->StrToStr(attrValue)); + att->SetVal2(att->StrToMidivalue(attrValue)); return true; } } @@ -537,14 +537,14 @@ bool Att::SetMidi( Object *element, std::string attrType, std::string attrValue AttMidivelocity *att = dynamic_cast(element); assert( att ); if (attrType == "vel") { - att->SetVel(att->StrToStr(attrValue)); + att->SetVel(att->StrToMidivalue(attrValue)); return true; } } if (element->HasAttClass( ATT_TIMEBASE ) ) { AttTimebase *att = dynamic_cast(element); assert( att ); - if (attrType == "ppqInt") { + if (attrType == "ppq") { att->SetPpq(att->StrToInt(attrValue)); return true; } @@ -558,74 +558,74 @@ void Att::GetMidi( Object *element, ArrayOfStrAttr *attributes ) { AttChannelized *att = dynamic_cast(element); assert( att ); if (att->HasMidiChannel()) { - attributes->push_back(std::make_pair("midiChannel", att->StrToStr(att->GetMidiChannel()))); + attributes->push_back(std::make_pair("midiChannel", att->MidichannelToStr(att->GetMidiChannel()))); } if (att->HasMidiDuty()) { - attributes->push_back(std::make_pair("midiDuty", att->StrToStr(att->GetMidiDuty()))); + attributes->push_back(std::make_pair("midiDuty", att->IntToStr(att->GetMidiDuty()))); } if (att->HasMidiPort()) { - attributes->push_back(std::make_pair("midiPort", att->StrToStr(att->GetMidiPort()))); + attributes->push_back(std::make_pair("midiPort", att->MidivalueToStr(att->GetMidiPort()))); } if (att->HasMidiTrack()) { - attributes->push_back(std::make_pair("midiTrackInt", att->IntToStr(att->GetMidiTrack()))); + attributes->push_back(std::make_pair("midiTrack", att->IntToStr(att->GetMidiTrack()))); } } if (element->HasAttClass( ATT_MIDIINSTRUMENT ) ) { AttMidiinstrument *att = dynamic_cast(element); assert( att ); if (att->HasMidiInstrnum()) { - attributes->push_back(std::make_pair("midiInstrnum", att->StrToStr(att->GetMidiInstrnum()))); + attributes->push_back(std::make_pair("midiInstrnum", att->MidivalueToStr(att->GetMidiInstrnum()))); } if (att->HasMidiInstrname()) { - attributes->push_back(std::make_pair("midiInstrname", att->StrToStr(att->GetMidiInstrname()))); + attributes->push_back(std::make_pair("midiInstrname", att->MidinamesToStr(att->GetMidiInstrname()))); } if (att->HasMidiPan()) { - attributes->push_back(std::make_pair("midiPan", att->StrToStr(att->GetMidiPan()))); + attributes->push_back(std::make_pair("midiPan", att->MidivalueToStr(att->GetMidiPan()))); } if (att->HasMidiVolume()) { - attributes->push_back(std::make_pair("midiVolume", att->StrToStr(att->GetMidiVolume()))); + attributes->push_back(std::make_pair("midiVolume", att->MidivalueToStr(att->GetMidiVolume()))); } } if (element->HasAttClass( ATT_MIDINUMBER ) ) { AttMidinumber *att = dynamic_cast(element); assert( att ); if (att->HasNum()) { - attributes->push_back(std::make_pair("numInt", att->IntToStr(att->GetNum()))); + attributes->push_back(std::make_pair("num", att->IntToStr(att->GetNum()))); } } if (element->HasAttClass( ATT_MIDITEMPO ) ) { AttMiditempo *att = dynamic_cast(element); assert( att ); if (att->HasMidiTempo()) { - attributes->push_back(std::make_pair("midiTempo", att->StrToStr(att->GetMidiTempo()))); + attributes->push_back(std::make_pair("midiTempo", att->MiditempoToStr(att->GetMidiTempo()))); } } if (element->HasAttClass( ATT_MIDIVALUE ) ) { AttMidivalue *att = dynamic_cast(element); assert( att ); if (att->HasVal()) { - attributes->push_back(std::make_pair("val", att->StrToStr(att->GetVal()))); + attributes->push_back(std::make_pair("val", att->MidivalueToStr(att->GetVal()))); } } if (element->HasAttClass( ATT_MIDIVALUE2 ) ) { AttMidivalue2 *att = dynamic_cast(element); assert( att ); if (att->HasVal2()) { - attributes->push_back(std::make_pair("val2", att->StrToStr(att->GetVal2()))); + attributes->push_back(std::make_pair("val2", att->MidivalueToStr(att->GetVal2()))); } } if (element->HasAttClass( ATT_MIDIVELOCITY ) ) { AttMidivelocity *att = dynamic_cast(element); assert( att ); if (att->HasVel()) { - attributes->push_back(std::make_pair("vel", att->StrToStr(att->GetVel()))); + attributes->push_back(std::make_pair("vel", att->MidivalueToStr(att->GetVel()))); } } if (element->HasAttClass( ATT_TIMEBASE ) ) { AttTimebase *att = dynamic_cast(element); assert( att ); if (att->HasPpq()) { - attributes->push_back(std::make_pair("ppqInt", att->IntToStr(att->GetPpq()))); + attributes->push_back(std::make_pair("ppq", att->IntToStr(att->GetPpq()))); } } diff --git a/libmei/atts_midi.h b/libmei/atts_midi.h index 4fd6801c466..b8f8cc137ea 100644 --- a/libmei/atts_midi.h +++ b/libmei/atts_midi.h @@ -16,12 +16,12 @@ #define __VRV_ATTS_MIDI_H__ #include "att.h" -#include "att_classes.h" +#include "attdef.h" #include "pugixml.hpp" //---------------------------------------------------------------------------- -#include + namespace vrv { @@ -50,36 +50,36 @@ class AttChannelized: public Att * to the default value) **/ ///@{ - void SetMidiChannel(std::string midiChannel_) { m_midiChannel = midiChannel_; }; - std::string GetMidiChannel() const { return m_midiChannel; }; + void SetMidiChannel(data_MIDICHANNEL midiChannel_) { m_midiChannel = midiChannel_; }; + data_MIDICHANNEL GetMidiChannel() const { return m_midiChannel; }; bool HasMidiChannel( ); // - void SetMidiDuty(std::string midiDuty_) { m_midiDuty = midiDuty_; }; - std::string GetMidiDuty() const { return m_midiDuty; }; + void SetMidiDuty(int midiDuty_) { m_midiDuty = midiDuty_; }; + int GetMidiDuty() const { return m_midiDuty; }; bool HasMidiDuty( ); // - void SetMidiPort(std::string midiPort_) { m_midiPort = midiPort_; }; - std::string GetMidiPort() const { return m_midiPort; }; + void SetMidiPort(data_MIDIVALUE midiPort_) { m_midiPort = midiPort_; }; + data_MIDIVALUE GetMidiPort() const { return m_midiPort; }; bool HasMidiPort( ); // - void SetMidiTrack(int midiTrackInt_) { m_midiTrackInt = midiTrackInt_; }; - int GetMidiTrack() const { return m_midiTrackInt; }; + void SetMidiTrack(int midiTrack_) { m_midiTrack = midiTrack_; }; + int GetMidiTrack() const { return m_midiTrack; }; bool HasMidiTrack( ); ///@} private: /** Records a MIDI channel value. **/ - std::string m_midiChannel; + data_MIDICHANNEL m_midiChannel; /** Specifies the 'on' part of the duty cycle as a percentage of a note's duration. **/ - std::string m_midiDuty; + int m_midiDuty; /** Sets the MIDI port value. **/ - std::string m_midiPort; + data_MIDIVALUE m_midiPort; /** Sets the MIDI track. **/ - int m_midiTrackInt; + int m_midiTrack; /* include */ }; @@ -109,39 +109,39 @@ class AttMidiinstrument: public Att * to the default value) **/ ///@{ - void SetMidiInstrnum(std::string midiInstrnum_) { m_midiInstrnum = midiInstrnum_; }; - std::string GetMidiInstrnum() const { return m_midiInstrnum; }; + void SetMidiInstrnum(data_MIDIVALUE midiInstrnum_) { m_midiInstrnum = midiInstrnum_; }; + data_MIDIVALUE GetMidiInstrnum() const { return m_midiInstrnum; }; bool HasMidiInstrnum( ); // - void SetMidiInstrname(std::string midiInstrname_) { m_midiInstrname = midiInstrname_; }; - std::string GetMidiInstrname() const { return m_midiInstrname; }; + void SetMidiInstrname(data_MIDINAMES midiInstrname_) { m_midiInstrname = midiInstrname_; }; + data_MIDINAMES GetMidiInstrname() const { return m_midiInstrname; }; bool HasMidiInstrname( ); // - void SetMidiPan(std::string midiPan_) { m_midiPan = midiPan_; }; - std::string GetMidiPan() const { return m_midiPan; }; + void SetMidiPan(data_MIDIVALUE midiPan_) { m_midiPan = midiPan_; }; + data_MIDIVALUE GetMidiPan() const { return m_midiPan; }; bool HasMidiPan( ); // - void SetMidiVolume(std::string midiVolume_) { m_midiVolume = midiVolume_; }; - std::string GetMidiVolume() const { return m_midiVolume; }; + void SetMidiVolume(data_MIDIVALUE midiVolume_) { m_midiVolume = midiVolume_; }; + data_MIDIVALUE GetMidiVolume() const { return m_midiVolume; }; bool HasMidiVolume( ); ///@} private: /** Sets the MIDI instrument number. **/ - std::string m_midiInstrnum; + data_MIDIVALUE m_midiInstrnum; /** Provides a General MIDI label for the MIDI instrument. **/ - std::string m_midiInstrname; + data_MIDINAMES m_midiInstrname; /** * Sets the instrument's position in a stereo field. * Values of 0 and 1 both pan left, 127 pans right, and 64 pans to the center. **/ - std::string m_midiPan; + data_MIDIVALUE m_midiPan; /** Sets the instrument's volume. **/ - std::string m_midiVolume; + data_MIDIVALUE m_midiVolume; /* include */ }; @@ -171,8 +171,8 @@ class AttMidinumber: public Att * to the default value) **/ ///@{ - void SetNum(int numInt_) { m_numInt = numInt_; }; - int GetNum() const { return m_numInt; }; + void SetNum(int num_) { m_num = num_; }; + int GetNum() const { return m_num; }; bool HasNum( ); ///@} @@ -182,7 +182,7 @@ class AttMidinumber: public Att * Along with numbase, describes duration as a ratio. * num is the first value in the ratio, while numbase is the second. **/ - int m_numInt; + int m_num; /* include */ }; @@ -212,8 +212,8 @@ class AttMiditempo: public Att * to the default value) **/ ///@{ - void SetMidiTempo(std::string midiTempo_) { m_midiTempo = midiTempo_; }; - std::string GetMidiTempo() const { return m_midiTempo; }; + void SetMidiTempo(data_MIDITEMPO midiTempo_) { m_midiTempo = midiTempo_; }; + data_MIDITEMPO GetMidiTempo() const { return m_midiTempo; }; bool HasMidiTempo( ); ///@} @@ -223,7 +223,7 @@ class AttMiditempo: public Att * Contains a MIDI value, that is, the number of quarter notes per minute in the * range from 10 to 1000. **/ - std::string m_midiTempo; + data_MIDITEMPO m_midiTempo; /* include */ }; @@ -253,15 +253,15 @@ class AttMidivalue: public Att * to the default value) **/ ///@{ - void SetVal(std::string val_) { m_val = val_; }; - std::string GetVal() const { return m_val; }; + void SetVal(data_MIDIVALUE val_) { m_val = val_; }; + data_MIDIVALUE GetVal() const { return m_val; }; bool HasVal( ); ///@} private: /** MIDI number. **/ - std::string m_val; + data_MIDIVALUE m_val; /* include */ }; @@ -291,15 +291,15 @@ class AttMidivalue2: public Att * to the default value) **/ ///@{ - void SetVal2(std::string val2_) { m_val2 = val2_; }; - std::string GetVal2() const { return m_val2; }; + void SetVal2(data_MIDIVALUE val2_) { m_val2 = val2_; }; + data_MIDIVALUE GetVal2() const { return m_val2; }; bool HasVal2( ); ///@} private: /** MIDI number. **/ - std::string m_val2; + data_MIDIVALUE m_val2; /* include */ }; @@ -329,15 +329,15 @@ class AttMidivelocity: public Att * to the default value) **/ ///@{ - void SetVel(std::string vel_) { m_vel = vel_; }; - std::string GetVel() const { return m_vel; }; + void SetVel(data_MIDIVALUE vel_) { m_vel = vel_; }; + data_MIDIVALUE GetVel() const { return m_vel; }; bool HasVel( ); ///@} private: /** MIDI Note-on/off velocity. **/ - std::string m_vel; + data_MIDIVALUE m_vel; /* include */ }; @@ -367,8 +367,8 @@ class AttTimebase: public Att * to the default value) **/ ///@{ - void SetPpq(int ppqInt_) { m_ppqInt = ppqInt_; }; - int GetPpq() const { return m_ppqInt; }; + void SetPpq(int ppq_) { m_ppq = ppq_; }; + int GetPpq() const { return m_ppq; }; bool HasPpq( ); ///@} @@ -379,7 +379,7 @@ class AttTimebase: public Att * quarter note. * Unlike MIDI, MEI permits different values for a score and individual staves. **/ - int m_ppqInt; + int m_ppq; /* include */ }; diff --git a/libmei/atts_neumes.cpp b/libmei/atts_neumes.cpp index d62a40e76a9..bf769cc9bd2 100644 --- a/libmei/atts_neumes.cpp +++ b/libmei/atts_neumes.cpp @@ -39,33 +39,33 @@ AttIneumeLog::~AttIneumeLog() { } void AttIneumeLog::ResetIneumeLog() { - m_form = ""; - m_name = ""; + m_form = INEUMEFORM_NONE; + m_name = INEUMENAME_NONE; } -bool AttIneumeLog::ReadIneumeLog( pugi::xml_node element ) { +bool AttIneumeLog::ReadIneumeLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("form")) { - this->SetForm(StrToStr(element.attribute("form").value())); + this->SetForm(StrToIneumeform(element.attribute("form").value())); element.remove_attribute("form"); hasAttribute = true; } if (element.attribute("name")) { - this->SetName(StrToStr(element.attribute("name").value())); + this->SetName(StrToIneumename(element.attribute("name").value())); element.remove_attribute("name"); hasAttribute = true; } return hasAttribute; } -bool AttIneumeLog::WriteIneumeLog( pugi::xml_node element ) { +bool AttIneumeLog::WriteIneumeLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasForm()) { - element.append_attribute("form") = StrToStr(this->GetForm()).c_str(); + element.append_attribute("form") = IneumeformToStr(this->GetForm()).c_str(); wroteAttribute = true; } if (this->HasName()) { - element.append_attribute("name") = StrToStr(this->GetName()).c_str(); + element.append_attribute("name") = IneumenameToStr(this->GetName()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -73,12 +73,12 @@ bool AttIneumeLog::WriteIneumeLog( pugi::xml_node element ) { bool AttIneumeLog::HasForm( ) { - return (m_form != ""); + return (m_form != INEUMEFORM_NONE); } bool AttIneumeLog::HasName( ) { - return (m_name != ""); + return (m_name != INEUMENAME_NONE); } @@ -97,33 +97,33 @@ AttUneumeLog::~AttUneumeLog() { } void AttUneumeLog::ResetUneumeLog() { - m_form = ""; - m_name = ""; + m_form = UNEUMEFORM_NONE; + m_name = UNEUMENAME_NONE; } -bool AttUneumeLog::ReadUneumeLog( pugi::xml_node element ) { +bool AttUneumeLog::ReadUneumeLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("form")) { - this->SetForm(StrToStr(element.attribute("form").value())); + this->SetForm(StrToUneumeform(element.attribute("form").value())); element.remove_attribute("form"); hasAttribute = true; } if (element.attribute("name")) { - this->SetName(StrToStr(element.attribute("name").value())); + this->SetName(StrToUneumename(element.attribute("name").value())); element.remove_attribute("name"); hasAttribute = true; } return hasAttribute; } -bool AttUneumeLog::WriteUneumeLog( pugi::xml_node element ) { +bool AttUneumeLog::WriteUneumeLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasForm()) { - element.append_attribute("form") = StrToStr(this->GetForm()).c_str(); + element.append_attribute("form") = UneumeformToStr(this->GetForm()).c_str(); wroteAttribute = true; } if (this->HasName()) { - element.append_attribute("name") = StrToStr(this->GetName()).c_str(); + element.append_attribute("name") = UneumenameToStr(this->GetName()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -131,12 +131,12 @@ bool AttUneumeLog::WriteUneumeLog( pugi::xml_node element ) { bool AttUneumeLog::HasForm( ) { - return (m_form != ""); + return (m_form != UNEUMEFORM_NONE); } bool AttUneumeLog::HasName( ) { - return (m_name != ""); + return (m_name != UNEUMENAME_NONE); } @@ -147,11 +147,11 @@ bool Att::SetNeumes( Object *element, std::string attrType, std::string attrValu AttIneumeLog *att = dynamic_cast(element); assert( att ); if (attrType == "form") { - att->SetForm(att->StrToStr(attrValue)); + att->SetForm(att->StrToIneumeform(attrValue)); return true; } if (attrType == "name") { - att->SetName(att->StrToStr(attrValue)); + att->SetName(att->StrToIneumename(attrValue)); return true; } } @@ -159,11 +159,11 @@ bool Att::SetNeumes( Object *element, std::string attrType, std::string attrValu AttUneumeLog *att = dynamic_cast(element); assert( att ); if (attrType == "form") { - att->SetForm(att->StrToStr(attrValue)); + att->SetForm(att->StrToUneumeform(attrValue)); return true; } if (attrType == "name") { - att->SetName(att->StrToStr(attrValue)); + att->SetName(att->StrToUneumename(attrValue)); return true; } } @@ -176,20 +176,20 @@ void Att::GetNeumes( Object *element, ArrayOfStrAttr *attributes ) { AttIneumeLog *att = dynamic_cast(element); assert( att ); if (att->HasForm()) { - attributes->push_back(std::make_pair("form", att->StrToStr(att->GetForm()))); + attributes->push_back(std::make_pair("form", att->IneumeformToStr(att->GetForm()))); } if (att->HasName()) { - attributes->push_back(std::make_pair("name", att->StrToStr(att->GetName()))); + attributes->push_back(std::make_pair("name", att->IneumenameToStr(att->GetName()))); } } if (element->HasAttClass( ATT_UNEUMELOG ) ) { AttUneumeLog *att = dynamic_cast(element); assert( att ); if (att->HasForm()) { - attributes->push_back(std::make_pair("form", att->StrToStr(att->GetForm()))); + attributes->push_back(std::make_pair("form", att->UneumeformToStr(att->GetForm()))); } if (att->HasName()) { - attributes->push_back(std::make_pair("name", att->StrToStr(att->GetName()))); + attributes->push_back(std::make_pair("name", att->UneumenameToStr(att->GetName()))); } } diff --git a/libmei/atts_neumes.h b/libmei/atts_neumes.h index 10e8a2d1164..b644142ec47 100644 --- a/libmei/atts_neumes.h +++ b/libmei/atts_neumes.h @@ -16,12 +16,12 @@ #define __VRV_ATTS_NEUMES_H__ #include "att.h" -#include "att_classes.h" +#include "attdef.h" #include "pugixml.hpp" //---------------------------------------------------------------------------- -#include + namespace vrv { @@ -50,22 +50,22 @@ class AttIneumeLog: public Att * to the default value) **/ ///@{ - void SetForm(std::string form_) { m_form = form_; }; - std::string GetForm() const { return m_form; }; + void SetForm(data_INEUMEFORM form_) { m_form = form_; }; + data_INEUMEFORM GetForm() const { return m_form; }; bool HasForm( ); // - void SetName(std::string name_) { m_name = name_; }; - std::string GetName() const { return m_name; }; + void SetName(data_INEUMENAME name_) { m_name = name_; }; + data_INEUMENAME GetName() const { return m_name; }; bool HasName( ); ///@} private: /** Records the appearance and usually the function of the bar line. **/ - std::string m_form; + data_INEUMEFORM m_form; /** Records the name of the neume. **/ - std::string m_name; + data_INEUMENAME m_name; /* include */ }; @@ -95,22 +95,22 @@ class AttUneumeLog: public Att * to the default value) **/ ///@{ - void SetForm(std::string form_) { m_form = form_; }; - std::string GetForm() const { return m_form; }; + void SetForm(data_UNEUMEFORM form_) { m_form = form_; }; + data_UNEUMEFORM GetForm() const { return m_form; }; bool HasForm( ); // - void SetName(std::string name_) { m_name = name_; }; - std::string GetName() const { return m_name; }; + void SetName(data_UNEUMENAME name_) { m_name = name_; }; + data_UNEUMENAME GetName() const { return m_name; }; bool HasName( ); ///@} private: /** Records the appearance and usually the function of the bar line. **/ - std::string m_form; + data_UNEUMEFORM m_form; /** Records the name of the neume. **/ - std::string m_name; + data_UNEUMENAME m_name; /* include */ }; diff --git a/libmei/atts_pagebased.cpp b/libmei/atts_pagebased.cpp index c98d37bb061..01c5005b4c0 100644 --- a/libmei/atts_pagebased.cpp +++ b/libmei/atts_pagebased.cpp @@ -42,7 +42,7 @@ void AttSurface::ResetSurface() { m_surface = ""; } -bool AttSurface::ReadSurface( pugi::xml_node element ) { +bool AttSurface::ReadSurface( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("surface")) { this->SetSurface(StrToStr(element.attribute("surface").value())); @@ -52,7 +52,7 @@ bool AttSurface::ReadSurface( pugi::xml_node element ) { return hasAttribute; } -bool AttSurface::WriteSurface( pugi::xml_node element ) { +bool AttSurface::WriteSurface( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasSurface()) { element.append_attribute("surface") = StrToStr(this->GetSurface()).c_str(); diff --git a/libmei/atts_pagebased.h b/libmei/atts_pagebased.h index df3b74eb5c1..e6f8b691c15 100644 --- a/libmei/atts_pagebased.h +++ b/libmei/atts_pagebased.h @@ -16,7 +16,7 @@ #define __VRV_ATTS_PAGEBASED_H__ #include "att.h" -#include "att_classes.h" +#include "attdef.h" #include "pugixml.hpp" //---------------------------------------------------------------------------- diff --git a/libmei/atts_performance.cpp b/libmei/atts_performance.cpp index 33956176193..c4656085db7 100644 --- a/libmei/atts_performance.cpp +++ b/libmei/atts_performance.cpp @@ -42,7 +42,7 @@ void AttAlignment::ResetAlignment() { m_when = ""; } -bool AttAlignment::ReadAlignment( pugi::xml_node element ) { +bool AttAlignment::ReadAlignment( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("when")) { this->SetWhen(StrToStr(element.attribute("when").value())); @@ -52,7 +52,7 @@ bool AttAlignment::ReadAlignment( pugi::xml_node element ) { return hasAttribute; } -bool AttAlignment::WriteAlignment( pugi::xml_node element ) { +bool AttAlignment::WriteAlignment( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasWhen()) { element.append_attribute("when") = StrToStr(this->GetWhen()).c_str(); diff --git a/libmei/atts_performance.h b/libmei/atts_performance.h index 994bf8e8c6a..48f5f726846 100644 --- a/libmei/atts_performance.h +++ b/libmei/atts_performance.h @@ -16,7 +16,7 @@ #define __VRV_ATTS_PERFORMANCE_H__ #include "att.h" -#include "att_classes.h" +#include "attdef.h" #include "pugixml.hpp" //---------------------------------------------------------------------------- diff --git a/libmei/atts_shared.cpp b/libmei/atts_shared.cpp index 02e1c7c9d27..6da92bff5cc 100644 --- a/libmei/atts_shared.cpp +++ b/libmei/atts_shared.cpp @@ -39,23 +39,23 @@ AttAccidLog::~AttAccidLog() { } void AttAccidLog::ResetAccidLog() { - m_func = FUNC_NONE; + m_func = accidLog_FUNC_NONE; } -bool AttAccidLog::ReadAccidLog( pugi::xml_node element ) { +bool AttAccidLog::ReadAccidLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("func")) { - this->SetFunc(StrToFunc(element.attribute("func").value())); + this->SetFunc(StrToAccidLogFunc(element.attribute("func").value())); element.remove_attribute("func"); hasAttribute = true; } return hasAttribute; } -bool AttAccidLog::WriteAccidLog( pugi::xml_node element ) { +bool AttAccidLog::WriteAccidLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasFunc()) { - element.append_attribute("func") = FuncToStr(this->GetFunc()).c_str(); + element.append_attribute("func") = AccidLogFuncToStr(this->GetFunc()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -63,7 +63,7 @@ bool AttAccidLog::WriteAccidLog( pugi::xml_node element ) { bool AttAccidLog::HasFunc( ) { - return (m_func != FUNC_NONE); + return (m_func != accidLog_FUNC_NONE); } @@ -85,7 +85,7 @@ void AttAccidental::ResetAccidental() { m_accid = ACCIDENTAL_EXPLICIT_NONE; } -bool AttAccidental::ReadAccidental( pugi::xml_node element ) { +bool AttAccidental::ReadAccidental( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("accid")) { this->SetAccid(StrToAccidentalExplicit(element.attribute("accid").value())); @@ -95,7 +95,7 @@ bool AttAccidental::ReadAccidental( pugi::xml_node element ) { return hasAttribute; } -bool AttAccidental::WriteAccidental( pugi::xml_node element ) { +bool AttAccidental::WriteAccidental( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasAccid()) { element.append_attribute("accid") = AccidentalExplicitToStr(this->GetAccid()).c_str(); @@ -125,23 +125,23 @@ AttAccidentalPerformed::~AttAccidentalPerformed() { } void AttAccidentalPerformed::ResetAccidentalPerformed() { - m_accidGes = ""; + m_accidGes = ACCIDENTAL_IMPLICIT_NONE; } -bool AttAccidentalPerformed::ReadAccidentalPerformed( pugi::xml_node element ) { +bool AttAccidentalPerformed::ReadAccidentalPerformed( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("accid.ges")) { - this->SetAccidGes(StrToStr(element.attribute("accid.ges").value())); + this->SetAccidGes(StrToAccidentalImplicit(element.attribute("accid.ges").value())); element.remove_attribute("accid.ges"); hasAttribute = true; } return hasAttribute; } -bool AttAccidentalPerformed::WriteAccidentalPerformed( pugi::xml_node element ) { +bool AttAccidentalPerformed::WriteAccidentalPerformed( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasAccidGes()) { - element.append_attribute("accid.ges") = StrToStr(this->GetAccidGes()).c_str(); + element.append_attribute("accid.ges") = AccidentalImplicitToStr(this->GetAccidGes()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -149,7 +149,7 @@ bool AttAccidentalPerformed::WriteAccidentalPerformed( pugi::xml_node element ) bool AttAccidentalPerformed::HasAccidGes( ) { - return (m_accidGes != ""); + return (m_accidGes != ACCIDENTAL_IMPLICIT_NONE); } @@ -168,23 +168,23 @@ AttArticulation::~AttArticulation() { } void AttArticulation::ResetArticulation() { - m_artic = ""; + m_artic = ARTICULATION_NONE; } -bool AttArticulation::ReadArticulation( pugi::xml_node element ) { +bool AttArticulation::ReadArticulation( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("artic")) { - this->SetArtic(StrToStr(element.attribute("artic").value())); + this->SetArtic(StrToArticulation(element.attribute("artic").value())); element.remove_attribute("artic"); hasAttribute = true; } return hasAttribute; } -bool AttArticulation::WriteArticulation( pugi::xml_node element ) { +bool AttArticulation::WriteArticulation( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasArtic()) { - element.append_attribute("artic") = StrToStr(this->GetArtic()).c_str(); + element.append_attribute("artic") = ArticulationToStr(this->GetArtic()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -192,7 +192,7 @@ bool AttArticulation::WriteArticulation( pugi::xml_node element ) { bool AttArticulation::HasArtic( ) { - return (m_artic != ""); + return (m_artic != ARTICULATION_NONE); } @@ -211,23 +211,23 @@ AttArticulationPerformed::~AttArticulationPerformed() { } void AttArticulationPerformed::ResetArticulationPerformed() { - m_articGes = ""; + m_articGes = ARTICULATION_NONE; } -bool AttArticulationPerformed::ReadArticulationPerformed( pugi::xml_node element ) { +bool AttArticulationPerformed::ReadArticulationPerformed( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("artic.ges")) { - this->SetArticGes(StrToStr(element.attribute("artic.ges").value())); + this->SetArticGes(StrToArticulation(element.attribute("artic.ges").value())); element.remove_attribute("artic.ges"); hasAttribute = true; } return hasAttribute; } -bool AttArticulationPerformed::WriteArticulationPerformed( pugi::xml_node element ) { +bool AttArticulationPerformed::WriteArticulationPerformed( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasArticGes()) { - element.append_attribute("artic.ges") = StrToStr(this->GetArticGes()).c_str(); + element.append_attribute("artic.ges") = ArticulationToStr(this->GetArticGes()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -235,7 +235,7 @@ bool AttArticulationPerformed::WriteArticulationPerformed( pugi::xml_node eleme bool AttArticulationPerformed::HasArticGes( ) { - return (m_articGes != ""); + return (m_articGes != ARTICULATION_NONE); } @@ -257,7 +257,7 @@ void AttAugmentdots::ResetAugmentdots() { m_dots = 0; } -bool AttAugmentdots::ReadAugmentdots( pugi::xml_node element ) { +bool AttAugmentdots::ReadAugmentdots( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("dots")) { this->SetDots(StrToInt(element.attribute("dots").value())); @@ -267,7 +267,7 @@ bool AttAugmentdots::ReadAugmentdots( pugi::xml_node element ) { return hasAttribute; } -bool AttAugmentdots::WriteAugmentdots( pugi::xml_node element ) { +bool AttAugmentdots::WriteAugmentdots( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasDots()) { element.append_attribute("dots") = IntToStr(this->GetDots()).c_str(); @@ -301,7 +301,7 @@ void AttAuthorized::ResetAuthorized() { m_authURI = ""; } -bool AttAuthorized::ReadAuthorized( pugi::xml_node element ) { +bool AttAuthorized::ReadAuthorized( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("authority")) { this->SetAuthority(StrToStr(element.attribute("authority").value())); @@ -316,7 +316,7 @@ bool AttAuthorized::ReadAuthorized( pugi::xml_node element ) { return hasAttribute; } -bool AttAuthorized::WriteAuthorized( pugi::xml_node element ) { +bool AttAuthorized::WriteAuthorized( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasAuthority()) { element.append_attribute("authority") = StrToStr(this->GetAuthority()).c_str(); @@ -358,20 +358,20 @@ void AttBarLineLog::ResetBarLineLog() { m_form = BARRENDITION_single; } -bool AttBarLineLog::ReadBarLineLog( pugi::xml_node element ) { +bool AttBarLineLog::ReadBarLineLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("form")) { - this->SetForm(StrToBarRendition(element.attribute("form").value())); + this->SetForm(StrToBarrendition(element.attribute("form").value())); element.remove_attribute("form"); hasAttribute = true; } return hasAttribute; } -bool AttBarLineLog::WriteBarLineLog( pugi::xml_node element ) { +bool AttBarLineLog::WriteBarLineLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasForm()) { - element.append_attribute("form") = BarRenditionToStr(this->GetForm()).c_str(); + element.append_attribute("form") = BarrenditionToStr(this->GetForm()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -398,33 +398,33 @@ AttBarplacement::~AttBarplacement() { } void AttBarplacement::ResetBarplacement() { - m_barplace = ""; - m_taktplace = ""; + m_barplace = BARPLACE_NONE; + m_taktplace = 0; } -bool AttBarplacement::ReadBarplacement( pugi::xml_node element ) { +bool AttBarplacement::ReadBarplacement( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("barplace")) { - this->SetBarplace(StrToStr(element.attribute("barplace").value())); + this->SetBarplace(StrToBarplace(element.attribute("barplace").value())); element.remove_attribute("barplace"); hasAttribute = true; } if (element.attribute("taktplace")) { - this->SetTaktplace(StrToStr(element.attribute("taktplace").value())); + this->SetTaktplace(StrToInt(element.attribute("taktplace").value())); element.remove_attribute("taktplace"); hasAttribute = true; } return hasAttribute; } -bool AttBarplacement::WriteBarplacement( pugi::xml_node element ) { +bool AttBarplacement::WriteBarplacement( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasBarplace()) { - element.append_attribute("barplace") = StrToStr(this->GetBarplace()).c_str(); + element.append_attribute("barplace") = BarplaceToStr(this->GetBarplace()).c_str(); wroteAttribute = true; } if (this->HasTaktplace()) { - element.append_attribute("taktplace") = StrToStr(this->GetTaktplace()).c_str(); + element.append_attribute("taktplace") = IntToStr(this->GetTaktplace()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -432,12 +432,12 @@ bool AttBarplacement::WriteBarplacement( pugi::xml_node element ) { bool AttBarplacement::HasBarplace( ) { - return (m_barplace != ""); + return (m_barplace != BARPLACE_NONE); } bool AttBarplacement::HasTaktplace( ) { - return (m_taktplace != ""); + return (m_taktplace != 0); } @@ -457,11 +457,11 @@ AttBeamingVis::~AttBeamingVis() { void AttBeamingVis::ResetBeamingVis() { m_beamColor = ""; - m_beamRend = ""; - m_beamSlopeDbl = 0.0; + m_beamRend = beamingVis_BEAMREND_NONE; + m_beamSlope = 0.0; } -bool AttBeamingVis::ReadBeamingVis( pugi::xml_node element ) { +bool AttBeamingVis::ReadBeamingVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("beam.color")) { this->SetBeamColor(StrToStr(element.attribute("beam.color").value())); @@ -469,7 +469,7 @@ bool AttBeamingVis::ReadBeamingVis( pugi::xml_node element ) { hasAttribute = true; } if (element.attribute("beam.rend")) { - this->SetBeamRend(StrToStr(element.attribute("beam.rend").value())); + this->SetBeamRend(StrToBeamingVisBeamrend(element.attribute("beam.rend").value())); element.remove_attribute("beam.rend"); hasAttribute = true; } @@ -481,14 +481,14 @@ bool AttBeamingVis::ReadBeamingVis( pugi::xml_node element ) { return hasAttribute; } -bool AttBeamingVis::WriteBeamingVis( pugi::xml_node element ) { +bool AttBeamingVis::WriteBeamingVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasBeamColor()) { element.append_attribute("beam.color") = StrToStr(this->GetBeamColor()).c_str(); wroteAttribute = true; } if (this->HasBeamRend()) { - element.append_attribute("beam.rend") = StrToStr(this->GetBeamRend()).c_str(); + element.append_attribute("beam.rend") = BeamingVisBeamrendToStr(this->GetBeamRend()).c_str(); wroteAttribute = true; } if (this->HasBeamSlope()) { @@ -505,12 +505,12 @@ bool AttBeamingVis::HasBeamColor( ) bool AttBeamingVis::HasBeamRend( ) { - return (m_beamRend != ""); + return (m_beamRend != beamingVis_BEAMREND_NONE); } bool AttBeamingVis::HasBeamSlope( ) { - return (m_beamSlopeDbl != 0.0); + return (m_beamSlope != 0.0); } @@ -532,7 +532,7 @@ void AttBibl::ResetBibl() { m_analog = ""; } -bool AttBibl::ReadBibl( pugi::xml_node element ) { +bool AttBibl::ReadBibl( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("analog")) { this->SetAnalog(StrToStr(element.attribute("analog").value())); @@ -542,7 +542,7 @@ bool AttBibl::ReadBibl( pugi::xml_node element ) { return hasAttribute; } -bool AttBibl::WriteBibl( pugi::xml_node element ) { +bool AttBibl::WriteBibl( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasAnalog()) { element.append_attribute("analog") = StrToStr(this->GetAnalog()).c_str(); @@ -575,7 +575,7 @@ void AttCalendared::ResetCalendared() { m_calendar = ""; } -bool AttCalendared::ReadCalendared( pugi::xml_node element ) { +bool AttCalendared::ReadCalendared( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("calendar")) { this->SetCalendar(StrToStr(element.attribute("calendar").value())); @@ -585,7 +585,7 @@ bool AttCalendared::ReadCalendared( pugi::xml_node element ) { return hasAttribute; } -bool AttCalendared::WriteCalendared( pugi::xml_node element ) { +bool AttCalendared::WriteCalendared( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasCalendar()) { element.append_attribute("calendar") = StrToStr(this->GetCalendar()).c_str(); @@ -618,7 +618,7 @@ void AttCanonical::ResetCanonical() { m_codedval = ""; } -bool AttCanonical::ReadCanonical( pugi::xml_node element ) { +bool AttCanonical::ReadCanonical( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("codedval")) { this->SetCodedval(StrToStr(element.attribute("codedval").value())); @@ -628,7 +628,7 @@ bool AttCanonical::ReadCanonical( pugi::xml_node element ) { return hasAttribute; } -bool AttCanonical::WriteCanonical( pugi::xml_node element ) { +bool AttCanonical::WriteCanonical( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasCodedval()) { element.append_attribute("codedval") = StrToStr(this->GetCodedval()).c_str(); @@ -658,23 +658,23 @@ AttChordVis::~AttChordVis() { } void AttChordVis::ResetChordVis() { - m_cluster = ""; + m_cluster = CLUSTER_NONE; } -bool AttChordVis::ReadChordVis( pugi::xml_node element ) { +bool AttChordVis::ReadChordVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("cluster")) { - this->SetCluster(StrToStr(element.attribute("cluster").value())); + this->SetCluster(StrToCluster(element.attribute("cluster").value())); element.remove_attribute("cluster"); hasAttribute = true; } return hasAttribute; } -bool AttChordVis::WriteChordVis( pugi::xml_node element ) { +bool AttChordVis::WriteChordVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasCluster()) { - element.append_attribute("cluster") = StrToStr(this->GetCluster()).c_str(); + element.append_attribute("cluster") = ClusterToStr(this->GetCluster()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -682,7 +682,7 @@ bool AttChordVis::WriteChordVis( pugi::xml_node element ) { bool AttChordVis::HasCluster( ) { - return (m_cluster != ""); + return (m_cluster != CLUSTER_NONE); } @@ -704,7 +704,7 @@ void AttClasscodeident::ResetClasscodeident() { m_classcode = ""; } -bool AttClasscodeident::ReadClasscodeident( pugi::xml_node element ) { +bool AttClasscodeident::ReadClasscodeident( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("classcode")) { this->SetClasscode(StrToStr(element.attribute("classcode").value())); @@ -714,7 +714,7 @@ bool AttClasscodeident::ReadClasscodeident( pugi::xml_node element ) { return hasAttribute; } -bool AttClasscodeident::WriteClasscodeident( pugi::xml_node element ) { +bool AttClasscodeident::WriteClasscodeident( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasClasscode()) { element.append_attribute("classcode") = StrToStr(this->GetClasscode()).c_str(); @@ -744,23 +744,23 @@ AttClefLog::~AttClefLog() { } void AttClefLog::ResetClefLog() { - m_cautionary = ""; + m_cautionary = BOOLEAN_NONE; } -bool AttClefLog::ReadClefLog( pugi::xml_node element ) { +bool AttClefLog::ReadClefLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("cautionary")) { - this->SetCautionary(StrToStr(element.attribute("cautionary").value())); + this->SetCautionary(StrToBoolean(element.attribute("cautionary").value())); element.remove_attribute("cautionary"); hasAttribute = true; } return hasAttribute; } -bool AttClefLog::WriteClefLog( pugi::xml_node element ) { +bool AttClefLog::WriteClefLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasCautionary()) { - element.append_attribute("cautionary") = StrToStr(this->GetCautionary()).c_str(); + element.append_attribute("cautionary") = BooleanToStr(this->GetCautionary()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -768,7 +768,7 @@ bool AttClefLog::WriteClefLog( pugi::xml_node element ) { bool AttClefLog::HasCautionary( ) { - return (m_cautionary != ""); + return (m_cautionary != BOOLEAN_NONE); } @@ -793,10 +793,10 @@ void AttCleffingLog::ResetCleffingLog() { m_clefDisPlace = PLACE_NONE; } -bool AttCleffingLog::ReadCleffingLog( pugi::xml_node element ) { +bool AttCleffingLog::ReadCleffingLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("clef.shape")) { - this->SetClefShape(StrToClefShape(element.attribute("clef.shape").value())); + this->SetClefShape(StrToClefshape(element.attribute("clef.shape").value())); element.remove_attribute("clef.shape"); hasAttribute = true; } @@ -818,10 +818,10 @@ bool AttCleffingLog::ReadCleffingLog( pugi::xml_node element ) { return hasAttribute; } -bool AttCleffingLog::WriteCleffingLog( pugi::xml_node element ) { +bool AttCleffingLog::WriteCleffingLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasClefShape()) { - element.append_attribute("clef.shape") = ClefShapeToStr(this->GetClefShape()).c_str(); + element.append_attribute("clef.shape") = ClefshapeToStr(this->GetClefShape()).c_str(); wroteAttribute = true; } if (this->HasClefLine()) { @@ -876,10 +876,10 @@ AttCleffingVis::~AttCleffingVis() { void AttCleffingVis::ResetCleffingVis() { m_clefColor = ""; - m_clefVisible = ""; + m_clefVisible = BOOLEAN_NONE; } -bool AttCleffingVis::ReadCleffingVis( pugi::xml_node element ) { +bool AttCleffingVis::ReadCleffingVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("clef.color")) { this->SetClefColor(StrToStr(element.attribute("clef.color").value())); @@ -887,21 +887,21 @@ bool AttCleffingVis::ReadCleffingVis( pugi::xml_node element ) { hasAttribute = true; } if (element.attribute("clef.visible")) { - this->SetClefVisible(StrToStr(element.attribute("clef.visible").value())); + this->SetClefVisible(StrToBoolean(element.attribute("clef.visible").value())); element.remove_attribute("clef.visible"); hasAttribute = true; } return hasAttribute; } -bool AttCleffingVis::WriteCleffingVis( pugi::xml_node element ) { +bool AttCleffingVis::WriteCleffingVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasClefColor()) { element.append_attribute("clef.color") = StrToStr(this->GetClefColor()).c_str(); wroteAttribute = true; } if (this->HasClefVisible()) { - element.append_attribute("clef.visible") = StrToStr(this->GetClefVisible()).c_str(); + element.append_attribute("clef.visible") = BooleanToStr(this->GetClefVisible()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -914,7 +914,7 @@ bool AttCleffingVis::HasClefColor( ) bool AttCleffingVis::HasClefVisible( ) { - return (m_clefVisible != ""); + return (m_clefVisible != BOOLEAN_NONE); } @@ -936,20 +936,20 @@ void AttClefshape::ResetClefshape() { m_shape = CLEFSHAPE_NONE; } -bool AttClefshape::ReadClefshape( pugi::xml_node element ) { +bool AttClefshape::ReadClefshape( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("shape")) { - this->SetShape(StrToClefShape(element.attribute("shape").value())); + this->SetShape(StrToClefshape(element.attribute("shape").value())); element.remove_attribute("shape"); hasAttribute = true; } return hasAttribute; } -bool AttClefshape::WriteClefshape( pugi::xml_node element ) { +bool AttClefshape::WriteClefshape( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasShape()) { - element.append_attribute("shape") = ClefShapeToStr(this->GetShape()).c_str(); + element.append_attribute("shape") = ClefshapeToStr(this->GetShape()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -979,7 +979,7 @@ void AttColor::ResetColor() { m_color = ""; } -bool AttColor::ReadColor( pugi::xml_node element ) { +bool AttColor::ReadColor( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("color")) { this->SetColor(StrToStr(element.attribute("color").value())); @@ -989,7 +989,7 @@ bool AttColor::ReadColor( pugi::xml_node element ) { return hasAttribute; } -bool AttColor::WriteColor( pugi::xml_node element ) { +bool AttColor::WriteColor( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasColor()) { element.append_attribute("color") = StrToStr(this->GetColor()).c_str(); @@ -1022,20 +1022,20 @@ void AttColoration::ResetColoration() { m_colored = BOOLEAN_NONE; } -bool AttColoration::ReadColoration( pugi::xml_node element ) { +bool AttColoration::ReadColoration( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("colored")) { - this->SetColored(StrToBool(element.attribute("colored").value())); + this->SetColored(StrToBoolean(element.attribute("colored").value())); element.remove_attribute("colored"); hasAttribute = true; } return hasAttribute; } -bool AttColoration::WriteColoration( pugi::xml_node element ) { +bool AttColoration::WriteColoration( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasColored()) { - element.append_attribute("colored") = BoolToStr(this->GetColored()).c_str(); + element.append_attribute("colored") = BooleanToStr(this->GetColored()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -1065,7 +1065,7 @@ void AttCommon::ResetCommon() { m_n = 0; } -bool AttCommon::ReadCommon( pugi::xml_node element ) { +bool AttCommon::ReadCommon( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("n")) { this->SetN(StrToInt(element.attribute("n").value())); @@ -1075,7 +1075,7 @@ bool AttCommon::ReadCommon( pugi::xml_node element ) { return hasAttribute; } -bool AttCommon::WriteCommon( pugi::xml_node element ) { +bool AttCommon::WriteCommon( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasN()) { element.append_attribute("n") = IntToStr(this->GetN()).c_str(); @@ -1109,7 +1109,7 @@ void AttCommonPart::ResetCommonPart() { m_base = ""; } -bool AttCommonPart::ReadCommonPart( pugi::xml_node element ) { +bool AttCommonPart::ReadCommonPart( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("label")) { this->SetLabel(StrToStr(element.attribute("label").value())); @@ -1124,7 +1124,7 @@ bool AttCommonPart::ReadCommonPart( pugi::xml_node element ) { return hasAttribute; } -bool AttCommonPart::WriteCommonPart( pugi::xml_node element ) { +bool AttCommonPart::WriteCommonPart( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasLabel()) { element.append_attribute("label") = StrToStr(this->GetLabel()).c_str(); @@ -1163,13 +1163,13 @@ AttCoordinated::~AttCoordinated() { } void AttCoordinated::ResetCoordinated() { - m_ulxInt = 0; - m_ulyInt = 0; - m_lrxInt = 0; - m_lryInt = 0; + m_ulx = 0; + m_uly = 0; + m_lrx = 0; + m_lry = 0; } -bool AttCoordinated::ReadCoordinated( pugi::xml_node element ) { +bool AttCoordinated::ReadCoordinated( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("ulx")) { this->SetUlx(StrToInt(element.attribute("ulx").value())); @@ -1194,7 +1194,7 @@ bool AttCoordinated::ReadCoordinated( pugi::xml_node element ) { return hasAttribute; } -bool AttCoordinated::WriteCoordinated( pugi::xml_node element ) { +bool AttCoordinated::WriteCoordinated( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasUlx()) { element.append_attribute("ulx") = IntToStr(this->GetUlx()).c_str(); @@ -1217,22 +1217,22 @@ bool AttCoordinated::WriteCoordinated( pugi::xml_node element ) { bool AttCoordinated::HasUlx( ) { - return (m_ulxInt != 0); + return (m_ulx != 0); } bool AttCoordinated::HasUly( ) { - return (m_ulyInt != 0); + return (m_uly != 0); } bool AttCoordinated::HasLrx( ) { - return (m_lrxInt != 0); + return (m_lrx != 0); } bool AttCoordinated::HasLry( ) { - return (m_lryInt != 0); + return (m_lry != 0); } @@ -1253,10 +1253,10 @@ AttCurvature::~AttCurvature() { void AttCurvature::ResetCurvature() { m_bezier = ""; m_bulge = 0.0; - m_curvedir = CURVEDIR_NONE; + m_curvedir = curvature_CURVEDIR_NONE; } -bool AttCurvature::ReadCurvature( pugi::xml_node element ) { +bool AttCurvature::ReadCurvature( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("bezier")) { this->SetBezier(StrToStr(element.attribute("bezier").value())); @@ -1269,14 +1269,14 @@ bool AttCurvature::ReadCurvature( pugi::xml_node element ) { hasAttribute = true; } if (element.attribute("curvedir")) { - this->SetCurvedir(StrToCurvedir(element.attribute("curvedir").value())); + this->SetCurvedir(StrToCurvatureCurvedir(element.attribute("curvedir").value())); element.remove_attribute("curvedir"); hasAttribute = true; } return hasAttribute; } -bool AttCurvature::WriteCurvature( pugi::xml_node element ) { +bool AttCurvature::WriteCurvature( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasBezier()) { element.append_attribute("bezier") = StrToStr(this->GetBezier()).c_str(); @@ -1287,7 +1287,7 @@ bool AttCurvature::WriteCurvature( pugi::xml_node element ) { wroteAttribute = true; } if (this->HasCurvedir()) { - element.append_attribute("curvedir") = CurvedirToStr(this->GetCurvedir()).c_str(); + element.append_attribute("curvedir") = CurvatureCurvedirToStr(this->GetCurvedir()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -1305,7 +1305,7 @@ bool AttCurvature::HasBulge( ) bool AttCurvature::HasCurvedir( ) { - return (m_curvedir != CURVEDIR_NONE); + return (m_curvedir != curvature_CURVEDIR_NONE); } @@ -1324,14 +1324,14 @@ AttCurverend::~AttCurverend() { } void AttCurverend::ResetCurverend() { - m_lform = ""; + m_lform = LINEFORM_NONE; m_lwidth = ""; } -bool AttCurverend::ReadCurverend( pugi::xml_node element ) { +bool AttCurverend::ReadCurverend( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("lform")) { - this->SetLform(StrToStr(element.attribute("lform").value())); + this->SetLform(StrToLineform(element.attribute("lform").value())); element.remove_attribute("lform"); hasAttribute = true; } @@ -1343,10 +1343,10 @@ bool AttCurverend::ReadCurverend( pugi::xml_node element ) { return hasAttribute; } -bool AttCurverend::WriteCurverend( pugi::xml_node element ) { +bool AttCurverend::WriteCurverend( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasLform()) { - element.append_attribute("lform") = StrToStr(this->GetLform()).c_str(); + element.append_attribute("lform") = LineformToStr(this->GetLform()).c_str(); wroteAttribute = true; } if (this->HasLwidth()) { @@ -1358,7 +1358,7 @@ bool AttCurverend::WriteCurverend( pugi::xml_node element ) { bool AttCurverend::HasLform( ) { - return (m_lform != ""); + return (m_lform != LINEFORM_NONE); } bool AttCurverend::HasLwidth( ) @@ -1385,7 +1385,7 @@ void AttCustosLog::ResetCustosLog() { m_target = ""; } -bool AttCustosLog::ReadCustosLog( pugi::xml_node element ) { +bool AttCustosLog::ReadCustosLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("target")) { this->SetTarget(StrToStr(element.attribute("target").value())); @@ -1395,7 +1395,7 @@ bool AttCustosLog::ReadCustosLog( pugi::xml_node element ) { return hasAttribute; } -bool AttCustosLog::WriteCustosLog( pugi::xml_node element ) { +bool AttCustosLog::WriteCustosLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasTarget()) { element.append_attribute("target") = StrToStr(this->GetTarget()).c_str(); @@ -1432,7 +1432,7 @@ void AttDatable::ResetDatable() { m_startdate = ""; } -bool AttDatable::ReadDatable( pugi::xml_node element ) { +bool AttDatable::ReadDatable( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("enddate")) { this->SetEnddate(StrToStr(element.attribute("enddate").value())); @@ -1462,7 +1462,7 @@ bool AttDatable::ReadDatable( pugi::xml_node element ) { return hasAttribute; } -bool AttDatable::WriteDatable( pugi::xml_node element ) { +bool AttDatable::WriteDatable( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasEnddate()) { element.append_attribute("enddate") = StrToStr(this->GetEnddate()).c_str(); @@ -1531,7 +1531,7 @@ void AttDatapointing::ResetDatapointing() { m_data = ""; } -bool AttDatapointing::ReadDatapointing( pugi::xml_node element ) { +bool AttDatapointing::ReadDatapointing( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("data")) { this->SetData(StrToStr(element.attribute("data").value())); @@ -1541,7 +1541,7 @@ bool AttDatapointing::ReadDatapointing( pugi::xml_node element ) { return hasAttribute; } -bool AttDatapointing::WriteDatapointing( pugi::xml_node element ) { +bool AttDatapointing::WriteDatapointing( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasData()) { element.append_attribute("data") = StrToStr(this->GetData()).c_str(); @@ -1574,7 +1574,7 @@ void AttDeclaring::ResetDeclaring() { m_decls = ""; } -bool AttDeclaring::ReadDeclaring( pugi::xml_node element ) { +bool AttDeclaring::ReadDeclaring( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("decls")) { this->SetDecls(StrToStr(element.attribute("decls").value())); @@ -1584,7 +1584,7 @@ bool AttDeclaring::ReadDeclaring( pugi::xml_node element ) { return hasAttribute; } -bool AttDeclaring::WriteDeclaring( pugi::xml_node element ) { +bool AttDeclaring::WriteDeclaring( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasDecls()) { element.append_attribute("decls") = StrToStr(this->GetDecls()).c_str(); @@ -1619,7 +1619,7 @@ void AttDistances::ResetDistances() { m_textDist = ""; } -bool AttDistances::ReadDistances( pugi::xml_node element ) { +bool AttDistances::ReadDistances( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("dynam.dist")) { this->SetDynamDist(StrToStr(element.attribute("dynam.dist").value())); @@ -1639,7 +1639,7 @@ bool AttDistances::ReadDistances( pugi::xml_node element ) { return hasAttribute; } -bool AttDistances::WriteDistances( pugi::xml_node element ) { +bool AttDistances::WriteDistances( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasDynamDist()) { element.append_attribute("dynam.dist") = StrToStr(this->GetDynamDist()).c_str(); @@ -1687,23 +1687,23 @@ AttDotLog::~AttDotLog() { } void AttDotLog::ResetDotLog() { - m_form = BARRENDITION_single; + m_form = dotLog_FORM_NONE; } -bool AttDotLog::ReadDotLog( pugi::xml_node element ) { +bool AttDotLog::ReadDotLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("form")) { - this->SetForm(StrToBarRendition(element.attribute("form").value())); + this->SetForm(StrToDotLogForm(element.attribute("form").value())); element.remove_attribute("form"); hasAttribute = true; } return hasAttribute; } -bool AttDotLog::WriteDotLog( pugi::xml_node element ) { +bool AttDotLog::WriteDotLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasForm()) { - element.append_attribute("form") = BarRenditionToStr(this->GetForm()).c_str(); + element.append_attribute("form") = DotLogFormToStr(this->GetForm()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -1711,7 +1711,7 @@ bool AttDotLog::WriteDotLog( pugi::xml_node element ) { bool AttDotLog::HasForm( ) { - return (m_form != BARRENDITION_single); + return (m_form != dotLog_FORM_NONE); } @@ -1733,20 +1733,20 @@ void AttDurationAdditive::ResetDurationAdditive() { m_dur = DURATION_NONE; } -bool AttDurationAdditive::ReadDurationAdditive( pugi::xml_node element ) { +bool AttDurationAdditive::ReadDurationAdditive( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("dur")) { - this->SetDur(StrToDur(element.attribute("dur").value())); + this->SetDur(StrToDuration(element.attribute("dur").value())); element.remove_attribute("dur"); hasAttribute = true; } return hasAttribute; } -bool AttDurationAdditive::WriteDurationAdditive( pugi::xml_node element ) { +bool AttDurationAdditive::WriteDurationAdditive( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasDur()) { - element.append_attribute("dur") = DurToStr(this->GetDur()).c_str(); + element.append_attribute("dur") = DurationToStr(this->GetDur()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -1773,15 +1773,15 @@ AttDurationDefault::~AttDurationDefault() { } void AttDurationDefault::ResetDurationDefault() { - m_durDefault = ""; - m_numDefaultInt = 0; - m_numbaseDefaultInt = 0; + m_durDefault = DURATION_NONE; + m_numDefault = 0; + m_numbaseDefault = 0; } -bool AttDurationDefault::ReadDurationDefault( pugi::xml_node element ) { +bool AttDurationDefault::ReadDurationDefault( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("dur.default")) { - this->SetDurDefault(StrToStr(element.attribute("dur.default").value())); + this->SetDurDefault(StrToDuration(element.attribute("dur.default").value())); element.remove_attribute("dur.default"); hasAttribute = true; } @@ -1798,10 +1798,10 @@ bool AttDurationDefault::ReadDurationDefault( pugi::xml_node element ) { return hasAttribute; } -bool AttDurationDefault::WriteDurationDefault( pugi::xml_node element ) { +bool AttDurationDefault::WriteDurationDefault( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasDurDefault()) { - element.append_attribute("dur.default") = StrToStr(this->GetDurDefault()).c_str(); + element.append_attribute("dur.default") = DurationToStr(this->GetDurDefault()).c_str(); wroteAttribute = true; } if (this->HasNumDefault()) { @@ -1817,17 +1817,17 @@ bool AttDurationDefault::WriteDurationDefault( pugi::xml_node element ) { bool AttDurationDefault::HasDurDefault( ) { - return (m_durDefault != ""); + return (m_durDefault != DURATION_NONE); } bool AttDurationDefault::HasNumDefault( ) { - return (m_numDefaultInt != 0); + return (m_numDefault != 0); } bool AttDurationDefault::HasNumbaseDefault( ) { - return (m_numbaseDefaultInt != 0); + return (m_numbaseDefault != 0); } @@ -1849,20 +1849,20 @@ void AttDurationMusical::ResetDurationMusical() { m_dur = DURATION_NONE; } -bool AttDurationMusical::ReadDurationMusical( pugi::xml_node element ) { +bool AttDurationMusical::ReadDurationMusical( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("dur")) { - this->SetDur(StrToDur(element.attribute("dur").value())); + this->SetDur(StrToDuration(element.attribute("dur").value())); element.remove_attribute("dur"); hasAttribute = true; } return hasAttribute; } -bool AttDurationMusical::WriteDurationMusical( pugi::xml_node element ) { +bool AttDurationMusical::WriteDurationMusical( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasDur()) { - element.append_attribute("dur") = DurToStr(this->GetDur()).c_str(); + element.append_attribute("dur") = DurationToStr(this->GetDur()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -1892,20 +1892,20 @@ void AttDurationPerformed::ResetDurationPerformed() { m_durGes = DURATION_NONE; } -bool AttDurationPerformed::ReadDurationPerformed( pugi::xml_node element ) { +bool AttDurationPerformed::ReadDurationPerformed( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("dur.ges")) { - this->SetDurGes(StrToDur(element.attribute("dur.ges").value())); + this->SetDurGes(StrToDuration(element.attribute("dur.ges").value())); element.remove_attribute("dur.ges"); hasAttribute = true; } return hasAttribute; } -bool AttDurationPerformed::WriteDurationPerformed( pugi::xml_node element ) { +bool AttDurationPerformed::WriteDurationPerformed( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasDurGes()) { - element.append_attribute("dur.ges") = DurToStr(this->GetDurGes()).c_str(); + element.append_attribute("dur.ges") = DurationToStr(this->GetDurGes()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -1936,7 +1936,7 @@ void AttDurationRatio::ResetDurationRatio() { m_numbase = -1; } -bool AttDurationRatio::ReadDurationRatio( pugi::xml_node element ) { +bool AttDurationRatio::ReadDurationRatio( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("num")) { this->SetNum(StrToInt(element.attribute("num").value())); @@ -1951,7 +1951,7 @@ bool AttDurationRatio::ReadDurationRatio( pugi::xml_node element ) { return hasAttribute; } -bool AttDurationRatio::WriteDurationRatio( pugi::xml_node element ) { +bool AttDurationRatio::WriteDurationRatio( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasNum()) { element.append_attribute("num") = IntToStr(this->GetNum()).c_str(); @@ -1990,23 +1990,23 @@ AttEnclosingchars::~AttEnclosingchars() { } void AttEnclosingchars::ResetEnclosingchars() { - m_enclose = ""; + m_enclose = ENCLOSURE_NONE; } -bool AttEnclosingchars::ReadEnclosingchars( pugi::xml_node element ) { +bool AttEnclosingchars::ReadEnclosingchars( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("enclose")) { - this->SetEnclose(StrToStr(element.attribute("enclose").value())); + this->SetEnclose(StrToEnclosure(element.attribute("enclose").value())); element.remove_attribute("enclose"); hasAttribute = true; } return hasAttribute; } -bool AttEnclosingchars::WriteEnclosingchars( pugi::xml_node element ) { +bool AttEnclosingchars::WriteEnclosingchars( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasEnclose()) { - element.append_attribute("enclose") = StrToStr(this->GetEnclose()).c_str(); + element.append_attribute("enclose") = EnclosureToStr(this->GetEnclose()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -2014,7 +2014,7 @@ bool AttEnclosingchars::WriteEnclosingchars( pugi::xml_node element ) { bool AttEnclosingchars::HasEnclose( ) { - return (m_enclose != ""); + return (m_enclose != ENCLOSURE_NONE); } @@ -2033,23 +2033,23 @@ AttEndings::~AttEndings() { } void AttEndings::ResetEndings() { - m_endingRend = ""; + m_endingRend = endings_ENDINGREND_NONE; } -bool AttEndings::ReadEndings( pugi::xml_node element ) { +bool AttEndings::ReadEndings( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("ending.rend")) { - this->SetEndingRend(StrToStr(element.attribute("ending.rend").value())); + this->SetEndingRend(StrToEndingsEndingrend(element.attribute("ending.rend").value())); element.remove_attribute("ending.rend"); hasAttribute = true; } return hasAttribute; } -bool AttEndings::WriteEndings( pugi::xml_node element ) { +bool AttEndings::WriteEndings( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasEndingRend()) { - element.append_attribute("ending.rend") = StrToStr(this->GetEndingRend()).c_str(); + element.append_attribute("ending.rend") = EndingsEndingrendToStr(this->GetEndingRend()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -2057,7 +2057,7 @@ bool AttEndings::WriteEndings( pugi::xml_node element ) { bool AttEndings::HasEndingRend( ) { - return (m_endingRend != ""); + return (m_endingRend != endings_ENDINGREND_NONE); } @@ -2076,23 +2076,23 @@ AttExtender::~AttExtender() { } void AttExtender::ResetExtender() { - m_extender = ""; + m_extender = BOOLEAN_NONE; } -bool AttExtender::ReadExtender( pugi::xml_node element ) { +bool AttExtender::ReadExtender( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("extender")) { - this->SetExtender(StrToStr(element.attribute("extender").value())); + this->SetExtender(StrToBoolean(element.attribute("extender").value())); element.remove_attribute("extender"); hasAttribute = true; } return hasAttribute; } -bool AttExtender::WriteExtender( pugi::xml_node element ) { +bool AttExtender::WriteExtender( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasExtender()) { - element.append_attribute("extender") = StrToStr(this->GetExtender()).c_str(); + element.append_attribute("extender") = BooleanToStr(this->GetExtender()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -2100,7 +2100,7 @@ bool AttExtender::WriteExtender( pugi::xml_node element ) { bool AttExtender::HasExtender( ) { - return (m_extender != ""); + return (m_extender != BOOLEAN_NONE); } @@ -2122,7 +2122,7 @@ void AttFermatapresent::ResetFermatapresent() { m_fermata = PLACE_NONE; } -bool AttFermatapresent::ReadFermatapresent( pugi::xml_node element ) { +bool AttFermatapresent::ReadFermatapresent( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("fermata")) { this->SetFermata(StrToPlace(element.attribute("fermata").value())); @@ -2132,7 +2132,7 @@ bool AttFermatapresent::ReadFermatapresent( pugi::xml_node element ) { return hasAttribute; } -bool AttFermatapresent::WriteFermatapresent( pugi::xml_node element ) { +bool AttFermatapresent::WriteFermatapresent( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasFermata()) { element.append_attribute("fermata") = PlaceToStr(this->GetFermata()).c_str(); @@ -2162,10 +2162,10 @@ AttFiling::~AttFiling() { } void AttFiling::ResetFiling() { - m_nonfilingInt = 0; + m_nonfiling = 0; } -bool AttFiling::ReadFiling( pugi::xml_node element ) { +bool AttFiling::ReadFiling( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("nonfiling")) { this->SetNonfiling(StrToInt(element.attribute("nonfiling").value())); @@ -2175,7 +2175,7 @@ bool AttFiling::ReadFiling( pugi::xml_node element ) { return hasAttribute; } -bool AttFiling::WriteFiling( pugi::xml_node element ) { +bool AttFiling::WriteFiling( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasNonfiling()) { element.append_attribute("nonfiling") = IntToStr(this->GetNonfiling()).c_str(); @@ -2186,7 +2186,7 @@ bool AttFiling::WriteFiling( pugi::xml_node element ) { bool AttFiling::HasNonfiling( ) { - return (m_nonfilingInt != 0); + return (m_nonfiling != 0); } @@ -2205,10 +2205,10 @@ AttGrpSymLog::~AttGrpSymLog() { } void AttGrpSymLog::ResetGrpSymLog() { - m_levelInt = 0; + m_level = 0; } -bool AttGrpSymLog::ReadGrpSymLog( pugi::xml_node element ) { +bool AttGrpSymLog::ReadGrpSymLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("level")) { this->SetLevel(StrToInt(element.attribute("level").value())); @@ -2218,7 +2218,7 @@ bool AttGrpSymLog::ReadGrpSymLog( pugi::xml_node element ) { return hasAttribute; } -bool AttGrpSymLog::WriteGrpSymLog( pugi::xml_node element ) { +bool AttGrpSymLog::WriteGrpSymLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasLevel()) { element.append_attribute("level") = IntToStr(this->GetLevel()).c_str(); @@ -2229,7 +2229,7 @@ bool AttGrpSymLog::WriteGrpSymLog( pugi::xml_node element ) { bool AttGrpSymLog::HasLevel( ) { - return (m_levelInt != 0); + return (m_level != 0); } @@ -2251,7 +2251,7 @@ void AttHandident::ResetHandident() { m_hand = ""; } -bool AttHandident::ReadHandident( pugi::xml_node element ) { +bool AttHandident::ReadHandident( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("hand")) { this->SetHand(StrToStr(element.attribute("hand").value())); @@ -2261,7 +2261,7 @@ bool AttHandident::ReadHandident( pugi::xml_node element ) { return hasAttribute; } -bool AttHandident::WriteHandident( pugi::xml_node element ) { +bool AttHandident::WriteHandident( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasHand()) { element.append_attribute("hand") = StrToStr(this->GetHand()).c_str(); @@ -2294,7 +2294,7 @@ void AttHeight::ResetHeight() { m_height = ""; } -bool AttHeight::ReadHeight( pugi::xml_node element ) { +bool AttHeight::ReadHeight( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("height")) { this->SetHeight(StrToStr(element.attribute("height").value())); @@ -2304,7 +2304,7 @@ bool AttHeight::ReadHeight( pugi::xml_node element ) { return hasAttribute; } -bool AttHeight::WriteHeight( pugi::xml_node element ) { +bool AttHeight::WriteHeight( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasHeight()) { element.append_attribute("height") = StrToStr(this->GetHeight()).c_str(); @@ -2334,23 +2334,23 @@ AttHorizontalalign::~AttHorizontalalign() { } void AttHorizontalalign::ResetHorizontalalign() { - m_halign = ""; + m_halign = HORIZONTALALIGNMENT_NONE; } -bool AttHorizontalalign::ReadHorizontalalign( pugi::xml_node element ) { +bool AttHorizontalalign::ReadHorizontalalign( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("halign")) { - this->SetHalign(StrToStr(element.attribute("halign").value())); + this->SetHalign(StrToHorizontalalignment(element.attribute("halign").value())); element.remove_attribute("halign"); hasAttribute = true; } return hasAttribute; } -bool AttHorizontalalign::WriteHorizontalalign( pugi::xml_node element ) { +bool AttHorizontalalign::WriteHorizontalalign( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasHalign()) { - element.append_attribute("halign") = StrToStr(this->GetHalign()).c_str(); + element.append_attribute("halign") = HorizontalalignmentToStr(this->GetHalign()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -2358,7 +2358,7 @@ bool AttHorizontalalign::WriteHorizontalalign( pugi::xml_node element ) { bool AttHorizontalalign::HasHalign( ) { - return (m_halign != ""); + return (m_halign != HORIZONTALALIGNMENT_NONE); } @@ -2380,7 +2380,7 @@ void AttInstrumentident::ResetInstrumentident() { m_instr = ""; } -bool AttInstrumentident::ReadInstrumentident( pugi::xml_node element ) { +bool AttInstrumentident::ReadInstrumentident( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("instr")) { this->SetInstr(StrToStr(element.attribute("instr").value())); @@ -2390,7 +2390,7 @@ bool AttInstrumentident::ReadInstrumentident( pugi::xml_node element ) { return hasAttribute; } -bool AttInstrumentident::WriteInstrumentident( pugi::xml_node element ) { +bool AttInstrumentident::WriteInstrumentident( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasInstr()) { element.append_attribute("instr") = StrToStr(this->GetInstr()).c_str(); @@ -2423,7 +2423,7 @@ void AttInternetmedia::ResetInternetmedia() { m_mimetype = ""; } -bool AttInternetmedia::ReadInternetmedia( pugi::xml_node element ) { +bool AttInternetmedia::ReadInternetmedia( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("mimetype")) { this->SetMimetype(StrToStr(element.attribute("mimetype").value())); @@ -2433,7 +2433,7 @@ bool AttInternetmedia::ReadInternetmedia( pugi::xml_node element ) { return hasAttribute; } -bool AttInternetmedia::WriteInternetmedia( pugi::xml_node element ) { +bool AttInternetmedia::WriteInternetmedia( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasMimetype()) { element.append_attribute("mimetype") = StrToStr(this->GetMimetype()).c_str(); @@ -2466,7 +2466,7 @@ void AttJoined::ResetJoined() { m_join = ""; } -bool AttJoined::ReadJoined( pugi::xml_node element ) { +bool AttJoined::ReadJoined( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("join")) { this->SetJoin(StrToStr(element.attribute("join").value())); @@ -2476,7 +2476,7 @@ bool AttJoined::ReadJoined( pugi::xml_node element ) { return hasAttribute; } -bool AttJoined::WriteJoined( pugi::xml_node element ) { +bool AttJoined::WriteJoined( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasJoin()) { element.append_attribute("join") = StrToStr(this->GetJoin()).c_str(); @@ -2506,23 +2506,23 @@ AttKeySigLog::~AttKeySigLog() { } void AttKeySigLog::ResetKeySigLog() { - m_mode = ""; + m_mode = MODE_NONE; } -bool AttKeySigLog::ReadKeySigLog( pugi::xml_node element ) { +bool AttKeySigLog::ReadKeySigLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("mode")) { - this->SetMode(StrToStr(element.attribute("mode").value())); + this->SetMode(StrToMode(element.attribute("mode").value())); element.remove_attribute("mode"); hasAttribute = true; } return hasAttribute; } -bool AttKeySigLog::WriteKeySigLog( pugi::xml_node element ) { +bool AttKeySigLog::WriteKeySigLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasMode()) { - element.append_attribute("mode") = StrToStr(this->GetMode()).c_str(); + element.append_attribute("mode") = ModeToStr(this->GetMode()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -2530,7 +2530,7 @@ bool AttKeySigLog::WriteKeySigLog( pugi::xml_node element ) { bool AttKeySigLog::HasMode( ) { - return (m_mode != ""); + return (m_mode != MODE_NONE); } @@ -2556,7 +2556,7 @@ void AttKeySigDefaultLog::ResetKeySigDefaultLog() { m_keySigMixed = ""; } -bool AttKeySigDefaultLog::ReadKeySigDefaultLog( pugi::xml_node element ) { +bool AttKeySigDefaultLog::ReadKeySigDefaultLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("key.accid")) { this->SetKeyAccid(StrToAccidentalImplicit(element.attribute("key.accid").value())); @@ -2569,12 +2569,12 @@ bool AttKeySigDefaultLog::ReadKeySigDefaultLog( pugi::xml_node element ) { hasAttribute = true; } if (element.attribute("key.pname")) { - this->SetKeyPname(StrToPitchName(element.attribute("key.pname").value())); + this->SetKeyPname(StrToPitchname(element.attribute("key.pname").value())); element.remove_attribute("key.pname"); hasAttribute = true; } if (element.attribute("key.sig")) { - this->SetKeySig(StrToKeySignature(element.attribute("key.sig").value())); + this->SetKeySig(StrToKeysignature(element.attribute("key.sig").value())); element.remove_attribute("key.sig"); hasAttribute = true; } @@ -2586,7 +2586,7 @@ bool AttKeySigDefaultLog::ReadKeySigDefaultLog( pugi::xml_node element ) { return hasAttribute; } -bool AttKeySigDefaultLog::WriteKeySigDefaultLog( pugi::xml_node element ) { +bool AttKeySigDefaultLog::WriteKeySigDefaultLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasKeyAccid()) { element.append_attribute("key.accid") = AccidentalImplicitToStr(this->GetKeyAccid()).c_str(); @@ -2597,11 +2597,11 @@ bool AttKeySigDefaultLog::WriteKeySigDefaultLog( pugi::xml_node element ) { wroteAttribute = true; } if (this->HasKeyPname()) { - element.append_attribute("key.pname") = PitchNameToStr(this->GetKeyPname()).c_str(); + element.append_attribute("key.pname") = PitchnameToStr(this->GetKeyPname()).c_str(); wroteAttribute = true; } if (this->HasKeySig()) { - element.append_attribute("key.sig") = KeySignatureToStr(this->GetKeySig()).c_str(); + element.append_attribute("key.sig") = KeysignatureToStr(this->GetKeySig()).c_str(); wroteAttribute = true; } if (this->HasKeySigMixed()) { @@ -2656,29 +2656,29 @@ void AttKeySigDefaultVis::ResetKeySigDefaultVis() { m_keySigShowchange = BOOLEAN_NONE; } -bool AttKeySigDefaultVis::ReadKeySigDefaultVis( pugi::xml_node element ) { +bool AttKeySigDefaultVis::ReadKeySigDefaultVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("key.sig.show")) { - this->SetKeySigShow(StrToBool(element.attribute("key.sig.show").value())); + this->SetKeySigShow(StrToBoolean(element.attribute("key.sig.show").value())); element.remove_attribute("key.sig.show"); hasAttribute = true; } if (element.attribute("key.sig.showchange")) { - this->SetKeySigShowchange(StrToBool(element.attribute("key.sig.showchange").value())); + this->SetKeySigShowchange(StrToBoolean(element.attribute("key.sig.showchange").value())); element.remove_attribute("key.sig.showchange"); hasAttribute = true; } return hasAttribute; } -bool AttKeySigDefaultVis::WriteKeySigDefaultVis( pugi::xml_node element ) { +bool AttKeySigDefaultVis::WriteKeySigDefaultVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasKeySigShow()) { - element.append_attribute("key.sig.show") = BoolToStr(this->GetKeySigShow()).c_str(); + element.append_attribute("key.sig.show") = BooleanToStr(this->GetKeySigShow()).c_str(); wroteAttribute = true; } if (this->HasKeySigShowchange()) { - element.append_attribute("key.sig.showchange") = BoolToStr(this->GetKeySigShowchange()).c_str(); + element.append_attribute("key.sig.showchange") = BooleanToStr(this->GetKeySigShowchange()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -2713,7 +2713,7 @@ void AttLabelsAddl::ResetLabelsAddl() { m_labelAbbr = ""; } -bool AttLabelsAddl::ReadLabelsAddl( pugi::xml_node element ) { +bool AttLabelsAddl::ReadLabelsAddl( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("label.abbr")) { this->SetLabelAbbr(StrToStr(element.attribute("label.abbr").value())); @@ -2723,7 +2723,7 @@ bool AttLabelsAddl::ReadLabelsAddl( pugi::xml_node element ) { return hasAttribute; } -bool AttLabelsAddl::WriteLabelsAddl( pugi::xml_node element ) { +bool AttLabelsAddl::WriteLabelsAddl( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasLabelAbbr()) { element.append_attribute("label.abbr") = StrToStr(this->GetLabelAbbr()).c_str(); @@ -2757,7 +2757,7 @@ void AttLang::ResetLang() { m_translit = ""; } -bool AttLang::ReadLang( pugi::xml_node element ) { +bool AttLang::ReadLang( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("lang")) { this->SetLang(StrToStr(element.attribute("lang").value())); @@ -2772,7 +2772,7 @@ bool AttLang::ReadLang( pugi::xml_node element ) { return hasAttribute; } -bool AttLang::WriteLang( pugi::xml_node element ) { +bool AttLang::WriteLang( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasLang()) { element.append_attribute("lang") = StrToStr(this->GetLang()).c_str(); @@ -2814,7 +2814,7 @@ void AttLayerLog::ResetLayerLog() { m_def = ""; } -bool AttLayerLog::ReadLayerLog( pugi::xml_node element ) { +bool AttLayerLog::ReadLayerLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("def")) { this->SetDef(StrToStr(element.attribute("def").value())); @@ -2824,7 +2824,7 @@ bool AttLayerLog::ReadLayerLog( pugi::xml_node element ) { return hasAttribute; } -bool AttLayerLog::WriteLayerLog( pugi::xml_node element ) { +bool AttLayerLog::WriteLayerLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasDef()) { element.append_attribute("def") = StrToStr(this->GetDef()).c_str(); @@ -2854,10 +2854,10 @@ AttLayerident::~AttLayerident() { } void AttLayerident::ResetLayerident() { - m_layerInt = 0; + m_layer = 0; } -bool AttLayerident::ReadLayerident( pugi::xml_node element ) { +bool AttLayerident::ReadLayerident( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("layer")) { this->SetLayer(StrToInt(element.attribute("layer").value())); @@ -2867,7 +2867,7 @@ bool AttLayerident::ReadLayerident( pugi::xml_node element ) { return hasAttribute; } -bool AttLayerident::WriteLayerident( pugi::xml_node element ) { +bool AttLayerident::WriteLayerident( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasLayer()) { element.append_attribute("layer") = IntToStr(this->GetLayer()).c_str(); @@ -2878,7 +2878,7 @@ bool AttLayerident::WriteLayerident( pugi::xml_node element ) { bool AttLayerident::HasLayer( ) { - return (m_layerInt != 0); + return (m_layer != 0); } @@ -2897,18 +2897,18 @@ AttLineVis::~AttLineVis() { } void AttLineVis::ResetLineVis() { - m_form = BARRENDITION_single; + m_form = LINEFORM_NONE; m_width = ""; - m_endsym = ""; + m_endsym = LINESTARTENDSYMBOL_NONE; m_endsymsize = ""; - m_startsym = ""; + m_startsym = LINESTARTENDSYMBOL_NONE; m_startsymsize = ""; } -bool AttLineVis::ReadLineVis( pugi::xml_node element ) { +bool AttLineVis::ReadLineVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("form")) { - this->SetForm(StrToBarRendition(element.attribute("form").value())); + this->SetForm(StrToLineform(element.attribute("form").value())); element.remove_attribute("form"); hasAttribute = true; } @@ -2918,7 +2918,7 @@ bool AttLineVis::ReadLineVis( pugi::xml_node element ) { hasAttribute = true; } if (element.attribute("endsym")) { - this->SetEndsym(StrToStr(element.attribute("endsym").value())); + this->SetEndsym(StrToLinestartendsymbol(element.attribute("endsym").value())); element.remove_attribute("endsym"); hasAttribute = true; } @@ -2928,7 +2928,7 @@ bool AttLineVis::ReadLineVis( pugi::xml_node element ) { hasAttribute = true; } if (element.attribute("startsym")) { - this->SetStartsym(StrToStr(element.attribute("startsym").value())); + this->SetStartsym(StrToLinestartendsymbol(element.attribute("startsym").value())); element.remove_attribute("startsym"); hasAttribute = true; } @@ -2940,10 +2940,10 @@ bool AttLineVis::ReadLineVis( pugi::xml_node element ) { return hasAttribute; } -bool AttLineVis::WriteLineVis( pugi::xml_node element ) { +bool AttLineVis::WriteLineVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasForm()) { - element.append_attribute("form") = BarRenditionToStr(this->GetForm()).c_str(); + element.append_attribute("form") = LineformToStr(this->GetForm()).c_str(); wroteAttribute = true; } if (this->HasWidth()) { @@ -2951,7 +2951,7 @@ bool AttLineVis::WriteLineVis( pugi::xml_node element ) { wroteAttribute = true; } if (this->HasEndsym()) { - element.append_attribute("endsym") = StrToStr(this->GetEndsym()).c_str(); + element.append_attribute("endsym") = LinestartendsymbolToStr(this->GetEndsym()).c_str(); wroteAttribute = true; } if (this->HasEndsymsize()) { @@ -2959,7 +2959,7 @@ bool AttLineVis::WriteLineVis( pugi::xml_node element ) { wroteAttribute = true; } if (this->HasStartsym()) { - element.append_attribute("startsym") = StrToStr(this->GetStartsym()).c_str(); + element.append_attribute("startsym") = LinestartendsymbolToStr(this->GetStartsym()).c_str(); wroteAttribute = true; } if (this->HasStartsymsize()) { @@ -2971,7 +2971,7 @@ bool AttLineVis::WriteLineVis( pugi::xml_node element ) { bool AttLineVis::HasForm( ) { - return (m_form != BARRENDITION_single); + return (m_form != LINEFORM_NONE); } bool AttLineVis::HasWidth( ) @@ -2981,7 +2981,7 @@ bool AttLineVis::HasWidth( ) bool AttLineVis::HasEndsym( ) { - return (m_endsym != ""); + return (m_endsym != LINESTARTENDSYMBOL_NONE); } bool AttLineVis::HasEndsymsize( ) @@ -2991,7 +2991,7 @@ bool AttLineVis::HasEndsymsize( ) bool AttLineVis::HasStartsym( ) { - return (m_startsym != ""); + return (m_startsym != LINESTARTENDSYMBOL_NONE); } bool AttLineVis::HasStartsymsize( ) @@ -3018,7 +3018,7 @@ void AttLineloc::ResetLineloc() { m_line = 0; } -bool AttLineloc::ReadLineloc( pugi::xml_node element ) { +bool AttLineloc::ReadLineloc( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("line")) { this->SetLine(StrToInt(element.attribute("line").value())); @@ -3028,7 +3028,7 @@ bool AttLineloc::ReadLineloc( pugi::xml_node element ) { return hasAttribute; } -bool AttLineloc::WriteLineloc( pugi::xml_node element ) { +bool AttLineloc::WriteLineloc( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasLine()) { element.append_attribute("line") = IntToStr(this->GetLine()).c_str(); @@ -3058,16 +3058,16 @@ AttLinerend::~AttLinerend() { } void AttLinerend::ResetLinerend() { - m_lendsym = ""; + m_lendsym = LINESTARTENDSYMBOL_NONE; m_lendsymsize = ""; - m_lstartsym = ""; + m_lstartsym = LINESTARTENDSYMBOL_NONE; m_lstartsymsize = ""; } -bool AttLinerend::ReadLinerend( pugi::xml_node element ) { +bool AttLinerend::ReadLinerend( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("lendsym")) { - this->SetLendsym(StrToStr(element.attribute("lendsym").value())); + this->SetLendsym(StrToLinestartendsymbol(element.attribute("lendsym").value())); element.remove_attribute("lendsym"); hasAttribute = true; } @@ -3077,7 +3077,7 @@ bool AttLinerend::ReadLinerend( pugi::xml_node element ) { hasAttribute = true; } if (element.attribute("lstartsym")) { - this->SetLstartsym(StrToStr(element.attribute("lstartsym").value())); + this->SetLstartsym(StrToLinestartendsymbol(element.attribute("lstartsym").value())); element.remove_attribute("lstartsym"); hasAttribute = true; } @@ -3089,10 +3089,10 @@ bool AttLinerend::ReadLinerend( pugi::xml_node element ) { return hasAttribute; } -bool AttLinerend::WriteLinerend( pugi::xml_node element ) { +bool AttLinerend::WriteLinerend( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasLendsym()) { - element.append_attribute("lendsym") = StrToStr(this->GetLendsym()).c_str(); + element.append_attribute("lendsym") = LinestartendsymbolToStr(this->GetLendsym()).c_str(); wroteAttribute = true; } if (this->HasLendsymsize()) { @@ -3100,7 +3100,7 @@ bool AttLinerend::WriteLinerend( pugi::xml_node element ) { wroteAttribute = true; } if (this->HasLstartsym()) { - element.append_attribute("lstartsym") = StrToStr(this->GetLstartsym()).c_str(); + element.append_attribute("lstartsym") = LinestartendsymbolToStr(this->GetLstartsym()).c_str(); wroteAttribute = true; } if (this->HasLstartsymsize()) { @@ -3112,7 +3112,7 @@ bool AttLinerend::WriteLinerend( pugi::xml_node element ) { bool AttLinerend::HasLendsym( ) { - return (m_lendsym != ""); + return (m_lendsym != LINESTARTENDSYMBOL_NONE); } bool AttLinerend::HasLendsymsize( ) @@ -3122,7 +3122,7 @@ bool AttLinerend::HasLendsymsize( ) bool AttLinerend::HasLstartsym( ) { - return (m_lstartsym != ""); + return (m_lstartsym != LINESTARTENDSYMBOL_NONE); } bool AttLinerend::HasLstartsymsize( ) @@ -3146,14 +3146,14 @@ AttLinerendBase::~AttLinerendBase() { } void AttLinerendBase::ResetLinerendBase() { - m_lform = ""; + m_lform = LINEFORM_NONE; m_lwidth = ""; } -bool AttLinerendBase::ReadLinerendBase( pugi::xml_node element ) { +bool AttLinerendBase::ReadLinerendBase( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("lform")) { - this->SetLform(StrToStr(element.attribute("lform").value())); + this->SetLform(StrToLineform(element.attribute("lform").value())); element.remove_attribute("lform"); hasAttribute = true; } @@ -3165,10 +3165,10 @@ bool AttLinerendBase::ReadLinerendBase( pugi::xml_node element ) { return hasAttribute; } -bool AttLinerendBase::WriteLinerendBase( pugi::xml_node element ) { +bool AttLinerendBase::WriteLinerendBase( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasLform()) { - element.append_attribute("lform") = StrToStr(this->GetLform()).c_str(); + element.append_attribute("lform") = LineformToStr(this->GetLform()).c_str(); wroteAttribute = true; } if (this->HasLwidth()) { @@ -3180,7 +3180,7 @@ bool AttLinerendBase::WriteLinerendBase( pugi::xml_node element ) { bool AttLinerendBase::HasLform( ) { - return (m_lform != ""); + return (m_lform != LINEFORM_NONE); } bool AttLinerendBase::HasLwidth( ) @@ -3208,11 +3208,11 @@ void AttLyricstyle::ResetLyricstyle() { m_lyricFam = ""; m_lyricName = ""; m_lyricSize = ""; - m_lyricStyle = ""; - m_lyricWeight = ""; + m_lyricStyle = FONTSTYLE_NONE; + m_lyricWeight = FONTWEIGHT_NONE; } -bool AttLyricstyle::ReadLyricstyle( pugi::xml_node element ) { +bool AttLyricstyle::ReadLyricstyle( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("lyric.align")) { this->SetLyricAlign(StrToStr(element.attribute("lyric.align").value())); @@ -3235,19 +3235,19 @@ bool AttLyricstyle::ReadLyricstyle( pugi::xml_node element ) { hasAttribute = true; } if (element.attribute("lyric.style")) { - this->SetLyricStyle(StrToStr(element.attribute("lyric.style").value())); + this->SetLyricStyle(StrToFontstyle(element.attribute("lyric.style").value())); element.remove_attribute("lyric.style"); hasAttribute = true; } if (element.attribute("lyric.weight")) { - this->SetLyricWeight(StrToStr(element.attribute("lyric.weight").value())); + this->SetLyricWeight(StrToFontweight(element.attribute("lyric.weight").value())); element.remove_attribute("lyric.weight"); hasAttribute = true; } return hasAttribute; } -bool AttLyricstyle::WriteLyricstyle( pugi::xml_node element ) { +bool AttLyricstyle::WriteLyricstyle( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasLyricAlign()) { element.append_attribute("lyric.align") = StrToStr(this->GetLyricAlign()).c_str(); @@ -3266,11 +3266,11 @@ bool AttLyricstyle::WriteLyricstyle( pugi::xml_node element ) { wroteAttribute = true; } if (this->HasLyricStyle()) { - element.append_attribute("lyric.style") = StrToStr(this->GetLyricStyle()).c_str(); + element.append_attribute("lyric.style") = FontstyleToStr(this->GetLyricStyle()).c_str(); wroteAttribute = true; } if (this->HasLyricWeight()) { - element.append_attribute("lyric.weight") = StrToStr(this->GetLyricWeight()).c_str(); + element.append_attribute("lyric.weight") = FontweightToStr(this->GetLyricWeight()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -3298,12 +3298,12 @@ bool AttLyricstyle::HasLyricSize( ) bool AttLyricstyle::HasLyricStyle( ) { - return (m_lyricStyle != ""); + return (m_lyricStyle != FONTSTYLE_NONE); } bool AttLyricstyle::HasLyricWeight( ) { - return (m_lyricWeight != ""); + return (m_lyricWeight != FONTWEIGHT_NONE); } @@ -3326,29 +3326,29 @@ void AttMeasureLog::ResetMeasureLog() { m_right = BARRENDITION_single; } -bool AttMeasureLog::ReadMeasureLog( pugi::xml_node element ) { +bool AttMeasureLog::ReadMeasureLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("left")) { - this->SetLeft(StrToBarRendition(element.attribute("left").value())); + this->SetLeft(StrToBarrendition(element.attribute("left").value())); element.remove_attribute("left"); hasAttribute = true; } if (element.attribute("right")) { - this->SetRight(StrToBarRendition(element.attribute("right").value())); + this->SetRight(StrToBarrendition(element.attribute("right").value())); element.remove_attribute("right"); hasAttribute = true; } return hasAttribute; } -bool AttMeasureLog::WriteMeasureLog( pugi::xml_node element ) { +bool AttMeasureLog::WriteMeasureLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasLeft()) { - element.append_attribute("left") = BarRenditionToStr(this->GetLeft()).c_str(); + element.append_attribute("left") = BarrenditionToStr(this->GetLeft()).c_str(); wroteAttribute = true; } if (this->HasRight()) { - element.append_attribute("right") = BarRenditionToStr(this->GetRight()).c_str(); + element.append_attribute("right") = BarrenditionToStr(this->GetRight()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -3380,23 +3380,23 @@ AttMeasurement::~AttMeasurement() { } void AttMeasurement::ResetMeasurement() { - m_unit = 0; + m_unit = ""; } -bool AttMeasurement::ReadMeasurement( pugi::xml_node element ) { +bool AttMeasurement::ReadMeasurement( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("unit")) { - this->SetUnit(StrToInt(element.attribute("unit").value())); + this->SetUnit(StrToStr(element.attribute("unit").value())); element.remove_attribute("unit"); hasAttribute = true; } return hasAttribute; } -bool AttMeasurement::WriteMeasurement( pugi::xml_node element ) { +bool AttMeasurement::WriteMeasurement( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasUnit()) { - element.append_attribute("unit") = IntToStr(this->GetUnit()).c_str(); + element.append_attribute("unit") = StrToStr(this->GetUnit()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -3404,7 +3404,7 @@ bool AttMeasurement::WriteMeasurement( pugi::xml_node element ) { bool AttMeasurement::HasUnit( ) { - return (m_unit != 0); + return (m_unit != ""); } @@ -3423,23 +3423,23 @@ AttMeasurenumbers::~AttMeasurenumbers() { } void AttMeasurenumbers::ResetMeasurenumbers() { - m_mnumVisible = ""; + m_mnumVisible = BOOLEAN_NONE; } -bool AttMeasurenumbers::ReadMeasurenumbers( pugi::xml_node element ) { +bool AttMeasurenumbers::ReadMeasurenumbers( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("mnum.visible")) { - this->SetMnumVisible(StrToStr(element.attribute("mnum.visible").value())); + this->SetMnumVisible(StrToBoolean(element.attribute("mnum.visible").value())); element.remove_attribute("mnum.visible"); hasAttribute = true; } return hasAttribute; } -bool AttMeasurenumbers::WriteMeasurenumbers( pugi::xml_node element ) { +bool AttMeasurenumbers::WriteMeasurenumbers( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasMnumVisible()) { - element.append_attribute("mnum.visible") = StrToStr(this->GetMnumVisible()).c_str(); + element.append_attribute("mnum.visible") = BooleanToStr(this->GetMnumVisible()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -3447,7 +3447,7 @@ bool AttMeasurenumbers::WriteMeasurenumbers( pugi::xml_node element ) { bool AttMeasurenumbers::HasMnumVisible( ) { - return (m_mnumVisible != ""); + return (m_mnumVisible != BOOLEAN_NONE); } @@ -3468,10 +3468,10 @@ AttMediabounds::~AttMediabounds() { void AttMediabounds::ResetMediabounds() { m_begin = ""; m_end = ""; - m_betype = ""; + m_betype = BETYPE_NONE; } -bool AttMediabounds::ReadMediabounds( pugi::xml_node element ) { +bool AttMediabounds::ReadMediabounds( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("begin")) { this->SetBegin(StrToStr(element.attribute("begin").value())); @@ -3484,14 +3484,14 @@ bool AttMediabounds::ReadMediabounds( pugi::xml_node element ) { hasAttribute = true; } if (element.attribute("betype")) { - this->SetBetype(StrToStr(element.attribute("betype").value())); + this->SetBetype(StrToBetype(element.attribute("betype").value())); element.remove_attribute("betype"); hasAttribute = true; } return hasAttribute; } -bool AttMediabounds::WriteMediabounds( pugi::xml_node element ) { +bool AttMediabounds::WriteMediabounds( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasBegin()) { element.append_attribute("begin") = StrToStr(this->GetBegin()).c_str(); @@ -3502,7 +3502,7 @@ bool AttMediabounds::WriteMediabounds( pugi::xml_node element ) { wroteAttribute = true; } if (this->HasBetype()) { - element.append_attribute("betype") = StrToStr(this->GetBetype()).c_str(); + element.append_attribute("betype") = BetypeToStr(this->GetBetype()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -3520,7 +3520,7 @@ bool AttMediabounds::HasEnd( ) bool AttMediabounds::HasBetype( ) { - return (m_betype != ""); + return (m_betype != BETYPE_NONE); } @@ -3542,7 +3542,7 @@ void AttMedium::ResetMedium() { m_medium = ""; } -bool AttMedium::ReadMedium( pugi::xml_node element ) { +bool AttMedium::ReadMedium( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("medium")) { this->SetMedium(StrToStr(element.attribute("medium").value())); @@ -3552,7 +3552,7 @@ bool AttMedium::ReadMedium( pugi::xml_node element ) { return hasAttribute; } -bool AttMedium::WriteMedium( pugi::xml_node element ) { +bool AttMedium::WriteMedium( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasMedium()) { element.append_attribute("medium") = StrToStr(this->GetMedium()).c_str(); @@ -3582,23 +3582,23 @@ AttMeiversion::~AttMeiversion() { } void AttMeiversion::ResetMeiversion() { - m_meiversion = ""; + m_meiversion = meiversion_MEIVERSION_NONE; } -bool AttMeiversion::ReadMeiversion( pugi::xml_node element ) { +bool AttMeiversion::ReadMeiversion( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("meiversion")) { - this->SetMeiversion(StrToStr(element.attribute("meiversion").value())); + this->SetMeiversion(StrToMeiversionMeiversion(element.attribute("meiversion").value())); element.remove_attribute("meiversion"); hasAttribute = true; } return hasAttribute; } -bool AttMeiversion::WriteMeiversion( pugi::xml_node element ) { +bool AttMeiversion::WriteMeiversion( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasMeiversion()) { - element.append_attribute("meiversion") = StrToStr(this->GetMeiversion()).c_str(); + element.append_attribute("meiversion") = MeiversionMeiversionToStr(this->GetMeiversion()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -3606,7 +3606,7 @@ bool AttMeiversion::WriteMeiversion( pugi::xml_node element ) { bool AttMeiversion::HasMeiversion( ) { - return (m_meiversion != ""); + return (m_meiversion != meiversion_MEIVERSION_NONE); } @@ -3629,29 +3629,29 @@ void AttMensurLog::ResetMensurLog() { m_sign = MENSURATIONSIGN_NONE; } -bool AttMensurLog::ReadMensurLog( pugi::xml_node element ) { +bool AttMensurLog::ReadMensurLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("dot")) { - this->SetDot(StrToBool(element.attribute("dot").value())); + this->SetDot(StrToBoolean(element.attribute("dot").value())); element.remove_attribute("dot"); hasAttribute = true; } if (element.attribute("sign")) { - this->SetSign(StrToMensurationSign(element.attribute("sign").value())); + this->SetSign(StrToMensurationsign(element.attribute("sign").value())); element.remove_attribute("sign"); hasAttribute = true; } return hasAttribute; } -bool AttMensurLog::WriteMensurLog( pugi::xml_node element ) { +bool AttMensurLog::WriteMensurLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasDot()) { - element.append_attribute("dot") = BoolToStr(this->GetDot()).c_str(); + element.append_attribute("dot") = BooleanToStr(this->GetDot()).c_str(); wroteAttribute = true; } if (this->HasSign()) { - element.append_attribute("sign") = MensurationSignToStr(this->GetSign()).c_str(); + element.append_attribute("sign") = MensurationsignToStr(this->GetSign()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -3688,7 +3688,7 @@ void AttMeterSigLog::ResetMeterSigLog() { m_unit = 0; } -bool AttMeterSigLog::ReadMeterSigLog( pugi::xml_node element ) { +bool AttMeterSigLog::ReadMeterSigLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("count")) { this->SetCount(StrToInt(element.attribute("count").value())); @@ -3696,7 +3696,7 @@ bool AttMeterSigLog::ReadMeterSigLog( pugi::xml_node element ) { hasAttribute = true; } if (element.attribute("sym")) { - this->SetSym(StrToMeterSign(element.attribute("sym").value())); + this->SetSym(StrToMetersign(element.attribute("sym").value())); element.remove_attribute("sym"); hasAttribute = true; } @@ -3708,14 +3708,14 @@ bool AttMeterSigLog::ReadMeterSigLog( pugi::xml_node element ) { return hasAttribute; } -bool AttMeterSigLog::WriteMeterSigLog( pugi::xml_node element ) { +bool AttMeterSigLog::WriteMeterSigLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasCount()) { element.append_attribute("count") = IntToStr(this->GetCount()).c_str(); wroteAttribute = true; } if (this->HasSym()) { - element.append_attribute("sym") = MeterSignToStr(this->GetSym()).c_str(); + element.append_attribute("sym") = MetersignToStr(this->GetSym()).c_str(); wroteAttribute = true; } if (this->HasUnit()) { @@ -3756,23 +3756,23 @@ AttMeterSigVis::~AttMeterSigVis() { } void AttMeterSigVis::ResetMeterSigVis() { - m_form = BARRENDITION_single; + m_form = meterSigVis_FORM_NONE; } -bool AttMeterSigVis::ReadMeterSigVis( pugi::xml_node element ) { +bool AttMeterSigVis::ReadMeterSigVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("form")) { - this->SetForm(StrToBarRendition(element.attribute("form").value())); + this->SetForm(StrToMeterSigVisForm(element.attribute("form").value())); element.remove_attribute("form"); hasAttribute = true; } return hasAttribute; } -bool AttMeterSigVis::WriteMeterSigVis( pugi::xml_node element ) { +bool AttMeterSigVis::WriteMeterSigVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasForm()) { - element.append_attribute("form") = BarRenditionToStr(this->GetForm()).c_str(); + element.append_attribute("form") = MeterSigVisFormToStr(this->GetForm()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -3780,7 +3780,7 @@ bool AttMeterSigVis::WriteMeterSigVis( pugi::xml_node element ) { bool AttMeterSigVis::HasForm( ) { - return (m_form != BARRENDITION_single); + return (m_form != meterSigVis_FORM_NONE); } @@ -3803,7 +3803,7 @@ void AttMeterSigDefaultLog::ResetMeterSigDefaultLog() { m_meterUnit = 0; } -bool AttMeterSigDefaultLog::ReadMeterSigDefaultLog( pugi::xml_node element ) { +bool AttMeterSigDefaultLog::ReadMeterSigDefaultLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("meter.count")) { this->SetMeterCount(StrToInt(element.attribute("meter.count").value())); @@ -3818,7 +3818,7 @@ bool AttMeterSigDefaultLog::ReadMeterSigDefaultLog( pugi::xml_node element ) { return hasAttribute; } -bool AttMeterSigDefaultLog::WriteMeterSigDefaultLog( pugi::xml_node element ) { +bool AttMeterSigDefaultLog::WriteMeterSigDefaultLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasMeterCount()) { element.append_attribute("meter.count") = IntToStr(this->GetMeterCount()).c_str(); @@ -3857,43 +3857,43 @@ AttMeterSigDefaultVis::~AttMeterSigDefaultVis() { } void AttMeterSigDefaultVis::ResetMeterSigDefaultVis() { - m_meterRend = ""; - m_meterShowchange = ""; + m_meterRend = meterSigDefaultVis_METERREND_NONE; + m_meterShowchange = BOOLEAN_NONE; m_meterSym = METERSIGN_NONE; } -bool AttMeterSigDefaultVis::ReadMeterSigDefaultVis( pugi::xml_node element ) { +bool AttMeterSigDefaultVis::ReadMeterSigDefaultVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("meter.rend")) { - this->SetMeterRend(StrToStr(element.attribute("meter.rend").value())); + this->SetMeterRend(StrToMeterSigDefaultVisMeterrend(element.attribute("meter.rend").value())); element.remove_attribute("meter.rend"); hasAttribute = true; } if (element.attribute("meter.showchange")) { - this->SetMeterShowchange(StrToStr(element.attribute("meter.showchange").value())); + this->SetMeterShowchange(StrToBoolean(element.attribute("meter.showchange").value())); element.remove_attribute("meter.showchange"); hasAttribute = true; } if (element.attribute("meter.sym")) { - this->SetMeterSym(StrToMeterSign(element.attribute("meter.sym").value())); + this->SetMeterSym(StrToMetersign(element.attribute("meter.sym").value())); element.remove_attribute("meter.sym"); hasAttribute = true; } return hasAttribute; } -bool AttMeterSigDefaultVis::WriteMeterSigDefaultVis( pugi::xml_node element ) { +bool AttMeterSigDefaultVis::WriteMeterSigDefaultVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasMeterRend()) { - element.append_attribute("meter.rend") = StrToStr(this->GetMeterRend()).c_str(); + element.append_attribute("meter.rend") = MeterSigDefaultVisMeterrendToStr(this->GetMeterRend()).c_str(); wroteAttribute = true; } if (this->HasMeterShowchange()) { - element.append_attribute("meter.showchange") = StrToStr(this->GetMeterShowchange()).c_str(); + element.append_attribute("meter.showchange") = BooleanToStr(this->GetMeterShowchange()).c_str(); wroteAttribute = true; } if (this->HasMeterSym()) { - element.append_attribute("meter.sym") = MeterSignToStr(this->GetMeterSym()).c_str(); + element.append_attribute("meter.sym") = MetersignToStr(this->GetMeterSym()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -3901,12 +3901,12 @@ bool AttMeterSigDefaultVis::WriteMeterSigDefaultVis( pugi::xml_node element ) { bool AttMeterSigDefaultVis::HasMeterRend( ) { - return (m_meterRend != ""); + return (m_meterRend != meterSigDefaultVis_METERREND_NONE); } bool AttMeterSigDefaultVis::HasMeterShowchange( ) { - return (m_meterShowchange != ""); + return (m_meterShowchange != BOOLEAN_NONE); } bool AttMeterSigDefaultVis::HasMeterSym( ) @@ -3930,23 +3930,23 @@ AttMeterconformance::~AttMeterconformance() { } void AttMeterconformance::ResetMeterconformance() { - m_metcon = ""; + m_metcon = meterconformance_METCON_NONE; } -bool AttMeterconformance::ReadMeterconformance( pugi::xml_node element ) { +bool AttMeterconformance::ReadMeterconformance( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("metcon")) { - this->SetMetcon(StrToStr(element.attribute("metcon").value())); + this->SetMetcon(StrToMeterconformanceMetcon(element.attribute("metcon").value())); element.remove_attribute("metcon"); hasAttribute = true; } return hasAttribute; } -bool AttMeterconformance::WriteMeterconformance( pugi::xml_node element ) { +bool AttMeterconformance::WriteMeterconformance( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasMetcon()) { - element.append_attribute("metcon") = StrToStr(this->GetMetcon()).c_str(); + element.append_attribute("metcon") = MeterconformanceMetconToStr(this->GetMetcon()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -3954,7 +3954,7 @@ bool AttMeterconformance::WriteMeterconformance( pugi::xml_node element ) { bool AttMeterconformance::HasMetcon( ) { - return (m_metcon != ""); + return (m_metcon != meterconformance_METCON_NONE); } @@ -3973,33 +3973,33 @@ AttMeterconformanceBar::~AttMeterconformanceBar() { } void AttMeterconformanceBar::ResetMeterconformanceBar() { - m_metcon = ""; - m_control = ""; + m_metcon = BOOLEAN_NONE; + m_control = BOOLEAN_NONE; } -bool AttMeterconformanceBar::ReadMeterconformanceBar( pugi::xml_node element ) { +bool AttMeterconformanceBar::ReadMeterconformanceBar( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("metcon")) { - this->SetMetcon(StrToStr(element.attribute("metcon").value())); + this->SetMetcon(StrToBoolean(element.attribute("metcon").value())); element.remove_attribute("metcon"); hasAttribute = true; } if (element.attribute("control")) { - this->SetControl(StrToStr(element.attribute("control").value())); + this->SetControl(StrToBoolean(element.attribute("control").value())); element.remove_attribute("control"); hasAttribute = true; } return hasAttribute; } -bool AttMeterconformanceBar::WriteMeterconformanceBar( pugi::xml_node element ) { +bool AttMeterconformanceBar::WriteMeterconformanceBar( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasMetcon()) { - element.append_attribute("metcon") = StrToStr(this->GetMetcon()).c_str(); + element.append_attribute("metcon") = BooleanToStr(this->GetMetcon()).c_str(); wroteAttribute = true; } if (this->HasControl()) { - element.append_attribute("control") = StrToStr(this->GetControl()).c_str(); + element.append_attribute("control") = BooleanToStr(this->GetControl()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -4007,12 +4007,12 @@ bool AttMeterconformanceBar::WriteMeterconformanceBar( pugi::xml_node element ) bool AttMeterconformanceBar::HasMetcon( ) { - return (m_metcon != ""); + return (m_metcon != BOOLEAN_NONE); } bool AttMeterconformanceBar::HasControl( ) { - return (m_control != ""); + return (m_control != BOOLEAN_NONE); } @@ -4032,11 +4032,11 @@ AttMmtempo::~AttMmtempo() { void AttMmtempo::ResetMmtempo() { m_mm = ""; - m_mmUnit = ""; - m_mmDots = ""; + m_mmUnit = DURATION_NONE; + m_mmDots = 0; } -bool AttMmtempo::ReadMmtempo( pugi::xml_node element ) { +bool AttMmtempo::ReadMmtempo( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("mm")) { this->SetMm(StrToStr(element.attribute("mm").value())); @@ -4044,30 +4044,30 @@ bool AttMmtempo::ReadMmtempo( pugi::xml_node element ) { hasAttribute = true; } if (element.attribute("mm.unit")) { - this->SetMmUnit(StrToStr(element.attribute("mm.unit").value())); + this->SetMmUnit(StrToDuration(element.attribute("mm.unit").value())); element.remove_attribute("mm.unit"); hasAttribute = true; } if (element.attribute("mm.dots")) { - this->SetMmDots(StrToStr(element.attribute("mm.dots").value())); + this->SetMmDots(StrToInt(element.attribute("mm.dots").value())); element.remove_attribute("mm.dots"); hasAttribute = true; } return hasAttribute; } -bool AttMmtempo::WriteMmtempo( pugi::xml_node element ) { +bool AttMmtempo::WriteMmtempo( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasMm()) { element.append_attribute("mm") = StrToStr(this->GetMm()).c_str(); wroteAttribute = true; } if (this->HasMmUnit()) { - element.append_attribute("mm.unit") = StrToStr(this->GetMmUnit()).c_str(); + element.append_attribute("mm.unit") = DurationToStr(this->GetMmUnit()).c_str(); wroteAttribute = true; } if (this->HasMmDots()) { - element.append_attribute("mm.dots") = StrToStr(this->GetMmDots()).c_str(); + element.append_attribute("mm.dots") = IntToStr(this->GetMmDots()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -4080,12 +4080,12 @@ bool AttMmtempo::HasMm( ) bool AttMmtempo::HasMmUnit( ) { - return (m_mmUnit != ""); + return (m_mmUnit != DURATION_NONE); } bool AttMmtempo::HasMmDots( ) { - return (m_mmDots != ""); + return (m_mmDots != 0); } @@ -4107,20 +4107,20 @@ void AttMultinummeasures::ResetMultinummeasures() { m_multiNumber = BOOLEAN_NONE; } -bool AttMultinummeasures::ReadMultinummeasures( pugi::xml_node element ) { +bool AttMultinummeasures::ReadMultinummeasures( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("multi.number")) { - this->SetMultiNumber(StrToBool(element.attribute("multi.number").value())); + this->SetMultiNumber(StrToBoolean(element.attribute("multi.number").value())); element.remove_attribute("multi.number"); hasAttribute = true; } return hasAttribute; } -bool AttMultinummeasures::WriteMultinummeasures( pugi::xml_node element ) { +bool AttMultinummeasures::WriteMultinummeasures( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasMultiNumber()) { - element.append_attribute("multi.number") = BoolToStr(this->GetMultiNumber()).c_str(); + element.append_attribute("multi.number") = BooleanToStr(this->GetMultiNumber()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -4151,7 +4151,7 @@ void AttName::ResetName() { m_role = ""; } -bool AttName::ReadName( pugi::xml_node element ) { +bool AttName::ReadName( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("nymref")) { this->SetNymref(StrToStr(element.attribute("nymref").value())); @@ -4166,7 +4166,7 @@ bool AttName::ReadName( pugi::xml_node element ) { return hasAttribute; } -bool AttName::WriteName( pugi::xml_node element ) { +bool AttName::WriteName( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasNymref()) { element.append_attribute("nymref") = StrToStr(this->GetNymref()).c_str(); @@ -4209,7 +4209,7 @@ void AttNotationstyle::ResetNotationstyle() { m_musicSize = ""; } -bool AttNotationstyle::ReadNotationstyle( pugi::xml_node element ) { +bool AttNotationstyle::ReadNotationstyle( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("music.name")) { this->SetMusicName(StrToStr(element.attribute("music.name").value())); @@ -4224,7 +4224,7 @@ bool AttNotationstyle::ReadNotationstyle( pugi::xml_node element ) { return hasAttribute; } -bool AttNotationstyle::WriteNotationstyle( pugi::xml_node element ) { +bool AttNotationstyle::WriteNotationstyle( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasMusicName()) { element.append_attribute("music.name") = StrToStr(this->GetMusicName()).c_str(); @@ -4263,43 +4263,43 @@ AttNoteGes::~AttNoteGes() { } void AttNoteGes::ResetNoteGes() { - m_octGes = ""; - m_pnameGes = ""; - m_pnum = ""; + m_octGes = 0; + m_pnameGes = PITCHNAME_NONE; + m_pnum = 0; } -bool AttNoteGes::ReadNoteGes( pugi::xml_node element ) { +bool AttNoteGes::ReadNoteGes( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("oct.ges")) { - this->SetOctGes(StrToStr(element.attribute("oct.ges").value())); + this->SetOctGes(StrToInt(element.attribute("oct.ges").value())); element.remove_attribute("oct.ges"); hasAttribute = true; } if (element.attribute("pname.ges")) { - this->SetPnameGes(StrToStr(element.attribute("pname.ges").value())); + this->SetPnameGes(StrToPitchname(element.attribute("pname.ges").value())); element.remove_attribute("pname.ges"); hasAttribute = true; } if (element.attribute("pnum")) { - this->SetPnum(StrToStr(element.attribute("pnum").value())); + this->SetPnum(StrToInt(element.attribute("pnum").value())); element.remove_attribute("pnum"); hasAttribute = true; } return hasAttribute; } -bool AttNoteGes::WriteNoteGes( pugi::xml_node element ) { +bool AttNoteGes::WriteNoteGes( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasOctGes()) { - element.append_attribute("oct.ges") = StrToStr(this->GetOctGes()).c_str(); + element.append_attribute("oct.ges") = IntToStr(this->GetOctGes()).c_str(); wroteAttribute = true; } if (this->HasPnameGes()) { - element.append_attribute("pname.ges") = StrToStr(this->GetPnameGes()).c_str(); + element.append_attribute("pname.ges") = PitchnameToStr(this->GetPnameGes()).c_str(); wroteAttribute = true; } if (this->HasPnum()) { - element.append_attribute("pnum") = StrToStr(this->GetPnum()).c_str(); + element.append_attribute("pnum") = IntToStr(this->GetPnum()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -4307,17 +4307,17 @@ bool AttNoteGes::WriteNoteGes( pugi::xml_node element ) { bool AttNoteGes::HasOctGes( ) { - return (m_octGes != ""); + return (m_octGes != 0); } bool AttNoteGes::HasPnameGes( ) { - return (m_pnameGes != ""); + return (m_pnameGes != PITCHNAME_NONE); } bool AttNoteGes::HasPnum( ) { - return (m_pnum != ""); + return (m_pnum != 0); } @@ -4342,10 +4342,10 @@ void AttNoteheads::ResetNoteheads() { m_headMod = ""; m_headRotation = ""; m_headShape = ""; - m_headVisible = ""; + m_headVisible = BOOLEAN_NONE; } -bool AttNoteheads::ReadNoteheads( pugi::xml_node element ) { +bool AttNoteheads::ReadNoteheads( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("head.color")) { this->SetHeadColor(StrToStr(element.attribute("head.color").value())); @@ -4378,14 +4378,14 @@ bool AttNoteheads::ReadNoteheads( pugi::xml_node element ) { hasAttribute = true; } if (element.attribute("head.visible")) { - this->SetHeadVisible(StrToStr(element.attribute("head.visible").value())); + this->SetHeadVisible(StrToBoolean(element.attribute("head.visible").value())); element.remove_attribute("head.visible"); hasAttribute = true; } return hasAttribute; } -bool AttNoteheads::WriteNoteheads( pugi::xml_node element ) { +bool AttNoteheads::WriteNoteheads( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasHeadColor()) { element.append_attribute("head.color") = StrToStr(this->GetHeadColor()).c_str(); @@ -4412,7 +4412,7 @@ bool AttNoteheads::WriteNoteheads( pugi::xml_node element ) { wroteAttribute = true; } if (this->HasHeadVisible()) { - element.append_attribute("head.visible") = StrToStr(this->GetHeadVisible()).c_str(); + element.append_attribute("head.visible") = BooleanToStr(this->GetHeadVisible()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -4450,7 +4450,7 @@ bool AttNoteheads::HasHeadShape( ) bool AttNoteheads::HasHeadVisible( ) { - return (m_headVisible != ""); + return (m_headVisible != BOOLEAN_NONE); } @@ -4472,7 +4472,7 @@ void AttOctave::ResetOctave() { m_oct = 0; } -bool AttOctave::ReadOctave( pugi::xml_node element ) { +bool AttOctave::ReadOctave( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("oct")) { this->SetOct(StrToInt(element.attribute("oct").value())); @@ -4482,7 +4482,7 @@ bool AttOctave::ReadOctave( pugi::xml_node element ) { return hasAttribute; } -bool AttOctave::WriteOctave( pugi::xml_node element ) { +bool AttOctave::WriteOctave( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasOct()) { element.append_attribute("oct") = IntToStr(this->GetOct()).c_str(); @@ -4512,23 +4512,23 @@ AttOctavedefault::~AttOctavedefault() { } void AttOctavedefault::ResetOctavedefault() { - m_octaveDefault = ""; + m_octaveDefault = 0; } -bool AttOctavedefault::ReadOctavedefault( pugi::xml_node element ) { +bool AttOctavedefault::ReadOctavedefault( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("octave.default")) { - this->SetOctaveDefault(StrToStr(element.attribute("octave.default").value())); + this->SetOctaveDefault(StrToInt(element.attribute("octave.default").value())); element.remove_attribute("octave.default"); hasAttribute = true; } return hasAttribute; } -bool AttOctavedefault::WriteOctavedefault( pugi::xml_node element ) { +bool AttOctavedefault::WriteOctavedefault( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasOctaveDefault()) { - element.append_attribute("octave.default") = StrToStr(this->GetOctaveDefault()).c_str(); + element.append_attribute("octave.default") = IntToStr(this->GetOctaveDefault()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -4536,7 +4536,7 @@ bool AttOctavedefault::WriteOctavedefault( pugi::xml_node element ) { bool AttOctavedefault::HasOctaveDefault( ) { - return (m_octaveDefault != ""); + return (m_octaveDefault != 0); } @@ -4559,7 +4559,7 @@ void AttOctavedisplacement::ResetOctavedisplacement() { m_disPlace = PLACE_NONE; } -bool AttOctavedisplacement::ReadOctavedisplacement( pugi::xml_node element ) { +bool AttOctavedisplacement::ReadOctavedisplacement( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("dis")) { this->SetDis(StrToOctaveDis(element.attribute("dis").value())); @@ -4574,7 +4574,7 @@ bool AttOctavedisplacement::ReadOctavedisplacement( pugi::xml_node element ) { return hasAttribute; } -bool AttOctavedisplacement::WriteOctavedisplacement( pugi::xml_node element ) { +bool AttOctavedisplacement::WriteOctavedisplacement( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasDis()) { element.append_attribute("dis") = OctaveDisToStr(this->GetDis()).c_str(); @@ -4613,23 +4613,23 @@ AttOnelinestaff::~AttOnelinestaff() { } void AttOnelinestaff::ResetOnelinestaff() { - m_ontheline = ""; + m_ontheline = BOOLEAN_NONE; } -bool AttOnelinestaff::ReadOnelinestaff( pugi::xml_node element ) { +bool AttOnelinestaff::ReadOnelinestaff( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("ontheline")) { - this->SetOntheline(StrToStr(element.attribute("ontheline").value())); + this->SetOntheline(StrToBoolean(element.attribute("ontheline").value())); element.remove_attribute("ontheline"); hasAttribute = true; } return hasAttribute; } -bool AttOnelinestaff::WriteOnelinestaff( pugi::xml_node element ) { +bool AttOnelinestaff::WriteOnelinestaff( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasOntheline()) { - element.append_attribute("ontheline") = StrToStr(this->GetOntheline()).c_str(); + element.append_attribute("ontheline") = BooleanToStr(this->GetOntheline()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -4637,7 +4637,7 @@ bool AttOnelinestaff::WriteOnelinestaff( pugi::xml_node element ) { bool AttOnelinestaff::HasOntheline( ) { - return (m_ontheline != ""); + return (m_ontheline != BOOLEAN_NONE); } @@ -4656,23 +4656,23 @@ AttOptimization::~AttOptimization() { } void AttOptimization::ResetOptimization() { - m_optimize = ""; + m_optimize = BOOLEAN_NONE; } -bool AttOptimization::ReadOptimization( pugi::xml_node element ) { +bool AttOptimization::ReadOptimization( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("optimize")) { - this->SetOptimize(StrToStr(element.attribute("optimize").value())); + this->SetOptimize(StrToBoolean(element.attribute("optimize").value())); element.remove_attribute("optimize"); hasAttribute = true; } return hasAttribute; } -bool AttOptimization::WriteOptimization( pugi::xml_node element ) { +bool AttOptimization::WriteOptimization( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasOptimize()) { - element.append_attribute("optimize") = StrToStr(this->GetOptimize()).c_str(); + element.append_attribute("optimize") = BooleanToStr(this->GetOptimize()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -4680,7 +4680,7 @@ bool AttOptimization::WriteOptimization( pugi::xml_node element ) { bool AttOptimization::HasOptimize( ) { - return (m_optimize != ""); + return (m_optimize != BOOLEAN_NONE); } @@ -4699,10 +4699,10 @@ AttPadLog::~AttPadLog() { } void AttPadLog::ResetPadLog() { - m_num = -1; + m_num = 0; } -bool AttPadLog::ReadPadLog( pugi::xml_node element ) { +bool AttPadLog::ReadPadLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("num")) { this->SetNum(StrToInt(element.attribute("num").value())); @@ -4712,7 +4712,7 @@ bool AttPadLog::ReadPadLog( pugi::xml_node element ) { return hasAttribute; } -bool AttPadLog::WritePadLog( pugi::xml_node element ) { +bool AttPadLog::WritePadLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasNum()) { element.append_attribute("num") = IntToStr(this->GetNum()).c_str(); @@ -4723,7 +4723,7 @@ bool AttPadLog::WritePadLog( pugi::xml_node element ) { bool AttPadLog::HasNum( ) { - return (m_num != -1); + return (m_num != 0); } @@ -4752,7 +4752,7 @@ void AttPages::ResetPages() { m_pageScale = ""; } -bool AttPages::ReadPages( pugi::xml_node element ) { +bool AttPages::ReadPages( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("page.height")) { this->SetPageHeight(StrToStr(element.attribute("page.height").value())); @@ -4797,7 +4797,7 @@ bool AttPages::ReadPages( pugi::xml_node element ) { return hasAttribute; } -bool AttPages::WritePages( pugi::xml_node element ) { +bool AttPages::WritePages( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasPageHeight()) { element.append_attribute("page.height") = StrToStr(this->GetPageHeight()).c_str(); @@ -4890,23 +4890,23 @@ AttPbVis::~AttPbVis() { } void AttPbVis::ResetPbVis() { - m_folium = ""; + m_folium = pbVis_FOLIUM_NONE; } -bool AttPbVis::ReadPbVis( pugi::xml_node element ) { +bool AttPbVis::ReadPbVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("folium")) { - this->SetFolium(StrToStr(element.attribute("folium").value())); + this->SetFolium(StrToPbVisFolium(element.attribute("folium").value())); element.remove_attribute("folium"); hasAttribute = true; } return hasAttribute; } -bool AttPbVis::WritePbVis( pugi::xml_node element ) { +bool AttPbVis::WritePbVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasFolium()) { - element.append_attribute("folium") = StrToStr(this->GetFolium()).c_str(); + element.append_attribute("folium") = PbVisFoliumToStr(this->GetFolium()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -4914,7 +4914,7 @@ bool AttPbVis::WritePbVis( pugi::xml_node element ) { bool AttPbVis::HasFolium( ) { - return (m_folium != ""); + return (m_folium != pbVis_FOLIUM_NONE); } @@ -4936,20 +4936,20 @@ void AttPitch::ResetPitch() { m_pname = PITCHNAME_NONE; } -bool AttPitch::ReadPitch( pugi::xml_node element ) { +bool AttPitch::ReadPitch( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("pname")) { - this->SetPname(StrToPitchName(element.attribute("pname").value())); + this->SetPname(StrToPitchname(element.attribute("pname").value())); element.remove_attribute("pname"); hasAttribute = true; } return hasAttribute; } -bool AttPitch::WritePitch( pugi::xml_node element ) { +bool AttPitch::WritePitch( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasPname()) { - element.append_attribute("pname") = PitchNameToStr(this->GetPname()).c_str(); + element.append_attribute("pname") = PitchnameToStr(this->GetPname()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -4979,20 +4979,20 @@ void AttPlacement::ResetPlacement() { m_place = STAFFREL_NONE; } -bool AttPlacement::ReadPlacement( pugi::xml_node element ) { +bool AttPlacement::ReadPlacement( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("place")) { - this->SetPlace(StrToStaffRel(element.attribute("place").value())); + this->SetPlace(StrToStaffrel(element.attribute("place").value())); element.remove_attribute("place"); hasAttribute = true; } return hasAttribute; } -bool AttPlacement::WritePlacement( pugi::xml_node element ) { +bool AttPlacement::WritePlacement( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasPlace()) { - element.append_attribute("place") = StaffRelToStr(this->GetPlace()).c_str(); + element.append_attribute("place") = StaffrelToStr(this->GetPlace()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -5020,10 +5020,10 @@ AttPlist::~AttPlist() { void AttPlist::ResetPlist() { m_plist = ""; - m_evaluate = ""; + m_evaluate = plist_EVALUATE_NONE; } -bool AttPlist::ReadPlist( pugi::xml_node element ) { +bool AttPlist::ReadPlist( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("plist")) { this->SetPlist(StrToStr(element.attribute("plist").value())); @@ -5031,21 +5031,21 @@ bool AttPlist::ReadPlist( pugi::xml_node element ) { hasAttribute = true; } if (element.attribute("evaluate")) { - this->SetEvaluate(StrToStr(element.attribute("evaluate").value())); + this->SetEvaluate(StrToPlistEvaluate(element.attribute("evaluate").value())); element.remove_attribute("evaluate"); hasAttribute = true; } return hasAttribute; } -bool AttPlist::WritePlist( pugi::xml_node element ) { +bool AttPlist::WritePlist( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasPlist()) { element.append_attribute("plist") = StrToStr(this->GetPlist()).c_str(); wroteAttribute = true; } if (this->HasEvaluate()) { - element.append_attribute("evaluate") = StrToStr(this->GetEvaluate()).c_str(); + element.append_attribute("evaluate") = PlistEvaluateToStr(this->GetEvaluate()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -5058,7 +5058,7 @@ bool AttPlist::HasPlist( ) bool AttPlist::HasEvaluate( ) { - return (m_evaluate != ""); + return (m_evaluate != plist_EVALUATE_NONE); } @@ -5085,7 +5085,7 @@ void AttPointing::ResetPointing() { m_title = ""; } -bool AttPointing::ReadPointing( pugi::xml_node element ) { +bool AttPointing::ReadPointing( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("actuate")) { this->SetActuate(StrToStr(element.attribute("actuate").value())); @@ -5120,7 +5120,7 @@ bool AttPointing::ReadPointing( pugi::xml_node element ) { return hasAttribute; } -bool AttPointing::WritePointing( pugi::xml_node element ) { +bool AttPointing::WritePointing( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasActuate()) { element.append_attribute("actuate") = StrToStr(this->GetActuate()).c_str(); @@ -5195,10 +5195,10 @@ AttQuantity::~AttQuantity() { } void AttQuantity::ResetQuantity() { - m_quantityDbl = 0.0; + m_quantity = 0.0; } -bool AttQuantity::ReadQuantity( pugi::xml_node element ) { +bool AttQuantity::ReadQuantity( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("quantity")) { this->SetQuantity(StrToDbl(element.attribute("quantity").value())); @@ -5208,7 +5208,7 @@ bool AttQuantity::ReadQuantity( pugi::xml_node element ) { return hasAttribute; } -bool AttQuantity::WriteQuantity( pugi::xml_node element ) { +bool AttQuantity::WriteQuantity( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasQuantity()) { element.append_attribute("quantity") = DblToStr(this->GetQuantity()).c_str(); @@ -5219,7 +5219,7 @@ bool AttQuantity::WriteQuantity( pugi::xml_node element ) { bool AttQuantity::HasQuantity( ) { - return (m_quantityDbl != 0.0); + return (m_quantity != 0.0); } @@ -5238,23 +5238,23 @@ AttRelativesize::~AttRelativesize() { } void AttRelativesize::ResetRelativesize() { - m_size = ""; + m_size = SIZE_NONE; } -bool AttRelativesize::ReadRelativesize( pugi::xml_node element ) { +bool AttRelativesize::ReadRelativesize( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("size")) { - this->SetSize(StrToStr(element.attribute("size").value())); + this->SetSize(StrToSize(element.attribute("size").value())); element.remove_attribute("size"); hasAttribute = true; } return hasAttribute; } -bool AttRelativesize::WriteRelativesize( pugi::xml_node element ) { +bool AttRelativesize::WriteRelativesize( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasSize()) { - element.append_attribute("size") = StrToStr(this->GetSize()).c_str(); + element.append_attribute("size") = SizeToStr(this->GetSize()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -5262,7 +5262,7 @@ bool AttRelativesize::WriteRelativesize( pugi::xml_node element ) { bool AttRelativesize::HasSize( ) { - return (m_size != ""); + return (m_size != SIZE_NONE); } @@ -5284,7 +5284,7 @@ void AttResponsibility::ResetResponsibility() { m_resp = ""; } -bool AttResponsibility::ReadResponsibility( pugi::xml_node element ) { +bool AttResponsibility::ReadResponsibility( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("resp")) { this->SetResp(StrToStr(element.attribute("resp").value())); @@ -5294,7 +5294,7 @@ bool AttResponsibility::ReadResponsibility( pugi::xml_node element ) { return hasAttribute; } -bool AttResponsibility::WriteResponsibility( pugi::xml_node element ) { +bool AttResponsibility::WriteResponsibility( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasResp()) { element.append_attribute("resp") = StrToStr(this->GetResp()).c_str(); @@ -5324,23 +5324,23 @@ AttSbVis::~AttSbVis() { } void AttSbVis::ResetSbVis() { - m_form = BARRENDITION_single; + m_form = sbVis_FORM_NONE; } -bool AttSbVis::ReadSbVis( pugi::xml_node element ) { +bool AttSbVis::ReadSbVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("form")) { - this->SetForm(StrToBarRendition(element.attribute("form").value())); + this->SetForm(StrToSbVisForm(element.attribute("form").value())); element.remove_attribute("form"); hasAttribute = true; } return hasAttribute; } -bool AttSbVis::WriteSbVis( pugi::xml_node element ) { +bool AttSbVis::WriteSbVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasForm()) { - element.append_attribute("form") = BarRenditionToStr(this->GetForm()).c_str(); + element.append_attribute("form") = SbVisFormToStr(this->GetForm()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -5348,7 +5348,7 @@ bool AttSbVis::WriteSbVis( pugi::xml_node element ) { bool AttSbVis::HasForm( ) { - return (m_form != BARRENDITION_single); + return (m_form != sbVis_FORM_NONE); } @@ -5370,20 +5370,20 @@ void AttScalable::ResetScalable() { m_scale = 0; } -bool AttScalable::ReadScalable( pugi::xml_node element ) { +bool AttScalable::ReadScalable( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("scale")) { - this->SetScale(StrToPercent(element.attribute("scale").value())); + this->SetScale(StrToInt(element.attribute("scale").value())); element.remove_attribute("scale"); hasAttribute = true; } return hasAttribute; } -bool AttScalable::WriteScalable( pugi::xml_node element ) { +bool AttScalable::WriteScalable( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasScale()) { - element.append_attribute("scale") = PercentToStr(this->GetScale()).c_str(); + element.append_attribute("scale") = IntToStr(this->GetScale()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -5410,15 +5410,15 @@ AttScoreDefGes::~AttScoreDefGes() { } void AttScoreDefGes::ResetScoreDefGes() { - m_tunePname = ""; - m_tuneHzDbl = 0.0; - m_tuneTemper = ""; + m_tunePname = PITCHNAME_NONE; + m_tuneHz = 0.0; + m_tuneTemper = TEMPERAMENT_NONE; } -bool AttScoreDefGes::ReadScoreDefGes( pugi::xml_node element ) { +bool AttScoreDefGes::ReadScoreDefGes( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("tune.pname")) { - this->SetTunePname(StrToStr(element.attribute("tune.pname").value())); + this->SetTunePname(StrToPitchname(element.attribute("tune.pname").value())); element.remove_attribute("tune.pname"); hasAttribute = true; } @@ -5428,17 +5428,17 @@ bool AttScoreDefGes::ReadScoreDefGes( pugi::xml_node element ) { hasAttribute = true; } if (element.attribute("tune.temper")) { - this->SetTuneTemper(StrToStr(element.attribute("tune.temper").value())); + this->SetTuneTemper(StrToTemperament(element.attribute("tune.temper").value())); element.remove_attribute("tune.temper"); hasAttribute = true; } return hasAttribute; } -bool AttScoreDefGes::WriteScoreDefGes( pugi::xml_node element ) { +bool AttScoreDefGes::WriteScoreDefGes( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasTunePname()) { - element.append_attribute("tune.pname") = StrToStr(this->GetTunePname()).c_str(); + element.append_attribute("tune.pname") = PitchnameToStr(this->GetTunePname()).c_str(); wroteAttribute = true; } if (this->HasTuneHz()) { @@ -5446,7 +5446,7 @@ bool AttScoreDefGes::WriteScoreDefGes( pugi::xml_node element ) { wroteAttribute = true; } if (this->HasTuneTemper()) { - element.append_attribute("tune.temper") = StrToStr(this->GetTuneTemper()).c_str(); + element.append_attribute("tune.temper") = TemperamentToStr(this->GetTuneTemper()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -5454,17 +5454,17 @@ bool AttScoreDefGes::WriteScoreDefGes( pugi::xml_node element ) { bool AttScoreDefGes::HasTunePname( ) { - return (m_tunePname != ""); + return (m_tunePname != PITCHNAME_NONE); } bool AttScoreDefGes::HasTuneHz( ) { - return (m_tuneHzDbl != 0.0); + return (m_tuneHz != 0.0); } bool AttScoreDefGes::HasTuneTemper( ) { - return (m_tuneTemper != ""); + return (m_tuneTemper != TEMPERAMENT_NONE); } @@ -5486,7 +5486,7 @@ void AttScoreDefVis::ResetScoreDefVis() { m_vuHeight = ""; } -bool AttScoreDefVis::ReadScoreDefVis( pugi::xml_node element ) { +bool AttScoreDefVis::ReadScoreDefVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("vu.height")) { this->SetVuHeight(StrToStr(element.attribute("vu.height").value())); @@ -5496,7 +5496,7 @@ bool AttScoreDefVis::ReadScoreDefVis( pugi::xml_node element ) { return hasAttribute; } -bool AttScoreDefVis::WriteScoreDefVis( pugi::xml_node element ) { +bool AttScoreDefVis::WriteScoreDefVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasVuHeight()) { element.append_attribute("vu.height") = StrToStr(this->GetVuHeight()).c_str(); @@ -5526,23 +5526,23 @@ AttSectionVis::~AttSectionVis() { } void AttSectionVis::ResetSectionVis() { - m_restart = ""; + m_restart = BOOLEAN_NONE; } -bool AttSectionVis::ReadSectionVis( pugi::xml_node element ) { +bool AttSectionVis::ReadSectionVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("restart")) { - this->SetRestart(StrToStr(element.attribute("restart").value())); + this->SetRestart(StrToBoolean(element.attribute("restart").value())); element.remove_attribute("restart"); hasAttribute = true; } return hasAttribute; } -bool AttSectionVis::WriteSectionVis( pugi::xml_node element ) { +bool AttSectionVis::WriteSectionVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasRestart()) { - element.append_attribute("restart") = StrToStr(this->GetRestart()).c_str(); + element.append_attribute("restart") = BooleanToStr(this->GetRestart()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -5550,7 +5550,7 @@ bool AttSectionVis::WriteSectionVis( pugi::xml_node element ) { bool AttSectionVis::HasRestart( ) { - return (m_restart != ""); + return (m_restart != BOOLEAN_NONE); } @@ -5569,10 +5569,10 @@ AttSequence::~AttSequence() { } void AttSequence::ResetSequence() { - m_seqInt = 0; + m_seq = 0; } -bool AttSequence::ReadSequence( pugi::xml_node element ) { +bool AttSequence::ReadSequence( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("seq")) { this->SetSeq(StrToInt(element.attribute("seq").value())); @@ -5582,7 +5582,7 @@ bool AttSequence::ReadSequence( pugi::xml_node element ) { return hasAttribute; } -bool AttSequence::WriteSequence( pugi::xml_node element ) { +bool AttSequence::WriteSequence( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasSeq()) { element.append_attribute("seq") = IntToStr(this->GetSeq()).c_str(); @@ -5593,7 +5593,7 @@ bool AttSequence::WriteSequence( pugi::xml_node element ) { bool AttSequence::HasSeq( ) { - return (m_seqInt != 0); + return (m_seq != 0); } @@ -5615,7 +5615,7 @@ void AttSlashcount::ResetSlashcount() { m_slash = 0; } -bool AttSlashcount::ReadSlashcount( pugi::xml_node element ) { +bool AttSlashcount::ReadSlashcount( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("slash")) { this->SetSlash(StrToInt(element.attribute("slash").value())); @@ -5625,7 +5625,7 @@ bool AttSlashcount::ReadSlashcount( pugi::xml_node element ) { return hasAttribute; } -bool AttSlashcount::WriteSlashcount( pugi::xml_node element ) { +bool AttSlashcount::WriteSlashcount( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasSlash()) { element.append_attribute("slash") = IntToStr(this->GetSlash()).c_str(); @@ -5658,7 +5658,7 @@ void AttSlurpresent::ResetSlurpresent() { m_slur = ""; } -bool AttSlurpresent::ReadSlurpresent( pugi::xml_node element ) { +bool AttSlurpresent::ReadSlurpresent( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("slur")) { this->SetSlur(StrToStr(element.attribute("slur").value())); @@ -5668,7 +5668,7 @@ bool AttSlurpresent::ReadSlurpresent( pugi::xml_node element ) { return hasAttribute; } -bool AttSlurpresent::WriteSlurpresent( pugi::xml_node element ) { +bool AttSlurpresent::WriteSlurpresent( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasSlur()) { element.append_attribute("slur") = StrToStr(this->GetSlur()).c_str(); @@ -5698,23 +5698,23 @@ AttSpaceVis::~AttSpaceVis() { } void AttSpaceVis::ResetSpaceVis() { - m_compressable = ""; + m_compressable = BOOLEAN_NONE; } -bool AttSpaceVis::ReadSpaceVis( pugi::xml_node element ) { +bool AttSpaceVis::ReadSpaceVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("compressable")) { - this->SetCompressable(StrToStr(element.attribute("compressable").value())); + this->SetCompressable(StrToBoolean(element.attribute("compressable").value())); element.remove_attribute("compressable"); hasAttribute = true; } return hasAttribute; } -bool AttSpaceVis::WriteSpaceVis( pugi::xml_node element ) { +bool AttSpaceVis::WriteSpaceVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasCompressable()) { - element.append_attribute("compressable") = StrToStr(this->GetCompressable()).c_str(); + element.append_attribute("compressable") = BooleanToStr(this->GetCompressable()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -5722,7 +5722,7 @@ bool AttSpaceVis::WriteSpaceVis( pugi::xml_node element ) { bool AttSpaceVis::HasCompressable( ) { - return (m_compressable != ""); + return (m_compressable != BOOLEAN_NONE); } @@ -5741,13 +5741,13 @@ AttSpacing::~AttSpacing() { } void AttSpacing::ResetSpacing() { - m_spacingPackexpDbl = 0.0; - m_spacingPackfactDbl = 0.0; + m_spacingPackexp = 0.0; + m_spacingPackfact = 0.0; m_spacingStaff = ""; m_spacingSystem = ""; } -bool AttSpacing::ReadSpacing( pugi::xml_node element ) { +bool AttSpacing::ReadSpacing( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("spacing.packexp")) { this->SetSpacingPackexp(StrToDbl(element.attribute("spacing.packexp").value())); @@ -5772,7 +5772,7 @@ bool AttSpacing::ReadSpacing( pugi::xml_node element ) { return hasAttribute; } -bool AttSpacing::WriteSpacing( pugi::xml_node element ) { +bool AttSpacing::WriteSpacing( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasSpacingPackexp()) { element.append_attribute("spacing.packexp") = DblToStr(this->GetSpacingPackexp()).c_str(); @@ -5795,12 +5795,12 @@ bool AttSpacing::WriteSpacing( pugi::xml_node element ) { bool AttSpacing::HasSpacingPackexp( ) { - return (m_spacingPackexpDbl != 0.0); + return (m_spacingPackexp != 0.0); } bool AttSpacing::HasSpacingPackfact( ) { - return (m_spacingPackfactDbl != 0.0); + return (m_spacingPackfact != 0.0); } bool AttSpacing::HasSpacingStaff( ) @@ -5832,7 +5832,7 @@ void AttStaffLog::ResetStaffLog() { m_def = ""; } -bool AttStaffLog::ReadStaffLog( pugi::xml_node element ) { +bool AttStaffLog::ReadStaffLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("def")) { this->SetDef(StrToStr(element.attribute("def").value())); @@ -5842,7 +5842,7 @@ bool AttStaffLog::ReadStaffLog( pugi::xml_node element ) { return hasAttribute; } -bool AttStaffLog::WriteStaffLog( pugi::xml_node element ) { +bool AttStaffLog::WriteStaffLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasDef()) { element.append_attribute("def") = StrToStr(this->GetDef()).c_str(); @@ -5874,16 +5874,16 @@ AttStaffDefVis::~AttStaffDefVis() { void AttStaffDefVis::ResetStaffDefVis() { m_gridShow = BOOLEAN_NONE; m_layerscheme = LAYERSCHEME_NONE; - m_linesInt = 0; + m_lines = 0; m_linesColor = ""; m_linesVisible = BOOLEAN_NONE; m_spacing = ""; } -bool AttStaffDefVis::ReadStaffDefVis( pugi::xml_node element ) { +bool AttStaffDefVis::ReadStaffDefVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("grid.show")) { - this->SetGridShow(StrToBool(element.attribute("grid.show").value())); + this->SetGridShow(StrToBoolean(element.attribute("grid.show").value())); element.remove_attribute("grid.show"); hasAttribute = true; } @@ -5903,7 +5903,7 @@ bool AttStaffDefVis::ReadStaffDefVis( pugi::xml_node element ) { hasAttribute = true; } if (element.attribute("lines.visible")) { - this->SetLinesVisible(StrToBool(element.attribute("lines.visible").value())); + this->SetLinesVisible(StrToBoolean(element.attribute("lines.visible").value())); element.remove_attribute("lines.visible"); hasAttribute = true; } @@ -5915,10 +5915,10 @@ bool AttStaffDefVis::ReadStaffDefVis( pugi::xml_node element ) { return hasAttribute; } -bool AttStaffDefVis::WriteStaffDefVis( pugi::xml_node element ) { +bool AttStaffDefVis::WriteStaffDefVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasGridShow()) { - element.append_attribute("grid.show") = BoolToStr(this->GetGridShow()).c_str(); + element.append_attribute("grid.show") = BooleanToStr(this->GetGridShow()).c_str(); wroteAttribute = true; } if (this->HasLayerscheme()) { @@ -5934,7 +5934,7 @@ bool AttStaffDefVis::WriteStaffDefVis( pugi::xml_node element ) { wroteAttribute = true; } if (this->HasLinesVisible()) { - element.append_attribute("lines.visible") = BoolToStr(this->GetLinesVisible()).c_str(); + element.append_attribute("lines.visible") = BooleanToStr(this->GetLinesVisible()).c_str(); wroteAttribute = true; } if (this->HasSpacing()) { @@ -5956,7 +5956,7 @@ bool AttStaffDefVis::HasLayerscheme( ) bool AttStaffDefVis::HasLines( ) { - return (m_linesInt != 0); + return (m_lines != 0); } bool AttStaffDefVis::HasLinesColor( ) @@ -5993,20 +5993,20 @@ void AttStaffGrpVis::ResetStaffGrpVis() { m_barthru = BOOLEAN_NONE; } -bool AttStaffGrpVis::ReadStaffGrpVis( pugi::xml_node element ) { +bool AttStaffGrpVis::ReadStaffGrpVis( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("barthru")) { - this->SetBarthru(StrToBool(element.attribute("barthru").value())); + this->SetBarthru(StrToBoolean(element.attribute("barthru").value())); element.remove_attribute("barthru"); hasAttribute = true; } return hasAttribute; } -bool AttStaffGrpVis::WriteStaffGrpVis( pugi::xml_node element ) { +bool AttStaffGrpVis::WriteStaffGrpVis( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasBarthru()) { - element.append_attribute("barthru") = BoolToStr(this->GetBarthru()).c_str(); + element.append_attribute("barthru") = BooleanToStr(this->GetBarthru()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -6033,23 +6033,23 @@ AttStaffgroupingsym::~AttStaffgroupingsym() { } void AttStaffgroupingsym::ResetStaffgroupingsym() { - m_symbol = SYMBOL_NONE; + m_symbol = staffgroupingsym_SYMBOL_NONE; } -bool AttStaffgroupingsym::ReadStaffgroupingsym( pugi::xml_node element ) { +bool AttStaffgroupingsym::ReadStaffgroupingsym( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("symbol")) { - this->SetSymbol(StrToSymbol(element.attribute("symbol").value())); + this->SetSymbol(StrToStaffgroupingsymSymbol(element.attribute("symbol").value())); element.remove_attribute("symbol"); hasAttribute = true; } return hasAttribute; } -bool AttStaffgroupingsym::WriteStaffgroupingsym( pugi::xml_node element ) { +bool AttStaffgroupingsym::WriteStaffgroupingsym( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasSymbol()) { - element.append_attribute("symbol") = SymbolToStr(this->GetSymbol()).c_str(); + element.append_attribute("symbol") = StaffgroupingsymSymbolToStr(this->GetSymbol()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -6057,7 +6057,7 @@ bool AttStaffgroupingsym::WriteStaffgroupingsym( pugi::xml_node element ) { bool AttStaffgroupingsym::HasSymbol( ) { - return (m_symbol != SYMBOL_NONE); + return (m_symbol != staffgroupingsym_SYMBOL_NONE); } @@ -6079,7 +6079,7 @@ void AttStaffident::ResetStaffident() { m_staff = 0; } -bool AttStaffident::ReadStaffident( pugi::xml_node element ) { +bool AttStaffident::ReadStaffident( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("staff")) { this->SetStaff(StrToInt(element.attribute("staff").value())); @@ -6089,7 +6089,7 @@ bool AttStaffident::ReadStaffident( pugi::xml_node element ) { return hasAttribute; } -bool AttStaffident::WriteStaffident( pugi::xml_node element ) { +bool AttStaffident::WriteStaffident( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasStaff()) { element.append_attribute("staff") = IntToStr(this->GetStaff()).c_str(); @@ -6119,23 +6119,23 @@ AttStaffloc::~AttStaffloc() { } void AttStaffloc::ResetStaffloc() { - m_loc = ""; + m_loc = 0; } -bool AttStaffloc::ReadStaffloc( pugi::xml_node element ) { +bool AttStaffloc::ReadStaffloc( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("loc")) { - this->SetLoc(StrToStr(element.attribute("loc").value())); + this->SetLoc(StrToInt(element.attribute("loc").value())); element.remove_attribute("loc"); hasAttribute = true; } return hasAttribute; } -bool AttStaffloc::WriteStaffloc( pugi::xml_node element ) { +bool AttStaffloc::WriteStaffloc( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasLoc()) { - element.append_attribute("loc") = StrToStr(this->GetLoc()).c_str(); + element.append_attribute("loc") = IntToStr(this->GetLoc()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -6143,7 +6143,7 @@ bool AttStaffloc::WriteStaffloc( pugi::xml_node element ) { bool AttStaffloc::HasLoc( ) { - return (m_loc != ""); + return (m_loc != 0); } @@ -6166,10 +6166,10 @@ void AttStafflocPitched::ResetStafflocPitched() { m_oloc = 0; } -bool AttStafflocPitched::ReadStafflocPitched( pugi::xml_node element ) { +bool AttStafflocPitched::ReadStafflocPitched( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("ploc")) { - this->SetPloc(StrToPitchName(element.attribute("ploc").value())); + this->SetPloc(StrToPitchname(element.attribute("ploc").value())); element.remove_attribute("ploc"); hasAttribute = true; } @@ -6181,10 +6181,10 @@ bool AttStafflocPitched::ReadStafflocPitched( pugi::xml_node element ) { return hasAttribute; } -bool AttStafflocPitched::WriteStafflocPitched( pugi::xml_node element ) { +bool AttStafflocPitched::WriteStafflocPitched( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasPloc()) { - element.append_attribute("ploc") = PitchNameToStr(this->GetPloc()).c_str(); + element.append_attribute("ploc") = PitchnameToStr(this->GetPloc()).c_str(); wroteAttribute = true; } if (this->HasOloc()) { @@ -6223,7 +6223,7 @@ void AttStartendid::ResetStartendid() { m_endid = ""; } -bool AttStartendid::ReadStartendid( pugi::xml_node element ) { +bool AttStartendid::ReadStartendid( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("endid")) { this->SetEndid(StrToStr(element.attribute("endid").value())); @@ -6233,7 +6233,7 @@ bool AttStartendid::ReadStartendid( pugi::xml_node element ) { return hasAttribute; } -bool AttStartendid::WriteStartendid( pugi::xml_node element ) { +bool AttStartendid::WriteStartendid( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasEndid()) { element.append_attribute("endid") = StrToStr(this->GetEndid()).c_str(); @@ -6266,7 +6266,7 @@ void AttStartid::ResetStartid() { m_startid = ""; } -bool AttStartid::ReadStartid( pugi::xml_node element ) { +bool AttStartid::ReadStartid( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("startid")) { this->SetStartid(StrToStr(element.attribute("startid").value())); @@ -6276,7 +6276,7 @@ bool AttStartid::ReadStartid( pugi::xml_node element ) { return hasAttribute; } -bool AttStartid::WriteStartid( pugi::xml_node element ) { +bool AttStartid::WriteStartid( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasStartid()) { element.append_attribute("startid") = StrToStr(this->GetStartid()).c_str(); @@ -6307,72 +6307,72 @@ AttStems::~AttStems() { void AttStems::ResetStems() { m_stemDir = STEMDIRECTION_NONE; - m_stemLen = 0; + m_stemLen = ""; m_stemMod = STEMMODIFIER_NONE; m_stemPos = STEMPOSITION_NONE; - m_stemX = 0; - m_stemY = 0; + m_stemX = 0.0; + m_stemY = 0.0; } -bool AttStems::ReadStems( pugi::xml_node element ) { +bool AttStems::ReadStems( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("stem.dir")) { - this->SetStemDir(StrToStemDirection(element.attribute("stem.dir").value())); + this->SetStemDir(StrToStemdirection(element.attribute("stem.dir").value())); element.remove_attribute("stem.dir"); hasAttribute = true; } if (element.attribute("stem.len")) { - this->SetStemLen(StrToInt(element.attribute("stem.len").value())); + this->SetStemLen(StrToStr(element.attribute("stem.len").value())); element.remove_attribute("stem.len"); hasAttribute = true; } if (element.attribute("stem.mod")) { - this->SetStemMod(StrToStemModifier(element.attribute("stem.mod").value())); + this->SetStemMod(StrToStemmodifier(element.attribute("stem.mod").value())); element.remove_attribute("stem.mod"); hasAttribute = true; } if (element.attribute("stem.pos")) { - this->SetStemPos(StrToStemPosition(element.attribute("stem.pos").value())); + this->SetStemPos(StrToStemposition(element.attribute("stem.pos").value())); element.remove_attribute("stem.pos"); hasAttribute = true; } if (element.attribute("stem.x")) { - this->SetStemX(StrToInt(element.attribute("stem.x").value())); + this->SetStemX(StrToDbl(element.attribute("stem.x").value())); element.remove_attribute("stem.x"); hasAttribute = true; } if (element.attribute("stem.y")) { - this->SetStemY(StrToInt(element.attribute("stem.y").value())); + this->SetStemY(StrToDbl(element.attribute("stem.y").value())); element.remove_attribute("stem.y"); hasAttribute = true; } return hasAttribute; } -bool AttStems::WriteStems( pugi::xml_node element ) { +bool AttStems::WriteStems( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasStemDir()) { - element.append_attribute("stem.dir") = StemDirectionToStr(this->GetStemDir()).c_str(); + element.append_attribute("stem.dir") = StemdirectionToStr(this->GetStemDir()).c_str(); wroteAttribute = true; } if (this->HasStemLen()) { - element.append_attribute("stem.len") = IntToStr(this->GetStemLen()).c_str(); + element.append_attribute("stem.len") = StrToStr(this->GetStemLen()).c_str(); wroteAttribute = true; } if (this->HasStemMod()) { - element.append_attribute("stem.mod") = StemModifierToStr(this->GetStemMod()).c_str(); + element.append_attribute("stem.mod") = StemmodifierToStr(this->GetStemMod()).c_str(); wroteAttribute = true; } if (this->HasStemPos()) { - element.append_attribute("stem.pos") = StemPositionToStr(this->GetStemPos()).c_str(); + element.append_attribute("stem.pos") = StempositionToStr(this->GetStemPos()).c_str(); wroteAttribute = true; } if (this->HasStemX()) { - element.append_attribute("stem.x") = IntToStr(this->GetStemX()).c_str(); + element.append_attribute("stem.x") = DblToStr(this->GetStemX()).c_str(); wroteAttribute = true; } if (this->HasStemY()) { - element.append_attribute("stem.y") = IntToStr(this->GetStemY()).c_str(); + element.append_attribute("stem.y") = DblToStr(this->GetStemY()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -6385,7 +6385,7 @@ bool AttStems::HasStemDir( ) bool AttStems::HasStemLen( ) { - return (m_stemLen != 0); + return (m_stemLen != ""); } bool AttStems::HasStemMod( ) @@ -6400,12 +6400,12 @@ bool AttStems::HasStemPos( ) bool AttStems::HasStemX( ) { - return (m_stemX != 0); + return (m_stemX != 0.0); } bool AttStems::HasStemY( ) { - return (m_stemY != 0); + return (m_stemY != 0.0); } @@ -6424,33 +6424,33 @@ AttSylLog::~AttSylLog() { } void AttSylLog::ResetSylLog() { - m_con = CON_NONE; - m_wordpos = WORDPOS_NONE; + m_con = sylLog_CON_NONE; + m_wordpos = sylLog_WORDPOS_NONE; } -bool AttSylLog::ReadSylLog( pugi::xml_node element ) { +bool AttSylLog::ReadSylLog( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("con")) { - this->SetCon(StrToCon(element.attribute("con").value())); + this->SetCon(StrToSylLogCon(element.attribute("con").value())); element.remove_attribute("con"); hasAttribute = true; } if (element.attribute("wordpos")) { - this->SetWordpos(StrToWordPos(element.attribute("wordpos").value())); + this->SetWordpos(StrToSylLogWordpos(element.attribute("wordpos").value())); element.remove_attribute("wordpos"); hasAttribute = true; } return hasAttribute; } -bool AttSylLog::WriteSylLog( pugi::xml_node element ) { +bool AttSylLog::WriteSylLog( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasCon()) { - element.append_attribute("con") = ConToStr(this->GetCon()).c_str(); + element.append_attribute("con") = SylLogConToStr(this->GetCon()).c_str(); wroteAttribute = true; } if (this->HasWordpos()) { - element.append_attribute("wordpos") = WordPosToStr(this->GetWordpos()).c_str(); + element.append_attribute("wordpos") = SylLogWordposToStr(this->GetWordpos()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -6458,12 +6458,12 @@ bool AttSylLog::WriteSylLog( pugi::xml_node element ) { bool AttSylLog::HasCon( ) { - return (m_con != CON_NONE); + return (m_con != sylLog_CON_NONE); } bool AttSylLog::HasWordpos( ) { - return (m_wordpos != WORDPOS_NONE); + return (m_wordpos != sylLog_WORDPOS_NONE); } @@ -6485,7 +6485,7 @@ void AttSyltext::ResetSyltext() { m_syl = ""; } -bool AttSyltext::ReadSyltext( pugi::xml_node element ) { +bool AttSyltext::ReadSyltext( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("syl")) { this->SetSyl(StrToStr(element.attribute("syl").value())); @@ -6495,7 +6495,7 @@ bool AttSyltext::ReadSyltext( pugi::xml_node element ) { return hasAttribute; } -bool AttSyltext::WriteSyltext( pugi::xml_node element ) { +bool AttSyltext::WriteSyltext( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasSyl()) { element.append_attribute("syl") = StrToStr(this->GetSyl()).c_str(); @@ -6525,16 +6525,16 @@ AttSystems::~AttSystems() { } void AttSystems::ResetSystems() { - m_systemLeftline = ""; + m_systemLeftline = BOOLEAN_NONE; m_systemLeftmar = ""; m_systemRightmar = ""; m_systemTopmar = ""; } -bool AttSystems::ReadSystems( pugi::xml_node element ) { +bool AttSystems::ReadSystems( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("system.leftline")) { - this->SetSystemLeftline(StrToStr(element.attribute("system.leftline").value())); + this->SetSystemLeftline(StrToBoolean(element.attribute("system.leftline").value())); element.remove_attribute("system.leftline"); hasAttribute = true; } @@ -6556,10 +6556,10 @@ bool AttSystems::ReadSystems( pugi::xml_node element ) { return hasAttribute; } -bool AttSystems::WriteSystems( pugi::xml_node element ) { +bool AttSystems::WriteSystems( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasSystemLeftline()) { - element.append_attribute("system.leftline") = StrToStr(this->GetSystemLeftline()).c_str(); + element.append_attribute("system.leftline") = BooleanToStr(this->GetSystemLeftline()).c_str(); wroteAttribute = true; } if (this->HasSystemLeftmar()) { @@ -6579,7 +6579,7 @@ bool AttSystems::WriteSystems( pugi::xml_node element ) { bool AttSystems::HasSystemLeftline( ) { - return (m_systemLeftline != ""); + return (m_systemLeftline != BOOLEAN_NONE); } bool AttSystems::HasSystemLeftmar( ) @@ -6616,11 +6616,11 @@ void AttTextstyle::ResetTextstyle() { m_textFam = ""; m_textName = ""; m_textSize = ""; - m_textStyle = ""; - m_textWeight = ""; + m_textStyle = FONTSTYLE_NONE; + m_textWeight = FONTWEIGHT_NONE; } -bool AttTextstyle::ReadTextstyle( pugi::xml_node element ) { +bool AttTextstyle::ReadTextstyle( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("text.fam")) { this->SetTextFam(StrToStr(element.attribute("text.fam").value())); @@ -6638,19 +6638,19 @@ bool AttTextstyle::ReadTextstyle( pugi::xml_node element ) { hasAttribute = true; } if (element.attribute("text.style")) { - this->SetTextStyle(StrToStr(element.attribute("text.style").value())); + this->SetTextStyle(StrToFontstyle(element.attribute("text.style").value())); element.remove_attribute("text.style"); hasAttribute = true; } if (element.attribute("text.weight")) { - this->SetTextWeight(StrToStr(element.attribute("text.weight").value())); + this->SetTextWeight(StrToFontweight(element.attribute("text.weight").value())); element.remove_attribute("text.weight"); hasAttribute = true; } return hasAttribute; } -bool AttTextstyle::WriteTextstyle( pugi::xml_node element ) { +bool AttTextstyle::WriteTextstyle( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasTextFam()) { element.append_attribute("text.fam") = StrToStr(this->GetTextFam()).c_str(); @@ -6665,11 +6665,11 @@ bool AttTextstyle::WriteTextstyle( pugi::xml_node element ) { wroteAttribute = true; } if (this->HasTextStyle()) { - element.append_attribute("text.style") = StrToStr(this->GetTextStyle()).c_str(); + element.append_attribute("text.style") = FontstyleToStr(this->GetTextStyle()).c_str(); wroteAttribute = true; } if (this->HasTextWeight()) { - element.append_attribute("text.weight") = StrToStr(this->GetTextWeight()).c_str(); + element.append_attribute("text.weight") = FontweightToStr(this->GetTextWeight()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -6692,12 +6692,12 @@ bool AttTextstyle::HasTextSize( ) bool AttTextstyle::HasTextStyle( ) { - return (m_textStyle != ""); + return (m_textStyle != FONTSTYLE_NONE); } bool AttTextstyle::HasTextWeight( ) { - return (m_textWeight != ""); + return (m_textWeight != FONTWEIGHT_NONE); } @@ -6719,7 +6719,7 @@ void AttTiepresent::ResetTiepresent() { m_tie = TIE_NONE; } -bool AttTiepresent::ReadTiepresent( pugi::xml_node element ) { +bool AttTiepresent::ReadTiepresent( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("tie")) { this->SetTie(StrToTie(element.attribute("tie").value())); @@ -6729,7 +6729,7 @@ bool AttTiepresent::ReadTiepresent( pugi::xml_node element ) { return hasAttribute; } -bool AttTiepresent::WriteTiepresent( pugi::xml_node element ) { +bool AttTiepresent::WriteTiepresent( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasTie()) { element.append_attribute("tie") = TieToStr(this->GetTie()).c_str(); @@ -6762,7 +6762,7 @@ void AttTimestampMusical::ResetTimestampMusical() { m_tstamp = -1.0; } -bool AttTimestampMusical::ReadTimestampMusical( pugi::xml_node element ) { +bool AttTimestampMusical::ReadTimestampMusical( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("tstamp")) { this->SetTstamp(StrToDbl(element.attribute("tstamp").value())); @@ -6772,7 +6772,7 @@ bool AttTimestampMusical::ReadTimestampMusical( pugi::xml_node element ) { return hasAttribute; } -bool AttTimestampMusical::WriteTimestampMusical( pugi::xml_node element ) { +bool AttTimestampMusical::WriteTimestampMusical( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasTstamp()) { element.append_attribute("tstamp") = DblToStr(this->GetTstamp()).c_str(); @@ -6802,14 +6802,14 @@ AttTimestampPerformed::~AttTimestampPerformed() { } void AttTimestampPerformed::ResetTimestampPerformed() { - m_tstampGes = ""; + m_tstampGes = DURATION_NONE; m_tstampReal = ""; } -bool AttTimestampPerformed::ReadTimestampPerformed( pugi::xml_node element ) { +bool AttTimestampPerformed::ReadTimestampPerformed( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("tstamp.ges")) { - this->SetTstampGes(StrToStr(element.attribute("tstamp.ges").value())); + this->SetTstampGes(StrToDuration(element.attribute("tstamp.ges").value())); element.remove_attribute("tstamp.ges"); hasAttribute = true; } @@ -6821,10 +6821,10 @@ bool AttTimestampPerformed::ReadTimestampPerformed( pugi::xml_node element ) { return hasAttribute; } -bool AttTimestampPerformed::WriteTimestampPerformed( pugi::xml_node element ) { +bool AttTimestampPerformed::WriteTimestampPerformed( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasTstampGes()) { - element.append_attribute("tstamp.ges") = StrToStr(this->GetTstampGes()).c_str(); + element.append_attribute("tstamp.ges") = DurationToStr(this->GetTstampGes()).c_str(); wroteAttribute = true; } if (this->HasTstampReal()) { @@ -6836,7 +6836,7 @@ bool AttTimestampPerformed::WriteTimestampPerformed( pugi::xml_node element ) { bool AttTimestampPerformed::HasTstampGes( ) { - return (m_tstampGes != ""); + return (m_tstampGes != DURATION_NONE); } bool AttTimestampPerformed::HasTstampReal( ) @@ -6863,20 +6863,20 @@ void AttTimestamp2Musical::ResetTimestamp2Musical() { m_tstamp2 = std::make_pair(-1,-1.0); } -bool AttTimestamp2Musical::ReadTimestamp2Musical( pugi::xml_node element ) { +bool AttTimestamp2Musical::ReadTimestamp2Musical( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("tstamp2")) { - this->SetTstamp2(StrToTstamp2(element.attribute("tstamp2").value())); + this->SetTstamp2(StrToMeasurebeat(element.attribute("tstamp2").value())); element.remove_attribute("tstamp2"); hasAttribute = true; } return hasAttribute; } -bool AttTimestamp2Musical::WriteTimestamp2Musical( pugi::xml_node element ) { +bool AttTimestamp2Musical::WriteTimestamp2Musical( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasTstamp2()) { - element.append_attribute("tstamp2") = Tstamp2ToStr(this->GetTstamp2()).c_str(); + element.append_attribute("tstamp2") = MeasurebeatToStr(this->GetTstamp2()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -6903,11 +6903,11 @@ AttTransposition::~AttTransposition() { } void AttTransposition::ResetTransposition() { - m_transDiatDbl = 0.0; - m_transSemiDbl = 0.0; + m_transDiat = 0.0; + m_transSemi = 0.0; } -bool AttTransposition::ReadTransposition( pugi::xml_node element ) { +bool AttTransposition::ReadTransposition( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("trans.diat")) { this->SetTransDiat(StrToDbl(element.attribute("trans.diat").value())); @@ -6922,7 +6922,7 @@ bool AttTransposition::ReadTransposition( pugi::xml_node element ) { return hasAttribute; } -bool AttTransposition::WriteTransposition( pugi::xml_node element ) { +bool AttTransposition::WriteTransposition( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasTransDiat()) { element.append_attribute("trans.diat") = DblToStr(this->GetTransDiat()).c_str(); @@ -6937,12 +6937,12 @@ bool AttTransposition::WriteTransposition( pugi::xml_node element ) { bool AttTransposition::HasTransDiat( ) { - return (m_transDiatDbl != 0.0); + return (m_transDiat != 0.0); } bool AttTransposition::HasTransSemi( ) { - return (m_transSemiDbl != 0.0); + return (m_transSemi != 0.0); } @@ -6964,7 +6964,7 @@ void AttTupletpresent::ResetTupletpresent() { m_tuplet = ""; } -bool AttTupletpresent::ReadTupletpresent( pugi::xml_node element ) { +bool AttTupletpresent::ReadTupletpresent( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("tuplet")) { this->SetTuplet(StrToStr(element.attribute("tuplet").value())); @@ -6974,7 +6974,7 @@ bool AttTupletpresent::ReadTupletpresent( pugi::xml_node element ) { return hasAttribute; } -bool AttTupletpresent::WriteTupletpresent( pugi::xml_node element ) { +bool AttTupletpresent::WriteTupletpresent( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasTuplet()) { element.append_attribute("tuplet") = StrToStr(this->GetTuplet()).c_str(); @@ -7008,7 +7008,7 @@ void AttTyped::ResetTyped() { m_subtype = ""; } -bool AttTyped::ReadTyped( pugi::xml_node element ) { +bool AttTyped::ReadTyped( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("type")) { this->SetType(StrToStr(element.attribute("type").value())); @@ -7023,7 +7023,7 @@ bool AttTyped::ReadTyped( pugi::xml_node element ) { return hasAttribute; } -bool AttTyped::WriteTyped( pugi::xml_node element ) { +bool AttTyped::WriteTyped( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasType()) { element.append_attribute("type") = StrToStr(this->GetType()).c_str(); @@ -7064,12 +7064,12 @@ AttTypography::~AttTypography() { void AttTypography::ResetTypography() { m_fontfam = ""; m_fontname = ""; - m_fontsizeDbl = 0.0; + m_fontsize = 0.0; m_fontstyle = FONTSTYLE_NONE; m_fontweight = FONTWEIGHT_NONE; } -bool AttTypography::ReadTypography( pugi::xml_node element ) { +bool AttTypography::ReadTypography( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("fontfam")) { this->SetFontfam(StrToStr(element.attribute("fontfam").value())); @@ -7099,7 +7099,7 @@ bool AttTypography::ReadTypography( pugi::xml_node element ) { return hasAttribute; } -bool AttTypography::WriteTypography( pugi::xml_node element ) { +bool AttTypography::WriteTypography( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasFontfam()) { element.append_attribute("fontfam") = StrToStr(this->GetFontfam()).c_str(); @@ -7136,7 +7136,7 @@ bool AttTypography::HasFontname( ) bool AttTypography::HasFontsize( ) { - return (m_fontsizeDbl != 0.0); + return (m_fontsize != 0.0); } bool AttTypography::HasFontstyle( ) @@ -7165,23 +7165,23 @@ AttVisibility::~AttVisibility() { } void AttVisibility::ResetVisibility() { - m_visible = ""; + m_visible = BOOLEAN_NONE; } -bool AttVisibility::ReadVisibility( pugi::xml_node element ) { +bool AttVisibility::ReadVisibility( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("visible")) { - this->SetVisible(StrToStr(element.attribute("visible").value())); + this->SetVisible(StrToBoolean(element.attribute("visible").value())); element.remove_attribute("visible"); hasAttribute = true; } return hasAttribute; } -bool AttVisibility::WriteVisibility( pugi::xml_node element ) { +bool AttVisibility::WriteVisibility( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasVisible()) { - element.append_attribute("visible") = StrToStr(this->GetVisible()).c_str(); + element.append_attribute("visible") = BooleanToStr(this->GetVisible()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -7189,7 +7189,7 @@ bool AttVisibility::WriteVisibility( pugi::xml_node element ) { bool AttVisibility::HasVisible( ) { - return (m_visible != ""); + return (m_visible != BOOLEAN_NONE); } @@ -7211,7 +7211,7 @@ void AttVisualoffsetHo::ResetVisualoffsetHo() { m_ho = ""; } -bool AttVisualoffsetHo::ReadVisualoffsetHo( pugi::xml_node element ) { +bool AttVisualoffsetHo::ReadVisualoffsetHo( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("ho")) { this->SetHo(StrToStr(element.attribute("ho").value())); @@ -7221,7 +7221,7 @@ bool AttVisualoffsetHo::ReadVisualoffsetHo( pugi::xml_node element ) { return hasAttribute; } -bool AttVisualoffsetHo::WriteVisualoffsetHo( pugi::xml_node element ) { +bool AttVisualoffsetHo::WriteVisualoffsetHo( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasHo()) { element.append_attribute("ho") = StrToStr(this->GetHo()).c_str(); @@ -7251,23 +7251,23 @@ AttVisualoffsetTo::~AttVisualoffsetTo() { } void AttVisualoffsetTo::ResetVisualoffsetTo() { - m_to = ""; + m_to = 0.0; } -bool AttVisualoffsetTo::ReadVisualoffsetTo( pugi::xml_node element ) { +bool AttVisualoffsetTo::ReadVisualoffsetTo( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("to")) { - this->SetTo(StrToStr(element.attribute("to").value())); + this->SetTo(StrToDbl(element.attribute("to").value())); element.remove_attribute("to"); hasAttribute = true; } return hasAttribute; } -bool AttVisualoffsetTo::WriteVisualoffsetTo( pugi::xml_node element ) { +bool AttVisualoffsetTo::WriteVisualoffsetTo( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasTo()) { - element.append_attribute("to") = StrToStr(this->GetTo()).c_str(); + element.append_attribute("to") = DblToStr(this->GetTo()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -7275,7 +7275,7 @@ bool AttVisualoffsetTo::WriteVisualoffsetTo( pugi::xml_node element ) { bool AttVisualoffsetTo::HasTo( ) { - return (m_to != ""); + return (m_to != 0.0); } @@ -7297,7 +7297,7 @@ void AttVisualoffsetVo::ResetVisualoffsetVo() { m_vo = ""; } -bool AttVisualoffsetVo::ReadVisualoffsetVo( pugi::xml_node element ) { +bool AttVisualoffsetVo::ReadVisualoffsetVo( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("vo")) { this->SetVo(StrToStr(element.attribute("vo").value())); @@ -7307,7 +7307,7 @@ bool AttVisualoffsetVo::ReadVisualoffsetVo( pugi::xml_node element ) { return hasAttribute; } -bool AttVisualoffsetVo::WriteVisualoffsetVo( pugi::xml_node element ) { +bool AttVisualoffsetVo::WriteVisualoffsetVo( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasVo()) { element.append_attribute("vo") = StrToStr(this->GetVo()).c_str(); @@ -7341,7 +7341,7 @@ void AttVisualoffset2Ho::ResetVisualoffset2Ho() { m_endho = ""; } -bool AttVisualoffset2Ho::ReadVisualoffset2Ho( pugi::xml_node element ) { +bool AttVisualoffset2Ho::ReadVisualoffset2Ho( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("startho")) { this->SetStartho(StrToStr(element.attribute("startho").value())); @@ -7356,7 +7356,7 @@ bool AttVisualoffset2Ho::ReadVisualoffset2Ho( pugi::xml_node element ) { return hasAttribute; } -bool AttVisualoffset2Ho::WriteVisualoffset2Ho( pugi::xml_node element ) { +bool AttVisualoffset2Ho::WriteVisualoffset2Ho( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasStartho()) { element.append_attribute("startho") = StrToStr(this->GetStartho()).c_str(); @@ -7395,33 +7395,33 @@ AttVisualoffset2To::~AttVisualoffset2To() { } void AttVisualoffset2To::ResetVisualoffset2To() { - m_startto = ""; - m_endto = ""; + m_startto = 0.0; + m_endto = 0.0; } -bool AttVisualoffset2To::ReadVisualoffset2To( pugi::xml_node element ) { +bool AttVisualoffset2To::ReadVisualoffset2To( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("startto")) { - this->SetStartto(StrToStr(element.attribute("startto").value())); + this->SetStartto(StrToDbl(element.attribute("startto").value())); element.remove_attribute("startto"); hasAttribute = true; } if (element.attribute("endto")) { - this->SetEndto(StrToStr(element.attribute("endto").value())); + this->SetEndto(StrToDbl(element.attribute("endto").value())); element.remove_attribute("endto"); hasAttribute = true; } return hasAttribute; } -bool AttVisualoffset2To::WriteVisualoffset2To( pugi::xml_node element ) { +bool AttVisualoffset2To::WriteVisualoffset2To( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasStartto()) { - element.append_attribute("startto") = StrToStr(this->GetStartto()).c_str(); + element.append_attribute("startto") = DblToStr(this->GetStartto()).c_str(); wroteAttribute = true; } if (this->HasEndto()) { - element.append_attribute("endto") = StrToStr(this->GetEndto()).c_str(); + element.append_attribute("endto") = DblToStr(this->GetEndto()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -7429,12 +7429,12 @@ bool AttVisualoffset2To::WriteVisualoffset2To( pugi::xml_node element ) { bool AttVisualoffset2To::HasStartto( ) { - return (m_startto != ""); + return (m_startto != 0.0); } bool AttVisualoffset2To::HasEndto( ) { - return (m_endto != ""); + return (m_endto != 0.0); } @@ -7457,7 +7457,7 @@ void AttVisualoffset2Vo::ResetVisualoffset2Vo() { m_endvo = ""; } -bool AttVisualoffset2Vo::ReadVisualoffset2Vo( pugi::xml_node element ) { +bool AttVisualoffset2Vo::ReadVisualoffset2Vo( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("startvo")) { this->SetStartvo(StrToStr(element.attribute("startvo").value())); @@ -7472,7 +7472,7 @@ bool AttVisualoffset2Vo::ReadVisualoffset2Vo( pugi::xml_node element ) { return hasAttribute; } -bool AttVisualoffset2Vo::WriteVisualoffset2Vo( pugi::xml_node element ) { +bool AttVisualoffset2Vo::WriteVisualoffset2Vo( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasStartvo()) { element.append_attribute("startvo") = StrToStr(this->GetStartvo()).c_str(); @@ -7514,7 +7514,7 @@ void AttWhitespace::ResetWhitespace() { m_space = ""; } -bool AttWhitespace::ReadWhitespace( pugi::xml_node element ) { +bool AttWhitespace::ReadWhitespace( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("space")) { this->SetSpace(StrToStr(element.attribute("space").value())); @@ -7524,7 +7524,7 @@ bool AttWhitespace::ReadWhitespace( pugi::xml_node element ) { return hasAttribute; } -bool AttWhitespace::WriteWhitespace( pugi::xml_node element ) { +bool AttWhitespace::WriteWhitespace( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasSpace()) { element.append_attribute("space") = StrToStr(this->GetSpace()).c_str(); @@ -7557,7 +7557,7 @@ void AttWidth::ResetWidth() { m_width = ""; } -bool AttWidth::ReadWidth( pugi::xml_node element ) { +bool AttWidth::ReadWidth( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("width")) { this->SetWidth(StrToStr(element.attribute("width").value())); @@ -7567,7 +7567,7 @@ bool AttWidth::ReadWidth( pugi::xml_node element ) { return hasAttribute; } -bool AttWidth::WriteWidth( pugi::xml_node element ) { +bool AttWidth::WriteWidth( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasWidth()) { element.append_attribute("width") = StrToStr(this->GetWidth()).c_str(); @@ -7597,11 +7597,11 @@ AttXy::~AttXy() { } void AttXy::ResetXy() { - m_xDbl = 0.0; - m_yDbl = 0.0; + m_x = 0.0; + m_y = 0.0; } -bool AttXy::ReadXy( pugi::xml_node element ) { +bool AttXy::ReadXy( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("x")) { this->SetX(StrToDbl(element.attribute("x").value())); @@ -7616,7 +7616,7 @@ bool AttXy::ReadXy( pugi::xml_node element ) { return hasAttribute; } -bool AttXy::WriteXy( pugi::xml_node element ) { +bool AttXy::WriteXy( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasX()) { element.append_attribute("x") = DblToStr(this->GetX()).c_str(); @@ -7631,12 +7631,12 @@ bool AttXy::WriteXy( pugi::xml_node element ) { bool AttXy::HasX( ) { - return (m_xDbl != 0.0); + return (m_x != 0.0); } bool AttXy::HasY( ) { - return (m_yDbl != 0.0); + return (m_y != 0.0); } @@ -7655,11 +7655,11 @@ AttXy2::~AttXy2() { } void AttXy2::ResetXy2() { - m_x2Dbl = 0.0; - m_y2Dbl = 0.0; + m_x2 = 0.0; + m_y2 = 0.0; } -bool AttXy2::ReadXy2( pugi::xml_node element ) { +bool AttXy2::ReadXy2( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("x2")) { this->SetX2(StrToDbl(element.attribute("x2").value())); @@ -7674,7 +7674,7 @@ bool AttXy2::ReadXy2( pugi::xml_node element ) { return hasAttribute; } -bool AttXy2::WriteXy2( pugi::xml_node element ) { +bool AttXy2::WriteXy2( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasX2()) { element.append_attribute("x2") = DblToStr(this->GetX2()).c_str(); @@ -7689,12 +7689,12 @@ bool AttXy2::WriteXy2( pugi::xml_node element ) { bool AttXy2::HasX2( ) { - return (m_x2Dbl != 0.0); + return (m_x2 != 0.0); } bool AttXy2::HasY2( ) { - return (m_y2Dbl != 0.0); + return (m_y2 != 0.0); } @@ -7705,7 +7705,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttAccidLog *att = dynamic_cast(element); assert( att ); if (attrType == "func") { - att->SetFunc(att->StrToFunc(attrValue)); + att->SetFunc(att->StrToAccidLogFunc(attrValue)); return true; } } @@ -7721,7 +7721,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttAccidentalPerformed *att = dynamic_cast(element); assert( att ); if (attrType == "accidGes") { - att->SetAccidGes(att->StrToStr(attrValue)); + att->SetAccidGes(att->StrToAccidentalImplicit(attrValue)); return true; } } @@ -7729,7 +7729,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttArticulation *att = dynamic_cast(element); assert( att ); if (attrType == "artic") { - att->SetArtic(att->StrToStr(attrValue)); + att->SetArtic(att->StrToArticulation(attrValue)); return true; } } @@ -7737,7 +7737,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttArticulationPerformed *att = dynamic_cast(element); assert( att ); if (attrType == "articGes") { - att->SetArticGes(att->StrToStr(attrValue)); + att->SetArticGes(att->StrToArticulation(attrValue)); return true; } } @@ -7765,7 +7765,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttBarLineLog *att = dynamic_cast(element); assert( att ); if (attrType == "form") { - att->SetForm(att->StrToBarRendition(attrValue)); + att->SetForm(att->StrToBarrendition(attrValue)); return true; } } @@ -7773,11 +7773,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttBarplacement *att = dynamic_cast(element); assert( att ); if (attrType == "barplace") { - att->SetBarplace(att->StrToStr(attrValue)); + att->SetBarplace(att->StrToBarplace(attrValue)); return true; } if (attrType == "taktplace") { - att->SetTaktplace(att->StrToStr(attrValue)); + att->SetTaktplace(att->StrToInt(attrValue)); return true; } } @@ -7789,10 +7789,10 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } if (attrType == "beamRend") { - att->SetBeamRend(att->StrToStr(attrValue)); + att->SetBeamRend(att->StrToBeamingVisBeamrend(attrValue)); return true; } - if (attrType == "beamSlopeDbl") { + if (attrType == "beamSlope") { att->SetBeamSlope(att->StrToDbl(attrValue)); return true; } @@ -7825,7 +7825,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttChordVis *att = dynamic_cast(element); assert( att ); if (attrType == "cluster") { - att->SetCluster(att->StrToStr(attrValue)); + att->SetCluster(att->StrToCluster(attrValue)); return true; } } @@ -7841,7 +7841,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttClefLog *att = dynamic_cast(element); assert( att ); if (attrType == "cautionary") { - att->SetCautionary(att->StrToStr(attrValue)); + att->SetCautionary(att->StrToBoolean(attrValue)); return true; } } @@ -7849,7 +7849,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttCleffingLog *att = dynamic_cast(element); assert( att ); if (attrType == "clefShape") { - att->SetClefShape(att->StrToClefShape(attrValue)); + att->SetClefShape(att->StrToClefshape(attrValue)); return true; } if (attrType == "clefLine") { @@ -7873,7 +7873,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } if (attrType == "clefVisible") { - att->SetClefVisible(att->StrToStr(attrValue)); + att->SetClefVisible(att->StrToBoolean(attrValue)); return true; } } @@ -7881,7 +7881,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttClefshape *att = dynamic_cast(element); assert( att ); if (attrType == "shape") { - att->SetShape(att->StrToClefShape(attrValue)); + att->SetShape(att->StrToClefshape(attrValue)); return true; } } @@ -7897,7 +7897,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttColoration *att = dynamic_cast(element); assert( att ); if (attrType == "colored") { - att->SetColored(att->StrToBool(attrValue)); + att->SetColored(att->StrToBoolean(attrValue)); return true; } } @@ -7924,19 +7924,19 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_COORDINATED ) ) { AttCoordinated *att = dynamic_cast(element); assert( att ); - if (attrType == "ulxInt") { + if (attrType == "ulx") { att->SetUlx(att->StrToInt(attrValue)); return true; } - if (attrType == "ulyInt") { + if (attrType == "uly") { att->SetUly(att->StrToInt(attrValue)); return true; } - if (attrType == "lrxInt") { + if (attrType == "lrx") { att->SetLrx(att->StrToInt(attrValue)); return true; } - if (attrType == "lryInt") { + if (attrType == "lry") { att->SetLry(att->StrToInt(attrValue)); return true; } @@ -7953,7 +7953,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } if (attrType == "curvedir") { - att->SetCurvedir(att->StrToCurvedir(attrValue)); + att->SetCurvedir(att->StrToCurvatureCurvedir(attrValue)); return true; } } @@ -7961,7 +7961,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttCurverend *att = dynamic_cast(element); assert( att ); if (attrType == "lform") { - att->SetLform(att->StrToStr(attrValue)); + att->SetLform(att->StrToLineform(attrValue)); return true; } if (attrType == "lwidth") { @@ -8037,7 +8037,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttDotLog *att = dynamic_cast(element); assert( att ); if (attrType == "form") { - att->SetForm(att->StrToBarRendition(attrValue)); + att->SetForm(att->StrToDotLogForm(attrValue)); return true; } } @@ -8045,7 +8045,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttDurationAdditive *att = dynamic_cast(element); assert( att ); if (attrType == "dur") { - att->SetDur(att->StrToDur(attrValue)); + att->SetDur(att->StrToDuration(attrValue)); return true; } } @@ -8053,14 +8053,14 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttDurationDefault *att = dynamic_cast(element); assert( att ); if (attrType == "durDefault") { - att->SetDurDefault(att->StrToStr(attrValue)); + att->SetDurDefault(att->StrToDuration(attrValue)); return true; } - if (attrType == "numDefaultInt") { + if (attrType == "numDefault") { att->SetNumDefault(att->StrToInt(attrValue)); return true; } - if (attrType == "numbaseDefaultInt") { + if (attrType == "numbaseDefault") { att->SetNumbaseDefault(att->StrToInt(attrValue)); return true; } @@ -8069,7 +8069,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttDurationMusical *att = dynamic_cast(element); assert( att ); if (attrType == "dur") { - att->SetDur(att->StrToDur(attrValue)); + att->SetDur(att->StrToDuration(attrValue)); return true; } } @@ -8077,7 +8077,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttDurationPerformed *att = dynamic_cast(element); assert( att ); if (attrType == "durGes") { - att->SetDurGes(att->StrToDur(attrValue)); + att->SetDurGes(att->StrToDuration(attrValue)); return true; } } @@ -8097,7 +8097,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttEnclosingchars *att = dynamic_cast(element); assert( att ); if (attrType == "enclose") { - att->SetEnclose(att->StrToStr(attrValue)); + att->SetEnclose(att->StrToEnclosure(attrValue)); return true; } } @@ -8105,7 +8105,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttEndings *att = dynamic_cast(element); assert( att ); if (attrType == "endingRend") { - att->SetEndingRend(att->StrToStr(attrValue)); + att->SetEndingRend(att->StrToEndingsEndingrend(attrValue)); return true; } } @@ -8113,7 +8113,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttExtender *att = dynamic_cast(element); assert( att ); if (attrType == "extender") { - att->SetExtender(att->StrToStr(attrValue)); + att->SetExtender(att->StrToBoolean(attrValue)); return true; } } @@ -8128,7 +8128,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_FILING ) ) { AttFiling *att = dynamic_cast(element); assert( att ); - if (attrType == "nonfilingInt") { + if (attrType == "nonfiling") { att->SetNonfiling(att->StrToInt(attrValue)); return true; } @@ -8136,7 +8136,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_GRPSYMLOG ) ) { AttGrpSymLog *att = dynamic_cast(element); assert( att ); - if (attrType == "levelInt") { + if (attrType == "level") { att->SetLevel(att->StrToInt(attrValue)); return true; } @@ -8161,7 +8161,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttHorizontalalign *att = dynamic_cast(element); assert( att ); if (attrType == "halign") { - att->SetHalign(att->StrToStr(attrValue)); + att->SetHalign(att->StrToHorizontalalignment(attrValue)); return true; } } @@ -8193,7 +8193,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttKeySigLog *att = dynamic_cast(element); assert( att ); if (attrType == "mode") { - att->SetMode(att->StrToStr(attrValue)); + att->SetMode(att->StrToMode(attrValue)); return true; } } @@ -8209,11 +8209,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } if (attrType == "keyPname") { - att->SetKeyPname(att->StrToPitchName(attrValue)); + att->SetKeyPname(att->StrToPitchname(attrValue)); return true; } if (attrType == "keySig") { - att->SetKeySig(att->StrToKeySignature(attrValue)); + att->SetKeySig(att->StrToKeysignature(attrValue)); return true; } if (attrType == "keySigMixed") { @@ -8225,11 +8225,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttKeySigDefaultVis *att = dynamic_cast(element); assert( att ); if (attrType == "keySigShow") { - att->SetKeySigShow(att->StrToBool(attrValue)); + att->SetKeySigShow(att->StrToBoolean(attrValue)); return true; } if (attrType == "keySigShowchange") { - att->SetKeySigShowchange(att->StrToBool(attrValue)); + att->SetKeySigShowchange(att->StrToBoolean(attrValue)); return true; } } @@ -8264,7 +8264,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_LAYERIDENT ) ) { AttLayerident *att = dynamic_cast(element); assert( att ); - if (attrType == "layerInt") { + if (attrType == "layer") { att->SetLayer(att->StrToInt(attrValue)); return true; } @@ -8273,7 +8273,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttLineVis *att = dynamic_cast(element); assert( att ); if (attrType == "form") { - att->SetForm(att->StrToBarRendition(attrValue)); + att->SetForm(att->StrToLineform(attrValue)); return true; } if (attrType == "width") { @@ -8281,7 +8281,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } if (attrType == "endsym") { - att->SetEndsym(att->StrToStr(attrValue)); + att->SetEndsym(att->StrToLinestartendsymbol(attrValue)); return true; } if (attrType == "endsymsize") { @@ -8289,7 +8289,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } if (attrType == "startsym") { - att->SetStartsym(att->StrToStr(attrValue)); + att->SetStartsym(att->StrToLinestartendsymbol(attrValue)); return true; } if (attrType == "startsymsize") { @@ -8309,7 +8309,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttLinerend *att = dynamic_cast(element); assert( att ); if (attrType == "lendsym") { - att->SetLendsym(att->StrToStr(attrValue)); + att->SetLendsym(att->StrToLinestartendsymbol(attrValue)); return true; } if (attrType == "lendsymsize") { @@ -8317,7 +8317,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } if (attrType == "lstartsym") { - att->SetLstartsym(att->StrToStr(attrValue)); + att->SetLstartsym(att->StrToLinestartendsymbol(attrValue)); return true; } if (attrType == "lstartsymsize") { @@ -8329,7 +8329,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttLinerendBase *att = dynamic_cast(element); assert( att ); if (attrType == "lform") { - att->SetLform(att->StrToStr(attrValue)); + att->SetLform(att->StrToLineform(attrValue)); return true; } if (attrType == "lwidth") { @@ -8357,11 +8357,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } if (attrType == "lyricStyle") { - att->SetLyricStyle(att->StrToStr(attrValue)); + att->SetLyricStyle(att->StrToFontstyle(attrValue)); return true; } if (attrType == "lyricWeight") { - att->SetLyricWeight(att->StrToStr(attrValue)); + att->SetLyricWeight(att->StrToFontweight(attrValue)); return true; } } @@ -8369,11 +8369,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttMeasureLog *att = dynamic_cast(element); assert( att ); if (attrType == "left") { - att->SetLeft(att->StrToBarRendition(attrValue)); + att->SetLeft(att->StrToBarrendition(attrValue)); return true; } if (attrType == "right") { - att->SetRight(att->StrToBarRendition(attrValue)); + att->SetRight(att->StrToBarrendition(attrValue)); return true; } } @@ -8381,7 +8381,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttMeasurement *att = dynamic_cast(element); assert( att ); if (attrType == "unit") { - att->SetUnit(att->StrToInt(attrValue)); + att->SetUnit(att->StrToStr(attrValue)); return true; } } @@ -8389,7 +8389,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttMeasurenumbers *att = dynamic_cast(element); assert( att ); if (attrType == "mnumVisible") { - att->SetMnumVisible(att->StrToStr(attrValue)); + att->SetMnumVisible(att->StrToBoolean(attrValue)); return true; } } @@ -8405,7 +8405,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } if (attrType == "betype") { - att->SetBetype(att->StrToStr(attrValue)); + att->SetBetype(att->StrToBetype(attrValue)); return true; } } @@ -8421,7 +8421,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttMeiversion *att = dynamic_cast(element); assert( att ); if (attrType == "meiversion") { - att->SetMeiversion(att->StrToStr(attrValue)); + att->SetMeiversion(att->StrToMeiversionMeiversion(attrValue)); return true; } } @@ -8429,11 +8429,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttMensurLog *att = dynamic_cast(element); assert( att ); if (attrType == "dot") { - att->SetDot(att->StrToBool(attrValue)); + att->SetDot(att->StrToBoolean(attrValue)); return true; } if (attrType == "sign") { - att->SetSign(att->StrToMensurationSign(attrValue)); + att->SetSign(att->StrToMensurationsign(attrValue)); return true; } } @@ -8445,7 +8445,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } if (attrType == "sym") { - att->SetSym(att->StrToMeterSign(attrValue)); + att->SetSym(att->StrToMetersign(attrValue)); return true; } if (attrType == "unit") { @@ -8457,7 +8457,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttMeterSigVis *att = dynamic_cast(element); assert( att ); if (attrType == "form") { - att->SetForm(att->StrToBarRendition(attrValue)); + att->SetForm(att->StrToMeterSigVisForm(attrValue)); return true; } } @@ -8477,15 +8477,15 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttMeterSigDefaultVis *att = dynamic_cast(element); assert( att ); if (attrType == "meterRend") { - att->SetMeterRend(att->StrToStr(attrValue)); + att->SetMeterRend(att->StrToMeterSigDefaultVisMeterrend(attrValue)); return true; } if (attrType == "meterShowchange") { - att->SetMeterShowchange(att->StrToStr(attrValue)); + att->SetMeterShowchange(att->StrToBoolean(attrValue)); return true; } if (attrType == "meterSym") { - att->SetMeterSym(att->StrToMeterSign(attrValue)); + att->SetMeterSym(att->StrToMetersign(attrValue)); return true; } } @@ -8493,7 +8493,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttMeterconformance *att = dynamic_cast(element); assert( att ); if (attrType == "metcon") { - att->SetMetcon(att->StrToStr(attrValue)); + att->SetMetcon(att->StrToMeterconformanceMetcon(attrValue)); return true; } } @@ -8501,11 +8501,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttMeterconformanceBar *att = dynamic_cast(element); assert( att ); if (attrType == "metcon") { - att->SetMetcon(att->StrToStr(attrValue)); + att->SetMetcon(att->StrToBoolean(attrValue)); return true; } if (attrType == "control") { - att->SetControl(att->StrToStr(attrValue)); + att->SetControl(att->StrToBoolean(attrValue)); return true; } } @@ -8517,11 +8517,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } if (attrType == "mmUnit") { - att->SetMmUnit(att->StrToStr(attrValue)); + att->SetMmUnit(att->StrToDuration(attrValue)); return true; } if (attrType == "mmDots") { - att->SetMmDots(att->StrToStr(attrValue)); + att->SetMmDots(att->StrToInt(attrValue)); return true; } } @@ -8529,7 +8529,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttMultinummeasures *att = dynamic_cast(element); assert( att ); if (attrType == "multiNumber") { - att->SetMultiNumber(att->StrToBool(attrValue)); + att->SetMultiNumber(att->StrToBoolean(attrValue)); return true; } } @@ -8561,15 +8561,15 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttNoteGes *att = dynamic_cast(element); assert( att ); if (attrType == "octGes") { - att->SetOctGes(att->StrToStr(attrValue)); + att->SetOctGes(att->StrToInt(attrValue)); return true; } if (attrType == "pnameGes") { - att->SetPnameGes(att->StrToStr(attrValue)); + att->SetPnameGes(att->StrToPitchname(attrValue)); return true; } if (attrType == "pnum") { - att->SetPnum(att->StrToStr(attrValue)); + att->SetPnum(att->StrToInt(attrValue)); return true; } } @@ -8601,7 +8601,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } if (attrType == "headVisible") { - att->SetHeadVisible(att->StrToStr(attrValue)); + att->SetHeadVisible(att->StrToBoolean(attrValue)); return true; } } @@ -8617,7 +8617,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttOctavedefault *att = dynamic_cast(element); assert( att ); if (attrType == "octaveDefault") { - att->SetOctaveDefault(att->StrToStr(attrValue)); + att->SetOctaveDefault(att->StrToInt(attrValue)); return true; } } @@ -8637,7 +8637,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttOnelinestaff *att = dynamic_cast(element); assert( att ); if (attrType == "ontheline") { - att->SetOntheline(att->StrToStr(attrValue)); + att->SetOntheline(att->StrToBoolean(attrValue)); return true; } } @@ -8645,7 +8645,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttOptimization *att = dynamic_cast(element); assert( att ); if (attrType == "optimize") { - att->SetOptimize(att->StrToStr(attrValue)); + att->SetOptimize(att->StrToBoolean(attrValue)); return true; } } @@ -8697,7 +8697,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttPbVis *att = dynamic_cast(element); assert( att ); if (attrType == "folium") { - att->SetFolium(att->StrToStr(attrValue)); + att->SetFolium(att->StrToPbVisFolium(attrValue)); return true; } } @@ -8705,7 +8705,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttPitch *att = dynamic_cast(element); assert( att ); if (attrType == "pname") { - att->SetPname(att->StrToPitchName(attrValue)); + att->SetPname(att->StrToPitchname(attrValue)); return true; } } @@ -8713,7 +8713,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttPlacement *att = dynamic_cast(element); assert( att ); if (attrType == "place") { - att->SetPlace(att->StrToStaffRel(attrValue)); + att->SetPlace(att->StrToStaffrel(attrValue)); return true; } } @@ -8725,7 +8725,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } if (attrType == "evaluate") { - att->SetEvaluate(att->StrToStr(attrValue)); + att->SetEvaluate(att->StrToPlistEvaluate(attrValue)); return true; } } @@ -8760,7 +8760,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_QUANTITY ) ) { AttQuantity *att = dynamic_cast(element); assert( att ); - if (attrType == "quantityDbl") { + if (attrType == "quantity") { att->SetQuantity(att->StrToDbl(attrValue)); return true; } @@ -8769,7 +8769,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttRelativesize *att = dynamic_cast(element); assert( att ); if (attrType == "size") { - att->SetSize(att->StrToStr(attrValue)); + att->SetSize(att->StrToSize(attrValue)); return true; } } @@ -8785,7 +8785,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttSbVis *att = dynamic_cast(element); assert( att ); if (attrType == "form") { - att->SetForm(att->StrToBarRendition(attrValue)); + att->SetForm(att->StrToSbVisForm(attrValue)); return true; } } @@ -8793,7 +8793,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttScalable *att = dynamic_cast(element); assert( att ); if (attrType == "scale") { - att->SetScale(att->StrToPercent(attrValue)); + att->SetScale(att->StrToInt(attrValue)); return true; } } @@ -8801,15 +8801,15 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttScoreDefGes *att = dynamic_cast(element); assert( att ); if (attrType == "tunePname") { - att->SetTunePname(att->StrToStr(attrValue)); + att->SetTunePname(att->StrToPitchname(attrValue)); return true; } - if (attrType == "tuneHzDbl") { + if (attrType == "tuneHz") { att->SetTuneHz(att->StrToDbl(attrValue)); return true; } if (attrType == "tuneTemper") { - att->SetTuneTemper(att->StrToStr(attrValue)); + att->SetTuneTemper(att->StrToTemperament(attrValue)); return true; } } @@ -8825,14 +8825,14 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttSectionVis *att = dynamic_cast(element); assert( att ); if (attrType == "restart") { - att->SetRestart(att->StrToStr(attrValue)); + att->SetRestart(att->StrToBoolean(attrValue)); return true; } } if (element->HasAttClass( ATT_SEQUENCE ) ) { AttSequence *att = dynamic_cast(element); assert( att ); - if (attrType == "seqInt") { + if (attrType == "seq") { att->SetSeq(att->StrToInt(attrValue)); return true; } @@ -8857,18 +8857,18 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttSpaceVis *att = dynamic_cast(element); assert( att ); if (attrType == "compressable") { - att->SetCompressable(att->StrToStr(attrValue)); + att->SetCompressable(att->StrToBoolean(attrValue)); return true; } } if (element->HasAttClass( ATT_SPACING ) ) { AttSpacing *att = dynamic_cast(element); assert( att ); - if (attrType == "spacingPackexpDbl") { + if (attrType == "spacingPackexp") { att->SetSpacingPackexp(att->StrToDbl(attrValue)); return true; } - if (attrType == "spacingPackfactDbl") { + if (attrType == "spacingPackfact") { att->SetSpacingPackfact(att->StrToDbl(attrValue)); return true; } @@ -8893,14 +8893,14 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttStaffDefVis *att = dynamic_cast(element); assert( att ); if (attrType == "gridShow") { - att->SetGridShow(att->StrToBool(attrValue)); + att->SetGridShow(att->StrToBoolean(attrValue)); return true; } if (attrType == "layerscheme") { att->SetLayerscheme(att->StrToLayerscheme(attrValue)); return true; } - if (attrType == "linesInt") { + if (attrType == "lines") { att->SetLines(att->StrToInt(attrValue)); return true; } @@ -8909,7 +8909,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } if (attrType == "linesVisible") { - att->SetLinesVisible(att->StrToBool(attrValue)); + att->SetLinesVisible(att->StrToBoolean(attrValue)); return true; } if (attrType == "spacing") { @@ -8921,7 +8921,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttStaffGrpVis *att = dynamic_cast(element); assert( att ); if (attrType == "barthru") { - att->SetBarthru(att->StrToBool(attrValue)); + att->SetBarthru(att->StrToBoolean(attrValue)); return true; } } @@ -8929,7 +8929,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttStaffgroupingsym *att = dynamic_cast(element); assert( att ); if (attrType == "symbol") { - att->SetSymbol(att->StrToSymbol(attrValue)); + att->SetSymbol(att->StrToStaffgroupingsymSymbol(attrValue)); return true; } } @@ -8945,7 +8945,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttStaffloc *att = dynamic_cast(element); assert( att ); if (attrType == "loc") { - att->SetLoc(att->StrToStr(attrValue)); + att->SetLoc(att->StrToInt(attrValue)); return true; } } @@ -8953,7 +8953,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttStafflocPitched *att = dynamic_cast(element); assert( att ); if (attrType == "ploc") { - att->SetPloc(att->StrToPitchName(attrValue)); + att->SetPloc(att->StrToPitchname(attrValue)); return true; } if (attrType == "oloc") { @@ -8981,27 +8981,27 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttStems *att = dynamic_cast(element); assert( att ); if (attrType == "stemDir") { - att->SetStemDir(att->StrToStemDirection(attrValue)); + att->SetStemDir(att->StrToStemdirection(attrValue)); return true; } if (attrType == "stemLen") { - att->SetStemLen(att->StrToInt(attrValue)); + att->SetStemLen(att->StrToStr(attrValue)); return true; } if (attrType == "stemMod") { - att->SetStemMod(att->StrToStemModifier(attrValue)); + att->SetStemMod(att->StrToStemmodifier(attrValue)); return true; } if (attrType == "stemPos") { - att->SetStemPos(att->StrToStemPosition(attrValue)); + att->SetStemPos(att->StrToStemposition(attrValue)); return true; } if (attrType == "stemX") { - att->SetStemX(att->StrToInt(attrValue)); + att->SetStemX(att->StrToDbl(attrValue)); return true; } if (attrType == "stemY") { - att->SetStemY(att->StrToInt(attrValue)); + att->SetStemY(att->StrToDbl(attrValue)); return true; } } @@ -9009,11 +9009,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttSylLog *att = dynamic_cast(element); assert( att ); if (attrType == "con") { - att->SetCon(att->StrToCon(attrValue)); + att->SetCon(att->StrToSylLogCon(attrValue)); return true; } if (attrType == "wordpos") { - att->SetWordpos(att->StrToWordPos(attrValue)); + att->SetWordpos(att->StrToSylLogWordpos(attrValue)); return true; } } @@ -9029,7 +9029,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttSystems *att = dynamic_cast(element); assert( att ); if (attrType == "systemLeftline") { - att->SetSystemLeftline(att->StrToStr(attrValue)); + att->SetSystemLeftline(att->StrToBoolean(attrValue)); return true; } if (attrType == "systemLeftmar") { @@ -9061,11 +9061,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu return true; } if (attrType == "textStyle") { - att->SetTextStyle(att->StrToStr(attrValue)); + att->SetTextStyle(att->StrToFontstyle(attrValue)); return true; } if (attrType == "textWeight") { - att->SetTextWeight(att->StrToStr(attrValue)); + att->SetTextWeight(att->StrToFontweight(attrValue)); return true; } } @@ -9089,7 +9089,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttTimestampPerformed *att = dynamic_cast(element); assert( att ); if (attrType == "tstampGes") { - att->SetTstampGes(att->StrToStr(attrValue)); + att->SetTstampGes(att->StrToDuration(attrValue)); return true; } if (attrType == "tstampReal") { @@ -9101,18 +9101,18 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttTimestamp2Musical *att = dynamic_cast(element); assert( att ); if (attrType == "tstamp2") { - att->SetTstamp2(att->StrToTstamp2(attrValue)); + att->SetTstamp2(att->StrToMeasurebeat(attrValue)); return true; } } if (element->HasAttClass( ATT_TRANSPOSITION ) ) { AttTransposition *att = dynamic_cast(element); assert( att ); - if (attrType == "transDiatDbl") { + if (attrType == "transDiat") { att->SetTransDiat(att->StrToDbl(attrValue)); return true; } - if (attrType == "transSemiDbl") { + if (attrType == "transSemi") { att->SetTransSemi(att->StrToDbl(attrValue)); return true; } @@ -9148,7 +9148,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu att->SetFontname(att->StrToStr(attrValue)); return true; } - if (attrType == "fontsizeDbl") { + if (attrType == "fontsize") { att->SetFontsize(att->StrToDbl(attrValue)); return true; } @@ -9165,7 +9165,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttVisibility *att = dynamic_cast(element); assert( att ); if (attrType == "visible") { - att->SetVisible(att->StrToStr(attrValue)); + att->SetVisible(att->StrToBoolean(attrValue)); return true; } } @@ -9181,7 +9181,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttVisualoffsetTo *att = dynamic_cast(element); assert( att ); if (attrType == "to") { - att->SetTo(att->StrToStr(attrValue)); + att->SetTo(att->StrToDbl(attrValue)); return true; } } @@ -9209,11 +9209,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttVisualoffset2To *att = dynamic_cast(element); assert( att ); if (attrType == "startto") { - att->SetStartto(att->StrToStr(attrValue)); + att->SetStartto(att->StrToDbl(attrValue)); return true; } if (attrType == "endto") { - att->SetEndto(att->StrToStr(attrValue)); + att->SetEndto(att->StrToDbl(attrValue)); return true; } } @@ -9248,11 +9248,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_XY ) ) { AttXy *att = dynamic_cast(element); assert( att ); - if (attrType == "xDbl") { + if (attrType == "x") { att->SetX(att->StrToDbl(attrValue)); return true; } - if (attrType == "yDbl") { + if (attrType == "y") { att->SetY(att->StrToDbl(attrValue)); return true; } @@ -9260,11 +9260,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_XY2 ) ) { AttXy2 *att = dynamic_cast(element); assert( att ); - if (attrType == "x2Dbl") { + if (attrType == "x2") { att->SetX2(att->StrToDbl(attrValue)); return true; } - if (attrType == "y2Dbl") { + if (attrType == "y2") { att->SetY2(att->StrToDbl(attrValue)); return true; } @@ -9278,7 +9278,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttAccidLog *att = dynamic_cast(element); assert( att ); if (att->HasFunc()) { - attributes->push_back(std::make_pair("func", att->FuncToStr(att->GetFunc()))); + attributes->push_back(std::make_pair("func", att->AccidLogFuncToStr(att->GetFunc()))); } } if (element->HasAttClass( ATT_ACCIDENTAL ) ) { @@ -9292,21 +9292,21 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttAccidentalPerformed *att = dynamic_cast(element); assert( att ); if (att->HasAccidGes()) { - attributes->push_back(std::make_pair("accidGes", att->StrToStr(att->GetAccidGes()))); + attributes->push_back(std::make_pair("accidGes", att->AccidentalImplicitToStr(att->GetAccidGes()))); } } if (element->HasAttClass( ATT_ARTICULATION ) ) { AttArticulation *att = dynamic_cast(element); assert( att ); if (att->HasArtic()) { - attributes->push_back(std::make_pair("artic", att->StrToStr(att->GetArtic()))); + attributes->push_back(std::make_pair("artic", att->ArticulationToStr(att->GetArtic()))); } } if (element->HasAttClass( ATT_ARTICULATIONPERFORMED ) ) { AttArticulationPerformed *att = dynamic_cast(element); assert( att ); if (att->HasArticGes()) { - attributes->push_back(std::make_pair("articGes", att->StrToStr(att->GetArticGes()))); + attributes->push_back(std::make_pair("articGes", att->ArticulationToStr(att->GetArticGes()))); } } if (element->HasAttClass( ATT_AUGMENTDOTS ) ) { @@ -9330,17 +9330,17 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttBarLineLog *att = dynamic_cast(element); assert( att ); if (att->HasForm()) { - attributes->push_back(std::make_pair("form", att->BarRenditionToStr(att->GetForm()))); + attributes->push_back(std::make_pair("form", att->BarrenditionToStr(att->GetForm()))); } } if (element->HasAttClass( ATT_BARPLACEMENT ) ) { AttBarplacement *att = dynamic_cast(element); assert( att ); if (att->HasBarplace()) { - attributes->push_back(std::make_pair("barplace", att->StrToStr(att->GetBarplace()))); + attributes->push_back(std::make_pair("barplace", att->BarplaceToStr(att->GetBarplace()))); } if (att->HasTaktplace()) { - attributes->push_back(std::make_pair("taktplace", att->StrToStr(att->GetTaktplace()))); + attributes->push_back(std::make_pair("taktplace", att->IntToStr(att->GetTaktplace()))); } } if (element->HasAttClass( ATT_BEAMINGVIS ) ) { @@ -9350,10 +9350,10 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("beamColor", att->StrToStr(att->GetBeamColor()))); } if (att->HasBeamRend()) { - attributes->push_back(std::make_pair("beamRend", att->StrToStr(att->GetBeamRend()))); + attributes->push_back(std::make_pair("beamRend", att->BeamingVisBeamrendToStr(att->GetBeamRend()))); } if (att->HasBeamSlope()) { - attributes->push_back(std::make_pair("beamSlopeDbl", att->DblToStr(att->GetBeamSlope()))); + attributes->push_back(std::make_pair("beamSlope", att->DblToStr(att->GetBeamSlope()))); } } if (element->HasAttClass( ATT_BIBL ) ) { @@ -9381,7 +9381,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttChordVis *att = dynamic_cast(element); assert( att ); if (att->HasCluster()) { - attributes->push_back(std::make_pair("cluster", att->StrToStr(att->GetCluster()))); + attributes->push_back(std::make_pair("cluster", att->ClusterToStr(att->GetCluster()))); } } if (element->HasAttClass( ATT_CLASSCODEIDENT ) ) { @@ -9395,14 +9395,14 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttClefLog *att = dynamic_cast(element); assert( att ); if (att->HasCautionary()) { - attributes->push_back(std::make_pair("cautionary", att->StrToStr(att->GetCautionary()))); + attributes->push_back(std::make_pair("cautionary", att->BooleanToStr(att->GetCautionary()))); } } if (element->HasAttClass( ATT_CLEFFINGLOG ) ) { AttCleffingLog *att = dynamic_cast(element); assert( att ); if (att->HasClefShape()) { - attributes->push_back(std::make_pair("clefShape", att->ClefShapeToStr(att->GetClefShape()))); + attributes->push_back(std::make_pair("clefShape", att->ClefshapeToStr(att->GetClefShape()))); } if (att->HasClefLine()) { attributes->push_back(std::make_pair("clefLine", att->IntToStr(att->GetClefLine()))); @@ -9421,14 +9421,14 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("clefColor", att->StrToStr(att->GetClefColor()))); } if (att->HasClefVisible()) { - attributes->push_back(std::make_pair("clefVisible", att->StrToStr(att->GetClefVisible()))); + attributes->push_back(std::make_pair("clefVisible", att->BooleanToStr(att->GetClefVisible()))); } } if (element->HasAttClass( ATT_CLEFSHAPE ) ) { AttClefshape *att = dynamic_cast(element); assert( att ); if (att->HasShape()) { - attributes->push_back(std::make_pair("shape", att->ClefShapeToStr(att->GetShape()))); + attributes->push_back(std::make_pair("shape", att->ClefshapeToStr(att->GetShape()))); } } if (element->HasAttClass( ATT_COLOR ) ) { @@ -9442,7 +9442,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttColoration *att = dynamic_cast(element); assert( att ); if (att->HasColored()) { - attributes->push_back(std::make_pair("colored", att->BoolToStr(att->GetColored()))); + attributes->push_back(std::make_pair("colored", att->BooleanToStr(att->GetColored()))); } } if (element->HasAttClass( ATT_COMMON ) ) { @@ -9466,16 +9466,16 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttCoordinated *att = dynamic_cast(element); assert( att ); if (att->HasUlx()) { - attributes->push_back(std::make_pair("ulxInt", att->IntToStr(att->GetUlx()))); + attributes->push_back(std::make_pair("ulx", att->IntToStr(att->GetUlx()))); } if (att->HasUly()) { - attributes->push_back(std::make_pair("ulyInt", att->IntToStr(att->GetUly()))); + attributes->push_back(std::make_pair("uly", att->IntToStr(att->GetUly()))); } if (att->HasLrx()) { - attributes->push_back(std::make_pair("lrxInt", att->IntToStr(att->GetLrx()))); + attributes->push_back(std::make_pair("lrx", att->IntToStr(att->GetLrx()))); } if (att->HasLry()) { - attributes->push_back(std::make_pair("lryInt", att->IntToStr(att->GetLry()))); + attributes->push_back(std::make_pair("lry", att->IntToStr(att->GetLry()))); } } if (element->HasAttClass( ATT_CURVATURE ) ) { @@ -9488,14 +9488,14 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("bulge", att->DblToStr(att->GetBulge()))); } if (att->HasCurvedir()) { - attributes->push_back(std::make_pair("curvedir", att->CurvedirToStr(att->GetCurvedir()))); + attributes->push_back(std::make_pair("curvedir", att->CurvatureCurvedirToStr(att->GetCurvedir()))); } } if (element->HasAttClass( ATT_CURVEREND ) ) { AttCurverend *att = dynamic_cast(element); assert( att ); if (att->HasLform()) { - attributes->push_back(std::make_pair("lform", att->StrToStr(att->GetLform()))); + attributes->push_back(std::make_pair("lform", att->LineformToStr(att->GetLform()))); } if (att->HasLwidth()) { attributes->push_back(std::make_pair("lwidth", att->StrToStr(att->GetLwidth()))); @@ -9558,41 +9558,41 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttDotLog *att = dynamic_cast(element); assert( att ); if (att->HasForm()) { - attributes->push_back(std::make_pair("form", att->BarRenditionToStr(att->GetForm()))); + attributes->push_back(std::make_pair("form", att->DotLogFormToStr(att->GetForm()))); } } if (element->HasAttClass( ATT_DURATIONADDITIVE ) ) { AttDurationAdditive *att = dynamic_cast(element); assert( att ); if (att->HasDur()) { - attributes->push_back(std::make_pair("dur", att->DurToStr(att->GetDur()))); + attributes->push_back(std::make_pair("dur", att->DurationToStr(att->GetDur()))); } } if (element->HasAttClass( ATT_DURATIONDEFAULT ) ) { AttDurationDefault *att = dynamic_cast(element); assert( att ); if (att->HasDurDefault()) { - attributes->push_back(std::make_pair("durDefault", att->StrToStr(att->GetDurDefault()))); + attributes->push_back(std::make_pair("durDefault", att->DurationToStr(att->GetDurDefault()))); } if (att->HasNumDefault()) { - attributes->push_back(std::make_pair("numDefaultInt", att->IntToStr(att->GetNumDefault()))); + attributes->push_back(std::make_pair("numDefault", att->IntToStr(att->GetNumDefault()))); } if (att->HasNumbaseDefault()) { - attributes->push_back(std::make_pair("numbaseDefaultInt", att->IntToStr(att->GetNumbaseDefault()))); + attributes->push_back(std::make_pair("numbaseDefault", att->IntToStr(att->GetNumbaseDefault()))); } } if (element->HasAttClass( ATT_DURATIONMUSICAL ) ) { AttDurationMusical *att = dynamic_cast(element); assert( att ); if (att->HasDur()) { - attributes->push_back(std::make_pair("dur", att->DurToStr(att->GetDur()))); + attributes->push_back(std::make_pair("dur", att->DurationToStr(att->GetDur()))); } } if (element->HasAttClass( ATT_DURATIONPERFORMED ) ) { AttDurationPerformed *att = dynamic_cast(element); assert( att ); if (att->HasDurGes()) { - attributes->push_back(std::make_pair("durGes", att->DurToStr(att->GetDurGes()))); + attributes->push_back(std::make_pair("durGes", att->DurationToStr(att->GetDurGes()))); } } if (element->HasAttClass( ATT_DURATIONRATIO ) ) { @@ -9609,21 +9609,21 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttEnclosingchars *att = dynamic_cast(element); assert( att ); if (att->HasEnclose()) { - attributes->push_back(std::make_pair("enclose", att->StrToStr(att->GetEnclose()))); + attributes->push_back(std::make_pair("enclose", att->EnclosureToStr(att->GetEnclose()))); } } if (element->HasAttClass( ATT_ENDINGS ) ) { AttEndings *att = dynamic_cast(element); assert( att ); if (att->HasEndingRend()) { - attributes->push_back(std::make_pair("endingRend", att->StrToStr(att->GetEndingRend()))); + attributes->push_back(std::make_pair("endingRend", att->EndingsEndingrendToStr(att->GetEndingRend()))); } } if (element->HasAttClass( ATT_EXTENDER ) ) { AttExtender *att = dynamic_cast(element); assert( att ); if (att->HasExtender()) { - attributes->push_back(std::make_pair("extender", att->StrToStr(att->GetExtender()))); + attributes->push_back(std::make_pair("extender", att->BooleanToStr(att->GetExtender()))); } } if (element->HasAttClass( ATT_FERMATAPRESENT ) ) { @@ -9637,14 +9637,14 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttFiling *att = dynamic_cast(element); assert( att ); if (att->HasNonfiling()) { - attributes->push_back(std::make_pair("nonfilingInt", att->IntToStr(att->GetNonfiling()))); + attributes->push_back(std::make_pair("nonfiling", att->IntToStr(att->GetNonfiling()))); } } if (element->HasAttClass( ATT_GRPSYMLOG ) ) { AttGrpSymLog *att = dynamic_cast(element); assert( att ); if (att->HasLevel()) { - attributes->push_back(std::make_pair("levelInt", att->IntToStr(att->GetLevel()))); + attributes->push_back(std::make_pair("level", att->IntToStr(att->GetLevel()))); } } if (element->HasAttClass( ATT_HANDIDENT ) ) { @@ -9665,7 +9665,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttHorizontalalign *att = dynamic_cast(element); assert( att ); if (att->HasHalign()) { - attributes->push_back(std::make_pair("halign", att->StrToStr(att->GetHalign()))); + attributes->push_back(std::make_pair("halign", att->HorizontalalignmentToStr(att->GetHalign()))); } } if (element->HasAttClass( ATT_INSTRUMENTIDENT ) ) { @@ -9693,7 +9693,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttKeySigLog *att = dynamic_cast(element); assert( att ); if (att->HasMode()) { - attributes->push_back(std::make_pair("mode", att->StrToStr(att->GetMode()))); + attributes->push_back(std::make_pair("mode", att->ModeToStr(att->GetMode()))); } } if (element->HasAttClass( ATT_KEYSIGDEFAULTLOG ) ) { @@ -9706,10 +9706,10 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("keyMode", att->ModeToStr(att->GetKeyMode()))); } if (att->HasKeyPname()) { - attributes->push_back(std::make_pair("keyPname", att->PitchNameToStr(att->GetKeyPname()))); + attributes->push_back(std::make_pair("keyPname", att->PitchnameToStr(att->GetKeyPname()))); } if (att->HasKeySig()) { - attributes->push_back(std::make_pair("keySig", att->KeySignatureToStr(att->GetKeySig()))); + attributes->push_back(std::make_pair("keySig", att->KeysignatureToStr(att->GetKeySig()))); } if (att->HasKeySigMixed()) { attributes->push_back(std::make_pair("keySigMixed", att->StrToStr(att->GetKeySigMixed()))); @@ -9719,10 +9719,10 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttKeySigDefaultVis *att = dynamic_cast(element); assert( att ); if (att->HasKeySigShow()) { - attributes->push_back(std::make_pair("keySigShow", att->BoolToStr(att->GetKeySigShow()))); + attributes->push_back(std::make_pair("keySigShow", att->BooleanToStr(att->GetKeySigShow()))); } if (att->HasKeySigShowchange()) { - attributes->push_back(std::make_pair("keySigShowchange", att->BoolToStr(att->GetKeySigShowchange()))); + attributes->push_back(std::make_pair("keySigShowchange", att->BooleanToStr(att->GetKeySigShowchange()))); } } if (element->HasAttClass( ATT_LABELSADDL ) ) { @@ -9753,26 +9753,26 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttLayerident *att = dynamic_cast(element); assert( att ); if (att->HasLayer()) { - attributes->push_back(std::make_pair("layerInt", att->IntToStr(att->GetLayer()))); + attributes->push_back(std::make_pair("layer", att->IntToStr(att->GetLayer()))); } } if (element->HasAttClass( ATT_LINEVIS ) ) { AttLineVis *att = dynamic_cast(element); assert( att ); if (att->HasForm()) { - attributes->push_back(std::make_pair("form", att->BarRenditionToStr(att->GetForm()))); + attributes->push_back(std::make_pair("form", att->LineformToStr(att->GetForm()))); } if (att->HasWidth()) { attributes->push_back(std::make_pair("width", att->StrToStr(att->GetWidth()))); } if (att->HasEndsym()) { - attributes->push_back(std::make_pair("endsym", att->StrToStr(att->GetEndsym()))); + attributes->push_back(std::make_pair("endsym", att->LinestartendsymbolToStr(att->GetEndsym()))); } if (att->HasEndsymsize()) { attributes->push_back(std::make_pair("endsymsize", att->StrToStr(att->GetEndsymsize()))); } if (att->HasStartsym()) { - attributes->push_back(std::make_pair("startsym", att->StrToStr(att->GetStartsym()))); + attributes->push_back(std::make_pair("startsym", att->LinestartendsymbolToStr(att->GetStartsym()))); } if (att->HasStartsymsize()) { attributes->push_back(std::make_pair("startsymsize", att->StrToStr(att->GetStartsymsize()))); @@ -9789,13 +9789,13 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttLinerend *att = dynamic_cast(element); assert( att ); if (att->HasLendsym()) { - attributes->push_back(std::make_pair("lendsym", att->StrToStr(att->GetLendsym()))); + attributes->push_back(std::make_pair("lendsym", att->LinestartendsymbolToStr(att->GetLendsym()))); } if (att->HasLendsymsize()) { attributes->push_back(std::make_pair("lendsymsize", att->StrToStr(att->GetLendsymsize()))); } if (att->HasLstartsym()) { - attributes->push_back(std::make_pair("lstartsym", att->StrToStr(att->GetLstartsym()))); + attributes->push_back(std::make_pair("lstartsym", att->LinestartendsymbolToStr(att->GetLstartsym()))); } if (att->HasLstartsymsize()) { attributes->push_back(std::make_pair("lstartsymsize", att->StrToStr(att->GetLstartsymsize()))); @@ -9805,7 +9805,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttLinerendBase *att = dynamic_cast(element); assert( att ); if (att->HasLform()) { - attributes->push_back(std::make_pair("lform", att->StrToStr(att->GetLform()))); + attributes->push_back(std::make_pair("lform", att->LineformToStr(att->GetLform()))); } if (att->HasLwidth()) { attributes->push_back(std::make_pair("lwidth", att->StrToStr(att->GetLwidth()))); @@ -9827,34 +9827,34 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("lyricSize", att->StrToStr(att->GetLyricSize()))); } if (att->HasLyricStyle()) { - attributes->push_back(std::make_pair("lyricStyle", att->StrToStr(att->GetLyricStyle()))); + attributes->push_back(std::make_pair("lyricStyle", att->FontstyleToStr(att->GetLyricStyle()))); } if (att->HasLyricWeight()) { - attributes->push_back(std::make_pair("lyricWeight", att->StrToStr(att->GetLyricWeight()))); + attributes->push_back(std::make_pair("lyricWeight", att->FontweightToStr(att->GetLyricWeight()))); } } if (element->HasAttClass( ATT_MEASURELOG ) ) { AttMeasureLog *att = dynamic_cast(element); assert( att ); if (att->HasLeft()) { - attributes->push_back(std::make_pair("left", att->BarRenditionToStr(att->GetLeft()))); + attributes->push_back(std::make_pair("left", att->BarrenditionToStr(att->GetLeft()))); } if (att->HasRight()) { - attributes->push_back(std::make_pair("right", att->BarRenditionToStr(att->GetRight()))); + attributes->push_back(std::make_pair("right", att->BarrenditionToStr(att->GetRight()))); } } if (element->HasAttClass( ATT_MEASUREMENT ) ) { AttMeasurement *att = dynamic_cast(element); assert( att ); if (att->HasUnit()) { - attributes->push_back(std::make_pair("unit", att->IntToStr(att->GetUnit()))); + attributes->push_back(std::make_pair("unit", att->StrToStr(att->GetUnit()))); } } if (element->HasAttClass( ATT_MEASURENUMBERS ) ) { AttMeasurenumbers *att = dynamic_cast(element); assert( att ); if (att->HasMnumVisible()) { - attributes->push_back(std::make_pair("mnumVisible", att->StrToStr(att->GetMnumVisible()))); + attributes->push_back(std::make_pair("mnumVisible", att->BooleanToStr(att->GetMnumVisible()))); } } if (element->HasAttClass( ATT_MEDIABOUNDS ) ) { @@ -9867,7 +9867,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("end", att->StrToStr(att->GetEnd()))); } if (att->HasBetype()) { - attributes->push_back(std::make_pair("betype", att->StrToStr(att->GetBetype()))); + attributes->push_back(std::make_pair("betype", att->BetypeToStr(att->GetBetype()))); } } if (element->HasAttClass( ATT_MEDIUM ) ) { @@ -9881,17 +9881,17 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttMeiversion *att = dynamic_cast(element); assert( att ); if (att->HasMeiversion()) { - attributes->push_back(std::make_pair("meiversion", att->StrToStr(att->GetMeiversion()))); + attributes->push_back(std::make_pair("meiversion", att->MeiversionMeiversionToStr(att->GetMeiversion()))); } } if (element->HasAttClass( ATT_MENSURLOG ) ) { AttMensurLog *att = dynamic_cast(element); assert( att ); if (att->HasDot()) { - attributes->push_back(std::make_pair("dot", att->BoolToStr(att->GetDot()))); + attributes->push_back(std::make_pair("dot", att->BooleanToStr(att->GetDot()))); } if (att->HasSign()) { - attributes->push_back(std::make_pair("sign", att->MensurationSignToStr(att->GetSign()))); + attributes->push_back(std::make_pair("sign", att->MensurationsignToStr(att->GetSign()))); } } if (element->HasAttClass( ATT_METERSIGLOG ) ) { @@ -9901,7 +9901,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("count", att->IntToStr(att->GetCount()))); } if (att->HasSym()) { - attributes->push_back(std::make_pair("sym", att->MeterSignToStr(att->GetSym()))); + attributes->push_back(std::make_pair("sym", att->MetersignToStr(att->GetSym()))); } if (att->HasUnit()) { attributes->push_back(std::make_pair("unit", att->IntToStr(att->GetUnit()))); @@ -9911,7 +9911,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttMeterSigVis *att = dynamic_cast(element); assert( att ); if (att->HasForm()) { - attributes->push_back(std::make_pair("form", att->BarRenditionToStr(att->GetForm()))); + attributes->push_back(std::make_pair("form", att->MeterSigVisFormToStr(att->GetForm()))); } } if (element->HasAttClass( ATT_METERSIGDEFAULTLOG ) ) { @@ -9928,30 +9928,30 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttMeterSigDefaultVis *att = dynamic_cast(element); assert( att ); if (att->HasMeterRend()) { - attributes->push_back(std::make_pair("meterRend", att->StrToStr(att->GetMeterRend()))); + attributes->push_back(std::make_pair("meterRend", att->MeterSigDefaultVisMeterrendToStr(att->GetMeterRend()))); } if (att->HasMeterShowchange()) { - attributes->push_back(std::make_pair("meterShowchange", att->StrToStr(att->GetMeterShowchange()))); + attributes->push_back(std::make_pair("meterShowchange", att->BooleanToStr(att->GetMeterShowchange()))); } if (att->HasMeterSym()) { - attributes->push_back(std::make_pair("meterSym", att->MeterSignToStr(att->GetMeterSym()))); + attributes->push_back(std::make_pair("meterSym", att->MetersignToStr(att->GetMeterSym()))); } } if (element->HasAttClass( ATT_METERCONFORMANCE ) ) { AttMeterconformance *att = dynamic_cast(element); assert( att ); if (att->HasMetcon()) { - attributes->push_back(std::make_pair("metcon", att->StrToStr(att->GetMetcon()))); + attributes->push_back(std::make_pair("metcon", att->MeterconformanceMetconToStr(att->GetMetcon()))); } } if (element->HasAttClass( ATT_METERCONFORMANCEBAR ) ) { AttMeterconformanceBar *att = dynamic_cast(element); assert( att ); if (att->HasMetcon()) { - attributes->push_back(std::make_pair("metcon", att->StrToStr(att->GetMetcon()))); + attributes->push_back(std::make_pair("metcon", att->BooleanToStr(att->GetMetcon()))); } if (att->HasControl()) { - attributes->push_back(std::make_pair("control", att->StrToStr(att->GetControl()))); + attributes->push_back(std::make_pair("control", att->BooleanToStr(att->GetControl()))); } } if (element->HasAttClass( ATT_MMTEMPO ) ) { @@ -9961,17 +9961,17 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("mm", att->StrToStr(att->GetMm()))); } if (att->HasMmUnit()) { - attributes->push_back(std::make_pair("mmUnit", att->StrToStr(att->GetMmUnit()))); + attributes->push_back(std::make_pair("mmUnit", att->DurationToStr(att->GetMmUnit()))); } if (att->HasMmDots()) { - attributes->push_back(std::make_pair("mmDots", att->StrToStr(att->GetMmDots()))); + attributes->push_back(std::make_pair("mmDots", att->IntToStr(att->GetMmDots()))); } } if (element->HasAttClass( ATT_MULTINUMMEASURES ) ) { AttMultinummeasures *att = dynamic_cast(element); assert( att ); if (att->HasMultiNumber()) { - attributes->push_back(std::make_pair("multiNumber", att->BoolToStr(att->GetMultiNumber()))); + attributes->push_back(std::make_pair("multiNumber", att->BooleanToStr(att->GetMultiNumber()))); } } if (element->HasAttClass( ATT_NAME ) ) { @@ -9998,13 +9998,13 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttNoteGes *att = dynamic_cast(element); assert( att ); if (att->HasOctGes()) { - attributes->push_back(std::make_pair("octGes", att->StrToStr(att->GetOctGes()))); + attributes->push_back(std::make_pair("octGes", att->IntToStr(att->GetOctGes()))); } if (att->HasPnameGes()) { - attributes->push_back(std::make_pair("pnameGes", att->StrToStr(att->GetPnameGes()))); + attributes->push_back(std::make_pair("pnameGes", att->PitchnameToStr(att->GetPnameGes()))); } if (att->HasPnum()) { - attributes->push_back(std::make_pair("pnum", att->StrToStr(att->GetPnum()))); + attributes->push_back(std::make_pair("pnum", att->IntToStr(att->GetPnum()))); } } if (element->HasAttClass( ATT_NOTEHEADS ) ) { @@ -10029,7 +10029,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("headShape", att->StrToStr(att->GetHeadShape()))); } if (att->HasHeadVisible()) { - attributes->push_back(std::make_pair("headVisible", att->StrToStr(att->GetHeadVisible()))); + attributes->push_back(std::make_pair("headVisible", att->BooleanToStr(att->GetHeadVisible()))); } } if (element->HasAttClass( ATT_OCTAVE ) ) { @@ -10043,7 +10043,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttOctavedefault *att = dynamic_cast(element); assert( att ); if (att->HasOctaveDefault()) { - attributes->push_back(std::make_pair("octaveDefault", att->StrToStr(att->GetOctaveDefault()))); + attributes->push_back(std::make_pair("octaveDefault", att->IntToStr(att->GetOctaveDefault()))); } } if (element->HasAttClass( ATT_OCTAVEDISPLACEMENT ) ) { @@ -10060,14 +10060,14 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttOnelinestaff *att = dynamic_cast(element); assert( att ); if (att->HasOntheline()) { - attributes->push_back(std::make_pair("ontheline", att->StrToStr(att->GetOntheline()))); + attributes->push_back(std::make_pair("ontheline", att->BooleanToStr(att->GetOntheline()))); } } if (element->HasAttClass( ATT_OPTIMIZATION ) ) { AttOptimization *att = dynamic_cast(element); assert( att ); if (att->HasOptimize()) { - attributes->push_back(std::make_pair("optimize", att->StrToStr(att->GetOptimize()))); + attributes->push_back(std::make_pair("optimize", att->BooleanToStr(att->GetOptimize()))); } } if (element->HasAttClass( ATT_PADLOG ) ) { @@ -10109,21 +10109,21 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttPbVis *att = dynamic_cast(element); assert( att ); if (att->HasFolium()) { - attributes->push_back(std::make_pair("folium", att->StrToStr(att->GetFolium()))); + attributes->push_back(std::make_pair("folium", att->PbVisFoliumToStr(att->GetFolium()))); } } if (element->HasAttClass( ATT_PITCH ) ) { AttPitch *att = dynamic_cast(element); assert( att ); if (att->HasPname()) { - attributes->push_back(std::make_pair("pname", att->PitchNameToStr(att->GetPname()))); + attributes->push_back(std::make_pair("pname", att->PitchnameToStr(att->GetPname()))); } } if (element->HasAttClass( ATT_PLACEMENT ) ) { AttPlacement *att = dynamic_cast(element); assert( att ); if (att->HasPlace()) { - attributes->push_back(std::make_pair("place", att->StaffRelToStr(att->GetPlace()))); + attributes->push_back(std::make_pair("place", att->StaffrelToStr(att->GetPlace()))); } } if (element->HasAttClass( ATT_PLIST ) ) { @@ -10133,7 +10133,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("plist", att->StrToStr(att->GetPlist()))); } if (att->HasEvaluate()) { - attributes->push_back(std::make_pair("evaluate", att->StrToStr(att->GetEvaluate()))); + attributes->push_back(std::make_pair("evaluate", att->PlistEvaluateToStr(att->GetEvaluate()))); } } if (element->HasAttClass( ATT_POINTING ) ) { @@ -10162,14 +10162,14 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttQuantity *att = dynamic_cast(element); assert( att ); if (att->HasQuantity()) { - attributes->push_back(std::make_pair("quantityDbl", att->DblToStr(att->GetQuantity()))); + attributes->push_back(std::make_pair("quantity", att->DblToStr(att->GetQuantity()))); } } if (element->HasAttClass( ATT_RELATIVESIZE ) ) { AttRelativesize *att = dynamic_cast(element); assert( att ); if (att->HasSize()) { - attributes->push_back(std::make_pair("size", att->StrToStr(att->GetSize()))); + attributes->push_back(std::make_pair("size", att->SizeToStr(att->GetSize()))); } } if (element->HasAttClass( ATT_RESPONSIBILITY ) ) { @@ -10183,27 +10183,27 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttSbVis *att = dynamic_cast(element); assert( att ); if (att->HasForm()) { - attributes->push_back(std::make_pair("form", att->BarRenditionToStr(att->GetForm()))); + attributes->push_back(std::make_pair("form", att->SbVisFormToStr(att->GetForm()))); } } if (element->HasAttClass( ATT_SCALABLE ) ) { AttScalable *att = dynamic_cast(element); assert( att ); if (att->HasScale()) { - attributes->push_back(std::make_pair("scale", att->PercentToStr(att->GetScale()))); + attributes->push_back(std::make_pair("scale", att->IntToStr(att->GetScale()))); } } if (element->HasAttClass( ATT_SCOREDEFGES ) ) { AttScoreDefGes *att = dynamic_cast(element); assert( att ); if (att->HasTunePname()) { - attributes->push_back(std::make_pair("tunePname", att->StrToStr(att->GetTunePname()))); + attributes->push_back(std::make_pair("tunePname", att->PitchnameToStr(att->GetTunePname()))); } if (att->HasTuneHz()) { - attributes->push_back(std::make_pair("tuneHzDbl", att->DblToStr(att->GetTuneHz()))); + attributes->push_back(std::make_pair("tuneHz", att->DblToStr(att->GetTuneHz()))); } if (att->HasTuneTemper()) { - attributes->push_back(std::make_pair("tuneTemper", att->StrToStr(att->GetTuneTemper()))); + attributes->push_back(std::make_pair("tuneTemper", att->TemperamentToStr(att->GetTuneTemper()))); } } if (element->HasAttClass( ATT_SCOREDEFVIS ) ) { @@ -10217,14 +10217,14 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttSectionVis *att = dynamic_cast(element); assert( att ); if (att->HasRestart()) { - attributes->push_back(std::make_pair("restart", att->StrToStr(att->GetRestart()))); + attributes->push_back(std::make_pair("restart", att->BooleanToStr(att->GetRestart()))); } } if (element->HasAttClass( ATT_SEQUENCE ) ) { AttSequence *att = dynamic_cast(element); assert( att ); if (att->HasSeq()) { - attributes->push_back(std::make_pair("seqInt", att->IntToStr(att->GetSeq()))); + attributes->push_back(std::make_pair("seq", att->IntToStr(att->GetSeq()))); } } if (element->HasAttClass( ATT_SLASHCOUNT ) ) { @@ -10245,17 +10245,17 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttSpaceVis *att = dynamic_cast(element); assert( att ); if (att->HasCompressable()) { - attributes->push_back(std::make_pair("compressable", att->StrToStr(att->GetCompressable()))); + attributes->push_back(std::make_pair("compressable", att->BooleanToStr(att->GetCompressable()))); } } if (element->HasAttClass( ATT_SPACING ) ) { AttSpacing *att = dynamic_cast(element); assert( att ); if (att->HasSpacingPackexp()) { - attributes->push_back(std::make_pair("spacingPackexpDbl", att->DblToStr(att->GetSpacingPackexp()))); + attributes->push_back(std::make_pair("spacingPackexp", att->DblToStr(att->GetSpacingPackexp()))); } if (att->HasSpacingPackfact()) { - attributes->push_back(std::make_pair("spacingPackfactDbl", att->DblToStr(att->GetSpacingPackfact()))); + attributes->push_back(std::make_pair("spacingPackfact", att->DblToStr(att->GetSpacingPackfact()))); } if (att->HasSpacingStaff()) { attributes->push_back(std::make_pair("spacingStaff", att->StrToStr(att->GetSpacingStaff()))); @@ -10275,19 +10275,19 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttStaffDefVis *att = dynamic_cast(element); assert( att ); if (att->HasGridShow()) { - attributes->push_back(std::make_pair("gridShow", att->BoolToStr(att->GetGridShow()))); + attributes->push_back(std::make_pair("gridShow", att->BooleanToStr(att->GetGridShow()))); } if (att->HasLayerscheme()) { attributes->push_back(std::make_pair("layerscheme", att->LayerschemeToStr(att->GetLayerscheme()))); } if (att->HasLines()) { - attributes->push_back(std::make_pair("linesInt", att->IntToStr(att->GetLines()))); + attributes->push_back(std::make_pair("lines", att->IntToStr(att->GetLines()))); } if (att->HasLinesColor()) { attributes->push_back(std::make_pair("linesColor", att->StrToStr(att->GetLinesColor()))); } if (att->HasLinesVisible()) { - attributes->push_back(std::make_pair("linesVisible", att->BoolToStr(att->GetLinesVisible()))); + attributes->push_back(std::make_pair("linesVisible", att->BooleanToStr(att->GetLinesVisible()))); } if (att->HasSpacing()) { attributes->push_back(std::make_pair("spacing", att->StrToStr(att->GetSpacing()))); @@ -10297,14 +10297,14 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttStaffGrpVis *att = dynamic_cast(element); assert( att ); if (att->HasBarthru()) { - attributes->push_back(std::make_pair("barthru", att->BoolToStr(att->GetBarthru()))); + attributes->push_back(std::make_pair("barthru", att->BooleanToStr(att->GetBarthru()))); } } if (element->HasAttClass( ATT_STAFFGROUPINGSYM ) ) { AttStaffgroupingsym *att = dynamic_cast(element); assert( att ); if (att->HasSymbol()) { - attributes->push_back(std::make_pair("symbol", att->SymbolToStr(att->GetSymbol()))); + attributes->push_back(std::make_pair("symbol", att->StaffgroupingsymSymbolToStr(att->GetSymbol()))); } } if (element->HasAttClass( ATT_STAFFIDENT ) ) { @@ -10318,14 +10318,14 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttStaffloc *att = dynamic_cast(element); assert( att ); if (att->HasLoc()) { - attributes->push_back(std::make_pair("loc", att->StrToStr(att->GetLoc()))); + attributes->push_back(std::make_pair("loc", att->IntToStr(att->GetLoc()))); } } if (element->HasAttClass( ATT_STAFFLOCPITCHED ) ) { AttStafflocPitched *att = dynamic_cast(element); assert( att ); if (att->HasPloc()) { - attributes->push_back(std::make_pair("ploc", att->PitchNameToStr(att->GetPloc()))); + attributes->push_back(std::make_pair("ploc", att->PitchnameToStr(att->GetPloc()))); } if (att->HasOloc()) { attributes->push_back(std::make_pair("oloc", att->IntToStr(att->GetOloc()))); @@ -10349,32 +10349,32 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttStems *att = dynamic_cast(element); assert( att ); if (att->HasStemDir()) { - attributes->push_back(std::make_pair("stemDir", att->StemDirectionToStr(att->GetStemDir()))); + attributes->push_back(std::make_pair("stemDir", att->StemdirectionToStr(att->GetStemDir()))); } if (att->HasStemLen()) { - attributes->push_back(std::make_pair("stemLen", att->IntToStr(att->GetStemLen()))); + attributes->push_back(std::make_pair("stemLen", att->StrToStr(att->GetStemLen()))); } if (att->HasStemMod()) { - attributes->push_back(std::make_pair("stemMod", att->StemModifierToStr(att->GetStemMod()))); + attributes->push_back(std::make_pair("stemMod", att->StemmodifierToStr(att->GetStemMod()))); } if (att->HasStemPos()) { - attributes->push_back(std::make_pair("stemPos", att->StemPositionToStr(att->GetStemPos()))); + attributes->push_back(std::make_pair("stemPos", att->StempositionToStr(att->GetStemPos()))); } if (att->HasStemX()) { - attributes->push_back(std::make_pair("stemX", att->IntToStr(att->GetStemX()))); + attributes->push_back(std::make_pair("stemX", att->DblToStr(att->GetStemX()))); } if (att->HasStemY()) { - attributes->push_back(std::make_pair("stemY", att->IntToStr(att->GetStemY()))); + attributes->push_back(std::make_pair("stemY", att->DblToStr(att->GetStemY()))); } } if (element->HasAttClass( ATT_SYLLOG ) ) { AttSylLog *att = dynamic_cast(element); assert( att ); if (att->HasCon()) { - attributes->push_back(std::make_pair("con", att->ConToStr(att->GetCon()))); + attributes->push_back(std::make_pair("con", att->SylLogConToStr(att->GetCon()))); } if (att->HasWordpos()) { - attributes->push_back(std::make_pair("wordpos", att->WordPosToStr(att->GetWordpos()))); + attributes->push_back(std::make_pair("wordpos", att->SylLogWordposToStr(att->GetWordpos()))); } } if (element->HasAttClass( ATT_SYLTEXT ) ) { @@ -10388,7 +10388,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttSystems *att = dynamic_cast(element); assert( att ); if (att->HasSystemLeftline()) { - attributes->push_back(std::make_pair("systemLeftline", att->StrToStr(att->GetSystemLeftline()))); + attributes->push_back(std::make_pair("systemLeftline", att->BooleanToStr(att->GetSystemLeftline()))); } if (att->HasSystemLeftmar()) { attributes->push_back(std::make_pair("systemLeftmar", att->StrToStr(att->GetSystemLeftmar()))); @@ -10413,10 +10413,10 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("textSize", att->StrToStr(att->GetTextSize()))); } if (att->HasTextStyle()) { - attributes->push_back(std::make_pair("textStyle", att->StrToStr(att->GetTextStyle()))); + attributes->push_back(std::make_pair("textStyle", att->FontstyleToStr(att->GetTextStyle()))); } if (att->HasTextWeight()) { - attributes->push_back(std::make_pair("textWeight", att->StrToStr(att->GetTextWeight()))); + attributes->push_back(std::make_pair("textWeight", att->FontweightToStr(att->GetTextWeight()))); } } if (element->HasAttClass( ATT_TIEPRESENT ) ) { @@ -10437,7 +10437,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttTimestampPerformed *att = dynamic_cast(element); assert( att ); if (att->HasTstampGes()) { - attributes->push_back(std::make_pair("tstampGes", att->StrToStr(att->GetTstampGes()))); + attributes->push_back(std::make_pair("tstampGes", att->DurationToStr(att->GetTstampGes()))); } if (att->HasTstampReal()) { attributes->push_back(std::make_pair("tstampReal", att->StrToStr(att->GetTstampReal()))); @@ -10447,17 +10447,17 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttTimestamp2Musical *att = dynamic_cast(element); assert( att ); if (att->HasTstamp2()) { - attributes->push_back(std::make_pair("tstamp2", att->Tstamp2ToStr(att->GetTstamp2()))); + attributes->push_back(std::make_pair("tstamp2", att->MeasurebeatToStr(att->GetTstamp2()))); } } if (element->HasAttClass( ATT_TRANSPOSITION ) ) { AttTransposition *att = dynamic_cast(element); assert( att ); if (att->HasTransDiat()) { - attributes->push_back(std::make_pair("transDiatDbl", att->DblToStr(att->GetTransDiat()))); + attributes->push_back(std::make_pair("transDiat", att->DblToStr(att->GetTransDiat()))); } if (att->HasTransSemi()) { - attributes->push_back(std::make_pair("transSemiDbl", att->DblToStr(att->GetTransSemi()))); + attributes->push_back(std::make_pair("transSemi", att->DblToStr(att->GetTransSemi()))); } } if (element->HasAttClass( ATT_TUPLETPRESENT ) ) { @@ -10487,7 +10487,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("fontname", att->StrToStr(att->GetFontname()))); } if (att->HasFontsize()) { - attributes->push_back(std::make_pair("fontsizeDbl", att->DblToStr(att->GetFontsize()))); + attributes->push_back(std::make_pair("fontsize", att->DblToStr(att->GetFontsize()))); } if (att->HasFontstyle()) { attributes->push_back(std::make_pair("fontstyle", att->FontstyleToStr(att->GetFontstyle()))); @@ -10500,7 +10500,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttVisibility *att = dynamic_cast(element); assert( att ); if (att->HasVisible()) { - attributes->push_back(std::make_pair("visible", att->StrToStr(att->GetVisible()))); + attributes->push_back(std::make_pair("visible", att->BooleanToStr(att->GetVisible()))); } } if (element->HasAttClass( ATT_VISUALOFFSETHO ) ) { @@ -10514,7 +10514,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttVisualoffsetTo *att = dynamic_cast(element); assert( att ); if (att->HasTo()) { - attributes->push_back(std::make_pair("to", att->StrToStr(att->GetTo()))); + attributes->push_back(std::make_pair("to", att->DblToStr(att->GetTo()))); } } if (element->HasAttClass( ATT_VISUALOFFSETVO ) ) { @@ -10538,10 +10538,10 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttVisualoffset2To *att = dynamic_cast(element); assert( att ); if (att->HasStartto()) { - attributes->push_back(std::make_pair("startto", att->StrToStr(att->GetStartto()))); + attributes->push_back(std::make_pair("startto", att->DblToStr(att->GetStartto()))); } if (att->HasEndto()) { - attributes->push_back(std::make_pair("endto", att->StrToStr(att->GetEndto()))); + attributes->push_back(std::make_pair("endto", att->DblToStr(att->GetEndto()))); } } if (element->HasAttClass( ATT_VISUALOFFSET2VO ) ) { @@ -10572,20 +10572,20 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttXy *att = dynamic_cast(element); assert( att ); if (att->HasX()) { - attributes->push_back(std::make_pair("xDbl", att->DblToStr(att->GetX()))); + attributes->push_back(std::make_pair("x", att->DblToStr(att->GetX()))); } if (att->HasY()) { - attributes->push_back(std::make_pair("yDbl", att->DblToStr(att->GetY()))); + attributes->push_back(std::make_pair("y", att->DblToStr(att->GetY()))); } } if (element->HasAttClass( ATT_XY2 ) ) { AttXy2 *att = dynamic_cast(element); assert( att ); if (att->HasX2()) { - attributes->push_back(std::make_pair("x2Dbl", att->DblToStr(att->GetX2()))); + attributes->push_back(std::make_pair("x2", att->DblToStr(att->GetX2()))); } if (att->HasY2()) { - attributes->push_back(std::make_pair("y2Dbl", att->DblToStr(att->GetY2()))); + attributes->push_back(std::make_pair("y2", att->DblToStr(att->GetY2()))); } } diff --git a/libmei/atts_shared.h b/libmei/atts_shared.h index c2ea7f4acba..e14005838a1 100644 --- a/libmei/atts_shared.h +++ b/libmei/atts_shared.h @@ -16,7 +16,7 @@ #define __VRV_ATTS_SHARED_H__ #include "att.h" -#include "att_classes.h" +#include "attdef.h" #include "pugixml.hpp" //---------------------------------------------------------------------------- @@ -50,15 +50,15 @@ class AttAccidLog: public Att * to the default value) **/ ///@{ - void SetFunc(data_FUNC func_) { m_func = func_; }; - data_FUNC GetFunc() const { return m_func; }; + void SetFunc(accidLog_FUNC func_) { m_func = func_; }; + accidLog_FUNC GetFunc() const { return m_func; }; bool HasFunc( ); ///@} private: /** Records the function of an accidental. **/ - data_FUNC m_func; + accidLog_FUNC m_func; /* include */ }; @@ -126,15 +126,15 @@ class AttAccidentalPerformed: public Att * to the default value) **/ ///@{ - void SetAccidGes(std::string accidGes_) { m_accidGes = accidGes_; }; - std::string GetAccidGes() const { return m_accidGes; }; + void SetAccidGes(data_ACCIDENTAL_IMPLICIT accidGes_) { m_accidGes = accidGes_; }; + data_ACCIDENTAL_IMPLICIT GetAccidGes() const { return m_accidGes; }; bool HasAccidGes( ); ///@} private: /** Records the performed pitch inflection. **/ - std::string m_accidGes; + data_ACCIDENTAL_IMPLICIT m_accidGes; /* include */ }; @@ -164,8 +164,8 @@ class AttArticulation: public Att * to the default value) **/ ///@{ - void SetArtic(std::string artic_) { m_artic = artic_; }; - std::string GetArtic() const { return m_artic; }; + void SetArtic(data_ARTICULATION artic_) { m_artic = artic_; }; + data_ARTICULATION GetArtic() const { return m_artic; }; bool HasArtic( ); ///@} @@ -178,7 +178,7 @@ class AttArticulation: public Att * should be encoded in the artic attribute; for example, fingerings should be * encoded using the element. **/ - std::string m_artic; + data_ARTICULATION m_artic; /* include */ }; @@ -208,15 +208,15 @@ class AttArticulationPerformed: public Att * to the default value) **/ ///@{ - void SetArticGes(std::string articGes_) { m_articGes = articGes_; }; - std::string GetArticGes() const { return m_articGes; }; + void SetArticGes(data_ARTICULATION articGes_) { m_articGes = articGes_; }; + data_ARTICULATION GetArticGes() const { return m_articGes; }; bool HasArticGes( ); ///@} private: /** Records performed articulation that differs from the written value. **/ - std::string m_articGes; + data_ARTICULATION m_articGes; /* include */ }; @@ -246,15 +246,15 @@ class AttAugmentdots: public Att * to the default value) **/ ///@{ - void SetDots(char dots_) { m_dots = dots_; }; - char GetDots() const { return m_dots; }; + void SetDots(int dots_) { m_dots = dots_; }; + int GetDots() const { return m_dots; }; bool HasDots( ); ///@} private: /** Records the number of augmentation dots required by a dotted duration. **/ - char m_dots; + int m_dots; /* include */ }; @@ -373,20 +373,20 @@ class AttBarplacement: public Att * to the default value) **/ ///@{ - void SetBarplace(std::string barplace_) { m_barplace = barplace_; }; - std::string GetBarplace() const { return m_barplace; }; + void SetBarplace(data_BARPLACE barplace_) { m_barplace = barplace_; }; + data_BARPLACE GetBarplace() const { return m_barplace; }; bool HasBarplace( ); // - void SetTaktplace(std::string taktplace_) { m_taktplace = taktplace_; }; - std::string GetTaktplace() const { return m_taktplace; }; + void SetTaktplace(int taktplace_) { m_taktplace = taktplace_; }; + int GetTaktplace() const { return m_taktplace; }; bool HasTaktplace( ); ///@} private: /** Records the location of a bar line. **/ - std::string m_barplace; + data_BARPLACE m_barplace; /** * If takt bar lines are to be used, then the taktplace attribute may be used to * denote the staff location of the shortened bar line. @@ -397,7 +397,7 @@ class AttBarplacement: public Att * 0,2,4,6,8,10. For example, a value of '9' puts the bar line through the top line * of a 5-line staff. **/ - std::string m_taktplace; + int m_taktplace; /* include */ }; @@ -432,13 +432,13 @@ class AttBeamingVis: public Att bool HasBeamColor( ); // - void SetBeamRend(std::string beamRend_) { m_beamRend = beamRend_; }; - std::string GetBeamRend() const { return m_beamRend; }; + void SetBeamRend(beamingVis_BEAMREND beamRend_) { m_beamRend = beamRend_; }; + beamingVis_BEAMREND GetBeamRend() const { return m_beamRend; }; bool HasBeamRend( ); // - void SetBeamSlope(double beamSlopeDbl_) { m_beamSlopeDbl = beamSlopeDbl_; }; - double GetBeamSlope() const { return m_beamSlopeDbl; }; + void SetBeamSlope(double beamSlope_) { m_beamSlope = beamSlope_; }; + double GetBeamSlope() const { return m_beamSlope; }; bool HasBeamSlope( ); ///@} @@ -447,9 +447,9 @@ class AttBeamingVis: public Att /** Color of beams, including those associated with tuplets. **/ std::string m_beamColor; /** Encodes whether a beam is "feathered" and in which direction. **/ - std::string m_beamRend; + beamingVis_BEAMREND m_beamRend; /** Captures beam slope. **/ - double m_beamSlopeDbl; + double m_beamSlope; /* include */ }; @@ -603,8 +603,8 @@ class AttChordVis: public Att * to the default value) **/ ///@{ - void SetCluster(std::string cluster_) { m_cluster = cluster_; }; - std::string GetCluster() const { return m_cluster; }; + void SetCluster(data_CLUSTER cluster_) { m_cluster = cluster_; }; + data_CLUSTER GetCluster() const { return m_cluster; }; bool HasCluster( ); ///@} @@ -616,7 +616,7 @@ class AttChordVis: public Att * The highest and lowest notes of the chord usually indicate the upper and lower * boundaries of the cluster note head. **/ - std::string m_cluster; + data_CLUSTER m_cluster; /* include */ }; @@ -688,8 +688,8 @@ class AttClefLog: public Att * to the default value) **/ ///@{ - void SetCautionary(std::string cautionary_) { m_cautionary = cautionary_; }; - std::string GetCautionary() const { return m_cautionary; }; + void SetCautionary(data_BOOLEAN cautionary_) { m_cautionary = cautionary_; }; + data_BOOLEAN GetCautionary() const { return m_cautionary; }; bool HasCautionary( ); ///@} @@ -699,7 +699,7 @@ class AttClefLog: public Att * Records the function of the clef. * A "cautionary" clef does not change the following pitches. **/ - std::string m_cautionary; + data_BOOLEAN m_cautionary; /* include */ }; @@ -797,8 +797,8 @@ class AttCleffingVis: public Att bool HasClefColor( ); // - void SetClefVisible(std::string clefVisible_) { m_clefVisible = clefVisible_; }; - std::string GetClefVisible() const { return m_clefVisible; }; + void SetClefVisible(data_BOOLEAN clefVisible_) { m_clefVisible = clefVisible_; }; + data_BOOLEAN GetClefVisible() const { return m_clefVisible; }; bool HasClefVisible( ); ///@} @@ -807,7 +807,7 @@ class AttCleffingVis: public Att /** Describes the color of the clef. **/ std::string m_clefColor; /** Determines whether the clef is to be displayed. **/ - std::string m_clefVisible; + data_BOOLEAN m_clefVisible; /* include */ }; @@ -1047,36 +1047,36 @@ class AttCoordinated: public Att * to the default value) **/ ///@{ - void SetUlx(int ulxInt_) { m_ulxInt = ulxInt_; }; - int GetUlx() const { return m_ulxInt; }; + void SetUlx(int ulx_) { m_ulx = ulx_; }; + int GetUlx() const { return m_ulx; }; bool HasUlx( ); // - void SetUly(int ulyInt_) { m_ulyInt = ulyInt_; }; - int GetUly() const { return m_ulyInt; }; + void SetUly(int uly_) { m_uly = uly_; }; + int GetUly() const { return m_uly; }; bool HasUly( ); // - void SetLrx(int lrxInt_) { m_lrxInt = lrxInt_; }; - int GetLrx() const { return m_lrxInt; }; + void SetLrx(int lrx_) { m_lrx = lrx_; }; + int GetLrx() const { return m_lrx; }; bool HasLrx( ); // - void SetLry(int lryInt_) { m_lryInt = lryInt_; }; - int GetLry() const { return m_lryInt; }; + void SetLry(int lry_) { m_lry = lry_; }; + int GetLry() const { return m_lry; }; bool HasLry( ); ///@} private: /** Indicates the upper-left corner x coordinate. **/ - int m_ulxInt; + int m_ulx; /** Indicates the upper-left corner y coordinate. **/ - int m_ulyInt; + int m_uly; /** Indicates the lower-right corner x coordinate. **/ - int m_lrxInt; + int m_lrx; /** Indicates the lower-left corner x coordinate. **/ - int m_lryInt; + int m_lry; /* include */ }; @@ -1116,8 +1116,8 @@ class AttCurvature: public Att bool HasBulge( ); // - void SetCurvedir(data_CURVEDIR curvedir_) { m_curvedir = curvedir_; }; - data_CURVEDIR GetCurvedir() const { return m_curvedir; }; + void SetCurvedir(curvature_CURVEDIR curvedir_) { m_curvedir = curvedir_; }; + curvature_CURVEDIR GetCurvedir() const { return m_curvedir; }; bool HasCurvedir( ); ///@} @@ -1139,7 +1139,7 @@ class AttCurvature: public Att **/ double m_bulge; /** Describes a curve with a generic term indicating the direction of curvature. **/ - data_CURVEDIR m_curvedir; + curvature_CURVEDIR m_curvedir; /* include */ }; @@ -1169,8 +1169,8 @@ class AttCurverend: public Att * to the default value) **/ ///@{ - void SetLform(std::string lform_) { m_lform = lform_; }; - std::string GetLform() const { return m_lform; }; + void SetLform(data_LINEFORM lform_) { m_lform = lform_; }; + data_LINEFORM GetLform() const { return m_lform; }; bool HasLform( ); // @@ -1182,7 +1182,7 @@ class AttCurverend: public Att private: /** Describes the line style of a curve. **/ - std::string m_lform; + data_LINEFORM m_lform; /** Width of a curved line. **/ std::string m_lwidth; @@ -1455,15 +1455,15 @@ class AttDotLog: public Att * to the default value) **/ ///@{ - void SetForm(data_BARRENDITION form_) { m_form = form_; }; - data_BARRENDITION GetForm() const { return m_form; }; + void SetForm(dotLog_FORM form_) { m_form = form_; }; + dotLog_FORM GetForm() const { return m_form; }; bool HasForm( ); ///@} private: /** Records the appearance and usually the function of the bar line. **/ - data_BARRENDITION m_form; + dotLog_FORM m_form; /* include */ }; @@ -1537,18 +1537,18 @@ class AttDurationDefault: public Att * to the default value) **/ ///@{ - void SetDurDefault(std::string durDefault_) { m_durDefault = durDefault_; }; - std::string GetDurDefault() const { return m_durDefault; }; + void SetDurDefault(data_DURATION durDefault_) { m_durDefault = durDefault_; }; + data_DURATION GetDurDefault() const { return m_durDefault; }; bool HasDurDefault( ); // - void SetNumDefault(int numDefaultInt_) { m_numDefaultInt = numDefaultInt_; }; - int GetNumDefault() const { return m_numDefaultInt; }; + void SetNumDefault(int numDefault_) { m_numDefault = numDefault_; }; + int GetNumDefault() const { return m_numDefault; }; bool HasNumDefault( ); // - void SetNumbaseDefault(int numbaseDefaultInt_) { m_numbaseDefaultInt = numbaseDefaultInt_; }; - int GetNumbaseDefault() const { return m_numbaseDefaultInt; }; + void SetNumbaseDefault(int numbaseDefault_) { m_numbaseDefault = numbaseDefault_; }; + int GetNumbaseDefault() const { return m_numbaseDefault; }; bool HasNumbaseDefault( ); ///@} @@ -1559,17 +1559,17 @@ class AttDurationDefault: public Att * chord, etc. * in a measure does not have a duration specified. **/ - std::string m_durDefault; + data_DURATION m_durDefault; /** * Along with numbase.default, describes the default duration as a ratio. * num.default is the first value in the ratio. **/ - int m_numDefaultInt; + int m_numDefault; /** * Along with num.default, describes the default duration as a ratio. * numbase.default is the second value in the ratio. **/ - int m_numbaseDefaultInt; + int m_numbaseDefault; /* include */ }; @@ -1737,8 +1737,8 @@ class AttEnclosingchars: public Att * to the default value) **/ ///@{ - void SetEnclose(std::string enclose_) { m_enclose = enclose_; }; - std::string GetEnclose() const { return m_enclose; }; + void SetEnclose(data_ENCLOSURE enclose_) { m_enclose = enclose_; }; + data_ENCLOSURE GetEnclose() const { return m_enclose; }; bool HasEnclose( ); ///@} @@ -1750,7 +1750,7 @@ class AttEnclosingchars: public Att * For an example of cautionary accidentals enclosed in parentheses, see Read, p. * 131, ex. 9-14. **/ - std::string m_enclose; + data_ENCLOSURE m_enclose; /* include */ }; @@ -1780,15 +1780,15 @@ class AttEndings: public Att * to the default value) **/ ///@{ - void SetEndingRend(std::string endingRend_) { m_endingRend = endingRend_; }; - std::string GetEndingRend() const { return m_endingRend; }; + void SetEndingRend(endings_ENDINGREND endingRend_) { m_endingRend = endingRend_; }; + endings_ENDINGREND GetEndingRend() const { return m_endingRend; }; bool HasEndingRend( ); ///@} private: /** Describes where ending marks should be displayed. **/ - std::string m_endingRend; + endings_ENDINGREND m_endingRend; /* include */ }; @@ -1818,15 +1818,15 @@ class AttExtender: public Att * to the default value) **/ ///@{ - void SetExtender(std::string extender_) { m_extender = extender_; }; - std::string GetExtender() const { return m_extender; }; + void SetExtender(data_BOOLEAN extender_) { m_extender = extender_; }; + data_BOOLEAN GetExtender() const { return m_extender; }; bool HasExtender( ); ///@} private: /** Indicates the presence of an extension symbol, typically a line. **/ - std::string m_extender; + data_BOOLEAN m_extender; /* include */ }; @@ -1898,8 +1898,8 @@ class AttFiling: public Att * to the default value) **/ ///@{ - void SetNonfiling(int nonfilingInt_) { m_nonfilingInt = nonfilingInt_; }; - int GetNonfiling() const { return m_nonfilingInt; }; + void SetNonfiling(int nonfiling_) { m_nonfiling = nonfiling_; }; + int GetNonfiling() const { return m_nonfiling; }; bool HasNonfiling( ); ///@} @@ -1909,7 +1909,7 @@ class AttFiling: public Att * Holds the number of initial characters (such as those constituing an article or * preposition) that should not be used for sorting a title or name. **/ - int m_nonfilingInt; + int m_nonfiling; /* include */ }; @@ -1939,15 +1939,15 @@ class AttGrpSymLog: public Att * to the default value) **/ ///@{ - void SetLevel(int levelInt_) { m_levelInt = levelInt_; }; - int GetLevel() const { return m_levelInt; }; + void SetLevel(int level_) { m_level = level_; }; + int GetLevel() const { return m_level; }; bool HasLevel( ); ///@} private: /** Indicates the nesting level of staff grouping symbols. **/ - int m_levelInt; + int m_level; /* include */ }; @@ -2056,15 +2056,15 @@ class AttHorizontalalign: public Att * to the default value) **/ ///@{ - void SetHalign(std::string halign_) { m_halign = halign_; }; - std::string GetHalign() const { return m_halign; }; + void SetHalign(data_HORIZONTALALIGNMENT halign_) { m_halign = halign_; }; + data_HORIZONTALALIGNMENT GetHalign() const { return m_halign; }; bool HasHalign( ); ///@} private: /** Records horizontal alignment. **/ - std::string m_halign; + data_HORIZONTALALIGNMENT m_halign; /* include */ }; @@ -2222,15 +2222,15 @@ class AttKeySigLog: public Att * to the default value) **/ ///@{ - void SetMode(std::string mode_) { m_mode = mode_; }; - std::string GetMode() const { return m_mode; }; + void SetMode(data_MODE mode_) { m_mode = mode_; }; + data_MODE GetMode() const { return m_mode; }; bool HasMode( ); ///@} private: /** Indicates major, minor, or other tonality. **/ - std::string m_mode; + data_MODE m_mode; /* include */ }; @@ -2511,15 +2511,15 @@ class AttLayerident: public Att * to the default value) **/ ///@{ - void SetLayer(int layerInt_) { m_layerInt = layerInt_; }; - int GetLayer() const { return m_layerInt; }; + void SetLayer(int layer_) { m_layer = layer_; }; + int GetLayer() const { return m_layer; }; bool HasLayer( ); ///@} private: /** Identifies the layer to which a feature applies. **/ - int m_layerInt; + int m_layer; /* include */ }; @@ -2549,8 +2549,8 @@ class AttLineVis: public Att * to the default value) **/ ///@{ - void SetForm(data_BARRENDITION form_) { m_form = form_; }; - data_BARRENDITION GetForm() const { return m_form; }; + void SetForm(data_LINEFORM form_) { m_form = form_; }; + data_LINEFORM GetForm() const { return m_form; }; bool HasForm( ); // @@ -2559,8 +2559,8 @@ class AttLineVis: public Att bool HasWidth( ); // - void SetEndsym(std::string endsym_) { m_endsym = endsym_; }; - std::string GetEndsym() const { return m_endsym; }; + void SetEndsym(data_LINESTARTENDSYMBOL endsym_) { m_endsym = endsym_; }; + data_LINESTARTENDSYMBOL GetEndsym() const { return m_endsym; }; bool HasEndsym( ); // @@ -2569,8 +2569,8 @@ class AttLineVis: public Att bool HasEndsymsize( ); // - void SetStartsym(std::string startsym_) { m_startsym = startsym_; }; - std::string GetStartsym() const { return m_startsym; }; + void SetStartsym(data_LINESTARTENDSYMBOL startsym_) { m_startsym = startsym_; }; + data_LINESTARTENDSYMBOL GetStartsym() const { return m_startsym; }; bool HasStartsym( ); // @@ -2582,15 +2582,15 @@ class AttLineVis: public Att private: /** Records the appearance and usually the function of the bar line. **/ - data_BARRENDITION m_form; + data_LINEFORM m_form; /** Width of the line. **/ std::string m_width; /** Symbol rendered at end of line. **/ - std::string m_endsym; + data_LINESTARTENDSYMBOL m_endsym; /** Holds the relative size of the line-end symbol. **/ std::string m_endsymsize; /** Symbol rendered at start of line. **/ - std::string m_startsym; + data_LINESTARTENDSYMBOL m_startsym; /** Holds the relative size of the line-start symbol. **/ std::string m_startsymsize; @@ -2664,8 +2664,8 @@ class AttLinerend: public Att * to the default value) **/ ///@{ - void SetLendsym(std::string lendsym_) { m_lendsym = lendsym_; }; - std::string GetLendsym() const { return m_lendsym; }; + void SetLendsym(data_LINESTARTENDSYMBOL lendsym_) { m_lendsym = lendsym_; }; + data_LINESTARTENDSYMBOL GetLendsym() const { return m_lendsym; }; bool HasLendsym( ); // @@ -2674,8 +2674,8 @@ class AttLinerend: public Att bool HasLendsymsize( ); // - void SetLstartsym(std::string lstartsym_) { m_lstartsym = lstartsym_; }; - std::string GetLstartsym() const { return m_lstartsym; }; + void SetLstartsym(data_LINESTARTENDSYMBOL lstartsym_) { m_lstartsym = lstartsym_; }; + data_LINESTARTENDSYMBOL GetLstartsym() const { return m_lstartsym; }; bool HasLstartsym( ); // @@ -2687,11 +2687,11 @@ class AttLinerend: public Att private: /** Symbol rendered at end of line. **/ - std::string m_lendsym; + data_LINESTARTENDSYMBOL m_lendsym; /** Holds the relative size of the line-end symbol. **/ std::string m_lendsymsize; /** Symbol rendered at start of line. **/ - std::string m_lstartsym; + data_LINESTARTENDSYMBOL m_lstartsym; /** Holds the relative size of the line-start symbol. **/ std::string m_lstartsymsize; @@ -2723,8 +2723,8 @@ class AttLinerendBase: public Att * to the default value) **/ ///@{ - void SetLform(std::string lform_) { m_lform = lform_; }; - std::string GetLform() const { return m_lform; }; + void SetLform(data_LINEFORM lform_) { m_lform = lform_; }; + data_LINEFORM GetLform() const { return m_lform; }; bool HasLform( ); // @@ -2736,7 +2736,7 @@ class AttLinerendBase: public Att private: /** Describes the line style of a curve. **/ - std::string m_lform; + data_LINEFORM m_lform; /** Width of a curved line. **/ std::string m_lwidth; @@ -2788,13 +2788,13 @@ class AttLyricstyle: public Att bool HasLyricSize( ); // - void SetLyricStyle(std::string lyricStyle_) { m_lyricStyle = lyricStyle_; }; - std::string GetLyricStyle() const { return m_lyricStyle; }; + void SetLyricStyle(data_FONTSTYLE lyricStyle_) { m_lyricStyle = lyricStyle_; }; + data_FONTSTYLE GetLyricStyle() const { return m_lyricStyle; }; bool HasLyricStyle( ); // - void SetLyricWeight(std::string lyricWeight_) { m_lyricWeight = lyricWeight_; }; - std::string GetLyricWeight() const { return m_lyricWeight; }; + void SetLyricWeight(data_FONTWEIGHT lyricWeight_) { m_lyricWeight = lyricWeight_; }; + data_FONTWEIGHT GetLyricWeight() const { return m_lyricWeight; }; bool HasLyricWeight( ); ///@} @@ -2809,9 +2809,9 @@ class AttLyricstyle: public Att /** Sets the default font size value for lyrics. **/ std::string m_lyricSize; /** Sets the default font style value for lyrics. **/ - std::string m_lyricStyle; + data_FONTSTYLE m_lyricStyle; /** Sets the default font weight value for lyrics. **/ - std::string m_lyricWeight; + data_FONTWEIGHT m_lyricWeight; /* include */ }; @@ -2890,15 +2890,15 @@ class AttMeasurement: public Att * to the default value) **/ ///@{ - void SetUnit(int unit_) { m_unit = unit_; }; - int GetUnit() const { return m_unit; }; + void SetUnit(std::string unit_) { m_unit = unit_; }; + std::string GetUnit() const { return m_unit; }; bool HasUnit( ); ///@} private: /** Indicates the unit of measurement. **/ - int m_unit; + std::string m_unit; /* include */ }; @@ -2928,15 +2928,15 @@ class AttMeasurenumbers: public Att * to the default value) **/ ///@{ - void SetMnumVisible(std::string mnumVisible_) { m_mnumVisible = mnumVisible_; }; - std::string GetMnumVisible() const { return m_mnumVisible; }; + void SetMnumVisible(data_BOOLEAN mnumVisible_) { m_mnumVisible = mnumVisible_; }; + data_BOOLEAN GetMnumVisible() const { return m_mnumVisible; }; bool HasMnumVisible( ); ///@} private: /** Indicates whether measure numbers should be displayed. **/ - std::string m_mnumVisible; + data_BOOLEAN m_mnumVisible; /* include */ }; @@ -2976,8 +2976,8 @@ class AttMediabounds: public Att bool HasEnd( ); // - void SetBetype(std::string betype_) { m_betype = betype_; }; - std::string GetBetype() const { return m_betype; }; + void SetBetype(data_BETYPE betype_) { m_betype = betype_; }; + data_BETYPE GetBetype() const { return m_betype; }; bool HasBetype( ); ///@} @@ -3001,7 +3001,7 @@ class AttMediabounds: public Att * The begin and end attributes can only be interpreted meaningfully in conjunction * with this attribute. **/ - std::string m_betype; + data_BETYPE m_betype; /* include */ }; @@ -3069,15 +3069,15 @@ class AttMeiversion: public Att * to the default value) **/ ///@{ - void SetMeiversion(std::string meiversion_) { m_meiversion = meiversion_; }; - std::string GetMeiversion() const { return m_meiversion; }; + void SetMeiversion(meiversion_MEIVERSION meiversion_) { m_meiversion = meiversion_; }; + meiversion_MEIVERSION GetMeiversion() const { return m_meiversion; }; bool HasMeiversion( ); ///@} private: /** Specifies a generic MEI version label. **/ - std::string m_meiversion; + meiversion_MEIVERSION m_meiversion; /* include */ }; @@ -3212,15 +3212,15 @@ class AttMeterSigVis: public Att * to the default value) **/ ///@{ - void SetForm(data_BARRENDITION form_) { m_form = form_; }; - data_BARRENDITION GetForm() const { return m_form; }; + void SetForm(meterSigVis_FORM form_) { m_form = form_; }; + meterSigVis_FORM GetForm() const { return m_form; }; bool HasForm( ); ///@} private: /** Records the appearance and usually the function of the bar line. **/ - data_BARRENDITION m_form; + meterSigVis_FORM m_form; /* include */ }; @@ -3303,13 +3303,13 @@ class AttMeterSigDefaultVis: public Att * to the default value) **/ ///@{ - void SetMeterRend(std::string meterRend_) { m_meterRend = meterRend_; }; - std::string GetMeterRend() const { return m_meterRend; }; + void SetMeterRend(meterSigDefaultVis_METERREND meterRend_) { m_meterRend = meterRend_; }; + meterSigDefaultVis_METERREND GetMeterRend() const { return m_meterRend; }; bool HasMeterRend( ); // - void SetMeterShowchange(std::string meterShowchange_) { m_meterShowchange = meterShowchange_; }; - std::string GetMeterShowchange() const { return m_meterShowchange; }; + void SetMeterShowchange(data_BOOLEAN meterShowchange_) { m_meterShowchange = meterShowchange_; }; + data_BOOLEAN GetMeterShowchange() const { return m_meterShowchange; }; bool HasMeterShowchange( ); // @@ -3321,12 +3321,12 @@ class AttMeterSigDefaultVis: public Att private: /** Contains an indication of how the meter signature should be rendered. **/ - std::string m_meterRend; + meterSigDefaultVis_METERREND m_meterRend; /** * Determines whether a new meter signature should be displayed when the meter * signature changes. **/ - std::string m_meterShowchange; + data_BOOLEAN m_meterShowchange; /** * Indicates the use of a meter symbol instead of a numeric meter signature, that * is, 'C' for common time or 'C' with a slash for cut time. @@ -3361,8 +3361,8 @@ class AttMeterconformance: public Att * to the default value) **/ ///@{ - void SetMetcon(std::string metcon_) { m_metcon = metcon_; }; - std::string GetMetcon() const { return m_metcon; }; + void SetMetcon(meterconformance_METCON metcon_) { m_metcon = metcon_; }; + meterconformance_METCON GetMetcon() const { return m_metcon; }; bool HasMetcon( ); ///@} @@ -3372,7 +3372,7 @@ class AttMeterconformance: public Att * Indicates the relationship between the content of a staff or layer and the * prevailing meter. **/ - std::string m_metcon; + meterconformance_METCON m_metcon; /* include */ }; @@ -3402,13 +3402,13 @@ class AttMeterconformanceBar: public Att * to the default value) **/ ///@{ - void SetMetcon(std::string metcon_) { m_metcon = metcon_; }; - std::string GetMetcon() const { return m_metcon; }; + void SetMetcon(data_BOOLEAN metcon_) { m_metcon = metcon_; }; + data_BOOLEAN GetMetcon() const { return m_metcon; }; bool HasMetcon( ); // - void SetControl(std::string control_) { m_control = control_; }; - std::string GetControl() const { return m_control; }; + void SetControl(data_BOOLEAN control_) { m_control = control_; }; + data_BOOLEAN GetControl() const { return m_control; }; bool HasControl( ); ///@} @@ -3418,7 +3418,7 @@ class AttMeterconformanceBar: public Att * Indicates the relationship between the content of a staff or layer and the * prevailing meter. **/ - std::string m_metcon; + data_BOOLEAN m_metcon; /** * Indicates whether or not a bar line is "controlling"; that is, if it indicates a * point of alignment across all the parts. @@ -3426,7 +3426,7 @@ class AttMeterconformanceBar: public Att * lines within parts may or may not be controlling. When applied to , * this attribute indicates the nature of the right barline but not the left. **/ - std::string m_control; + data_BOOLEAN m_control; /* include */ }; @@ -3461,13 +3461,13 @@ class AttMmtempo: public Att bool HasMm( ); // - void SetMmUnit(std::string mmUnit_) { m_mmUnit = mmUnit_; }; - std::string GetMmUnit() const { return m_mmUnit; }; + void SetMmUnit(data_DURATION mmUnit_) { m_mmUnit = mmUnit_; }; + data_DURATION GetMmUnit() const { return m_mmUnit; }; bool HasMmUnit( ); // - void SetMmDots(std::string mmDots_) { m_mmDots = mmDots_; }; - std::string GetMmDots() const { return m_mmDots; }; + void SetMmDots(int mmDots_) { m_mmDots = mmDots_; }; + int GetMmDots() const { return m_mmDots; }; bool HasMmDots( ); ///@} @@ -3480,9 +3480,9 @@ class AttMmtempo: public Att **/ std::string m_mm; /** Captures the metronomic unit. **/ - std::string m_mmUnit; + data_DURATION m_mmUnit; /** Records the number of augmentation dots required by a dotted metronome unit. **/ - std::string m_mmDots; + int m_mmDots; /* include */ }; @@ -3650,29 +3650,29 @@ class AttNoteGes: public Att * to the default value) **/ ///@{ - void SetOctGes(std::string octGes_) { m_octGes = octGes_; }; - std::string GetOctGes() const { return m_octGes; }; + void SetOctGes(char octGes_) { m_octGes = octGes_; }; + char GetOctGes() const { return m_octGes; }; bool HasOctGes( ); // - void SetPnameGes(std::string pnameGes_) { m_pnameGes = pnameGes_; }; - std::string GetPnameGes() const { return m_pnameGes; }; + void SetPnameGes(data_PITCHNAME pnameGes_) { m_pnameGes = pnameGes_; }; + data_PITCHNAME GetPnameGes() const { return m_pnameGes; }; bool HasPnameGes( ); // - void SetPnum(std::string pnum_) { m_pnum = pnum_; }; - std::string GetPnum() const { return m_pnum; }; + void SetPnum(int pnum_) { m_pnum = pnum_; }; + int GetPnum() const { return m_pnum; }; bool HasPnum( ); ///@} private: /** Records performed octave information that differs from the written value. **/ - std::string m_octGes; + char m_octGes; /** Contains a performed pitch name that differs from the written value. **/ - std::string m_pnameGes; + data_PITCHNAME m_pnameGes; /** Holds a pitch-to-number mapping, a base-40 or MIDI note number, for example. **/ - std::string m_pnum; + int m_pnum; /* include */ }; @@ -3732,8 +3732,8 @@ class AttNoteheads: public Att bool HasHeadShape( ); // - void SetHeadVisible(std::string headVisible_) { m_headVisible = headVisible_; }; - std::string GetHeadVisible() const { return m_headVisible; }; + void SetHeadVisible(data_BOOLEAN headVisible_) { m_headVisible = headVisible_; }; + data_BOOLEAN GetHeadVisible() const { return m_headVisible; }; bool HasHeadVisible( ); ///@} @@ -3759,7 +3759,7 @@ class AttNoteheads: public Att * Indicates if a feature should be rendered when the notation is presented * graphically or sounded when it is presented in an aural form. **/ - std::string m_headVisible; + data_BOOLEAN m_headVisible; /* include */ }; @@ -3827,8 +3827,8 @@ class AttOctavedefault: public Att * to the default value) **/ ///@{ - void SetOctaveDefault(std::string octaveDefault_) { m_octaveDefault = octaveDefault_; }; - std::string GetOctaveDefault() const { return m_octaveDefault; }; + void SetOctaveDefault(char octaveDefault_) { m_octaveDefault = octaveDefault_; }; + char GetOctaveDefault() const { return m_octaveDefault; }; bool HasOctaveDefault( ); ///@} @@ -3839,7 +3839,7 @@ class AttOctavedefault: public Att * chord, etc. * in a measure does not have an octave value specified. **/ - std::string m_octaveDefault; + char m_octaveDefault; /* include */ }; @@ -3914,8 +3914,8 @@ class AttOnelinestaff: public Att * to the default value) **/ ///@{ - void SetOntheline(std::string ontheline_) { m_ontheline = ontheline_; }; - std::string GetOntheline() const { return m_ontheline; }; + void SetOntheline(data_BOOLEAN ontheline_) { m_ontheline = ontheline_; }; + data_BOOLEAN GetOntheline() const { return m_ontheline; }; bool HasOntheline( ); ///@} @@ -3926,7 +3926,7 @@ class AttOnelinestaff: public Att * A value of 'true' places all notes on the line, while a value of 'false' places * stems-up notes above the line and stems-down notes below the line. **/ - std::string m_ontheline; + data_BOOLEAN m_ontheline; /* include */ }; @@ -3956,8 +3956,8 @@ class AttOptimization: public Att * to the default value) **/ ///@{ - void SetOptimize(std::string optimize_) { m_optimize = optimize_; }; - std::string GetOptimize() const { return m_optimize; }; + void SetOptimize(data_BOOLEAN optimize_) { m_optimize = optimize_; }; + data_BOOLEAN GetOptimize() const { return m_optimize; }; bool HasOptimize( ); ///@} @@ -3967,7 +3967,7 @@ class AttOptimization: public Att * Indicates whether staves without notes, rests, etc. * should be displayed. When the value is 'true', empty staves are displayed. **/ - std::string m_optimize; + data_BOOLEAN m_optimize; /* include */ }; @@ -4131,8 +4131,8 @@ class AttPbVis: public Att * to the default value) **/ ///@{ - void SetFolium(std::string folium_) { m_folium = folium_; }; - std::string GetFolium() const { return m_folium; }; + void SetFolium(pbVis_FOLIUM folium_) { m_folium = folium_; }; + pbVis_FOLIUM GetFolium() const { return m_folium; }; bool HasFolium( ); ///@} @@ -4142,7 +4142,7 @@ class AttPbVis: public Att * States the side of a leaf (as in a manuscript) on which the content following * the element occurs. **/ - std::string m_folium; + pbVis_FOLIUM m_folium; /* include */ }; @@ -4256,8 +4256,8 @@ class AttPlist: public Att bool HasPlist( ); // - void SetEvaluate(std::string evaluate_) { m_evaluate = evaluate_; }; - std::string GetEvaluate() const { return m_evaluate; }; + void SetEvaluate(plist_EVALUATE evaluate_) { m_evaluate = evaluate_; }; + plist_EVALUATE GetEvaluate() const { return m_evaluate; }; bool HasEvaluate( ); ///@} @@ -4269,7 +4269,7 @@ class AttPlist: public Att **/ std::string m_plist; /** Specifies the intended meaning when the target of a pointer is itself a pointer. **/ - std::string m_evaluate; + plist_EVALUATE m_evaluate; /* include */ }; @@ -4382,8 +4382,8 @@ class AttQuantity: public Att * to the default value) **/ ///@{ - void SetQuantity(double quantityDbl_) { m_quantityDbl = quantityDbl_; }; - double GetQuantity() const { return m_quantityDbl; }; + void SetQuantity(double quantity_) { m_quantity = quantity_; }; + double GetQuantity() const { return m_quantity; }; bool HasQuantity( ); ///@} @@ -4393,7 +4393,7 @@ class AttQuantity: public Att * Numeric value capturing a measurement or count. * Can only be interpreted in combination with the unit or currency attribute. **/ - double m_quantityDbl; + double m_quantity; /* include */ }; @@ -4423,15 +4423,15 @@ class AttRelativesize: public Att * to the default value) **/ ///@{ - void SetSize(std::string size_) { m_size = size_; }; - std::string GetSize() const { return m_size; }; + void SetSize(data_SIZE size_) { m_size = size_; }; + data_SIZE GetSize() const { return m_size; }; bool HasSize( ); ///@} private: /** Describes the relative size of a feature. **/ - std::string m_size; + data_SIZE m_size; /* include */ }; @@ -4503,15 +4503,15 @@ class AttSbVis: public Att * to the default value) **/ ///@{ - void SetForm(data_BARRENDITION form_) { m_form = form_; }; - data_BARRENDITION GetForm() const { return m_form; }; + void SetForm(sbVis_FORM form_) { m_form = form_; }; + sbVis_FORM GetForm() const { return m_form; }; bool HasForm( ); ///@} private: /** Records the appearance and usually the function of the bar line. **/ - data_BARRENDITION m_form; + sbVis_FORM m_form; /* include */ }; @@ -4541,15 +4541,15 @@ class AttScalable: public Att * to the default value) **/ ///@{ - void SetScale(data_PERCENT scale_) { m_scale = scale_; }; - data_PERCENT GetScale() const { return m_scale; }; + void SetScale(int scale_) { m_scale = scale_; }; + int GetScale() const { return m_scale; }; bool HasScale( ); ///@} private: /** Scale factor to be applied to the feature to make it the desired display size. **/ - data_PERCENT m_scale; + int m_scale; /* include */ }; @@ -4579,29 +4579,29 @@ class AttScoreDefGes: public Att * to the default value) **/ ///@{ - void SetTunePname(std::string tunePname_) { m_tunePname = tunePname_; }; - std::string GetTunePname() const { return m_tunePname; }; + void SetTunePname(data_PITCHNAME tunePname_) { m_tunePname = tunePname_; }; + data_PITCHNAME GetTunePname() const { return m_tunePname; }; bool HasTunePname( ); // - void SetTuneHz(double tuneHzDbl_) { m_tuneHzDbl = tuneHzDbl_; }; - double GetTuneHz() const { return m_tuneHzDbl; }; + void SetTuneHz(double tuneHz_) { m_tuneHz = tuneHz_; }; + double GetTuneHz() const { return m_tuneHz; }; bool HasTuneHz( ); // - void SetTuneTemper(std::string tuneTemper_) { m_tuneTemper = tuneTemper_; }; - std::string GetTuneTemper() const { return m_tuneTemper; }; + void SetTuneTemper(data_TEMPERAMENT tuneTemper_) { m_tuneTemper = tuneTemper_; }; + data_TEMPERAMENT GetTuneTemper() const { return m_tuneTemper; }; bool HasTuneTemper( ); ///@} private: /** Holds the pitch name of a tuning reference pitch. **/ - std::string m_tunePname; + data_PITCHNAME m_tunePname; /** Holds a value for cycles per second, i.e., Hertz, for a tuning reference pitch. **/ - double m_tuneHzDbl; + double m_tuneHz; /** Provides an indication of the tuning system, 'just', for example. **/ - std::string m_tuneTemper; + data_TEMPERAMENT m_tuneTemper; /* include */ }; @@ -4673,15 +4673,15 @@ class AttSectionVis: public Att * to the default value) **/ ///@{ - void SetRestart(std::string restart_) { m_restart = restart_; }; - std::string GetRestart() const { return m_restart; }; + void SetRestart(data_BOOLEAN restart_) { m_restart = restart_; }; + data_BOOLEAN GetRestart() const { return m_restart; }; bool HasRestart( ); ///@} private: /** Indicates that staves begin again with this section. **/ - std::string m_restart; + data_BOOLEAN m_restart; /* include */ }; @@ -4711,8 +4711,8 @@ class AttSequence: public Att * to the default value) **/ ///@{ - void SetSeq(int seqInt_) { m_seqInt = seqInt_; }; - int GetSeq() const { return m_seqInt; }; + void SetSeq(int seq_) { m_seq = seq_; }; + int GetSeq() const { return m_seq; }; bool HasSeq( ); ///@} @@ -4722,7 +4722,7 @@ class AttSequence: public Att * Used to assign a sequence number related to the order in which the encoded * features carrying this attribute are believed to have occurred. **/ - int m_seqInt; + int m_seq; /* include */ }; @@ -4832,8 +4832,8 @@ class AttSpaceVis: public Att * to the default value) **/ ///@{ - void SetCompressable(std::string compressable_) { m_compressable = compressable_; }; - std::string GetCompressable() const { return m_compressable; }; + void SetCompressable(data_BOOLEAN compressable_) { m_compressable = compressable_; }; + data_BOOLEAN GetCompressable() const { return m_compressable; }; bool HasCompressable( ); ///@} @@ -4843,7 +4843,7 @@ class AttSpaceVis: public Att * Indicates whether a space is 'compressible', i.e., if it may be removed at the * discretion of processing software. **/ - std::string m_compressable; + data_BOOLEAN m_compressable; /* include */ }; @@ -4873,13 +4873,13 @@ class AttSpacing: public Att * to the default value) **/ ///@{ - void SetSpacingPackexp(double spacingPackexpDbl_) { m_spacingPackexpDbl = spacingPackexpDbl_; }; - double GetSpacingPackexp() const { return m_spacingPackexpDbl; }; + void SetSpacingPackexp(double spacingPackexp_) { m_spacingPackexp = spacingPackexp_; }; + double GetSpacingPackexp() const { return m_spacingPackexp; }; bool HasSpacingPackexp( ); // - void SetSpacingPackfact(double spacingPackfactDbl_) { m_spacingPackfactDbl = spacingPackfactDbl_; }; - double GetSpacingPackfact() const { return m_spacingPackfactDbl; }; + void SetSpacingPackfact(double spacingPackfact_) { m_spacingPackfact = spacingPackfact_; }; + double GetSpacingPackfact() const { return m_spacingPackfact; }; bool HasSpacingPackfact( ); // @@ -4896,9 +4896,9 @@ class AttSpacing: public Att private: /** Describes a note's spacing relative to its time value. **/ - double m_spacingPackexpDbl; + double m_spacingPackexp; /** Describes the note spacing of output. **/ - double m_spacingPackfactDbl; + double m_spacingPackfact; /** * Specifies the minimum amount of space between adjacent staves in the same * system; measured from the bottom line of the staff above to the top line of the @@ -4989,8 +4989,8 @@ class AttStaffDefVis: public Att bool HasLayerscheme( ); // - void SetLines(int linesInt_) { m_linesInt = linesInt_; }; - int GetLines() const { return m_linesInt; }; + void SetLines(int lines_) { m_lines = lines_; }; + int GetLines() const { return m_lines; }; bool HasLines( ); // @@ -5016,7 +5016,7 @@ class AttStaffDefVis: public Att /** Indicates the number of layers and their stem directions. **/ data_LAYERSCHEME m_layerscheme; /** Indicates the number of staff lines. **/ - int m_linesInt; + int m_lines; /** * Captures the colors of the staff lines. * The value is structured; that is, it should have the same number of space- @@ -5105,15 +5105,15 @@ class AttStaffgroupingsym: public Att * to the default value) **/ ///@{ - void SetSymbol(data_SYMBOL symbol_) { m_symbol = symbol_; }; - data_SYMBOL GetSymbol() const { return m_symbol; }; + void SetSymbol(staffgroupingsym_SYMBOL symbol_) { m_symbol = symbol_; }; + staffgroupingsym_SYMBOL GetSymbol() const { return m_symbol; }; bool HasSymbol( ); ///@} private: /** Specifies the symbol used to group a set of staves. **/ - data_SYMBOL m_symbol; + staffgroupingsym_SYMBOL m_symbol; /* include */ }; @@ -5185,15 +5185,15 @@ class AttStaffloc: public Att * to the default value) **/ ///@{ - void SetLoc(std::string loc_) { m_loc = loc_; }; - std::string GetLoc() const { return m_loc; }; + void SetLoc(int loc_) { m_loc = loc_; }; + int GetLoc() const { return m_loc; }; bool HasLoc( ); ///@} private: /** Holds the staff location of the feature. **/ - std::string m_loc; + int m_loc; /* include */ }; @@ -5355,8 +5355,8 @@ class AttStems: public Att bool HasStemDir( ); // - void SetStemLen(int stemLen_) { m_stemLen = stemLen_; }; - int GetStemLen() const { return m_stemLen; }; + void SetStemLen(std::string stemLen_) { m_stemLen = stemLen_; }; + std::string GetStemLen() const { return m_stemLen; }; bool HasStemLen( ); // @@ -5370,13 +5370,13 @@ class AttStems: public Att bool HasStemPos( ); // - void SetStemX(int stemX_) { m_stemX = stemX_; }; - int GetStemX() const { return m_stemX; }; + void SetStemX(double stemX_) { m_stemX = stemX_; }; + double GetStemX() const { return m_stemX; }; bool HasStemX( ); // - void SetStemY(int stemY_) { m_stemY = stemY_; }; - int GetStemY() const { return m_stemY; }; + void SetStemY(double stemY_) { m_stemY = stemY_; }; + double GetStemY() const { return m_stemY; }; bool HasStemY( ); ///@} @@ -5385,7 +5385,7 @@ class AttStems: public Att /** Describes the direction of a stem. **/ data_STEMDIRECTION m_stemDir; /** Encodes the stem length. **/ - int m_stemLen; + std::string m_stemLen; /** * Encodes any stem "modifiers"; that is, symbols rendered on the stem, such as * tremolo or Sprechstimme indicators. @@ -5394,9 +5394,9 @@ class AttStems: public Att /** Records the position of the stem in relation to the note head(s). **/ data_STEMPOSITION m_stemPos; /** Records the output x coordinate of the stem's attachment point. **/ - int m_stemX; + double m_stemX; /** Records the output y coordinate of the stem's attachment point. **/ - int m_stemY; + double m_stemY; /* include */ }; @@ -5426,13 +5426,13 @@ class AttSylLog: public Att * to the default value) **/ ///@{ - void SetCon(data_CON con_) { m_con = con_; }; - data_CON GetCon() const { return m_con; }; + void SetCon(sylLog_CON con_) { m_con = con_; }; + sylLog_CON GetCon() const { return m_con; }; bool HasCon( ); // - void SetWordpos(data_WORDPOS wordpos_) { m_wordpos = wordpos_; }; - data_WORDPOS GetWordpos() const { return m_wordpos; }; + void SetWordpos(sylLog_WORDPOS wordpos_) { m_wordpos = wordpos_; }; + sylLog_WORDPOS GetWordpos() const { return m_wordpos; }; bool HasWordpos( ); ///@} @@ -5442,9 +5442,9 @@ class AttSylLog: public Att * Describes the symbols typically used to indicate breaks between syllables and * their functions. **/ - data_CON m_con; + sylLog_CON m_con; /** Records the position of a syllable within a word. **/ - data_WORDPOS m_wordpos; + sylLog_WORDPOS m_wordpos; /* include */ }; @@ -5512,8 +5512,8 @@ class AttSystems: public Att * to the default value) **/ ///@{ - void SetSystemLeftline(std::string systemLeftline_) { m_systemLeftline = systemLeftline_; }; - std::string GetSystemLeftline() const { return m_systemLeftline; }; + void SetSystemLeftline(data_BOOLEAN systemLeftline_) { m_systemLeftline = systemLeftline_; }; + data_BOOLEAN GetSystemLeftline() const { return m_systemLeftline; }; bool HasSystemLeftline( ); // @@ -5539,7 +5539,7 @@ class AttSystems: public Att * The default value is "true". Do not confuse this with the heavy vertical line * used as a grouping symbol. **/ - std::string m_systemLeftline; + data_BOOLEAN m_systemLeftline; /** * Describes the amount of whitespace at the left system margin relative to * page.leftmar. @@ -5599,13 +5599,13 @@ class AttTextstyle: public Att bool HasTextSize( ); // - void SetTextStyle(std::string textStyle_) { m_textStyle = textStyle_; }; - std::string GetTextStyle() const { return m_textStyle; }; + void SetTextStyle(data_FONTSTYLE textStyle_) { m_textStyle = textStyle_; }; + data_FONTSTYLE GetTextStyle() const { return m_textStyle; }; bool HasTextStyle( ); // - void SetTextWeight(std::string textWeight_) { m_textWeight = textWeight_; }; - std::string GetTextWeight() const { return m_textWeight; }; + void SetTextWeight(data_FONTWEIGHT textWeight_) { m_textWeight = textWeight_; }; + data_FONTWEIGHT GetTextWeight() const { return m_textWeight; }; bool HasTextWeight( ); ///@} @@ -5630,12 +5630,12 @@ class AttTextstyle: public Att * Provides a default value for the font style of text (other than lyrics) when * this information is not provided on the individual elements. **/ - std::string m_textStyle; + data_FONTSTYLE m_textStyle; /** * Provides a default value for the font weight for text (other than lyrics) when * this information is not provided on the individual elements. **/ - std::string m_textWeight; + data_FONTWEIGHT m_textWeight; /* include */ }; @@ -5748,8 +5748,8 @@ class AttTimestampPerformed: public Att * to the default value) **/ ///@{ - void SetTstampGes(std::string tstampGes_) { m_tstampGes = tstampGes_; }; - std::string GetTstampGes() const { return m_tstampGes; }; + void SetTstampGes(data_DURATION tstampGes_) { m_tstampGes = tstampGes_; }; + data_DURATION GetTstampGes() const { return m_tstampGes; }; bool HasTstampGes( ); // @@ -5765,7 +5765,7 @@ class AttTimestampPerformed: public Att * MusicXML 'divisions'), Humdrum **recip values, beats, seconds, or mensural * duration values. **/ - std::string m_tstampGes; + data_DURATION m_tstampGes; /** Used to record the onset time in terms of ISO time. **/ std::string m_tstampReal; @@ -5797,8 +5797,8 @@ class AttTimestamp2Musical: public Att * to the default value) **/ ///@{ - void SetTstamp2(typedef_TSTAMP2 tstamp2_) { m_tstamp2 = tstamp2_; }; - typedef_TSTAMP2 GetTstamp2() const { return m_tstamp2; }; + void SetTstamp2(data_MEASUREBEAT tstamp2_) { m_tstamp2 = tstamp2_; }; + data_MEASUREBEAT GetTstamp2() const { return m_tstamp2; }; bool HasTstamp2( ); ///@} @@ -5808,7 +5808,7 @@ class AttTimestamp2Musical: public Att * Encodes the ending point of an event in terms of musical time, i.e., a count of * measures plus a beat location. **/ - typedef_TSTAMP2 m_tstamp2; + data_MEASUREBEAT m_tstamp2; /* include */ }; @@ -5838,13 +5838,13 @@ class AttTransposition: public Att * to the default value) **/ ///@{ - void SetTransDiat(double transDiatDbl_) { m_transDiatDbl = transDiatDbl_; }; - double GetTransDiat() const { return m_transDiatDbl; }; + void SetTransDiat(double transDiat_) { m_transDiat = transDiat_; }; + double GetTransDiat() const { return m_transDiat; }; bool HasTransDiat( ); // - void SetTransSemi(double transSemiDbl_) { m_transSemiDbl = transSemiDbl_; }; - double GetTransSemi() const { return m_transSemiDbl; }; + void SetTransSemi(double transSemi_) { m_transSemi = transSemi_; }; + double GetTransSemi() const { return m_transSemi; }; bool HasTransSemi( ); ///@} @@ -5854,12 +5854,12 @@ class AttTransposition: public Att * Records the amount of diatonic pitch shift, e.g., C to C♯ = 0, C to Dâ™­ = 1, * necessary to calculate the sounded pitch from the written one. **/ - double m_transDiatDbl; + double m_transDiat; /** * Records the amount of pitch shift in semitones, e.g., C to C♯ = 1, C to Dâ™­ = * 1, necessary to calculate the sounded pitch from the written one. **/ - double m_transSemiDbl; + double m_transSemi; /* include */ }; @@ -5992,8 +5992,8 @@ class AttTypography: public Att bool HasFontname( ); // - void SetFontsize(double fontsizeDbl_) { m_fontsizeDbl = fontsizeDbl_; }; - double GetFontsize() const { return m_fontsizeDbl; }; + void SetFontsize(double fontsize_) { m_fontsize = fontsize_; }; + double GetFontsize() const { return m_fontsize; }; bool HasFontsize( ); // @@ -6014,7 +6014,7 @@ class AttTypography: public Att /** Holds the name of a font. **/ std::string m_fontname; /** Indicates the size of a font in printers' points, i.e., 1/72nd of an inch. **/ - double m_fontsizeDbl; + double m_fontsize; /** Records the style of a font, i.e, italic, oblique, or normal. **/ data_FONTSTYLE m_fontstyle; /** Used to indicate bold type. **/ @@ -6048,8 +6048,8 @@ class AttVisibility: public Att * to the default value) **/ ///@{ - void SetVisible(std::string visible_) { m_visible = visible_; }; - std::string GetVisible() const { return m_visible; }; + void SetVisible(data_BOOLEAN visible_) { m_visible = visible_; }; + data_BOOLEAN GetVisible() const { return m_visible; }; bool HasVisible( ); ///@} @@ -6059,7 +6059,7 @@ class AttVisibility: public Att * Indicates if a feature should be rendered when the notation is presented * graphically or sounded when it is presented in an aural form. **/ - std::string m_visible; + data_BOOLEAN m_visible; /* include */ }; @@ -6131,8 +6131,8 @@ class AttVisualoffsetTo: public Att * to the default value) **/ ///@{ - void SetTo(std::string to_) { m_to = to_; }; - std::string GetTo() const { return m_to; }; + void SetTo(double to_) { m_to = to_; }; + double GetTo() const { return m_to; }; bool HasTo( ); ///@} @@ -6142,7 +6142,7 @@ class AttVisualoffsetTo: public Att * Records a timestamp adjustment of a feature's programmatically-determined * location in terms of musical time; that is, beats. **/ - std::string m_to; + double m_to; /* include */ }; @@ -6265,13 +6265,13 @@ class AttVisualoffset2To: public Att * to the default value) **/ ///@{ - void SetStartto(std::string startto_) { m_startto = startto_; }; - std::string GetStartto() const { return m_startto; }; + void SetStartto(double startto_) { m_startto = startto_; }; + double GetStartto() const { return m_startto; }; bool HasStartto( ); // - void SetEndto(std::string endto_) { m_endto = endto_; }; - std::string GetEndto() const { return m_endto; }; + void SetEndto(double endto_) { m_endto = endto_; }; + double GetEndto() const { return m_endto; }; bool HasEndto( ); ///@} @@ -6281,12 +6281,12 @@ class AttVisualoffset2To: public Att * Records a timestamp adjustment of a feature's programmatically-determined start * point. **/ - std::string m_startto; + double m_startto; /** * Records a timestamp adjustment of a feature's programmatically-determined end * point. **/ - std::string m_endto; + double m_endto; /* include */ }; @@ -6443,13 +6443,13 @@ class AttXy: public Att * to the default value) **/ ///@{ - void SetX(double xDbl_) { m_xDbl = xDbl_; }; - double GetX() const { return m_xDbl; }; + void SetX(double x_) { m_x = x_; }; + double GetX() const { return m_x; }; bool HasX( ); // - void SetY(double yDbl_) { m_yDbl = yDbl_; }; - double GetY() const { return m_yDbl; }; + void SetY(double y_) { m_y = y_; }; + double GetY() const { return m_y; }; bool HasY( ); ///@} @@ -6460,13 +6460,13 @@ class AttXy: public Att * When it is necessary to record the placement of a feature in a facsimile image, * use the facs attribute. **/ - double m_xDbl; + double m_x; /** * Encodes an y coordinate for a feature in an output coordinate system. * When it is necessary to record the placement of a feature in a facsimile image, * use the facs attribute. **/ - double m_yDbl; + double m_y; /* include */ }; @@ -6496,22 +6496,22 @@ class AttXy2: public Att * to the default value) **/ ///@{ - void SetX2(double x2Dbl_) { m_x2Dbl = x2Dbl_; }; - double GetX2() const { return m_x2Dbl; }; + void SetX2(double x2_) { m_x2 = x2_; }; + double GetX2() const { return m_x2; }; bool HasX2( ); // - void SetY2(double y2Dbl_) { m_y2Dbl = y2Dbl_; }; - double GetY2() const { return m_y2Dbl; }; + void SetY2(double y2_) { m_y2 = y2_; }; + double GetY2() const { return m_y2; }; bool HasY2( ); ///@} private: /** Encodes the optional 2nd x coordinate. **/ - double m_x2Dbl; + double m_x2; /** Encodes the optional 2nd y coordinate. **/ - double m_y2Dbl; + double m_y2; /* include */ }; diff --git a/libmei/atts_tablature.cpp b/libmei/atts_tablature.cpp index d53cbb0ea0d..731ee8e1d37 100644 --- a/libmei/atts_tablature.cpp +++ b/libmei/atts_tablature.cpp @@ -39,33 +39,33 @@ AttNoteGesTablature::~AttNoteGesTablature() { } void AttNoteGesTablature::ResetNoteGesTablature() { - m_tabFret = ""; - m_tabString = ""; + m_tabFret = FRETNUMBER_NONE; + m_tabString = STRINGNUMBER_NONE; } -bool AttNoteGesTablature::ReadNoteGesTablature( pugi::xml_node element ) { +bool AttNoteGesTablature::ReadNoteGesTablature( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("tab.fret")) { - this->SetTabFret(StrToStr(element.attribute("tab.fret").value())); + this->SetTabFret(StrToFretnumber(element.attribute("tab.fret").value())); element.remove_attribute("tab.fret"); hasAttribute = true; } if (element.attribute("tab.string")) { - this->SetTabString(StrToStr(element.attribute("tab.string").value())); + this->SetTabString(StrToStringnumber(element.attribute("tab.string").value())); element.remove_attribute("tab.string"); hasAttribute = true; } return hasAttribute; } -bool AttNoteGesTablature::WriteNoteGesTablature( pugi::xml_node element ) { +bool AttNoteGesTablature::WriteNoteGesTablature( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasTabFret()) { - element.append_attribute("tab.fret") = StrToStr(this->GetTabFret()).c_str(); + element.append_attribute("tab.fret") = FretnumberToStr(this->GetTabFret()).c_str(); wroteAttribute = true; } if (this->HasTabString()) { - element.append_attribute("tab.string") = StrToStr(this->GetTabString()).c_str(); + element.append_attribute("tab.string") = StringnumberToStr(this->GetTabString()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -73,12 +73,12 @@ bool AttNoteGesTablature::WriteNoteGesTablature( pugi::xml_node element ) { bool AttNoteGesTablature::HasTabFret( ) { - return (m_tabFret != ""); + return (m_tabFret != FRETNUMBER_NONE); } bool AttNoteGesTablature::HasTabString( ) { - return (m_tabString != ""); + return (m_tabString != STRINGNUMBER_NONE); } @@ -100,7 +100,7 @@ void AttStaffDefGesTablature::ResetStaffDefGesTablature() { m_tabStrings = ""; } -bool AttStaffDefGesTablature::ReadStaffDefGesTablature( pugi::xml_node element ) { +bool AttStaffDefGesTablature::ReadStaffDefGesTablature( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("tab.strings")) { this->SetTabStrings(StrToStr(element.attribute("tab.strings").value())); @@ -110,7 +110,7 @@ bool AttStaffDefGesTablature::ReadStaffDefGesTablature( pugi::xml_node element return hasAttribute; } -bool AttStaffDefGesTablature::WriteStaffDefGesTablature( pugi::xml_node element ) { +bool AttStaffDefGesTablature::WriteStaffDefGesTablature( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasTabStrings()) { element.append_attribute("tab.strings") = StrToStr(this->GetTabStrings()).c_str(); @@ -132,11 +132,11 @@ bool Att::SetTablature( Object *element, std::string attrType, std::string attrV AttNoteGesTablature *att = dynamic_cast(element); assert( att ); if (attrType == "tabFret") { - att->SetTabFret(att->StrToStr(attrValue)); + att->SetTabFret(att->StrToFretnumber(attrValue)); return true; } if (attrType == "tabString") { - att->SetTabString(att->StrToStr(attrValue)); + att->SetTabString(att->StrToStringnumber(attrValue)); return true; } } @@ -157,10 +157,10 @@ void Att::GetTablature( Object *element, ArrayOfStrAttr *attributes ) { AttNoteGesTablature *att = dynamic_cast(element); assert( att ); if (att->HasTabFret()) { - attributes->push_back(std::make_pair("tabFret", att->StrToStr(att->GetTabFret()))); + attributes->push_back(std::make_pair("tabFret", att->FretnumberToStr(att->GetTabFret()))); } if (att->HasTabString()) { - attributes->push_back(std::make_pair("tabString", att->StrToStr(att->GetTabString()))); + attributes->push_back(std::make_pair("tabString", att->StringnumberToStr(att->GetTabString()))); } } if (element->HasAttClass( ATT_STAFFDEFGESTABLATURE ) ) { diff --git a/libmei/atts_tablature.h b/libmei/atts_tablature.h index a36386296cf..cf76bf8af52 100644 --- a/libmei/atts_tablature.h +++ b/libmei/atts_tablature.h @@ -16,7 +16,7 @@ #define __VRV_ATTS_TABLATURE_H__ #include "att.h" -#include "att_classes.h" +#include "attdef.h" #include "pugixml.hpp" //---------------------------------------------------------------------------- @@ -50,22 +50,22 @@ class AttNoteGesTablature: public Att * to the default value) **/ ///@{ - void SetTabFret(std::string tabFret_) { m_tabFret = tabFret_; }; - std::string GetTabFret() const { return m_tabFret; }; + void SetTabFret(data_FRETNUMBER tabFret_) { m_tabFret = tabFret_; }; + data_FRETNUMBER GetTabFret() const { return m_tabFret; }; bool HasTabFret( ); // - void SetTabString(std::string tabString_) { m_tabString = tabString_; }; - std::string GetTabString() const { return m_tabString; }; + void SetTabString(data_STRINGNUMBER tabString_) { m_tabString = tabString_; }; + data_STRINGNUMBER GetTabString() const { return m_tabString; }; bool HasTabString( ); ///@} private: /** Records the fret at which a string should be stopped. **/ - std::string m_tabFret; + data_FRETNUMBER m_tabFret; /** Records which string is to be played. **/ - std::string m_tabString; + data_STRINGNUMBER m_tabString; /* include */ }; diff --git a/libmei/atts_usersymbols.cpp b/libmei/atts_usersymbols.cpp index 3ab259d1adb..912861a604a 100644 --- a/libmei/atts_usersymbols.cpp +++ b/libmei/atts_usersymbols.cpp @@ -42,7 +42,7 @@ void AttAltsym::ResetAltsym() { m_altsym = ""; } -bool AttAltsym::ReadAltsym( pugi::xml_node element ) { +bool AttAltsym::ReadAltsym( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("altsym")) { this->SetAltsym(StrToStr(element.attribute("altsym").value())); @@ -52,7 +52,7 @@ bool AttAltsym::ReadAltsym( pugi::xml_node element ) { return hasAttribute; } -bool AttAltsym::WriteAltsym( pugi::xml_node element ) { +bool AttAltsym::WriteAltsym( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasAltsym()) { element.append_attribute("altsym") = StrToStr(this->GetAltsym()).c_str(); diff --git a/libmei/atts_usersymbols.h b/libmei/atts_usersymbols.h index ad2b56d568d..017861a4469 100644 --- a/libmei/atts_usersymbols.h +++ b/libmei/atts_usersymbols.h @@ -16,7 +16,7 @@ #define __VRV_ATTS_USERSYMBOLS_H__ #include "att.h" -#include "att_classes.h" +#include "attdef.h" #include "pugixml.hpp" //---------------------------------------------------------------------------- diff --git a/libmei/att_classes.h b/libmei/libmei_classes.h similarity index 100% rename from libmei/att_classes.h rename to libmei/libmei_classes.h diff --git a/libmei/libmei_converter.cpp b/libmei/libmei_converter.cpp new file mode 100644 index 00000000000..c2448a7327e --- /dev/null +++ b/libmei/libmei_converter.cpp @@ -0,0 +1,3063 @@ +///////////////////////////////////////////////////////////////////////////// +// Authors: Laurent Pugin and Rodolfo Zitellini +// Created: 2014 +// Copyright (c) Authors and others. All rights reserved. +// +// Code generated using a modified version of libmei +// by Andrew Hankinson, Alastair Porter, and Others +///////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////// +// NOTE: this file was generated with the Verovio libmei version and +// should not be edited because changes will be lost. +///////////////////////////////////////////////////////////////////////////// + +#include "libmei_converter.h" + +//---------------------------------------------------------------------------- + +#include + +//---------------------------------------------------------------------------- + +#include "vrv.h" + +namespace vrv { + +//---------------------------------------------------------------------------- +// LibmeiConverter +//---------------------------------------------------------------------------- + +std::string LibmeiConverter::AccidentalExplicitToStr(data_ACCIDENTAL_EXPLICIT data) +{ + std::string value; + switch(data) + { + case ACCIDENTAL_EXPLICIT_s : value = "s"; break; + case ACCIDENTAL_EXPLICIT_f : value = "f"; break; + case ACCIDENTAL_EXPLICIT_ss : value = "ss"; break; + case ACCIDENTAL_EXPLICIT_x : value = "x"; break; + case ACCIDENTAL_EXPLICIT_ff : value = "ff"; break; + case ACCIDENTAL_EXPLICIT_xs : value = "xs"; break; + case ACCIDENTAL_EXPLICIT_ts : value = "ts"; break; + case ACCIDENTAL_EXPLICIT_tf : value = "tf"; break; + case ACCIDENTAL_EXPLICIT_n : value = "n"; break; + case ACCIDENTAL_EXPLICIT_nf : value = "nf"; break; + case ACCIDENTAL_EXPLICIT_ns : value = "ns"; break; + case ACCIDENTAL_EXPLICIT_su : value = "su"; break; + case ACCIDENTAL_EXPLICIT_sd : value = "sd"; break; + case ACCIDENTAL_EXPLICIT_fu : value = "fu"; break; + case ACCIDENTAL_EXPLICIT_fd : value = "fd"; break; + case ACCIDENTAL_EXPLICIT_nu : value = "nu"; break; + case ACCIDENTAL_EXPLICIT_nd : value = "nd"; break; + case ACCIDENTAL_EXPLICIT_1qf : value = "1qf"; break; + case ACCIDENTAL_EXPLICIT_3qf : value = "3qf"; break; + case ACCIDENTAL_EXPLICIT_1qs : value = "1qs"; break; + case ACCIDENTAL_EXPLICIT_3qs : value = "3qs"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_ACCIDENTAL_EXPLICIT LibmeiConverter::StrToAccidentalExplicit(std::string value) +{ + + if (value == "s") return ACCIDENTAL_EXPLICIT_s; + if (value == "f") return ACCIDENTAL_EXPLICIT_f; + if (value == "ss") return ACCIDENTAL_EXPLICIT_ss; + if (value == "x") return ACCIDENTAL_EXPLICIT_x; + if (value == "ff") return ACCIDENTAL_EXPLICIT_ff; + if (value == "xs") return ACCIDENTAL_EXPLICIT_xs; + if (value == "ts") return ACCIDENTAL_EXPLICIT_ts; + if (value == "tf") return ACCIDENTAL_EXPLICIT_tf; + if (value == "n") return ACCIDENTAL_EXPLICIT_n; + if (value == "nf") return ACCIDENTAL_EXPLICIT_nf; + if (value == "ns") return ACCIDENTAL_EXPLICIT_ns; + if (value == "su") return ACCIDENTAL_EXPLICIT_su; + if (value == "sd") return ACCIDENTAL_EXPLICIT_sd; + if (value == "fu") return ACCIDENTAL_EXPLICIT_fu; + if (value == "fd") return ACCIDENTAL_EXPLICIT_fd; + if (value == "nu") return ACCIDENTAL_EXPLICIT_nu; + if (value == "nd") return ACCIDENTAL_EXPLICIT_nd; + if (value == "1qf") return ACCIDENTAL_EXPLICIT_1qf; + if (value == "3qf") return ACCIDENTAL_EXPLICIT_3qf; + if (value == "1qs") return ACCIDENTAL_EXPLICIT_1qs; + if (value == "3qs") return ACCIDENTAL_EXPLICIT_3qs; + LogWarning("Unsupported value '%s'", value.c_str() ); + return ACCIDENTAL_EXPLICIT_NONE; +} + +std::string LibmeiConverter::AccidentalImplicitToStr(data_ACCIDENTAL_IMPLICIT data) +{ + std::string value; + switch(data) + { + case ACCIDENTAL_IMPLICIT_s : value = "s"; break; + case ACCIDENTAL_IMPLICIT_f : value = "f"; break; + case ACCIDENTAL_IMPLICIT_ss : value = "ss"; break; + case ACCIDENTAL_IMPLICIT_ff : value = "ff"; break; + case ACCIDENTAL_IMPLICIT_n : value = "n"; break; + case ACCIDENTAL_IMPLICIT_su : value = "su"; break; + case ACCIDENTAL_IMPLICIT_sd : value = "sd"; break; + case ACCIDENTAL_IMPLICIT_fu : value = "fu"; break; + case ACCIDENTAL_IMPLICIT_fd : value = "fd"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_ACCIDENTAL_IMPLICIT LibmeiConverter::StrToAccidentalImplicit(std::string value) +{ + + if (value == "s") return ACCIDENTAL_IMPLICIT_s; + if (value == "f") return ACCIDENTAL_IMPLICIT_f; + if (value == "ss") return ACCIDENTAL_IMPLICIT_ss; + if (value == "ff") return ACCIDENTAL_IMPLICIT_ff; + if (value == "n") return ACCIDENTAL_IMPLICIT_n; + if (value == "su") return ACCIDENTAL_IMPLICIT_su; + if (value == "sd") return ACCIDENTAL_IMPLICIT_sd; + if (value == "fu") return ACCIDENTAL_IMPLICIT_fu; + if (value == "fd") return ACCIDENTAL_IMPLICIT_fd; + LogWarning("Unsupported value '%s'", value.c_str() ); + return ACCIDENTAL_IMPLICIT_NONE; +} + +std::string LibmeiConverter::ArticulationToStr(data_ARTICULATION data) +{ + std::string value; + switch(data) + { + case ARTICULATION_acc : value = "acc"; break; + case ARTICULATION_stacc : value = "stacc"; break; + case ARTICULATION_ten : value = "ten"; break; + case ARTICULATION_stacciss : value = "stacciss"; break; + case ARTICULATION_marc : value = "marc"; break; + case ARTICULATION_marc_stacc : value = "marc-stacc"; break; + case ARTICULATION_spicc : value = "spicc"; break; + case ARTICULATION_doit : value = "doit"; break; + case ARTICULATION_scoop : value = "scoop"; break; + case ARTICULATION_rip : value = "rip"; break; + case ARTICULATION_plop : value = "plop"; break; + case ARTICULATION_fall : value = "fall"; break; + case ARTICULATION_longfall : value = "longfall"; break; + case ARTICULATION_bend : value = "bend"; break; + case ARTICULATION_flip : value = "flip"; break; + case ARTICULATION_smear : value = "smear"; break; + case ARTICULATION_shake : value = "shake"; break; + case ARTICULATION_dnbow : value = "dnbow"; break; + case ARTICULATION_upbow : value = "upbow"; break; + case ARTICULATION_harm : value = "harm"; break; + case ARTICULATION_snap : value = "snap"; break; + case ARTICULATION_fingernail : value = "fingernail"; break; + case ARTICULATION_ten_stacc : value = "ten-stacc"; break; + case ARTICULATION_damp : value = "damp"; break; + case ARTICULATION_dampall : value = "dampall"; break; + case ARTICULATION_open : value = "open"; break; + case ARTICULATION_stop : value = "stop"; break; + case ARTICULATION_dbltongue : value = "dbltongue"; break; + case ARTICULATION_trpltongue : value = "trpltongue"; break; + case ARTICULATION_heel : value = "heel"; break; + case ARTICULATION_toe : value = "toe"; break; + case ARTICULATION_tap : value = "tap"; break; + case ARTICULATION_lhpizz : value = "lhpizz"; break; + case ARTICULATION_dot : value = "dot"; break; + case ARTICULATION_stroke : value = "stroke"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_ARTICULATION LibmeiConverter::StrToArticulation(std::string value) +{ + + if (value == "acc") return ARTICULATION_acc; + if (value == "stacc") return ARTICULATION_stacc; + if (value == "ten") return ARTICULATION_ten; + if (value == "stacciss") return ARTICULATION_stacciss; + if (value == "marc") return ARTICULATION_marc; + if (value == "marc-stacc") return ARTICULATION_marc_stacc; + if (value == "spicc") return ARTICULATION_spicc; + if (value == "doit") return ARTICULATION_doit; + if (value == "scoop") return ARTICULATION_scoop; + if (value == "rip") return ARTICULATION_rip; + if (value == "plop") return ARTICULATION_plop; + if (value == "fall") return ARTICULATION_fall; + if (value == "longfall") return ARTICULATION_longfall; + if (value == "bend") return ARTICULATION_bend; + if (value == "flip") return ARTICULATION_flip; + if (value == "smear") return ARTICULATION_smear; + if (value == "shake") return ARTICULATION_shake; + if (value == "dnbow") return ARTICULATION_dnbow; + if (value == "upbow") return ARTICULATION_upbow; + if (value == "harm") return ARTICULATION_harm; + if (value == "snap") return ARTICULATION_snap; + if (value == "fingernail") return ARTICULATION_fingernail; + if (value == "ten-stacc") return ARTICULATION_ten_stacc; + if (value == "damp") return ARTICULATION_damp; + if (value == "dampall") return ARTICULATION_dampall; + if (value == "open") return ARTICULATION_open; + if (value == "stop") return ARTICULATION_stop; + if (value == "dbltongue") return ARTICULATION_dbltongue; + if (value == "trpltongue") return ARTICULATION_trpltongue; + if (value == "heel") return ARTICULATION_heel; + if (value == "toe") return ARTICULATION_toe; + if (value == "tap") return ARTICULATION_tap; + if (value == "lhpizz") return ARTICULATION_lhpizz; + if (value == "dot") return ARTICULATION_dot; + if (value == "stroke") return ARTICULATION_stroke; + LogWarning("Unsupported value '%s'", value.c_str() ); + return ARTICULATION_NONE; +} + +std::string LibmeiConverter::BarplaceToStr(data_BARPLACE data) +{ + std::string value; + switch(data) + { + case BARPLACE_mensur : value = "mensur"; break; + case BARPLACE_staff : value = "staff"; break; + case BARPLACE_takt : value = "takt"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_BARPLACE LibmeiConverter::StrToBarplace(std::string value) +{ + + if (value == "mensur") return BARPLACE_mensur; + if (value == "staff") return BARPLACE_staff; + if (value == "takt") return BARPLACE_takt; + LogWarning("Unsupported value '%s'", value.c_str() ); + return BARPLACE_NONE; +} + +std::string LibmeiConverter::BarrenditionToStr(data_BARRENDITION data) +{ + std::string value; + switch(data) + { + case BARRENDITION_dashed : value = "dashed"; break; + case BARRENDITION_dotted : value = "dotted"; break; + case BARRENDITION_dbl : value = "dbl"; break; + case BARRENDITION_dbldashed : value = "dbldashed"; break; + case BARRENDITION_dbldotted : value = "dbldotted"; break; + case BARRENDITION_end : value = "end"; break; + case BARRENDITION_invis : value = "invis"; break; + case BARRENDITION_rptstart : value = "rptstart"; break; + case BARRENDITION_rptboth : value = "rptboth"; break; + case BARRENDITION_rptend : value = "rptend"; break; + case BARRENDITION_single : value = "single"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_BARRENDITION LibmeiConverter::StrToBarrendition(std::string value) +{ + + if (value == "dashed") return BARRENDITION_dashed; + if (value == "dotted") return BARRENDITION_dotted; + if (value == "dbl") return BARRENDITION_dbl; + if (value == "dbldashed") return BARRENDITION_dbldashed; + if (value == "dbldotted") return BARRENDITION_dbldotted; + if (value == "end") return BARRENDITION_end; + if (value == "invis") return BARRENDITION_invis; + if (value == "rptstart") return BARRENDITION_rptstart; + if (value == "rptboth") return BARRENDITION_rptboth; + if (value == "rptend") return BARRENDITION_rptend; + if (value == "single") return BARRENDITION_single; + LogWarning("Unsupported value '%s'", value.c_str() ); + return BARRENDITION_NONE; +} + +std::string LibmeiConverter::BetypeToStr(data_BETYPE data) +{ + std::string value; + switch(data) + { + case BETYPE_byte : value = "byte"; break; + case BETYPE_smil : value = "smil"; break; + case BETYPE_midi : value = "midi"; break; + case BETYPE_mmc : value = "mmc"; break; + case BETYPE_mtc : value = "mtc"; break; + case BETYPE_smpte_25 : value = "smpte-25"; break; + case BETYPE_smpte_24 : value = "smpte-24"; break; + case BETYPE_smpte_df30 : value = "smpte-df30"; break; + case BETYPE_smpte_ndf30 : value = "smpte-ndf30"; break; + case BETYPE_smpte_df29_97 : value = "smpte-df29.97"; break; + case BETYPE_smpte_ndf29_97 : value = "smpte-ndf29.97"; break; + case BETYPE_tcf : value = "tcf"; break; + case BETYPE_time : value = "time"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_BETYPE LibmeiConverter::StrToBetype(std::string value) +{ + + if (value == "byte") return BETYPE_byte; + if (value == "smil") return BETYPE_smil; + if (value == "midi") return BETYPE_midi; + if (value == "mmc") return BETYPE_mmc; + if (value == "mtc") return BETYPE_mtc; + if (value == "smpte-25") return BETYPE_smpte_25; + if (value == "smpte-24") return BETYPE_smpte_24; + if (value == "smpte-df30") return BETYPE_smpte_df30; + if (value == "smpte-ndf30") return BETYPE_smpte_ndf30; + if (value == "smpte-df29.97") return BETYPE_smpte_df29_97; + if (value == "smpte-ndf29.97") return BETYPE_smpte_ndf29_97; + if (value == "tcf") return BETYPE_tcf; + if (value == "time") return BETYPE_time; + LogWarning("Unsupported value '%s'", value.c_str() ); + return BETYPE_NONE; +} + +std::string LibmeiConverter::BooleanToStr(data_BOOLEAN data) +{ + std::string value; + switch(data) + { + case BOOLEAN_true : value = "true"; break; + case BOOLEAN_false : value = "false"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_BOOLEAN LibmeiConverter::StrToBoolean(std::string value) +{ + + if (value == "true") return BOOLEAN_true; + if (value == "false") return BOOLEAN_false; + LogWarning("Unsupported value '%s'", value.c_str() ); + return BOOLEAN_NONE; +} + +std::string LibmeiConverter::CertaintyToStr(data_CERTAINTY data) +{ + std::string value; + switch(data) + { + case CERTAINTY_high : value = "high"; break; + case CERTAINTY_medium : value = "medium"; break; + case CERTAINTY_low : value = "low"; break; + case CERTAINTY_unknown : value = "unknown"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_CERTAINTY LibmeiConverter::StrToCertainty(std::string value) +{ + + if (value == "high") return CERTAINTY_high; + if (value == "medium") return CERTAINTY_medium; + if (value == "low") return CERTAINTY_low; + if (value == "unknown") return CERTAINTY_unknown; + LogWarning("Unsupported value '%s'", value.c_str() ); + return CERTAINTY_NONE; +} + +std::string LibmeiConverter::ClefshapeToStr(data_CLEFSHAPE data) +{ + std::string value; + switch(data) + { + case CLEFSHAPE_G : value = "G"; break; + case CLEFSHAPE_GG : value = "GG"; break; + case CLEFSHAPE_F : value = "F"; break; + case CLEFSHAPE_C : value = "C"; break; + case CLEFSHAPE_perc : value = "perc"; break; + case CLEFSHAPE_TAB : value = "TAB"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_CLEFSHAPE LibmeiConverter::StrToClefshape(std::string value) +{ + + if (value == "G") return CLEFSHAPE_G; + if (value == "GG") return CLEFSHAPE_GG; + if (value == "F") return CLEFSHAPE_F; + if (value == "C") return CLEFSHAPE_C; + if (value == "perc") return CLEFSHAPE_perc; + if (value == "TAB") return CLEFSHAPE_TAB; + LogWarning("Unsupported value '%s'", value.c_str() ); + return CLEFSHAPE_NONE; +} + +std::string LibmeiConverter::ClusterToStr(data_CLUSTER data) +{ + std::string value; + switch(data) + { + case CLUSTER_white : value = "white"; break; + case CLUSTER_black : value = "black"; break; + case CLUSTER_chromatic : value = "chromatic"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_CLUSTER LibmeiConverter::StrToCluster(std::string value) +{ + + if (value == "white") return CLUSTER_white; + if (value == "black") return CLUSTER_black; + if (value == "chromatic") return CLUSTER_chromatic; + LogWarning("Unsupported value '%s'", value.c_str() ); + return CLUSTER_NONE; +} + +std::string LibmeiConverter::ColornamesToStr(data_COLORNAMES data) +{ + std::string value; + switch(data) + { + case COLORNAMES_aqua : value = "aqua"; break; + case COLORNAMES_black : value = "black"; break; + case COLORNAMES_blue : value = "blue"; break; + case COLORNAMES_fuchsia : value = "fuchsia"; break; + case COLORNAMES_gray : value = "gray"; break; + case COLORNAMES_green : value = "green"; break; + case COLORNAMES_lime : value = "lime"; break; + case COLORNAMES_maroon : value = "maroon"; break; + case COLORNAMES_navy : value = "navy"; break; + case COLORNAMES_olive : value = "olive"; break; + case COLORNAMES_purple : value = "purple"; break; + case COLORNAMES_red : value = "red"; break; + case COLORNAMES_silver : value = "silver"; break; + case COLORNAMES_teal : value = "teal"; break; + case COLORNAMES_white : value = "white"; break; + case COLORNAMES_yellow : value = "yellow"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_COLORNAMES LibmeiConverter::StrToColornames(std::string value) +{ + + if (value == "aqua") return COLORNAMES_aqua; + if (value == "black") return COLORNAMES_black; + if (value == "blue") return COLORNAMES_blue; + if (value == "fuchsia") return COLORNAMES_fuchsia; + if (value == "gray") return COLORNAMES_gray; + if (value == "green") return COLORNAMES_green; + if (value == "lime") return COLORNAMES_lime; + if (value == "maroon") return COLORNAMES_maroon; + if (value == "navy") return COLORNAMES_navy; + if (value == "olive") return COLORNAMES_olive; + if (value == "purple") return COLORNAMES_purple; + if (value == "red") return COLORNAMES_red; + if (value == "silver") return COLORNAMES_silver; + if (value == "teal") return COLORNAMES_teal; + if (value == "white") return COLORNAMES_white; + if (value == "yellow") return COLORNAMES_yellow; + LogWarning("Unsupported value '%s'", value.c_str() ); + return COLORNAMES_NONE; +} + +std::string LibmeiConverter::CurverenditionToStr(data_CURVERENDITION data) +{ + std::string value; + switch(data) + { + case CURVERENDITION_narrow : value = "narrow"; break; + case CURVERENDITION_medium : value = "medium"; break; + case CURVERENDITION_wide : value = "wide"; break; + case CURVERENDITION_dashed : value = "dashed"; break; + case CURVERENDITION_dotted : value = "dotted"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_CURVERENDITION LibmeiConverter::StrToCurverendition(std::string value) +{ + + if (value == "narrow") return CURVERENDITION_narrow; + if (value == "medium") return CURVERENDITION_medium; + if (value == "wide") return CURVERENDITION_wide; + if (value == "dashed") return CURVERENDITION_dashed; + if (value == "dotted") return CURVERENDITION_dotted; + LogWarning("Unsupported value '%s'", value.c_str() ); + return CURVERENDITION_NONE; +} + +std::string LibmeiConverter::EnclosureToStr(data_ENCLOSURE data) +{ + std::string value; + switch(data) + { + case ENCLOSURE_paren : value = "paren"; break; + case ENCLOSURE_brack : value = "brack"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_ENCLOSURE LibmeiConverter::StrToEnclosure(std::string value) +{ + + if (value == "paren") return ENCLOSURE_paren; + if (value == "brack") return ENCLOSURE_brack; + LogWarning("Unsupported value '%s'", value.c_str() ); + return ENCLOSURE_NONE; +} + +std::string LibmeiConverter::FontstyleToStr(data_FONTSTYLE data) +{ + std::string value; + switch(data) + { + case FONTSTYLE_italic : value = "italic"; break; + case FONTSTYLE_normal : value = "normal"; break; + case FONTSTYLE_oblique : value = "oblique"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_FONTSTYLE LibmeiConverter::StrToFontstyle(std::string value) +{ + + if (value == "italic") return FONTSTYLE_italic; + if (value == "normal") return FONTSTYLE_normal; + if (value == "oblique") return FONTSTYLE_oblique; + LogWarning("Unsupported value '%s'", value.c_str() ); + return FONTSTYLE_NONE; +} + +std::string LibmeiConverter::FontweightToStr(data_FONTWEIGHT data) +{ + std::string value; + switch(data) + { + case FONTWEIGHT_bold : value = "bold"; break; + case FONTWEIGHT_normal : value = "normal"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_FONTWEIGHT LibmeiConverter::StrToFontweight(std::string value) +{ + + if (value == "bold") return FONTWEIGHT_bold; + if (value == "normal") return FONTWEIGHT_normal; + LogWarning("Unsupported value '%s'", value.c_str() ); + return FONTWEIGHT_NONE; +} + +std::string LibmeiConverter::GlissandoToStr(data_GLISSANDO data) +{ + std::string value; + switch(data) + { + case GLISSANDO_i : value = "i"; break; + case GLISSANDO_m : value = "m"; break; + case GLISSANDO_t : value = "t"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_GLISSANDO LibmeiConverter::StrToGlissando(std::string value) +{ + + if (value == "i") return GLISSANDO_i; + if (value == "m") return GLISSANDO_m; + if (value == "t") return GLISSANDO_t; + LogWarning("Unsupported value '%s'", value.c_str() ); + return GLISSANDO_NONE; +} + +std::string LibmeiConverter::GraceToStr(data_GRACE data) +{ + std::string value; + switch(data) + { + case GRACE_acc : value = "acc"; break; + case GRACE_unacc : value = "unacc"; break; + case GRACE_unknown : value = "unknown"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_GRACE LibmeiConverter::StrToGrace(std::string value) +{ + + if (value == "acc") return GRACE_acc; + if (value == "unacc") return GRACE_unacc; + if (value == "unknown") return GRACE_unknown; + LogWarning("Unsupported value '%s'", value.c_str() ); + return GRACE_NONE; +} + +std::string LibmeiConverter::HorizontalalignmentToStr(data_HORIZONTALALIGNMENT data) +{ + std::string value; + switch(data) + { + case HORIZONTALALIGNMENT_left : value = "left"; break; + case HORIZONTALALIGNMENT_right : value = "right"; break; + case HORIZONTALALIGNMENT_center : value = "center"; break; + case HORIZONTALALIGNMENT_justify : value = "justify"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_HORIZONTALALIGNMENT LibmeiConverter::StrToHorizontalalignment(std::string value) +{ + + if (value == "left") return HORIZONTALALIGNMENT_left; + if (value == "right") return HORIZONTALALIGNMENT_right; + if (value == "center") return HORIZONTALALIGNMENT_center; + if (value == "justify") return HORIZONTALALIGNMENT_justify; + LogWarning("Unsupported value '%s'", value.c_str() ); + return HORIZONTALALIGNMENT_NONE; +} + +std::string LibmeiConverter::IneumeformToStr(data_INEUMEFORM data) +{ + std::string value; + switch(data) + { + case INEUMEFORM_liquescent1 : value = "liquescent1"; break; + case INEUMEFORM_liquescent2 : value = "liquescent2"; break; + case INEUMEFORM_tied : value = "tied"; break; + case INEUMEFORM_tiedliquescent1 : value = "tiedliquescent1"; break; + case INEUMEFORM_tiedliquescent2 : value = "tiedliquescent2"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_INEUMEFORM LibmeiConverter::StrToIneumeform(std::string value) +{ + + if (value == "liquescent1") return INEUMEFORM_liquescent1; + if (value == "liquescent2") return INEUMEFORM_liquescent2; + if (value == "tied") return INEUMEFORM_tied; + if (value == "tiedliquescent1") return INEUMEFORM_tiedliquescent1; + if (value == "tiedliquescent2") return INEUMEFORM_tiedliquescent2; + LogWarning("Unsupported value '%s'", value.c_str() ); + return INEUMEFORM_NONE; +} + +std::string LibmeiConverter::IneumenameToStr(data_INEUMENAME data) +{ + std::string value; + switch(data) + { + case INEUMENAME_pessubpunctis : value = "pessubpunctis"; break; + case INEUMENAME_climacus : value = "climacus"; break; + case INEUMENAME_scandicus : value = "scandicus"; break; + case INEUMENAME_bistropha : value = "bistropha"; break; + case INEUMENAME_tristropha : value = "tristropha"; break; + case INEUMENAME_pressusminor : value = "pressusminor"; break; + case INEUMENAME_pressusmaior : value = "pressusmaior"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_INEUMENAME LibmeiConverter::StrToIneumename(std::string value) +{ + + if (value == "pessubpunctis") return INEUMENAME_pessubpunctis; + if (value == "climacus") return INEUMENAME_climacus; + if (value == "scandicus") return INEUMENAME_scandicus; + if (value == "bistropha") return INEUMENAME_bistropha; + if (value == "tristropha") return INEUMENAME_tristropha; + if (value == "pressusminor") return INEUMENAME_pressusminor; + if (value == "pressusmaior") return INEUMENAME_pressusmaior; + LogWarning("Unsupported value '%s'", value.c_str() ); + return INEUMENAME_NONE; +} + +std::string LibmeiConverter::LayerschemeToStr(data_LAYERSCHEME data) +{ + std::string value; + switch(data) + { + case LAYERSCHEME_1 : value = "1"; break; + case LAYERSCHEME_2o : value = "2o"; break; + case LAYERSCHEME_2f : value = "2f"; break; + case LAYERSCHEME_3o : value = "3o"; break; + case LAYERSCHEME_3f : value = "3f"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_LAYERSCHEME LibmeiConverter::StrToLayerscheme(std::string value) +{ + + if (value == "1") return LAYERSCHEME_1; + if (value == "2o") return LAYERSCHEME_2o; + if (value == "2f") return LAYERSCHEME_2f; + if (value == "3o") return LAYERSCHEME_3o; + if (value == "3f") return LAYERSCHEME_3f; + LogWarning("Unsupported value '%s'", value.c_str() ); + return LAYERSCHEME_NONE; +} + +std::string LibmeiConverter::LigatureformToStr(data_LIGATUREFORM data) +{ + std::string value; + switch(data) + { + case LIGATUREFORM_recta : value = "recta"; break; + case LIGATUREFORM_obliqua : value = "obliqua"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_LIGATUREFORM LibmeiConverter::StrToLigatureform(std::string value) +{ + + if (value == "recta") return LIGATUREFORM_recta; + if (value == "obliqua") return LIGATUREFORM_obliqua; + LogWarning("Unsupported value '%s'", value.c_str() ); + return LIGATUREFORM_NONE; +} + +std::string LibmeiConverter::LineformToStr(data_LINEFORM data) +{ + std::string value; + switch(data) + { + case LINEFORM_dashed : value = "dashed"; break; + case LINEFORM_dotted : value = "dotted"; break; + case LINEFORM_solid : value = "solid"; break; + case LINEFORM_wavy : value = "wavy"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_LINEFORM LibmeiConverter::StrToLineform(std::string value) +{ + + if (value == "dashed") return LINEFORM_dashed; + if (value == "dotted") return LINEFORM_dotted; + if (value == "solid") return LINEFORM_solid; + if (value == "wavy") return LINEFORM_wavy; + LogWarning("Unsupported value '%s'", value.c_str() ); + return LINEFORM_NONE; +} + +std::string LibmeiConverter::LinestartendsymbolToStr(data_LINESTARTENDSYMBOL data) +{ + std::string value; + switch(data) + { + case LINESTARTENDSYMBOL_angledown : value = "angledown"; break; + case LINESTARTENDSYMBOL_angleup : value = "angleup"; break; + case LINESTARTENDSYMBOL_angleright : value = "angleright"; break; + case LINESTARTENDSYMBOL_angleleft : value = "angleleft"; break; + case LINESTARTENDSYMBOL_arrow : value = "arrow"; break; + case LINESTARTENDSYMBOL_arrowopen : value = "arrowopen"; break; + case LINESTARTENDSYMBOL_arrowwhite : value = "arrowwhite"; break; + case LINESTARTENDSYMBOL_harpoonleft : value = "harpoonleft"; break; + case LINESTARTENDSYMBOL_harpoonright : value = "harpoonright"; break; + case LINESTARTENDSYMBOL_none : value = "none"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_LINESTARTENDSYMBOL LibmeiConverter::StrToLinestartendsymbol(std::string value) +{ + + if (value == "angledown") return LINESTARTENDSYMBOL_angledown; + if (value == "angleup") return LINESTARTENDSYMBOL_angleup; + if (value == "angleright") return LINESTARTENDSYMBOL_angleright; + if (value == "angleleft") return LINESTARTENDSYMBOL_angleleft; + if (value == "arrow") return LINESTARTENDSYMBOL_arrow; + if (value == "arrowopen") return LINESTARTENDSYMBOL_arrowopen; + if (value == "arrowwhite") return LINESTARTENDSYMBOL_arrowwhite; + if (value == "harpoonleft") return LINESTARTENDSYMBOL_harpoonleft; + if (value == "harpoonright") return LINESTARTENDSYMBOL_harpoonright; + if (value == "none") return LINESTARTENDSYMBOL_none; + LogWarning("Unsupported value '%s'", value.c_str() ); + return LINESTARTENDSYMBOL_NONE; +} + +std::string LibmeiConverter::LinewidthtermToStr(data_LINEWIDTHTERM data) +{ + std::string value; + switch(data) + { + case LINEWIDTHTERM_narrow : value = "narrow"; break; + case LINEWIDTHTERM_medium : value = "medium"; break; + case LINEWIDTHTERM_wide : value = "wide"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_LINEWIDTHTERM LibmeiConverter::StrToLinewidthterm(std::string value) +{ + + if (value == "narrow") return LINEWIDTHTERM_narrow; + if (value == "medium") return LINEWIDTHTERM_medium; + if (value == "wide") return LINEWIDTHTERM_wide; + LogWarning("Unsupported value '%s'", value.c_str() ); + return LINEWIDTHTERM_NONE; +} + +std::string LibmeiConverter::MelodicfunctionToStr(data_MELODICFUNCTION data) +{ + std::string value; + switch(data) + { + case MELODICFUNCTION_aln : value = "aln"; break; + case MELODICFUNCTION_ant : value = "ant"; break; + case MELODICFUNCTION_app : value = "app"; break; + case MELODICFUNCTION_apt : value = "apt"; break; + case MELODICFUNCTION_arp : value = "arp"; break; + case MELODICFUNCTION_arp7 : value = "arp7"; break; + case MELODICFUNCTION_aun : value = "aun"; break; + case MELODICFUNCTION_chg : value = "chg"; break; + case MELODICFUNCTION_cln : value = "cln"; break; + case MELODICFUNCTION_ct : value = "ct"; break; + case MELODICFUNCTION_ct7 : value = "ct7"; break; + case MELODICFUNCTION_cun : value = "cun"; break; + case MELODICFUNCTION_cup : value = "cup"; break; + case MELODICFUNCTION_et : value = "et"; break; + case MELODICFUNCTION_ln : value = "ln"; break; + case MELODICFUNCTION_ped : value = "ped"; break; + case MELODICFUNCTION_rep : value = "rep"; break; + case MELODICFUNCTION_ret : value = "ret"; break; + case MELODICFUNCTION_23ret : value = "23ret"; break; + case MELODICFUNCTION_78ret : value = "78ret"; break; + case MELODICFUNCTION_sus : value = "sus"; break; + case MELODICFUNCTION_43sus : value = "43sus"; break; + case MELODICFUNCTION_98sus : value = "98sus"; break; + case MELODICFUNCTION_76sus : value = "76sus"; break; + case MELODICFUNCTION_un : value = "un"; break; + case MELODICFUNCTION_un7 : value = "un7"; break; + case MELODICFUNCTION_upt : value = "upt"; break; + case MELODICFUNCTION_upt7 : value = "upt7"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_MELODICFUNCTION LibmeiConverter::StrToMelodicfunction(std::string value) +{ + + if (value == "aln") return MELODICFUNCTION_aln; + if (value == "ant") return MELODICFUNCTION_ant; + if (value == "app") return MELODICFUNCTION_app; + if (value == "apt") return MELODICFUNCTION_apt; + if (value == "arp") return MELODICFUNCTION_arp; + if (value == "arp7") return MELODICFUNCTION_arp7; + if (value == "aun") return MELODICFUNCTION_aun; + if (value == "chg") return MELODICFUNCTION_chg; + if (value == "cln") return MELODICFUNCTION_cln; + if (value == "ct") return MELODICFUNCTION_ct; + if (value == "ct7") return MELODICFUNCTION_ct7; + if (value == "cun") return MELODICFUNCTION_cun; + if (value == "cup") return MELODICFUNCTION_cup; + if (value == "et") return MELODICFUNCTION_et; + if (value == "ln") return MELODICFUNCTION_ln; + if (value == "ped") return MELODICFUNCTION_ped; + if (value == "rep") return MELODICFUNCTION_rep; + if (value == "ret") return MELODICFUNCTION_ret; + if (value == "23ret") return MELODICFUNCTION_23ret; + if (value == "78ret") return MELODICFUNCTION_78ret; + if (value == "sus") return MELODICFUNCTION_sus; + if (value == "43sus") return MELODICFUNCTION_43sus; + if (value == "98sus") return MELODICFUNCTION_98sus; + if (value == "76sus") return MELODICFUNCTION_76sus; + if (value == "un") return MELODICFUNCTION_un; + if (value == "un7") return MELODICFUNCTION_un7; + if (value == "upt") return MELODICFUNCTION_upt; + if (value == "upt7") return MELODICFUNCTION_upt7; + LogWarning("Unsupported value '%s'", value.c_str() ); + return MELODICFUNCTION_NONE; +} + +std::string LibmeiConverter::MensurationsignToStr(data_MENSURATIONSIGN data) +{ + std::string value; + switch(data) + { + case MENSURATIONSIGN_C : value = "C"; break; + case MENSURATIONSIGN_O : value = "O"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_MENSURATIONSIGN LibmeiConverter::StrToMensurationsign(std::string value) +{ + + if (value == "C") return MENSURATIONSIGN_C; + if (value == "O") return MENSURATIONSIGN_O; + LogWarning("Unsupported value '%s'", value.c_str() ); + return MENSURATIONSIGN_NONE; +} + +std::string LibmeiConverter::MetersignToStr(data_METERSIGN data) +{ + std::string value; + switch(data) + { + case METERSIGN_common : value = "common"; break; + case METERSIGN_cut : value = "cut"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_METERSIGN LibmeiConverter::StrToMetersign(std::string value) +{ + + if (value == "common") return METERSIGN_common; + if (value == "cut") return METERSIGN_cut; + LogWarning("Unsupported value '%s'", value.c_str() ); + return METERSIGN_NONE; +} + +std::string LibmeiConverter::MidinamesToStr(data_MIDINAMES data) +{ + std::string value; + switch(data) + { + case MIDINAMES_Acoustic_Grand_Piano : value = "Acoustic_Grand_Piano"; break; + case MIDINAMES_Bright_Acoustic_Piano : value = "Bright_Acoustic_Piano"; break; + case MIDINAMES_Electric_Grand_Piano : value = "Electric_Grand_Piano"; break; + case MIDINAMES_Honky_tonk_Piano : value = "Honky-tonk_Piano"; break; + case MIDINAMES_Electric_Piano_1 : value = "Electric_Piano_1"; break; + case MIDINAMES_Electric_Piano_2 : value = "Electric_Piano_2"; break; + case MIDINAMES_Harpsichord : value = "Harpsichord"; break; + case MIDINAMES_Clavi : value = "Clavi"; break; + case MIDINAMES_Celesta : value = "Celesta"; break; + case MIDINAMES_Glockenspiel : value = "Glockenspiel"; break; + case MIDINAMES_Music_Box : value = "Music_Box"; break; + case MIDINAMES_Vibraphone : value = "Vibraphone"; break; + case MIDINAMES_Marimba : value = "Marimba"; break; + case MIDINAMES_Xylophone : value = "Xylophone"; break; + case MIDINAMES_Tubular_Bells : value = "Tubular_Bells"; break; + case MIDINAMES_Dulcimer : value = "Dulcimer"; break; + case MIDINAMES_Drawbar_Organ : value = "Drawbar_Organ"; break; + case MIDINAMES_Percussive_Organ : value = "Percussive_Organ"; break; + case MIDINAMES_Rock_Organ : value = "Rock_Organ"; break; + case MIDINAMES_Church_Organ : value = "Church_Organ"; break; + case MIDINAMES_Reed_Organ : value = "Reed_Organ"; break; + case MIDINAMES_Accordion : value = "Accordion"; break; + case MIDINAMES_Harmonica : value = "Harmonica"; break; + case MIDINAMES_Tango_Accordion : value = "Tango_Accordion"; break; + case MIDINAMES_Acoustic_Guitar_nylon : value = "Acoustic_Guitar_nylon"; break; + case MIDINAMES_Acoustic_Guitar_steel : value = "Acoustic_Guitar_steel"; break; + case MIDINAMES_Electric_Guitar_jazz : value = "Electric_Guitar_jazz"; break; + case MIDINAMES_Electric_Guitar_clean : value = "Electric_Guitar_clean"; break; + case MIDINAMES_Electric_Guitar_muted : value = "Electric_Guitar_muted"; break; + case MIDINAMES_Overdriven_Guitar : value = "Overdriven_Guitar"; break; + case MIDINAMES_Distortion_Guitar : value = "Distortion_Guitar"; break; + case MIDINAMES_Guitar_harmonics : value = "Guitar_harmonics"; break; + case MIDINAMES_Acoustic_Bass : value = "Acoustic_Bass"; break; + case MIDINAMES_Electric_Bass_finger : value = "Electric_Bass_finger"; break; + case MIDINAMES_Electric_Bass_pick : value = "Electric_Bass_pick"; break; + case MIDINAMES_Fretless_Bass : value = "Fretless_Bass"; break; + case MIDINAMES_Slap_Bass_1 : value = "Slap_Bass_1"; break; + case MIDINAMES_Slap_Bass_2 : value = "Slap_Bass_2"; break; + case MIDINAMES_Synth_Bass_1 : value = "Synth_Bass_1"; break; + case MIDINAMES_Synth_Bass_2 : value = "Synth_Bass_2"; break; + case MIDINAMES_Violin : value = "Violin"; break; + case MIDINAMES_Viola : value = "Viola"; break; + case MIDINAMES_Cello : value = "Cello"; break; + case MIDINAMES_Contrabass : value = "Contrabass"; break; + case MIDINAMES_Tremolo_Strings : value = "Tremolo_Strings"; break; + case MIDINAMES_Pizzicato_Strings : value = "Pizzicato_Strings"; break; + case MIDINAMES_Orchestral_Harp : value = "Orchestral_Harp"; break; + case MIDINAMES_Timpani : value = "Timpani"; break; + case MIDINAMES_String_Ensemble_1 : value = "String_Ensemble_1"; break; + case MIDINAMES_String_Ensemble_2 : value = "String_Ensemble_2"; break; + case MIDINAMES_SynthStrings_1 : value = "SynthStrings_1"; break; + case MIDINAMES_SynthStrings_2 : value = "SynthStrings_2"; break; + case MIDINAMES_Choir_Aahs : value = "Choir_Aahs"; break; + case MIDINAMES_Voice_Oohs : value = "Voice_Oohs"; break; + case MIDINAMES_Synth_Voice : value = "Synth_Voice"; break; + case MIDINAMES_Orchestra_Hit : value = "Orchestra_Hit"; break; + case MIDINAMES_Trumpet : value = "Trumpet"; break; + case MIDINAMES_Trombone : value = "Trombone"; break; + case MIDINAMES_Tuba : value = "Tuba"; break; + case MIDINAMES_Muted_Trumpet : value = "Muted_Trumpet"; break; + case MIDINAMES_French_Horn : value = "French_Horn"; break; + case MIDINAMES_Brass_Section : value = "Brass_Section"; break; + case MIDINAMES_SynthBrass_1 : value = "SynthBrass_1"; break; + case MIDINAMES_SynthBrass_2 : value = "SynthBrass_2"; break; + case MIDINAMES_Soprano_Sax : value = "Soprano_Sax"; break; + case MIDINAMES_Alto_Sax : value = "Alto_Sax"; break; + case MIDINAMES_Tenor_Sax : value = "Tenor_Sax"; break; + case MIDINAMES_Baritone_Sax : value = "Baritone_Sax"; break; + case MIDINAMES_Oboe : value = "Oboe"; break; + case MIDINAMES_English_Horn : value = "English_Horn"; break; + case MIDINAMES_Bassoon : value = "Bassoon"; break; + case MIDINAMES_Clarinet : value = "Clarinet"; break; + case MIDINAMES_Piccolo : value = "Piccolo"; break; + case MIDINAMES_Flute : value = "Flute"; break; + case MIDINAMES_Recorder : value = "Recorder"; break; + case MIDINAMES_Pan_Flute : value = "Pan_Flute"; break; + case MIDINAMES_Blown_Bottle : value = "Blown_Bottle"; break; + case MIDINAMES_Shakuhachi : value = "Shakuhachi"; break; + case MIDINAMES_Whistle : value = "Whistle"; break; + case MIDINAMES_Ocarina : value = "Ocarina"; break; + case MIDINAMES_Lead_1_square : value = "Lead_1_square"; break; + case MIDINAMES_Lead_2_sawtooth : value = "Lead_2_sawtooth"; break; + case MIDINAMES_Lead_3_calliope : value = "Lead_3_calliope"; break; + case MIDINAMES_Lead_4_chiff : value = "Lead_4_chiff"; break; + case MIDINAMES_Lead_5_charang : value = "Lead_5_charang"; break; + case MIDINAMES_Lead_6_voice : value = "Lead_6_voice"; break; + case MIDINAMES_Lead_7_fifths : value = "Lead_7_fifths"; break; + case MIDINAMES_Lead_8_bass_and_lead : value = "Lead_8_bass_and_lead"; break; + case MIDINAMES_Pad_1_new_age : value = "Pad_1_new_age"; break; + case MIDINAMES_Pad_2_warm : value = "Pad_2_warm"; break; + case MIDINAMES_Pad_3_polysynth : value = "Pad_3_polysynth"; break; + case MIDINAMES_Pad_4_choir : value = "Pad_4_choir"; break; + case MIDINAMES_Pad_5_bowed : value = "Pad_5_bowed"; break; + case MIDINAMES_Pad_6_metallic : value = "Pad_6_metallic"; break; + case MIDINAMES_Pad_7_halo : value = "Pad_7_halo"; break; + case MIDINAMES_Pad_8_sweep : value = "Pad_8_sweep"; break; + case MIDINAMES_FX_1_rain : value = "FX_1_rain"; break; + case MIDINAMES_FX_2_soundtrack : value = "FX_2_soundtrack"; break; + case MIDINAMES_FX_3_crystal : value = "FX_3_crystal"; break; + case MIDINAMES_FX_4_atmosphere : value = "FX_4_atmosphere"; break; + case MIDINAMES_FX_5_brightness : value = "FX_5_brightness"; break; + case MIDINAMES_FX_6_goblins : value = "FX_6_goblins"; break; + case MIDINAMES_FX_7_echoes : value = "FX_7_echoes"; break; + case MIDINAMES_FX_8_sci_fi : value = "FX_8_sci-fi"; break; + case MIDINAMES_Sitar : value = "Sitar"; break; + case MIDINAMES_Banjo : value = "Banjo"; break; + case MIDINAMES_Shamisen : value = "Shamisen"; break; + case MIDINAMES_Koto : value = "Koto"; break; + case MIDINAMES_Kalimba : value = "Kalimba"; break; + case MIDINAMES_Bagpipe : value = "Bagpipe"; break; + case MIDINAMES_Fiddle : value = "Fiddle"; break; + case MIDINAMES_Shanai : value = "Shanai"; break; + case MIDINAMES_Tinkle_Bell : value = "Tinkle_Bell"; break; + case MIDINAMES_Agogo : value = "Agogo"; break; + case MIDINAMES_Steel_Drums : value = "Steel_Drums"; break; + case MIDINAMES_Woodblock : value = "Woodblock"; break; + case MIDINAMES_Taiko_Drum : value = "Taiko_Drum"; break; + case MIDINAMES_Melodic_Tom : value = "Melodic_Tom"; break; + case MIDINAMES_Synth_Drum : value = "Synth_Drum"; break; + case MIDINAMES_Reverse_Cymbal : value = "Reverse_Cymbal"; break; + case MIDINAMES_Guitar_Fret_Noise : value = "Guitar_Fret_Noise"; break; + case MIDINAMES_Breath_Noise : value = "Breath_Noise"; break; + case MIDINAMES_Seashore : value = "Seashore"; break; + case MIDINAMES_Bird_Tweet : value = "Bird_Tweet"; break; + case MIDINAMES_Telephone_Ring : value = "Telephone_Ring"; break; + case MIDINAMES_Helicopter : value = "Helicopter"; break; + case MIDINAMES_Applause : value = "Applause"; break; + case MIDINAMES_Gunshot : value = "Gunshot"; break; + case MIDINAMES_Acoustic_Bass_Drum : value = "Acoustic_Bass_Drum"; break; + case MIDINAMES_Bass_Drum_1 : value = "Bass_Drum_1"; break; + case MIDINAMES_Side_Stick : value = "Side_Stick"; break; + case MIDINAMES_Acoustic_Snare : value = "Acoustic_Snare"; break; + case MIDINAMES_Hand_Clap : value = "Hand_Clap"; break; + case MIDINAMES_Electric_Snare : value = "Electric_Snare"; break; + case MIDINAMES_Low_Floor_Tom : value = "Low_Floor_Tom"; break; + case MIDINAMES_Closed_Hi_Hat : value = "Closed_Hi_Hat"; break; + case MIDINAMES_High_Floor_Tom : value = "High_Floor_Tom"; break; + case MIDINAMES_Pedal_Hi_Hat : value = "Pedal_Hi-Hat"; break; + case MIDINAMES_Low_Tom : value = "Low_Tom"; break; + case MIDINAMES_Open_Hi_Hat : value = "Open_Hi-Hat"; break; + case MIDINAMES_Low_Mid_Tom : value = "Low-Mid_Tom"; break; + case MIDINAMES_Hi_Mid_Tom : value = "Hi-Mid_Tom"; break; + case MIDINAMES_Crash_Cymbal_1 : value = "Crash_Cymbal_1"; break; + case MIDINAMES_High_Tom : value = "High_Tom"; break; + case MIDINAMES_Ride_Cymbal_1 : value = "Ride_Cymbal_1"; break; + case MIDINAMES_Chinese_Cymbal : value = "Chinese_Cymbal"; break; + case MIDINAMES_Ride_Bell : value = "Ride_Bell"; break; + case MIDINAMES_Tambourine : value = "Tambourine"; break; + case MIDINAMES_Splash_Cymbal : value = "Splash_Cymbal"; break; + case MIDINAMES_Cowbell : value = "Cowbell"; break; + case MIDINAMES_Crash_Cymbal_2 : value = "Crash_Cymbal_2"; break; + case MIDINAMES_Vibraslap : value = "Vibraslap"; break; + case MIDINAMES_Ride_Cymbal_2 : value = "Ride_Cymbal_2"; break; + case MIDINAMES_Hi_Bongo : value = "Hi_Bongo"; break; + case MIDINAMES_Low_Bongo : value = "Low_Bongo"; break; + case MIDINAMES_Mute_Hi_Conga : value = "Mute_Hi_Conga"; break; + case MIDINAMES_Open_Hi_Conga : value = "Open_Hi_Conga"; break; + case MIDINAMES_Low_Conga : value = "Low_Conga"; break; + case MIDINAMES_High_Timbale : value = "High_Timbale"; break; + case MIDINAMES_Low_Timbale : value = "Low_Timbale"; break; + case MIDINAMES_High_Agogo : value = "High_Agogo"; break; + case MIDINAMES_Low_Agogo : value = "Low_Agogo"; break; + case MIDINAMES_Cabasa : value = "Cabasa"; break; + case MIDINAMES_Maracas : value = "Maracas"; break; + case MIDINAMES_Short_Whistle : value = "Short_Whistle"; break; + case MIDINAMES_Long_Whistle : value = "Long_Whistle"; break; + case MIDINAMES_Short_Guiro : value = "Short_Guiro"; break; + case MIDINAMES_Long_Guiro : value = "Long_Guiro"; break; + case MIDINAMES_Claves : value = "Claves"; break; + case MIDINAMES_Hi_Wood_Block : value = "Hi_Wood_Block"; break; + case MIDINAMES_Low_Wood_Block : value = "Low_Wood_Block"; break; + case MIDINAMES_Mute_Cuica : value = "Mute_Cuica"; break; + case MIDINAMES_Open_Cuica : value = "Open_Cuica"; break; + case MIDINAMES_Mute_Triangle : value = "Mute_Triangle"; break; + case MIDINAMES_Open_Triangle : value = "Open_Triangle"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_MIDINAMES LibmeiConverter::StrToMidinames(std::string value) +{ + + if (value == "Acoustic_Grand_Piano") return MIDINAMES_Acoustic_Grand_Piano; + if (value == "Bright_Acoustic_Piano") return MIDINAMES_Bright_Acoustic_Piano; + if (value == "Electric_Grand_Piano") return MIDINAMES_Electric_Grand_Piano; + if (value == "Honky-tonk_Piano") return MIDINAMES_Honky_tonk_Piano; + if (value == "Electric_Piano_1") return MIDINAMES_Electric_Piano_1; + if (value == "Electric_Piano_2") return MIDINAMES_Electric_Piano_2; + if (value == "Harpsichord") return MIDINAMES_Harpsichord; + if (value == "Clavi") return MIDINAMES_Clavi; + if (value == "Celesta") return MIDINAMES_Celesta; + if (value == "Glockenspiel") return MIDINAMES_Glockenspiel; + if (value == "Music_Box") return MIDINAMES_Music_Box; + if (value == "Vibraphone") return MIDINAMES_Vibraphone; + if (value == "Marimba") return MIDINAMES_Marimba; + if (value == "Xylophone") return MIDINAMES_Xylophone; + if (value == "Tubular_Bells") return MIDINAMES_Tubular_Bells; + if (value == "Dulcimer") return MIDINAMES_Dulcimer; + if (value == "Drawbar_Organ") return MIDINAMES_Drawbar_Organ; + if (value == "Percussive_Organ") return MIDINAMES_Percussive_Organ; + if (value == "Rock_Organ") return MIDINAMES_Rock_Organ; + if (value == "Church_Organ") return MIDINAMES_Church_Organ; + if (value == "Reed_Organ") return MIDINAMES_Reed_Organ; + if (value == "Accordion") return MIDINAMES_Accordion; + if (value == "Harmonica") return MIDINAMES_Harmonica; + if (value == "Tango_Accordion") return MIDINAMES_Tango_Accordion; + if (value == "Acoustic_Guitar_nylon") return MIDINAMES_Acoustic_Guitar_nylon; + if (value == "Acoustic_Guitar_steel") return MIDINAMES_Acoustic_Guitar_steel; + if (value == "Electric_Guitar_jazz") return MIDINAMES_Electric_Guitar_jazz; + if (value == "Electric_Guitar_clean") return MIDINAMES_Electric_Guitar_clean; + if (value == "Electric_Guitar_muted") return MIDINAMES_Electric_Guitar_muted; + if (value == "Overdriven_Guitar") return MIDINAMES_Overdriven_Guitar; + if (value == "Distortion_Guitar") return MIDINAMES_Distortion_Guitar; + if (value == "Guitar_harmonics") return MIDINAMES_Guitar_harmonics; + if (value == "Acoustic_Bass") return MIDINAMES_Acoustic_Bass; + if (value == "Electric_Bass_finger") return MIDINAMES_Electric_Bass_finger; + if (value == "Electric_Bass_pick") return MIDINAMES_Electric_Bass_pick; + if (value == "Fretless_Bass") return MIDINAMES_Fretless_Bass; + if (value == "Slap_Bass_1") return MIDINAMES_Slap_Bass_1; + if (value == "Slap_Bass_2") return MIDINAMES_Slap_Bass_2; + if (value == "Synth_Bass_1") return MIDINAMES_Synth_Bass_1; + if (value == "Synth_Bass_2") return MIDINAMES_Synth_Bass_2; + if (value == "Violin") return MIDINAMES_Violin; + if (value == "Viola") return MIDINAMES_Viola; + if (value == "Cello") return MIDINAMES_Cello; + if (value == "Contrabass") return MIDINAMES_Contrabass; + if (value == "Tremolo_Strings") return MIDINAMES_Tremolo_Strings; + if (value == "Pizzicato_Strings") return MIDINAMES_Pizzicato_Strings; + if (value == "Orchestral_Harp") return MIDINAMES_Orchestral_Harp; + if (value == "Timpani") return MIDINAMES_Timpani; + if (value == "String_Ensemble_1") return MIDINAMES_String_Ensemble_1; + if (value == "String_Ensemble_2") return MIDINAMES_String_Ensemble_2; + if (value == "SynthStrings_1") return MIDINAMES_SynthStrings_1; + if (value == "SynthStrings_2") return MIDINAMES_SynthStrings_2; + if (value == "Choir_Aahs") return MIDINAMES_Choir_Aahs; + if (value == "Voice_Oohs") return MIDINAMES_Voice_Oohs; + if (value == "Synth_Voice") return MIDINAMES_Synth_Voice; + if (value == "Orchestra_Hit") return MIDINAMES_Orchestra_Hit; + if (value == "Trumpet") return MIDINAMES_Trumpet; + if (value == "Trombone") return MIDINAMES_Trombone; + if (value == "Tuba") return MIDINAMES_Tuba; + if (value == "Muted_Trumpet") return MIDINAMES_Muted_Trumpet; + if (value == "French_Horn") return MIDINAMES_French_Horn; + if (value == "Brass_Section") return MIDINAMES_Brass_Section; + if (value == "SynthBrass_1") return MIDINAMES_SynthBrass_1; + if (value == "SynthBrass_2") return MIDINAMES_SynthBrass_2; + if (value == "Soprano_Sax") return MIDINAMES_Soprano_Sax; + if (value == "Alto_Sax") return MIDINAMES_Alto_Sax; + if (value == "Tenor_Sax") return MIDINAMES_Tenor_Sax; + if (value == "Baritone_Sax") return MIDINAMES_Baritone_Sax; + if (value == "Oboe") return MIDINAMES_Oboe; + if (value == "English_Horn") return MIDINAMES_English_Horn; + if (value == "Bassoon") return MIDINAMES_Bassoon; + if (value == "Clarinet") return MIDINAMES_Clarinet; + if (value == "Piccolo") return MIDINAMES_Piccolo; + if (value == "Flute") return MIDINAMES_Flute; + if (value == "Recorder") return MIDINAMES_Recorder; + if (value == "Pan_Flute") return MIDINAMES_Pan_Flute; + if (value == "Blown_Bottle") return MIDINAMES_Blown_Bottle; + if (value == "Shakuhachi") return MIDINAMES_Shakuhachi; + if (value == "Whistle") return MIDINAMES_Whistle; + if (value == "Ocarina") return MIDINAMES_Ocarina; + if (value == "Lead_1_square") return MIDINAMES_Lead_1_square; + if (value == "Lead_2_sawtooth") return MIDINAMES_Lead_2_sawtooth; + if (value == "Lead_3_calliope") return MIDINAMES_Lead_3_calliope; + if (value == "Lead_4_chiff") return MIDINAMES_Lead_4_chiff; + if (value == "Lead_5_charang") return MIDINAMES_Lead_5_charang; + if (value == "Lead_6_voice") return MIDINAMES_Lead_6_voice; + if (value == "Lead_7_fifths") return MIDINAMES_Lead_7_fifths; + if (value == "Lead_8_bass_and_lead") return MIDINAMES_Lead_8_bass_and_lead; + if (value == "Pad_1_new_age") return MIDINAMES_Pad_1_new_age; + if (value == "Pad_2_warm") return MIDINAMES_Pad_2_warm; + if (value == "Pad_3_polysynth") return MIDINAMES_Pad_3_polysynth; + if (value == "Pad_4_choir") return MIDINAMES_Pad_4_choir; + if (value == "Pad_5_bowed") return MIDINAMES_Pad_5_bowed; + if (value == "Pad_6_metallic") return MIDINAMES_Pad_6_metallic; + if (value == "Pad_7_halo") return MIDINAMES_Pad_7_halo; + if (value == "Pad_8_sweep") return MIDINAMES_Pad_8_sweep; + if (value == "FX_1_rain") return MIDINAMES_FX_1_rain; + if (value == "FX_2_soundtrack") return MIDINAMES_FX_2_soundtrack; + if (value == "FX_3_crystal") return MIDINAMES_FX_3_crystal; + if (value == "FX_4_atmosphere") return MIDINAMES_FX_4_atmosphere; + if (value == "FX_5_brightness") return MIDINAMES_FX_5_brightness; + if (value == "FX_6_goblins") return MIDINAMES_FX_6_goblins; + if (value == "FX_7_echoes") return MIDINAMES_FX_7_echoes; + if (value == "FX_8_sci-fi") return MIDINAMES_FX_8_sci_fi; + if (value == "Sitar") return MIDINAMES_Sitar; + if (value == "Banjo") return MIDINAMES_Banjo; + if (value == "Shamisen") return MIDINAMES_Shamisen; + if (value == "Koto") return MIDINAMES_Koto; + if (value == "Kalimba") return MIDINAMES_Kalimba; + if (value == "Bagpipe") return MIDINAMES_Bagpipe; + if (value == "Fiddle") return MIDINAMES_Fiddle; + if (value == "Shanai") return MIDINAMES_Shanai; + if (value == "Tinkle_Bell") return MIDINAMES_Tinkle_Bell; + if (value == "Agogo") return MIDINAMES_Agogo; + if (value == "Steel_Drums") return MIDINAMES_Steel_Drums; + if (value == "Woodblock") return MIDINAMES_Woodblock; + if (value == "Taiko_Drum") return MIDINAMES_Taiko_Drum; + if (value == "Melodic_Tom") return MIDINAMES_Melodic_Tom; + if (value == "Synth_Drum") return MIDINAMES_Synth_Drum; + if (value == "Reverse_Cymbal") return MIDINAMES_Reverse_Cymbal; + if (value == "Guitar_Fret_Noise") return MIDINAMES_Guitar_Fret_Noise; + if (value == "Breath_Noise") return MIDINAMES_Breath_Noise; + if (value == "Seashore") return MIDINAMES_Seashore; + if (value == "Bird_Tweet") return MIDINAMES_Bird_Tweet; + if (value == "Telephone_Ring") return MIDINAMES_Telephone_Ring; + if (value == "Helicopter") return MIDINAMES_Helicopter; + if (value == "Applause") return MIDINAMES_Applause; + if (value == "Gunshot") return MIDINAMES_Gunshot; + if (value == "Acoustic_Bass_Drum") return MIDINAMES_Acoustic_Bass_Drum; + if (value == "Bass_Drum_1") return MIDINAMES_Bass_Drum_1; + if (value == "Side_Stick") return MIDINAMES_Side_Stick; + if (value == "Acoustic_Snare") return MIDINAMES_Acoustic_Snare; + if (value == "Hand_Clap") return MIDINAMES_Hand_Clap; + if (value == "Electric_Snare") return MIDINAMES_Electric_Snare; + if (value == "Low_Floor_Tom") return MIDINAMES_Low_Floor_Tom; + if (value == "Closed_Hi_Hat") return MIDINAMES_Closed_Hi_Hat; + if (value == "High_Floor_Tom") return MIDINAMES_High_Floor_Tom; + if (value == "Pedal_Hi-Hat") return MIDINAMES_Pedal_Hi_Hat; + if (value == "Low_Tom") return MIDINAMES_Low_Tom; + if (value == "Open_Hi-Hat") return MIDINAMES_Open_Hi_Hat; + if (value == "Low-Mid_Tom") return MIDINAMES_Low_Mid_Tom; + if (value == "Hi-Mid_Tom") return MIDINAMES_Hi_Mid_Tom; + if (value == "Crash_Cymbal_1") return MIDINAMES_Crash_Cymbal_1; + if (value == "High_Tom") return MIDINAMES_High_Tom; + if (value == "Ride_Cymbal_1") return MIDINAMES_Ride_Cymbal_1; + if (value == "Chinese_Cymbal") return MIDINAMES_Chinese_Cymbal; + if (value == "Ride_Bell") return MIDINAMES_Ride_Bell; + if (value == "Tambourine") return MIDINAMES_Tambourine; + if (value == "Splash_Cymbal") return MIDINAMES_Splash_Cymbal; + if (value == "Cowbell") return MIDINAMES_Cowbell; + if (value == "Crash_Cymbal_2") return MIDINAMES_Crash_Cymbal_2; + if (value == "Vibraslap") return MIDINAMES_Vibraslap; + if (value == "Ride_Cymbal_2") return MIDINAMES_Ride_Cymbal_2; + if (value == "Hi_Bongo") return MIDINAMES_Hi_Bongo; + if (value == "Low_Bongo") return MIDINAMES_Low_Bongo; + if (value == "Mute_Hi_Conga") return MIDINAMES_Mute_Hi_Conga; + if (value == "Open_Hi_Conga") return MIDINAMES_Open_Hi_Conga; + if (value == "Low_Conga") return MIDINAMES_Low_Conga; + if (value == "High_Timbale") return MIDINAMES_High_Timbale; + if (value == "Low_Timbale") return MIDINAMES_Low_Timbale; + if (value == "High_Agogo") return MIDINAMES_High_Agogo; + if (value == "Low_Agogo") return MIDINAMES_Low_Agogo; + if (value == "Cabasa") return MIDINAMES_Cabasa; + if (value == "Maracas") return MIDINAMES_Maracas; + if (value == "Short_Whistle") return MIDINAMES_Short_Whistle; + if (value == "Long_Whistle") return MIDINAMES_Long_Whistle; + if (value == "Short_Guiro") return MIDINAMES_Short_Guiro; + if (value == "Long_Guiro") return MIDINAMES_Long_Guiro; + if (value == "Claves") return MIDINAMES_Claves; + if (value == "Hi_Wood_Block") return MIDINAMES_Hi_Wood_Block; + if (value == "Low_Wood_Block") return MIDINAMES_Low_Wood_Block; + if (value == "Mute_Cuica") return MIDINAMES_Mute_Cuica; + if (value == "Open_Cuica") return MIDINAMES_Open_Cuica; + if (value == "Mute_Triangle") return MIDINAMES_Mute_Triangle; + if (value == "Open_Triangle") return MIDINAMES_Open_Triangle; + LogWarning("Unsupported value '%s'", value.c_str() ); + return MIDINAMES_NONE; +} + +std::string LibmeiConverter::ModeToStr(data_MODE data) +{ + std::string value; + switch(data) + { + case MODE_major : value = "major"; break; + case MODE_minor : value = "minor"; break; + case MODE_dorian : value = "dorian"; break; + case MODE_phrygian : value = "phrygian"; break; + case MODE_lydian : value = "lydian"; break; + case MODE_mixolydian : value = "mixolydian"; break; + case MODE_aeolian : value = "aeolian"; break; + case MODE_locrian : value = "locrian"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_MODE LibmeiConverter::StrToMode(std::string value) +{ + + if (value == "major") return MODE_major; + if (value == "minor") return MODE_minor; + if (value == "dorian") return MODE_dorian; + if (value == "phrygian") return MODE_phrygian; + if (value == "lydian") return MODE_lydian; + if (value == "mixolydian") return MODE_mixolydian; + if (value == "aeolian") return MODE_aeolian; + if (value == "locrian") return MODE_locrian; + LogWarning("Unsupported value '%s'", value.c_str() ); + return MODE_NONE; +} + +std::string LibmeiConverter::NotationtypeToStr(data_NOTATIONTYPE data) +{ + std::string value; + switch(data) + { + case NOTATIONTYPE_cmn : value = "cmn"; break; + case NOTATIONTYPE_mensural : value = "mensural"; break; + case NOTATIONTYPE_mensural_black : value = "mensural.black"; break; + case NOTATIONTYPE_mensural_white : value = "mensural.white"; break; + case NOTATIONTYPE_neume : value = "neume"; break; + case NOTATIONTYPE_tab : value = "tab"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_NOTATIONTYPE LibmeiConverter::StrToNotationtype(std::string value) +{ + + if (value == "cmn") return NOTATIONTYPE_cmn; + if (value == "mensural") return NOTATIONTYPE_mensural; + if (value == "mensural.black") return NOTATIONTYPE_mensural_black; + if (value == "mensural.white") return NOTATIONTYPE_mensural_white; + if (value == "neume") return NOTATIONTYPE_neume; + if (value == "tab") return NOTATIONTYPE_tab; + LogWarning("Unsupported value '%s'", value.c_str() ); + return NOTATIONTYPE_NONE; +} + +std::string LibmeiConverter::NoteheadmodifierListToStr(data_NOTEHEADMODIFIER_list data) +{ + std::string value; + switch(data) + { + case NOTEHEADMODIFIER_list_slash : value = "slash"; break; + case NOTEHEADMODIFIER_list_backslash : value = "backslash"; break; + case NOTEHEADMODIFIER_list_vline : value = "vline"; break; + case NOTEHEADMODIFIER_list_hline : value = "hline"; break; + case NOTEHEADMODIFIER_list_centerdot : value = "centerdot"; break; + case NOTEHEADMODIFIER_list_paren : value = "paren"; break; + case NOTEHEADMODIFIER_list_brack : value = "brack"; break; + case NOTEHEADMODIFIER_list_box : value = "box"; break; + case NOTEHEADMODIFIER_list_circle : value = "circle"; break; + case NOTEHEADMODIFIER_list_dblwhole : value = "dblwhole"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_NOTEHEADMODIFIER_list LibmeiConverter::StrToNoteheadmodifierList(std::string value) +{ + + if (value == "slash") return NOTEHEADMODIFIER_list_slash; + if (value == "backslash") return NOTEHEADMODIFIER_list_backslash; + if (value == "vline") return NOTEHEADMODIFIER_list_vline; + if (value == "hline") return NOTEHEADMODIFIER_list_hline; + if (value == "centerdot") return NOTEHEADMODIFIER_list_centerdot; + if (value == "paren") return NOTEHEADMODIFIER_list_paren; + if (value == "brack") return NOTEHEADMODIFIER_list_brack; + if (value == "box") return NOTEHEADMODIFIER_list_box; + if (value == "circle") return NOTEHEADMODIFIER_list_circle; + if (value == "dblwhole") return NOTEHEADMODIFIER_list_dblwhole; + LogWarning("Unsupported value '%s'", value.c_str() ); + return NOTEHEADMODIFIER_list_NONE; +} + +std::string LibmeiConverter::OtherstaffToStr(data_OTHERSTAFF data) +{ + std::string value; + switch(data) + { + case OTHERSTAFF_above : value = "above"; break; + case OTHERSTAFF_below : value = "below"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_OTHERSTAFF LibmeiConverter::StrToOtherstaff(std::string value) +{ + + if (value == "above") return OTHERSTAFF_above; + if (value == "below") return OTHERSTAFF_below; + LogWarning("Unsupported value '%s'", value.c_str() ); + return OTHERSTAFF_NONE; +} + +std::string LibmeiConverter::PlaceToStr(data_PLACE data) +{ + std::string value; + switch(data) + { + case PLACE_above : value = "above"; break; + case PLACE_below : value = "below"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_PLACE LibmeiConverter::StrToPlace(std::string value) +{ + + if (value == "above") return PLACE_above; + if (value == "below") return PLACE_below; + LogWarning("Unsupported value '%s'", value.c_str() ); + return PLACE_NONE; +} + +std::string LibmeiConverter::RotationdirectionToStr(data_ROTATIONDIRECTION data) +{ + std::string value; + switch(data) + { + case ROTATIONDIRECTION_none : value = "none"; break; + case ROTATIONDIRECTION_down : value = "down"; break; + case ROTATIONDIRECTION_left : value = "left"; break; + case ROTATIONDIRECTION_ne : value = "ne"; break; + case ROTATIONDIRECTION_nw : value = "nw"; break; + case ROTATIONDIRECTION_se : value = "se"; break; + case ROTATIONDIRECTION_sw : value = "sw"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_ROTATIONDIRECTION LibmeiConverter::StrToRotationdirection(std::string value) +{ + + if (value == "none") return ROTATIONDIRECTION_none; + if (value == "down") return ROTATIONDIRECTION_down; + if (value == "left") return ROTATIONDIRECTION_left; + if (value == "ne") return ROTATIONDIRECTION_ne; + if (value == "nw") return ROTATIONDIRECTION_nw; + if (value == "se") return ROTATIONDIRECTION_se; + if (value == "sw") return ROTATIONDIRECTION_sw; + LogWarning("Unsupported value '%s'", value.c_str() ); + return ROTATIONDIRECTION_NONE; +} + +std::string LibmeiConverter::SizeToStr(data_SIZE data) +{ + std::string value; + switch(data) + { + case SIZE_normal : value = "normal"; break; + case SIZE_cue : value = "cue"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_SIZE LibmeiConverter::StrToSize(std::string value) +{ + + if (value == "normal") return SIZE_normal; + if (value == "cue") return SIZE_cue; + LogWarning("Unsupported value '%s'", value.c_str() ); + return SIZE_NONE; +} + +std::string LibmeiConverter::StaffrelToStr(data_STAFFREL data) +{ + std::string value; + switch(data) + { + case STAFFREL_above : value = "above"; break; + case STAFFREL_below : value = "below"; break; + case STAFFREL_within : value = "within"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_STAFFREL LibmeiConverter::StrToStaffrel(std::string value) +{ + + if (value == "above") return STAFFREL_above; + if (value == "below") return STAFFREL_below; + if (value == "within") return STAFFREL_within; + LogWarning("Unsupported value '%s'", value.c_str() ); + return STAFFREL_NONE; +} + +std::string LibmeiConverter::StemmodifierToStr(data_STEMMODIFIER data) +{ + std::string value; + switch(data) + { + case STEMMODIFIER_none : value = "none"; break; + case STEMMODIFIER_1slash : value = "1slash"; break; + case STEMMODIFIER_2slash : value = "2slash"; break; + case STEMMODIFIER_3slash : value = "3slash"; break; + case STEMMODIFIER_4slash : value = "4slash"; break; + case STEMMODIFIER_5slash : value = "5slash"; break; + case STEMMODIFIER_6slash : value = "6slash"; break; + case STEMMODIFIER_sprech : value = "sprech"; break; + case STEMMODIFIER_z : value = "z"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_STEMMODIFIER LibmeiConverter::StrToStemmodifier(std::string value) +{ + + if (value == "none") return STEMMODIFIER_none; + if (value == "1slash") return STEMMODIFIER_1slash; + if (value == "2slash") return STEMMODIFIER_2slash; + if (value == "3slash") return STEMMODIFIER_3slash; + if (value == "4slash") return STEMMODIFIER_4slash; + if (value == "5slash") return STEMMODIFIER_5slash; + if (value == "6slash") return STEMMODIFIER_6slash; + if (value == "sprech") return STEMMODIFIER_sprech; + if (value == "z") return STEMMODIFIER_z; + LogWarning("Unsupported value '%s'", value.c_str() ); + return STEMMODIFIER_NONE; +} + +std::string LibmeiConverter::StempositionToStr(data_STEMPOSITION data) +{ + std::string value; + switch(data) + { + case STEMPOSITION_left : value = "left"; break; + case STEMPOSITION_right : value = "right"; break; + case STEMPOSITION_center : value = "center"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_STEMPOSITION LibmeiConverter::StrToStemposition(std::string value) +{ + + if (value == "left") return STEMPOSITION_left; + if (value == "right") return STEMPOSITION_right; + if (value == "center") return STEMPOSITION_center; + LogWarning("Unsupported value '%s'", value.c_str() ); + return STEMPOSITION_NONE; +} + +std::string LibmeiConverter::TemperamentToStr(data_TEMPERAMENT data) +{ + std::string value; + switch(data) + { + case TEMPERAMENT_equal : value = "equal"; break; + case TEMPERAMENT_just : value = "just"; break; + case TEMPERAMENT_mean : value = "mean"; break; + case TEMPERAMENT_pythagorean : value = "pythagorean"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_TEMPERAMENT LibmeiConverter::StrToTemperament(std::string value) +{ + + if (value == "equal") return TEMPERAMENT_equal; + if (value == "just") return TEMPERAMENT_just; + if (value == "mean") return TEMPERAMENT_mean; + if (value == "pythagorean") return TEMPERAMENT_pythagorean; + LogWarning("Unsupported value '%s'", value.c_str() ); + return TEMPERAMENT_NONE; +} + +std::string LibmeiConverter::TextrenditionlistToStr(data_TEXTRENDITIONLIST data) +{ + std::string value; + switch(data) + { + case TEXTRENDITIONLIST_xx_small : value = "xx-small"; break; + case TEXTRENDITIONLIST_x_small : value = "x-small"; break; + case TEXTRENDITIONLIST_small : value = "small"; break; + case TEXTRENDITIONLIST_medium : value = "medium"; break; + case TEXTRENDITIONLIST_large : value = "large"; break; + case TEXTRENDITIONLIST_x_large : value = "x-large"; break; + case TEXTRENDITIONLIST_xx_large : value = "xx-large"; break; + case TEXTRENDITIONLIST_smaller : value = "smaller"; break; + case TEXTRENDITIONLIST_larger : value = "larger"; break; + case TEXTRENDITIONLIST_italic : value = "italic"; break; + case TEXTRENDITIONLIST_oblique : value = "oblique"; break; + case TEXTRENDITIONLIST_smcaps : value = "smcaps"; break; + case TEXTRENDITIONLIST_bold : value = "bold"; break; + case TEXTRENDITIONLIST_bolder : value = "bolder"; break; + case TEXTRENDITIONLIST_lighter : value = "lighter"; break; + case TEXTRENDITIONLIST_box : value = "box"; break; + case TEXTRENDITIONLIST_circle : value = "circle"; break; + case TEXTRENDITIONLIST_dbox : value = "dbox"; break; + case TEXTRENDITIONLIST_tbox : value = "tbox"; break; + case TEXTRENDITIONLIST_bslash : value = "bslash"; break; + case TEXTRENDITIONLIST_fslash : value = "fslash"; break; + case TEXTRENDITIONLIST_line_through : value = "line-through"; break; + case TEXTRENDITIONLIST_none : value = "none"; break; + case TEXTRENDITIONLIST_overline : value = "overline"; break; + case TEXTRENDITIONLIST_overstrike : value = "overstrike"; break; + case TEXTRENDITIONLIST_strike : value = "strike"; break; + case TEXTRENDITIONLIST_sub : value = "sub"; break; + case TEXTRENDITIONLIST_sup : value = "sup"; break; + case TEXTRENDITIONLIST_underline : value = "underline"; break; + case TEXTRENDITIONLIST_ltr : value = "ltr"; break; + case TEXTRENDITIONLIST_rtl : value = "rtl"; break; + case TEXTRENDITIONLIST_lro : value = "lro"; break; + case TEXTRENDITIONLIST_rlo : value = "rlo"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_TEXTRENDITIONLIST LibmeiConverter::StrToTextrenditionlist(std::string value) +{ + + if (value == "xx-small") return TEXTRENDITIONLIST_xx_small; + if (value == "x-small") return TEXTRENDITIONLIST_x_small; + if (value == "small") return TEXTRENDITIONLIST_small; + if (value == "medium") return TEXTRENDITIONLIST_medium; + if (value == "large") return TEXTRENDITIONLIST_large; + if (value == "x-large") return TEXTRENDITIONLIST_x_large; + if (value == "xx-large") return TEXTRENDITIONLIST_xx_large; + if (value == "smaller") return TEXTRENDITIONLIST_smaller; + if (value == "larger") return TEXTRENDITIONLIST_larger; + if (value == "italic") return TEXTRENDITIONLIST_italic; + if (value == "oblique") return TEXTRENDITIONLIST_oblique; + if (value == "smcaps") return TEXTRENDITIONLIST_smcaps; + if (value == "bold") return TEXTRENDITIONLIST_bold; + if (value == "bolder") return TEXTRENDITIONLIST_bolder; + if (value == "lighter") return TEXTRENDITIONLIST_lighter; + if (value == "box") return TEXTRENDITIONLIST_box; + if (value == "circle") return TEXTRENDITIONLIST_circle; + if (value == "dbox") return TEXTRENDITIONLIST_dbox; + if (value == "tbox") return TEXTRENDITIONLIST_tbox; + if (value == "bslash") return TEXTRENDITIONLIST_bslash; + if (value == "fslash") return TEXTRENDITIONLIST_fslash; + if (value == "line-through") return TEXTRENDITIONLIST_line_through; + if (value == "none") return TEXTRENDITIONLIST_none; + if (value == "overline") return TEXTRENDITIONLIST_overline; + if (value == "overstrike") return TEXTRENDITIONLIST_overstrike; + if (value == "strike") return TEXTRENDITIONLIST_strike; + if (value == "sub") return TEXTRENDITIONLIST_sub; + if (value == "sup") return TEXTRENDITIONLIST_sup; + if (value == "underline") return TEXTRENDITIONLIST_underline; + if (value == "ltr") return TEXTRENDITIONLIST_ltr; + if (value == "rtl") return TEXTRENDITIONLIST_rtl; + if (value == "lro") return TEXTRENDITIONLIST_lro; + if (value == "rlo") return TEXTRENDITIONLIST_rlo; + LogWarning("Unsupported value '%s'", value.c_str() ); + return TEXTRENDITIONLIST_NONE; +} + +std::string LibmeiConverter::UneumeformToStr(data_UNEUMEFORM data) +{ + std::string value; + switch(data) + { + case UNEUMEFORM_liquescent1 : value = "liquescent1"; break; + case UNEUMEFORM_liquescent2 : value = "liquescent2"; break; + case UNEUMEFORM_liquescent3 : value = "liquescent3"; break; + case UNEUMEFORM_quilismatic : value = "quilismatic"; break; + case UNEUMEFORM_rectangular : value = "rectangular"; break; + case UNEUMEFORM_rhombic : value = "rhombic"; break; + case UNEUMEFORM_tied : value = "tied"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_UNEUMEFORM LibmeiConverter::StrToUneumeform(std::string value) +{ + + if (value == "liquescent1") return UNEUMEFORM_liquescent1; + if (value == "liquescent2") return UNEUMEFORM_liquescent2; + if (value == "liquescent3") return UNEUMEFORM_liquescent3; + if (value == "quilismatic") return UNEUMEFORM_quilismatic; + if (value == "rectangular") return UNEUMEFORM_rectangular; + if (value == "rhombic") return UNEUMEFORM_rhombic; + if (value == "tied") return UNEUMEFORM_tied; + LogWarning("Unsupported value '%s'", value.c_str() ); + return UNEUMEFORM_NONE; +} + +std::string LibmeiConverter::UneumenameToStr(data_UNEUMENAME data) +{ + std::string value; + switch(data) + { + case UNEUMENAME_punctum : value = "punctum"; break; + case UNEUMENAME_virga : value = "virga"; break; + case UNEUMENAME_pes : value = "pes"; break; + case UNEUMENAME_clivis : value = "clivis"; break; + case UNEUMENAME_torculus : value = "torculus"; break; + case UNEUMENAME_torculusresupinus : value = "torculusresupinus"; break; + case UNEUMENAME_porrectus : value = "porrectus"; break; + case UNEUMENAME_porrectusflexus : value = "porrectusflexus"; break; + case UNEUMENAME_apostropha : value = "apostropha"; break; + case UNEUMENAME_oriscus : value = "oriscus"; break; + case UNEUMENAME_pressusmaior : value = "pressusmaior"; break; + case UNEUMENAME_pressusminor : value = "pressusminor"; break; + case UNEUMENAME_virgastrata : value = "virgastrata"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +data_UNEUMENAME LibmeiConverter::StrToUneumename(std::string value) +{ + + if (value == "punctum") return UNEUMENAME_punctum; + if (value == "virga") return UNEUMENAME_virga; + if (value == "pes") return UNEUMENAME_pes; + if (value == "clivis") return UNEUMENAME_clivis; + if (value == "torculus") return UNEUMENAME_torculus; + if (value == "torculusresupinus") return UNEUMENAME_torculusresupinus; + if (value == "porrectus") return UNEUMENAME_porrectus; + if (value == "porrectusflexus") return UNEUMENAME_porrectusflexus; + if (value == "apostropha") return UNEUMENAME_apostropha; + if (value == "oriscus") return UNEUMENAME_oriscus; + if (value == "pressusmaior") return UNEUMENAME_pressusmaior; + if (value == "pressusminor") return UNEUMENAME_pressusminor; + if (value == "virgastrata") return UNEUMENAME_virgastrata; + LogWarning("Unsupported value '%s'", value.c_str() ); + return UNEUMENAME_NONE; +} + +std::string LibmeiConverter::AccidLogFuncToStr(accidLog_FUNC data) +{ + std::string value; + switch(data) + { + case accidLog_FUNC_caution : value = "caution"; break; + case accidLog_FUNC_edit : value = "edit"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +accidLog_FUNC LibmeiConverter::StrToAccidLogFunc(std::string value) +{ + + if (value == "caution") return accidLog_FUNC_caution; + if (value == "edit") return accidLog_FUNC_edit; + LogWarning("Unsupported value '%s'", value.c_str() ); + return accidLog_FUNC_NONE; +} + +std::string LibmeiConverter::ArpegLogOrderToStr(arpegLog_ORDER data) +{ + std::string value; + switch(data) + { + case arpegLog_ORDER_up : value = "up"; break; + case arpegLog_ORDER_down : value = "down"; break; + case arpegLog_ORDER_nonarp : value = "nonarp"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +arpegLog_ORDER LibmeiConverter::StrToArpegLogOrder(std::string value) +{ + + if (value == "up") return arpegLog_ORDER_up; + if (value == "down") return arpegLog_ORDER_down; + if (value == "nonarp") return arpegLog_ORDER_nonarp; + LogWarning("Unsupported value '%s'", value.c_str() ); + return arpegLog_ORDER_NONE; +} + +std::string LibmeiConverter::BTremLogFormToStr(bTremLog_FORM data) +{ + std::string value; + switch(data) + { + case bTremLog_FORM_meas : value = "meas"; break; + case bTremLog_FORM_unmeas : value = "unmeas"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +bTremLog_FORM LibmeiConverter::StrToBTremLogForm(std::string value) +{ + + if (value == "meas") return bTremLog_FORM_meas; + if (value == "unmeas") return bTremLog_FORM_unmeas; + LogWarning("Unsupported value '%s'", value.c_str() ); + return bTremLog_FORM_NONE; +} + +std::string LibmeiConverter::BeamingVisBeamrendToStr(beamingVis_BEAMREND data) +{ + std::string value; + switch(data) + { + case beamingVis_BEAMREND_acc : value = "acc"; break; + case beamingVis_BEAMREND_rit : value = "rit"; break; + case beamingVis_BEAMREND_norm : value = "norm"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +beamingVis_BEAMREND LibmeiConverter::StrToBeamingVisBeamrend(std::string value) +{ + + if (value == "acc") return beamingVis_BEAMREND_acc; + if (value == "rit") return beamingVis_BEAMREND_rit; + if (value == "norm") return beamingVis_BEAMREND_norm; + LogWarning("Unsupported value '%s'", value.c_str() ); + return beamingVis_BEAMREND_NONE; +} + +std::string LibmeiConverter::BeamrendFormToStr(beamrend_FORM data) +{ + std::string value; + switch(data) + { + case beamrend_FORM_acc : value = "acc"; break; + case beamrend_FORM_mixed : value = "mixed"; break; + case beamrend_FORM_rit : value = "rit"; break; + case beamrend_FORM_norm : value = "norm"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +beamrend_FORM LibmeiConverter::StrToBeamrendForm(std::string value) +{ + + if (value == "acc") return beamrend_FORM_acc; + if (value == "mixed") return beamrend_FORM_mixed; + if (value == "rit") return beamrend_FORM_rit; + if (value == "norm") return beamrend_FORM_norm; + LogWarning("Unsupported value '%s'", value.c_str() ); + return beamrend_FORM_NONE; +} + +std::string LibmeiConverter::CurvatureCurvedirToStr(curvature_CURVEDIR data) +{ + std::string value; + switch(data) + { + case curvature_CURVEDIR_above : value = "above"; break; + case curvature_CURVEDIR_below : value = "below"; break; + case curvature_CURVEDIR_mixed : value = "mixed"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +curvature_CURVEDIR LibmeiConverter::StrToCurvatureCurvedir(std::string value) +{ + + if (value == "above") return curvature_CURVEDIR_above; + if (value == "below") return curvature_CURVEDIR_below; + if (value == "mixed") return curvature_CURVEDIR_mixed; + LogWarning("Unsupported value '%s'", value.c_str() ); + return curvature_CURVEDIR_NONE; +} + +std::string LibmeiConverter::CutoutCutoutToStr(cutout_CUTOUT data) +{ + std::string value; + switch(data) + { + case cutout_CUTOUT_cutout : value = "cutout"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +cutout_CUTOUT LibmeiConverter::StrToCutoutCutout(std::string value) +{ + + if (value == "cutout") return cutout_CUTOUT_cutout; + LogWarning("Unsupported value '%s'", value.c_str() ); + return cutout_CUTOUT_NONE; +} + +std::string LibmeiConverter::DotLogFormToStr(dotLog_FORM data) +{ + std::string value; + switch(data) + { + case dotLog_FORM_aug : value = "aug"; break; + case dotLog_FORM_div : value = "div"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +dotLog_FORM LibmeiConverter::StrToDotLogForm(std::string value) +{ + + if (value == "aug") return dotLog_FORM_aug; + if (value == "div") return dotLog_FORM_div; + LogWarning("Unsupported value '%s'", value.c_str() ); + return dotLog_FORM_NONE; +} + +std::string LibmeiConverter::EndingsEndingrendToStr(endings_ENDINGREND data) +{ + std::string value; + switch(data) + { + case endings_ENDINGREND_top : value = "top"; break; + case endings_ENDINGREND_barred : value = "barred"; break; + case endings_ENDINGREND_grouped : value = "grouped"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +endings_ENDINGREND LibmeiConverter::StrToEndingsEndingrend(std::string value) +{ + + if (value == "top") return endings_ENDINGREND_top; + if (value == "barred") return endings_ENDINGREND_barred; + if (value == "grouped") return endings_ENDINGREND_grouped; + LogWarning("Unsupported value '%s'", value.c_str() ); + return endings_ENDINGREND_NONE; +} + +std::string LibmeiConverter::FTremLogFormToStr(fTremLog_FORM data) +{ + std::string value; + switch(data) + { + case fTremLog_FORM_meas : value = "meas"; break; + case fTremLog_FORM_unmeas : value = "unmeas"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +fTremLog_FORM LibmeiConverter::StrToFTremLogForm(std::string value) +{ + + if (value == "meas") return fTremLog_FORM_meas; + if (value == "unmeas") return fTremLog_FORM_unmeas; + LogWarning("Unsupported value '%s'", value.c_str() ); + return fTremLog_FORM_NONE; +} + +std::string LibmeiConverter::FermataVisFormToStr(fermataVis_FORM data) +{ + std::string value; + switch(data) + { + case fermataVis_FORM_inv : value = "inv"; break; + case fermataVis_FORM_norm : value = "norm"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +fermataVis_FORM LibmeiConverter::StrToFermataVisForm(std::string value) +{ + + if (value == "inv") return fermataVis_FORM_inv; + if (value == "norm") return fermataVis_FORM_norm; + LogWarning("Unsupported value '%s'", value.c_str() ); + return fermataVis_FORM_NONE; +} + +std::string LibmeiConverter::FermataVisShapeToStr(fermataVis_SHAPE data) +{ + std::string value; + switch(data) + { + case fermataVis_SHAPE_curved : value = "curved"; break; + case fermataVis_SHAPE_square : value = "square"; break; + case fermataVis_SHAPE_angular : value = "angular"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +fermataVis_SHAPE LibmeiConverter::StrToFermataVisShape(std::string value) +{ + + if (value == "curved") return fermataVis_SHAPE_curved; + if (value == "square") return fermataVis_SHAPE_square; + if (value == "angular") return fermataVis_SHAPE_angular; + LogWarning("Unsupported value '%s'", value.c_str() ); + return fermataVis_SHAPE_NONE; +} + +std::string LibmeiConverter::HairpinLogFormToStr(hairpinLog_FORM data) +{ + std::string value; + switch(data) + { + case hairpinLog_FORM_cres : value = "cres"; break; + case hairpinLog_FORM_dim : value = "dim"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +hairpinLog_FORM LibmeiConverter::StrToHairpinLogForm(std::string value) +{ + + if (value == "cres") return hairpinLog_FORM_cres; + if (value == "dim") return hairpinLog_FORM_dim; + LogWarning("Unsupported value '%s'", value.c_str() ); + return hairpinLog_FORM_NONE; +} + +std::string LibmeiConverter::HarmVisRendgridToStr(harmVis_RENDGRID data) +{ + std::string value; + switch(data) + { + case harmVis_RENDGRID_grid : value = "grid"; break; + case harmVis_RENDGRID_gridtext : value = "gridtext"; break; + case harmVis_RENDGRID_text : value = "text"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +harmVis_RENDGRID LibmeiConverter::StrToHarmVisRendgrid(std::string value) +{ + + if (value == "grid") return harmVis_RENDGRID_grid; + if (value == "gridtext") return harmVis_RENDGRID_gridtext; + if (value == "text") return harmVis_RENDGRID_text; + LogWarning("Unsupported value '%s'", value.c_str() ); + return harmVis_RENDGRID_NONE; +} + +std::string LibmeiConverter::HarpPedalLogAToStr(harpPedalLog_A data) +{ + std::string value; + switch(data) + { + case harpPedalLog_A_f : value = "f"; break; + case harpPedalLog_A_n : value = "n"; break; + case harpPedalLog_A_s : value = "s"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +harpPedalLog_A LibmeiConverter::StrToHarpPedalLogA(std::string value) +{ + + if (value == "f") return harpPedalLog_A_f; + if (value == "n") return harpPedalLog_A_n; + if (value == "s") return harpPedalLog_A_s; + LogWarning("Unsupported value '%s'", value.c_str() ); + return harpPedalLog_A_NONE; +} + +std::string LibmeiConverter::HarpPedalLogBToStr(harpPedalLog_B data) +{ + std::string value; + switch(data) + { + case harpPedalLog_B_f : value = "f"; break; + case harpPedalLog_B_n : value = "n"; break; + case harpPedalLog_B_s : value = "s"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +harpPedalLog_B LibmeiConverter::StrToHarpPedalLogB(std::string value) +{ + + if (value == "f") return harpPedalLog_B_f; + if (value == "n") return harpPedalLog_B_n; + if (value == "s") return harpPedalLog_B_s; + LogWarning("Unsupported value '%s'", value.c_str() ); + return harpPedalLog_B_NONE; +} + +std::string LibmeiConverter::HarpPedalLogCToStr(harpPedalLog_C data) +{ + std::string value; + switch(data) + { + case harpPedalLog_C_f : value = "f"; break; + case harpPedalLog_C_n : value = "n"; break; + case harpPedalLog_C_s : value = "s"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +harpPedalLog_C LibmeiConverter::StrToHarpPedalLogC(std::string value) +{ + + if (value == "f") return harpPedalLog_C_f; + if (value == "n") return harpPedalLog_C_n; + if (value == "s") return harpPedalLog_C_s; + LogWarning("Unsupported value '%s'", value.c_str() ); + return harpPedalLog_C_NONE; +} + +std::string LibmeiConverter::HarpPedalLogDToStr(harpPedalLog_D data) +{ + std::string value; + switch(data) + { + case harpPedalLog_D_f : value = "f"; break; + case harpPedalLog_D_n : value = "n"; break; + case harpPedalLog_D_s : value = "s"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +harpPedalLog_D LibmeiConverter::StrToHarpPedalLogD(std::string value) +{ + + if (value == "f") return harpPedalLog_D_f; + if (value == "n") return harpPedalLog_D_n; + if (value == "s") return harpPedalLog_D_s; + LogWarning("Unsupported value '%s'", value.c_str() ); + return harpPedalLog_D_NONE; +} + +std::string LibmeiConverter::HarpPedalLogEToStr(harpPedalLog_E data) +{ + std::string value; + switch(data) + { + case harpPedalLog_E_f : value = "f"; break; + case harpPedalLog_E_n : value = "n"; break; + case harpPedalLog_E_s : value = "s"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +harpPedalLog_E LibmeiConverter::StrToHarpPedalLogE(std::string value) +{ + + if (value == "f") return harpPedalLog_E_f; + if (value == "n") return harpPedalLog_E_n; + if (value == "s") return harpPedalLog_E_s; + LogWarning("Unsupported value '%s'", value.c_str() ); + return harpPedalLog_E_NONE; +} + +std::string LibmeiConverter::HarpPedalLogFToStr(harpPedalLog_F data) +{ + std::string value; + switch(data) + { + case harpPedalLog_F_f : value = "f"; break; + case harpPedalLog_F_n : value = "n"; break; + case harpPedalLog_F_s : value = "s"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +harpPedalLog_F LibmeiConverter::StrToHarpPedalLogF(std::string value) +{ + + if (value == "f") return harpPedalLog_F_f; + if (value == "n") return harpPedalLog_F_n; + if (value == "s") return harpPedalLog_F_s; + LogWarning("Unsupported value '%s'", value.c_str() ); + return harpPedalLog_F_NONE; +} + +std::string LibmeiConverter::HarpPedalLogGToStr(harpPedalLog_G data) +{ + std::string value; + switch(data) + { + case harpPedalLog_G_f : value = "f"; break; + case harpPedalLog_G_n : value = "n"; break; + case harpPedalLog_G_s : value = "s"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +harpPedalLog_G LibmeiConverter::StrToHarpPedalLogG(std::string value) +{ + + if (value == "f") return harpPedalLog_G_f; + if (value == "n") return harpPedalLog_G_n; + if (value == "s") return harpPedalLog_G_s; + LogWarning("Unsupported value '%s'", value.c_str() ); + return harpPedalLog_G_NONE; +} + +std::string LibmeiConverter::MeiversionMeiversionToStr(meiversion_MEIVERSION data) +{ + std::string value; + switch(data) + { + case meiversion_MEIVERSION_3_0_0 : value = "3.0.0"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +meiversion_MEIVERSION LibmeiConverter::StrToMeiversionMeiversion(std::string value) +{ + + if (value == "3.0.0") return meiversion_MEIVERSION_3_0_0; + LogWarning("Unsupported value '%s'", value.c_str() ); + return meiversion_MEIVERSION_NONE; +} + +std::string LibmeiConverter::MensurVisFormToStr(mensurVis_FORM data) +{ + std::string value; + switch(data) + { + case mensurVis_FORM_horizontal : value = "horizontal"; break; + case mensurVis_FORM_vertical : value = "vertical"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +mensurVis_FORM LibmeiConverter::StrToMensurVisForm(std::string value) +{ + + if (value == "horizontal") return mensurVis_FORM_horizontal; + if (value == "vertical") return mensurVis_FORM_vertical; + LogWarning("Unsupported value '%s'", value.c_str() ); + return mensurVis_FORM_NONE; +} + +std::string LibmeiConverter::MensuralVisMensurformToStr(mensuralVis_MENSURFORM data) +{ + std::string value; + switch(data) + { + case mensuralVis_MENSURFORM_horizontal : value = "horizontal"; break; + case mensuralVis_MENSURFORM_vertical : value = "vertical"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +mensuralVis_MENSURFORM LibmeiConverter::StrToMensuralVisMensurform(std::string value) +{ + + if (value == "horizontal") return mensuralVis_MENSURFORM_horizontal; + if (value == "vertical") return mensuralVis_MENSURFORM_vertical; + LogWarning("Unsupported value '%s'", value.c_str() ); + return mensuralVis_MENSURFORM_NONE; +} + +std::string LibmeiConverter::MeterSigVisFormToStr(meterSigVis_FORM data) +{ + std::string value; + switch(data) + { + case meterSigVis_FORM_num : value = "num"; break; + case meterSigVis_FORM_denomsym : value = "denomsym"; break; + case meterSigVis_FORM_norm : value = "norm"; break; + case meterSigVis_FORM_invis : value = "invis"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +meterSigVis_FORM LibmeiConverter::StrToMeterSigVisForm(std::string value) +{ + + if (value == "num") return meterSigVis_FORM_num; + if (value == "denomsym") return meterSigVis_FORM_denomsym; + if (value == "norm") return meterSigVis_FORM_norm; + if (value == "invis") return meterSigVis_FORM_invis; + LogWarning("Unsupported value '%s'", value.c_str() ); + return meterSigVis_FORM_NONE; +} + +std::string LibmeiConverter::MeterSigDefaultVisMeterrendToStr(meterSigDefaultVis_METERREND data) +{ + std::string value; + switch(data) + { + case meterSigDefaultVis_METERREND_num : value = "num"; break; + case meterSigDefaultVis_METERREND_denomsym : value = "denomsym"; break; + case meterSigDefaultVis_METERREND_norm : value = "norm"; break; + case meterSigDefaultVis_METERREND_invis : value = "invis"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +meterSigDefaultVis_METERREND LibmeiConverter::StrToMeterSigDefaultVisMeterrend(std::string value) +{ + + if (value == "num") return meterSigDefaultVis_METERREND_num; + if (value == "denomsym") return meterSigDefaultVis_METERREND_denomsym; + if (value == "norm") return meterSigDefaultVis_METERREND_norm; + if (value == "invis") return meterSigDefaultVis_METERREND_invis; + LogWarning("Unsupported value '%s'", value.c_str() ); + return meterSigDefaultVis_METERREND_NONE; +} + +std::string LibmeiConverter::MeterconformanceMetconToStr(meterconformance_METCON data) +{ + std::string value; + switch(data) + { + case meterconformance_METCON_c : value = "c"; break; + case meterconformance_METCON_i : value = "i"; break; + case meterconformance_METCON_o : value = "o"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +meterconformance_METCON LibmeiConverter::StrToMeterconformanceMetcon(std::string value) +{ + + if (value == "c") return meterconformance_METCON_c; + if (value == "i") return meterconformance_METCON_i; + if (value == "o") return meterconformance_METCON_o; + LogWarning("Unsupported value '%s'", value.c_str() ); + return meterconformance_METCON_NONE; +} + +std::string LibmeiConverter::MordentLogFormToStr(mordentLog_FORM data) +{ + std::string value; + switch(data) + { + case mordentLog_FORM_inv : value = "inv"; break; + case mordentLog_FORM_norm : value = "norm"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +mordentLog_FORM LibmeiConverter::StrToMordentLogForm(std::string value) +{ + + if (value == "inv") return mordentLog_FORM_inv; + if (value == "norm") return mordentLog_FORM_norm; + LogWarning("Unsupported value '%s'", value.c_str() ); + return mordentLog_FORM_NONE; +} + +std::string LibmeiConverter::NoteLogMensuralLigToStr(noteLogMensural_LIG data) +{ + std::string value; + switch(data) + { + case noteLogMensural_LIG_recta : value = "recta"; break; + case noteLogMensural_LIG_obliqua : value = "obliqua"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +noteLogMensural_LIG LibmeiConverter::StrToNoteLogMensuralLig(std::string value) +{ + + if (value == "recta") return noteLogMensural_LIG_recta; + if (value == "obliqua") return noteLogMensural_LIG_obliqua; + LogWarning("Unsupported value '%s'", value.c_str() ); + return noteLogMensural_LIG_NONE; +} + +std::string LibmeiConverter::OctaveLogCollToStr(octaveLog_COLL data) +{ + std::string value; + switch(data) + { + case octaveLog_COLL_coll : value = "coll"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +octaveLog_COLL LibmeiConverter::StrToOctaveLogColl(std::string value) +{ + + if (value == "coll") return octaveLog_COLL_coll; + LogWarning("Unsupported value '%s'", value.c_str() ); + return octaveLog_COLL_NONE; +} + +std::string LibmeiConverter::PbVisFoliumToStr(pbVis_FOLIUM data) +{ + std::string value; + switch(data) + { + case pbVis_FOLIUM_verso : value = "verso"; break; + case pbVis_FOLIUM_recto : value = "recto"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +pbVis_FOLIUM LibmeiConverter::StrToPbVisFolium(std::string value) +{ + + if (value == "verso") return pbVis_FOLIUM_verso; + if (value == "recto") return pbVis_FOLIUM_recto; + LogWarning("Unsupported value '%s'", value.c_str() ); + return pbVis_FOLIUM_NONE; +} + +std::string LibmeiConverter::PedalLogDirToStr(pedalLog_DIR data) +{ + std::string value; + switch(data) + { + case pedalLog_DIR_down : value = "down"; break; + case pedalLog_DIR_up : value = "up"; break; + case pedalLog_DIR_half : value = "half"; break; + case pedalLog_DIR_bounce : value = "bounce"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +pedalLog_DIR LibmeiConverter::StrToPedalLogDir(std::string value) +{ + + if (value == "down") return pedalLog_DIR_down; + if (value == "up") return pedalLog_DIR_up; + if (value == "half") return pedalLog_DIR_half; + if (value == "bounce") return pedalLog_DIR_bounce; + LogWarning("Unsupported value '%s'", value.c_str() ); + return pedalLog_DIR_NONE; +} + +std::string LibmeiConverter::PedalVisFormToStr(pedalVis_FORM data) +{ + std::string value; + switch(data) + { + case pedalVis_FORM_line : value = "line"; break; + case pedalVis_FORM_pedstar : value = "pedstar"; break; + case pedalVis_FORM_altpedstar : value = "altpedstar"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +pedalVis_FORM LibmeiConverter::StrToPedalVisForm(std::string value) +{ + + if (value == "line") return pedalVis_FORM_line; + if (value == "pedstar") return pedalVis_FORM_pedstar; + if (value == "altpedstar") return pedalVis_FORM_altpedstar; + LogWarning("Unsupported value '%s'", value.c_str() ); + return pedalVis_FORM_NONE; +} + +std::string LibmeiConverter::PianopedalsPedalstyleToStr(pianopedals_PEDALSTYLE data) +{ + std::string value; + switch(data) + { + case pianopedals_PEDALSTYLE_line : value = "line"; break; + case pianopedals_PEDALSTYLE_pedstar : value = "pedstar"; break; + case pianopedals_PEDALSTYLE_altpedstar : value = "altpedstar"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +pianopedals_PEDALSTYLE LibmeiConverter::StrToPianopedalsPedalstyle(std::string value) +{ + + if (value == "line") return pianopedals_PEDALSTYLE_line; + if (value == "pedstar") return pianopedals_PEDALSTYLE_pedstar; + if (value == "altpedstar") return pianopedals_PEDALSTYLE_altpedstar; + LogWarning("Unsupported value '%s'", value.c_str() ); + return pianopedals_PEDALSTYLE_NONE; +} + +std::string LibmeiConverter::PlistEvaluateToStr(plist_EVALUATE data) +{ + std::string value; + switch(data) + { + case plist_EVALUATE_all : value = "all"; break; + case plist_EVALUATE_one : value = "one"; break; + case plist_EVALUATE_none : value = "none"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +plist_EVALUATE LibmeiConverter::StrToPlistEvaluate(std::string value) +{ + + if (value == "all") return plist_EVALUATE_all; + if (value == "one") return plist_EVALUATE_one; + if (value == "none") return plist_EVALUATE_none; + LogWarning("Unsupported value '%s'", value.c_str() ); + return plist_EVALUATE_NONE; +} + +std::string LibmeiConverter::PointingXlinkactuateToStr(pointing_XLINKACTUATE data) +{ + std::string value; + switch(data) + { + case pointing_XLINKACTUATE_onLoad : value = "onLoad"; break; + case pointing_XLINKACTUATE_onRequest : value = "onRequest"; break; + case pointing_XLINKACTUATE_none : value = "none"; break; + case pointing_XLINKACTUATE_other : value = "other"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +pointing_XLINKACTUATE LibmeiConverter::StrToPointingXlinkactuate(std::string value) +{ + + if (value == "onLoad") return pointing_XLINKACTUATE_onLoad; + if (value == "onRequest") return pointing_XLINKACTUATE_onRequest; + if (value == "none") return pointing_XLINKACTUATE_none; + if (value == "other") return pointing_XLINKACTUATE_other; + LogWarning("Unsupported value '%s'", value.c_str() ); + return pointing_XLINKACTUATE_NONE; +} + +std::string LibmeiConverter::PointingXlinkshowToStr(pointing_XLINKSHOW data) +{ + std::string value; + switch(data) + { + case pointing_XLINKSHOW_new : value = "new"; break; + case pointing_XLINKSHOW_replace : value = "replace"; break; + case pointing_XLINKSHOW_embed : value = "embed"; break; + case pointing_XLINKSHOW_none : value = "none"; break; + case pointing_XLINKSHOW_other : value = "other"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +pointing_XLINKSHOW LibmeiConverter::StrToPointingXlinkshow(std::string value) +{ + + if (value == "new") return pointing_XLINKSHOW_new; + if (value == "replace") return pointing_XLINKSHOW_replace; + if (value == "embed") return pointing_XLINKSHOW_embed; + if (value == "none") return pointing_XLINKSHOW_none; + if (value == "other") return pointing_XLINKSHOW_other; + LogWarning("Unsupported value '%s'", value.c_str() ); + return pointing_XLINKSHOW_NONE; +} + +std::string LibmeiConverter::RegularmethodMethodToStr(regularmethod_METHOD data) +{ + std::string value; + switch(data) + { + case regularmethod_METHOD_silent : value = "silent"; break; + case regularmethod_METHOD_tags : value = "tags"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +regularmethod_METHOD LibmeiConverter::StrToRegularmethodMethod(std::string value) +{ + + if (value == "silent") return regularmethod_METHOD_silent; + if (value == "tags") return regularmethod_METHOD_tags; + LogWarning("Unsupported value '%s'", value.c_str() ); + return regularmethod_METHOD_NONE; +} + +std::string LibmeiConverter::RehearsalRehencloseToStr(rehearsal_REHENCLOSE data) +{ + std::string value; + switch(data) + { + case rehearsal_REHENCLOSE_box : value = "box"; break; + case rehearsal_REHENCLOSE_circle : value = "circle"; break; + case rehearsal_REHENCLOSE_none : value = "none"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +rehearsal_REHENCLOSE LibmeiConverter::StrToRehearsalRehenclose(std::string value) +{ + + if (value == "box") return rehearsal_REHENCLOSE_box; + if (value == "circle") return rehearsal_REHENCLOSE_circle; + if (value == "none") return rehearsal_REHENCLOSE_none; + LogWarning("Unsupported value '%s'", value.c_str() ); + return rehearsal_REHENCLOSE_NONE; +} + +std::string LibmeiConverter::SbVisFormToStr(sbVis_FORM data) +{ + std::string value; + switch(data) + { + case sbVis_FORM_hash : value = "hash"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +sbVis_FORM LibmeiConverter::StrToSbVisForm(std::string value) +{ + + if (value == "hash") return sbVis_FORM_hash; + LogWarning("Unsupported value '%s'", value.c_str() ); + return sbVis_FORM_NONE; +} + +std::string LibmeiConverter::StaffgroupingsymSymbolToStr(staffgroupingsym_SYMBOL data) +{ + std::string value; + switch(data) + { + case staffgroupingsym_SYMBOL_brace : value = "brace"; break; + case staffgroupingsym_SYMBOL_bracket : value = "bracket"; break; + case staffgroupingsym_SYMBOL_bracketsq : value = "bracketsq"; break; + case staffgroupingsym_SYMBOL_line : value = "line"; break; + case staffgroupingsym_SYMBOL_none : value = "none"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +staffgroupingsym_SYMBOL LibmeiConverter::StrToStaffgroupingsymSymbol(std::string value) +{ + + if (value == "brace") return staffgroupingsym_SYMBOL_brace; + if (value == "bracket") return staffgroupingsym_SYMBOL_bracket; + if (value == "bracketsq") return staffgroupingsym_SYMBOL_bracketsq; + if (value == "line") return staffgroupingsym_SYMBOL_line; + if (value == "none") return staffgroupingsym_SYMBOL_none; + LogWarning("Unsupported value '%s'", value.c_str() ); + return staffgroupingsym_SYMBOL_NONE; +} + +std::string LibmeiConverter::SylLogConToStr(sylLog_CON data) +{ + std::string value; + switch(data) + { + case sylLog_CON_s : value = "s"; break; + case sylLog_CON_d : value = "d"; break; + case sylLog_CON_u : value = "u"; break; + case sylLog_CON_t : value = "t"; break; + case sylLog_CON_c : value = "c"; break; + case sylLog_CON_v : value = "v"; break; + case sylLog_CON_i : value = "i"; break; + case sylLog_CON_b : value = "b"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +sylLog_CON LibmeiConverter::StrToSylLogCon(std::string value) +{ + + if (value == "s") return sylLog_CON_s; + if (value == "d") return sylLog_CON_d; + if (value == "u") return sylLog_CON_u; + if (value == "t") return sylLog_CON_t; + if (value == "c") return sylLog_CON_c; + if (value == "v") return sylLog_CON_v; + if (value == "i") return sylLog_CON_i; + if (value == "b") return sylLog_CON_b; + LogWarning("Unsupported value '%s'", value.c_str() ); + return sylLog_CON_NONE; +} + +std::string LibmeiConverter::SylLogWordposToStr(sylLog_WORDPOS data) +{ + std::string value; + switch(data) + { + case sylLog_WORDPOS_i : value = "i"; break; + case sylLog_WORDPOS_m : value = "m"; break; + case sylLog_WORDPOS_t : value = "t"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +sylLog_WORDPOS LibmeiConverter::StrToSylLogWordpos(std::string value) +{ + + if (value == "i") return sylLog_WORDPOS_i; + if (value == "m") return sylLog_WORDPOS_m; + if (value == "t") return sylLog_WORDPOS_t; + LogWarning("Unsupported value '%s'", value.c_str() ); + return sylLog_WORDPOS_NONE; +} + +std::string LibmeiConverter::TupletVisNumformatToStr(tupletVis_NUMFORMAT data) +{ + std::string value; + switch(data) + { + case tupletVis_NUMFORMAT_count : value = "count"; break; + case tupletVis_NUMFORMAT_ratio : value = "ratio"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +tupletVis_NUMFORMAT LibmeiConverter::StrToTupletVisNumformat(std::string value) +{ + + if (value == "count") return tupletVis_NUMFORMAT_count; + if (value == "ratio") return tupletVis_NUMFORMAT_ratio; + LogWarning("Unsupported value '%s'", value.c_str() ); + return tupletVis_NUMFORMAT_NONE; +} + +std::string LibmeiConverter::TurnLogFormToStr(turnLog_FORM data) +{ + std::string value; + switch(data) + { + case turnLog_FORM_inv : value = "inv"; break; + case turnLog_FORM_norm : value = "norm"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +turnLog_FORM LibmeiConverter::StrToTurnLogForm(std::string value) +{ + + if (value == "inv") return turnLog_FORM_inv; + if (value == "norm") return turnLog_FORM_norm; + LogWarning("Unsupported value '%s'", value.c_str() ); + return turnLog_FORM_NONE; +} + +std::string LibmeiConverter::WhitespaceXmlspaceToStr(whitespace_XMLSPACE data) +{ + std::string value; + switch(data) + { + case whitespace_XMLSPACE_default : value = "default"; break; + case whitespace_XMLSPACE_preserve : value = "preserve"; break; + default: + LogWarning("Unknown value '%d'", data); + value = ""; + break; + } + return value; +} + +whitespace_XMLSPACE LibmeiConverter::StrToWhitespaceXmlspace(std::string value) +{ + + if (value == "default") return whitespace_XMLSPACE_default; + if (value == "preserve") return whitespace_XMLSPACE_preserve; + LogWarning("Unsupported value '%s'", value.c_str() ); + return whitespace_XMLSPACE_NONE; +} + +} // vrv namespace diff --git a/libmei/libmei_converter.h b/libmei/libmei_converter.h new file mode 100644 index 00000000000..b0bb7f3c8f5 --- /dev/null +++ b/libmei/libmei_converter.h @@ -0,0 +1,307 @@ +///////////////////////////////////////////////////////////////////////////// +// Authors: Laurent Pugin and Rodolfo Zitellini +// Created: 2014 +// Copyright (c) Authors and others. All rights reserved. +// +// Code generated using a modified version of libmei +// by Andrew Hankinson, Alastair Porter, and Others +///////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////// +// NOTE: this file was generated with the Verovio libmei version and +// should not be edited because changes will be lost. +///////////////////////////////////////////////////////////////////////////// + +#ifndef __VRV_LIBMEI_CONVERTER_H__ +#define __VRV_LIBMEI_CONVERTER_H__ + +#include + +//---------------------------------------------------------------------------- + +#include "libmei_def.h" + +namespace vrv { + +//---------------------------------------------------------------------------- +// LibmeiConverter +//---------------------------------------------------------------------------- + +class LibmeiConverter +{ +public: + + std::string AccidentalExplicitToStr(data_ACCIDENTAL_EXPLICIT data); + data_ACCIDENTAL_EXPLICIT StrToAccidentalExplicit(std::string value); + + std::string AccidentalImplicitToStr(data_ACCIDENTAL_IMPLICIT data); + data_ACCIDENTAL_IMPLICIT StrToAccidentalImplicit(std::string value); + + std::string ArticulationToStr(data_ARTICULATION data); + data_ARTICULATION StrToArticulation(std::string value); + + std::string BarplaceToStr(data_BARPLACE data); + data_BARPLACE StrToBarplace(std::string value); + + std::string BarrenditionToStr(data_BARRENDITION data); + data_BARRENDITION StrToBarrendition(std::string value); + + std::string BetypeToStr(data_BETYPE data); + data_BETYPE StrToBetype(std::string value); + + std::string BooleanToStr(data_BOOLEAN data); + data_BOOLEAN StrToBoolean(std::string value); + + std::string CertaintyToStr(data_CERTAINTY data); + data_CERTAINTY StrToCertainty(std::string value); + + std::string ClefshapeToStr(data_CLEFSHAPE data); + data_CLEFSHAPE StrToClefshape(std::string value); + + std::string ClusterToStr(data_CLUSTER data); + data_CLUSTER StrToCluster(std::string value); + + std::string ColornamesToStr(data_COLORNAMES data); + data_COLORNAMES StrToColornames(std::string value); + + std::string CurverenditionToStr(data_CURVERENDITION data); + data_CURVERENDITION StrToCurverendition(std::string value); + + std::string EnclosureToStr(data_ENCLOSURE data); + data_ENCLOSURE StrToEnclosure(std::string value); + + std::string FontstyleToStr(data_FONTSTYLE data); + data_FONTSTYLE StrToFontstyle(std::string value); + + std::string FontweightToStr(data_FONTWEIGHT data); + data_FONTWEIGHT StrToFontweight(std::string value); + + std::string GlissandoToStr(data_GLISSANDO data); + data_GLISSANDO StrToGlissando(std::string value); + + std::string GraceToStr(data_GRACE data); + data_GRACE StrToGrace(std::string value); + + std::string HorizontalalignmentToStr(data_HORIZONTALALIGNMENT data); + data_HORIZONTALALIGNMENT StrToHorizontalalignment(std::string value); + + std::string IneumeformToStr(data_INEUMEFORM data); + data_INEUMEFORM StrToIneumeform(std::string value); + + std::string IneumenameToStr(data_INEUMENAME data); + data_INEUMENAME StrToIneumename(std::string value); + + std::string LayerschemeToStr(data_LAYERSCHEME data); + data_LAYERSCHEME StrToLayerscheme(std::string value); + + std::string LigatureformToStr(data_LIGATUREFORM data); + data_LIGATUREFORM StrToLigatureform(std::string value); + + std::string LineformToStr(data_LINEFORM data); + data_LINEFORM StrToLineform(std::string value); + + std::string LinestartendsymbolToStr(data_LINESTARTENDSYMBOL data); + data_LINESTARTENDSYMBOL StrToLinestartendsymbol(std::string value); + + std::string LinewidthtermToStr(data_LINEWIDTHTERM data); + data_LINEWIDTHTERM StrToLinewidthterm(std::string value); + + std::string MelodicfunctionToStr(data_MELODICFUNCTION data); + data_MELODICFUNCTION StrToMelodicfunction(std::string value); + + std::string MensurationsignToStr(data_MENSURATIONSIGN data); + data_MENSURATIONSIGN StrToMensurationsign(std::string value); + + std::string MetersignToStr(data_METERSIGN data); + data_METERSIGN StrToMetersign(std::string value); + + std::string MidinamesToStr(data_MIDINAMES data); + data_MIDINAMES StrToMidinames(std::string value); + + std::string ModeToStr(data_MODE data); + data_MODE StrToMode(std::string value); + + std::string NotationtypeToStr(data_NOTATIONTYPE data); + data_NOTATIONTYPE StrToNotationtype(std::string value); + + std::string NoteheadmodifierListToStr(data_NOTEHEADMODIFIER_list data); + data_NOTEHEADMODIFIER_list StrToNoteheadmodifierList(std::string value); + + std::string OtherstaffToStr(data_OTHERSTAFF data); + data_OTHERSTAFF StrToOtherstaff(std::string value); + + std::string PlaceToStr(data_PLACE data); + data_PLACE StrToPlace(std::string value); + + std::string RotationdirectionToStr(data_ROTATIONDIRECTION data); + data_ROTATIONDIRECTION StrToRotationdirection(std::string value); + + std::string SizeToStr(data_SIZE data); + data_SIZE StrToSize(std::string value); + + std::string StaffrelToStr(data_STAFFREL data); + data_STAFFREL StrToStaffrel(std::string value); + + std::string StemmodifierToStr(data_STEMMODIFIER data); + data_STEMMODIFIER StrToStemmodifier(std::string value); + + std::string StempositionToStr(data_STEMPOSITION data); + data_STEMPOSITION StrToStemposition(std::string value); + + std::string TemperamentToStr(data_TEMPERAMENT data); + data_TEMPERAMENT StrToTemperament(std::string value); + + std::string TextrenditionlistToStr(data_TEXTRENDITIONLIST data); + data_TEXTRENDITIONLIST StrToTextrenditionlist(std::string value); + + std::string UneumeformToStr(data_UNEUMEFORM data); + data_UNEUMEFORM StrToUneumeform(std::string value); + + std::string UneumenameToStr(data_UNEUMENAME data); + data_UNEUMENAME StrToUneumename(std::string value); + + std::string AccidLogFuncToStr(accidLog_FUNC data); + accidLog_FUNC StrToAccidLogFunc(std::string value); + + std::string ArpegLogOrderToStr(arpegLog_ORDER data); + arpegLog_ORDER StrToArpegLogOrder(std::string value); + + std::string BTremLogFormToStr(bTremLog_FORM data); + bTremLog_FORM StrToBTremLogForm(std::string value); + + std::string BeamingVisBeamrendToStr(beamingVis_BEAMREND data); + beamingVis_BEAMREND StrToBeamingVisBeamrend(std::string value); + + std::string BeamrendFormToStr(beamrend_FORM data); + beamrend_FORM StrToBeamrendForm(std::string value); + + std::string CurvatureCurvedirToStr(curvature_CURVEDIR data); + curvature_CURVEDIR StrToCurvatureCurvedir(std::string value); + + std::string CutoutCutoutToStr(cutout_CUTOUT data); + cutout_CUTOUT StrToCutoutCutout(std::string value); + + std::string DotLogFormToStr(dotLog_FORM data); + dotLog_FORM StrToDotLogForm(std::string value); + + std::string EndingsEndingrendToStr(endings_ENDINGREND data); + endings_ENDINGREND StrToEndingsEndingrend(std::string value); + + std::string FTremLogFormToStr(fTremLog_FORM data); + fTremLog_FORM StrToFTremLogForm(std::string value); + + std::string FermataVisFormToStr(fermataVis_FORM data); + fermataVis_FORM StrToFermataVisForm(std::string value); + + std::string FermataVisShapeToStr(fermataVis_SHAPE data); + fermataVis_SHAPE StrToFermataVisShape(std::string value); + + std::string HairpinLogFormToStr(hairpinLog_FORM data); + hairpinLog_FORM StrToHairpinLogForm(std::string value); + + std::string HarmVisRendgridToStr(harmVis_RENDGRID data); + harmVis_RENDGRID StrToHarmVisRendgrid(std::string value); + + std::string HarpPedalLogAToStr(harpPedalLog_A data); + harpPedalLog_A StrToHarpPedalLogA(std::string value); + + std::string HarpPedalLogBToStr(harpPedalLog_B data); + harpPedalLog_B StrToHarpPedalLogB(std::string value); + + std::string HarpPedalLogCToStr(harpPedalLog_C data); + harpPedalLog_C StrToHarpPedalLogC(std::string value); + + std::string HarpPedalLogDToStr(harpPedalLog_D data); + harpPedalLog_D StrToHarpPedalLogD(std::string value); + + std::string HarpPedalLogEToStr(harpPedalLog_E data); + harpPedalLog_E StrToHarpPedalLogE(std::string value); + + std::string HarpPedalLogFToStr(harpPedalLog_F data); + harpPedalLog_F StrToHarpPedalLogF(std::string value); + + std::string HarpPedalLogGToStr(harpPedalLog_G data); + harpPedalLog_G StrToHarpPedalLogG(std::string value); + + std::string MeiversionMeiversionToStr(meiversion_MEIVERSION data); + meiversion_MEIVERSION StrToMeiversionMeiversion(std::string value); + + std::string MensurVisFormToStr(mensurVis_FORM data); + mensurVis_FORM StrToMensurVisForm(std::string value); + + std::string MensuralVisMensurformToStr(mensuralVis_MENSURFORM data); + mensuralVis_MENSURFORM StrToMensuralVisMensurform(std::string value); + + std::string MeterSigVisFormToStr(meterSigVis_FORM data); + meterSigVis_FORM StrToMeterSigVisForm(std::string value); + + std::string MeterSigDefaultVisMeterrendToStr(meterSigDefaultVis_METERREND data); + meterSigDefaultVis_METERREND StrToMeterSigDefaultVisMeterrend(std::string value); + + std::string MeterconformanceMetconToStr(meterconformance_METCON data); + meterconformance_METCON StrToMeterconformanceMetcon(std::string value); + + std::string MordentLogFormToStr(mordentLog_FORM data); + mordentLog_FORM StrToMordentLogForm(std::string value); + + std::string NoteLogMensuralLigToStr(noteLogMensural_LIG data); + noteLogMensural_LIG StrToNoteLogMensuralLig(std::string value); + + std::string OctaveLogCollToStr(octaveLog_COLL data); + octaveLog_COLL StrToOctaveLogColl(std::string value); + + std::string PbVisFoliumToStr(pbVis_FOLIUM data); + pbVis_FOLIUM StrToPbVisFolium(std::string value); + + std::string PedalLogDirToStr(pedalLog_DIR data); + pedalLog_DIR StrToPedalLogDir(std::string value); + + std::string PedalVisFormToStr(pedalVis_FORM data); + pedalVis_FORM StrToPedalVisForm(std::string value); + + std::string PianopedalsPedalstyleToStr(pianopedals_PEDALSTYLE data); + pianopedals_PEDALSTYLE StrToPianopedalsPedalstyle(std::string value); + + std::string PlistEvaluateToStr(plist_EVALUATE data); + plist_EVALUATE StrToPlistEvaluate(std::string value); + + std::string PointingXlinkactuateToStr(pointing_XLINKACTUATE data); + pointing_XLINKACTUATE StrToPointingXlinkactuate(std::string value); + + std::string PointingXlinkshowToStr(pointing_XLINKSHOW data); + pointing_XLINKSHOW StrToPointingXlinkshow(std::string value); + + std::string RegularmethodMethodToStr(regularmethod_METHOD data); + regularmethod_METHOD StrToRegularmethodMethod(std::string value); + + std::string RehearsalRehencloseToStr(rehearsal_REHENCLOSE data); + rehearsal_REHENCLOSE StrToRehearsalRehenclose(std::string value); + + std::string SbVisFormToStr(sbVis_FORM data); + sbVis_FORM StrToSbVisForm(std::string value); + + std::string StaffgroupingsymSymbolToStr(staffgroupingsym_SYMBOL data); + staffgroupingsym_SYMBOL StrToStaffgroupingsymSymbol(std::string value); + + std::string SylLogConToStr(sylLog_CON data); + sylLog_CON StrToSylLogCon(std::string value); + + std::string SylLogWordposToStr(sylLog_WORDPOS data); + sylLog_WORDPOS StrToSylLogWordpos(std::string value); + + std::string TupletVisNumformatToStr(tupletVis_NUMFORMAT data); + tupletVis_NUMFORMAT StrToTupletVisNumformat(std::string value); + + std::string TurnLogFormToStr(turnLog_FORM data); + turnLog_FORM StrToTurnLogForm(std::string value); + + std::string WhitespaceXmlspaceToStr(whitespace_XMLSPACE data); + whitespace_XMLSPACE StrToWhitespaceXmlspace(std::string value); + + +}; + +} // vrv namespace + +#endif // __VRV_LIBMEI_CONVERTER_H__ + diff --git a/libmei/libmei_def.h b/libmei/libmei_def.h new file mode 100644 index 00000000000..96c331bec78 --- /dev/null +++ b/libmei/libmei_def.h @@ -0,0 +1,1276 @@ +///////////////////////////////////////////////////////////////////////////// +// Authors: Laurent Pugin and Rodolfo Zitellini +// Created: 2014 +// Copyright (c) Authors and others. All rights reserved. +// +// Code generated using a modified version of libmei +// by Andrew Hankinson, Alastair Porter, and Others +///////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////// +// NOTE: this file was generated with the Verovio libmei version and +// should not be edited because changes will be lost. +///////////////////////////////////////////////////////////////////////////// + +#ifndef __VRV_ATT_DEF_H__ +#define __VRV_ATT_DEF_H__ + +//---------------------------------------------------------------------------- + +namespace vrv { + +/** + * MEI data.ACCIDENTAL.EXPLICIT + */ +enum data_ACCIDENTAL_EXPLICIT { + ACCIDENTAL_EXPLICIT_NONE = 0, + ACCIDENTAL_EXPLICIT_s, + ACCIDENTAL_EXPLICIT_f, + ACCIDENTAL_EXPLICIT_ss, + ACCIDENTAL_EXPLICIT_x, + ACCIDENTAL_EXPLICIT_ff, + ACCIDENTAL_EXPLICIT_xs, + ACCIDENTAL_EXPLICIT_ts, + ACCIDENTAL_EXPLICIT_tf, + ACCIDENTAL_EXPLICIT_n, + ACCIDENTAL_EXPLICIT_nf, + ACCIDENTAL_EXPLICIT_ns, + ACCIDENTAL_EXPLICIT_su, + ACCIDENTAL_EXPLICIT_sd, + ACCIDENTAL_EXPLICIT_fu, + ACCIDENTAL_EXPLICIT_fd, + ACCIDENTAL_EXPLICIT_nu, + ACCIDENTAL_EXPLICIT_nd, + ACCIDENTAL_EXPLICIT_1qf, + ACCIDENTAL_EXPLICIT_3qf, + ACCIDENTAL_EXPLICIT_1qs, + ACCIDENTAL_EXPLICIT_3qs, +}; + +/** + * MEI data.ACCIDENTAL.IMPLICIT + */ +enum data_ACCIDENTAL_IMPLICIT { + ACCIDENTAL_IMPLICIT_NONE = 0, + ACCIDENTAL_IMPLICIT_s, + ACCIDENTAL_IMPLICIT_f, + ACCIDENTAL_IMPLICIT_ss, + ACCIDENTAL_IMPLICIT_ff, + ACCIDENTAL_IMPLICIT_n, + ACCIDENTAL_IMPLICIT_su, + ACCIDENTAL_IMPLICIT_sd, + ACCIDENTAL_IMPLICIT_fu, + ACCIDENTAL_IMPLICIT_fd, +}; + +/** + * MEI data.ARTICULATION + */ +enum data_ARTICULATION { + ARTICULATION_NONE = 0, + ARTICULATION_acc, + ARTICULATION_stacc, + ARTICULATION_ten, + ARTICULATION_stacciss, + ARTICULATION_marc, + ARTICULATION_marc_stacc, + ARTICULATION_spicc, + ARTICULATION_doit, + ARTICULATION_scoop, + ARTICULATION_rip, + ARTICULATION_plop, + ARTICULATION_fall, + ARTICULATION_longfall, + ARTICULATION_bend, + ARTICULATION_flip, + ARTICULATION_smear, + ARTICULATION_shake, + ARTICULATION_dnbow, + ARTICULATION_upbow, + ARTICULATION_harm, + ARTICULATION_snap, + ARTICULATION_fingernail, + ARTICULATION_ten_stacc, + ARTICULATION_damp, + ARTICULATION_dampall, + ARTICULATION_open, + ARTICULATION_stop, + ARTICULATION_dbltongue, + ARTICULATION_trpltongue, + ARTICULATION_heel, + ARTICULATION_toe, + ARTICULATION_tap, + ARTICULATION_lhpizz, + ARTICULATION_dot, + ARTICULATION_stroke, +}; + +/** + * MEI data.BARPLACE + */ +enum data_BARPLACE { + BARPLACE_NONE = 0, + BARPLACE_mensur, + BARPLACE_staff, + BARPLACE_takt, +}; + +/** + * MEI data.BARRENDITION + */ +enum data_BARRENDITION { + BARRENDITION_NONE = 0, + BARRENDITION_dashed, + BARRENDITION_dotted, + BARRENDITION_dbl, + BARRENDITION_dbldashed, + BARRENDITION_dbldotted, + BARRENDITION_end, + BARRENDITION_invis, + BARRENDITION_rptstart, + BARRENDITION_rptboth, + BARRENDITION_rptend, + BARRENDITION_single, +}; + +/** + * MEI data.BETYPE + */ +enum data_BETYPE { + BETYPE_NONE = 0, + BETYPE_byte, + BETYPE_smil, + BETYPE_midi, + BETYPE_mmc, + BETYPE_mtc, + BETYPE_smpte_25, + BETYPE_smpte_24, + BETYPE_smpte_df30, + BETYPE_smpte_ndf30, + BETYPE_smpte_df29_97, + BETYPE_smpte_ndf29_97, + BETYPE_tcf, + BETYPE_time, +}; + +/** + * MEI data.BOOLEAN + */ +enum data_BOOLEAN { + BOOLEAN_NONE = 0, + BOOLEAN_true, + BOOLEAN_false, +}; + +/** + * MEI data.CERTAINTY + */ +enum data_CERTAINTY { + CERTAINTY_NONE = 0, + CERTAINTY_high, + CERTAINTY_medium, + CERTAINTY_low, + CERTAINTY_unknown, +}; + +/** + * MEI data.CLEFSHAPE + */ +enum data_CLEFSHAPE { + CLEFSHAPE_NONE = 0, + CLEFSHAPE_G, + CLEFSHAPE_GG, + CLEFSHAPE_F, + CLEFSHAPE_C, + CLEFSHAPE_perc, + CLEFSHAPE_TAB, +}; + +/** + * MEI data.CLUSTER + */ +enum data_CLUSTER { + CLUSTER_NONE = 0, + CLUSTER_white, + CLUSTER_black, + CLUSTER_chromatic, +}; + +/** + * MEI data.COLORNAMES + */ +enum data_COLORNAMES { + COLORNAMES_NONE = 0, + COLORNAMES_aqua, + COLORNAMES_black, + COLORNAMES_blue, + COLORNAMES_fuchsia, + COLORNAMES_gray, + COLORNAMES_green, + COLORNAMES_lime, + COLORNAMES_maroon, + COLORNAMES_navy, + COLORNAMES_olive, + COLORNAMES_purple, + COLORNAMES_red, + COLORNAMES_silver, + COLORNAMES_teal, + COLORNAMES_white, + COLORNAMES_yellow, +}; + +/** + * MEI data.CURVERENDITION + */ +enum data_CURVERENDITION { + CURVERENDITION_NONE = 0, + CURVERENDITION_narrow, + CURVERENDITION_medium, + CURVERENDITION_wide, + CURVERENDITION_dashed, + CURVERENDITION_dotted, +}; + +/** + * MEI data.ENCLOSURE + */ +enum data_ENCLOSURE { + ENCLOSURE_NONE = 0, + ENCLOSURE_paren, + ENCLOSURE_brack, +}; + +/** + * MEI data.FONTSTYLE + */ +enum data_FONTSTYLE { + FONTSTYLE_NONE = 0, + FONTSTYLE_italic, + FONTSTYLE_normal, + FONTSTYLE_oblique, +}; + +/** + * MEI data.FONTWEIGHT + */ +enum data_FONTWEIGHT { + FONTWEIGHT_NONE = 0, + FONTWEIGHT_bold, + FONTWEIGHT_normal, +}; + +/** + * MEI data.GLISSANDO + */ +enum data_GLISSANDO { + GLISSANDO_NONE = 0, + GLISSANDO_i, + GLISSANDO_m, + GLISSANDO_t, +}; + +/** + * MEI data.GRACE + */ +enum data_GRACE { + GRACE_NONE = 0, + GRACE_acc, + GRACE_unacc, + GRACE_unknown, +}; + +/** + * MEI data.HORIZONTALALIGNMENT + */ +enum data_HORIZONTALALIGNMENT { + HORIZONTALALIGNMENT_NONE = 0, + HORIZONTALALIGNMENT_left, + HORIZONTALALIGNMENT_right, + HORIZONTALALIGNMENT_center, + HORIZONTALALIGNMENT_justify, +}; + +/** + * MEI data.INEUMEFORM + */ +enum data_INEUMEFORM { + INEUMEFORM_NONE = 0, + INEUMEFORM_liquescent1, + INEUMEFORM_liquescent2, + INEUMEFORM_tied, + INEUMEFORM_tiedliquescent1, + INEUMEFORM_tiedliquescent2, +}; + +/** + * MEI data.INEUMENAME + */ +enum data_INEUMENAME { + INEUMENAME_NONE = 0, + INEUMENAME_pessubpunctis, + INEUMENAME_climacus, + INEUMENAME_scandicus, + INEUMENAME_bistropha, + INEUMENAME_tristropha, + INEUMENAME_pressusminor, + INEUMENAME_pressusmaior, +}; + +/** + * MEI data.LAYERSCHEME + */ +enum data_LAYERSCHEME { + LAYERSCHEME_NONE = 0, + LAYERSCHEME_1, + LAYERSCHEME_2o, + LAYERSCHEME_2f, + LAYERSCHEME_3o, + LAYERSCHEME_3f, +}; + +/** + * MEI data.LIGATUREFORM + */ +enum data_LIGATUREFORM { + LIGATUREFORM_NONE = 0, + LIGATUREFORM_recta, + LIGATUREFORM_obliqua, +}; + +/** + * MEI data.LINEFORM + */ +enum data_LINEFORM { + LINEFORM_NONE = 0, + LINEFORM_dashed, + LINEFORM_dotted, + LINEFORM_solid, + LINEFORM_wavy, +}; + +/** + * MEI data.LINESTARTENDSYMBOL + */ +enum data_LINESTARTENDSYMBOL { + LINESTARTENDSYMBOL_NONE = 0, + LINESTARTENDSYMBOL_angledown, + LINESTARTENDSYMBOL_angleup, + LINESTARTENDSYMBOL_angleright, + LINESTARTENDSYMBOL_angleleft, + LINESTARTENDSYMBOL_arrow, + LINESTARTENDSYMBOL_arrowopen, + LINESTARTENDSYMBOL_arrowwhite, + LINESTARTENDSYMBOL_harpoonleft, + LINESTARTENDSYMBOL_harpoonright, + LINESTARTENDSYMBOL_none, +}; + +/** + * MEI data.LINEWIDTHTERM + */ +enum data_LINEWIDTHTERM { + LINEWIDTHTERM_NONE = 0, + LINEWIDTHTERM_narrow, + LINEWIDTHTERM_medium, + LINEWIDTHTERM_wide, +}; + +/** + * MEI data.MELODICFUNCTION + */ +enum data_MELODICFUNCTION { + MELODICFUNCTION_NONE = 0, + MELODICFUNCTION_aln, + MELODICFUNCTION_ant, + MELODICFUNCTION_app, + MELODICFUNCTION_apt, + MELODICFUNCTION_arp, + MELODICFUNCTION_arp7, + MELODICFUNCTION_aun, + MELODICFUNCTION_chg, + MELODICFUNCTION_cln, + MELODICFUNCTION_ct, + MELODICFUNCTION_ct7, + MELODICFUNCTION_cun, + MELODICFUNCTION_cup, + MELODICFUNCTION_et, + MELODICFUNCTION_ln, + MELODICFUNCTION_ped, + MELODICFUNCTION_rep, + MELODICFUNCTION_ret, + MELODICFUNCTION_23ret, + MELODICFUNCTION_78ret, + MELODICFUNCTION_sus, + MELODICFUNCTION_43sus, + MELODICFUNCTION_98sus, + MELODICFUNCTION_76sus, + MELODICFUNCTION_un, + MELODICFUNCTION_un7, + MELODICFUNCTION_upt, + MELODICFUNCTION_upt7, +}; + +/** + * MEI data.MENSURATIONSIGN + */ +enum data_MENSURATIONSIGN { + MENSURATIONSIGN_NONE = 0, + MENSURATIONSIGN_C, + MENSURATIONSIGN_O, +}; + +/** + * MEI data.METERSIGN + */ +enum data_METERSIGN { + METERSIGN_NONE = 0, + METERSIGN_common, + METERSIGN_cut, +}; + +/** + * MEI data.MIDINAMES + */ +enum data_MIDINAMES { + MIDINAMES_NONE = 0, + MIDINAMES_Acoustic_Grand_Piano, + MIDINAMES_Bright_Acoustic_Piano, + MIDINAMES_Electric_Grand_Piano, + MIDINAMES_Honky_tonk_Piano, + MIDINAMES_Electric_Piano_1, + MIDINAMES_Electric_Piano_2, + MIDINAMES_Harpsichord, + MIDINAMES_Clavi, + MIDINAMES_Celesta, + MIDINAMES_Glockenspiel, + MIDINAMES_Music_Box, + MIDINAMES_Vibraphone, + MIDINAMES_Marimba, + MIDINAMES_Xylophone, + MIDINAMES_Tubular_Bells, + MIDINAMES_Dulcimer, + MIDINAMES_Drawbar_Organ, + MIDINAMES_Percussive_Organ, + MIDINAMES_Rock_Organ, + MIDINAMES_Church_Organ, + MIDINAMES_Reed_Organ, + MIDINAMES_Accordion, + MIDINAMES_Harmonica, + MIDINAMES_Tango_Accordion, + MIDINAMES_Acoustic_Guitar_nylon, + MIDINAMES_Acoustic_Guitar_steel, + MIDINAMES_Electric_Guitar_jazz, + MIDINAMES_Electric_Guitar_clean, + MIDINAMES_Electric_Guitar_muted, + MIDINAMES_Overdriven_Guitar, + MIDINAMES_Distortion_Guitar, + MIDINAMES_Guitar_harmonics, + MIDINAMES_Acoustic_Bass, + MIDINAMES_Electric_Bass_finger, + MIDINAMES_Electric_Bass_pick, + MIDINAMES_Fretless_Bass, + MIDINAMES_Slap_Bass_1, + MIDINAMES_Slap_Bass_2, + MIDINAMES_Synth_Bass_1, + MIDINAMES_Synth_Bass_2, + MIDINAMES_Violin, + MIDINAMES_Viola, + MIDINAMES_Cello, + MIDINAMES_Contrabass, + MIDINAMES_Tremolo_Strings, + MIDINAMES_Pizzicato_Strings, + MIDINAMES_Orchestral_Harp, + MIDINAMES_Timpani, + MIDINAMES_String_Ensemble_1, + MIDINAMES_String_Ensemble_2, + MIDINAMES_SynthStrings_1, + MIDINAMES_SynthStrings_2, + MIDINAMES_Choir_Aahs, + MIDINAMES_Voice_Oohs, + MIDINAMES_Synth_Voice, + MIDINAMES_Orchestra_Hit, + MIDINAMES_Trumpet, + MIDINAMES_Trombone, + MIDINAMES_Tuba, + MIDINAMES_Muted_Trumpet, + MIDINAMES_French_Horn, + MIDINAMES_Brass_Section, + MIDINAMES_SynthBrass_1, + MIDINAMES_SynthBrass_2, + MIDINAMES_Soprano_Sax, + MIDINAMES_Alto_Sax, + MIDINAMES_Tenor_Sax, + MIDINAMES_Baritone_Sax, + MIDINAMES_Oboe, + MIDINAMES_English_Horn, + MIDINAMES_Bassoon, + MIDINAMES_Clarinet, + MIDINAMES_Piccolo, + MIDINAMES_Flute, + MIDINAMES_Recorder, + MIDINAMES_Pan_Flute, + MIDINAMES_Blown_Bottle, + MIDINAMES_Shakuhachi, + MIDINAMES_Whistle, + MIDINAMES_Ocarina, + MIDINAMES_Lead_1_square, + MIDINAMES_Lead_2_sawtooth, + MIDINAMES_Lead_3_calliope, + MIDINAMES_Lead_4_chiff, + MIDINAMES_Lead_5_charang, + MIDINAMES_Lead_6_voice, + MIDINAMES_Lead_7_fifths, + MIDINAMES_Lead_8_bass_and_lead, + MIDINAMES_Pad_1_new_age, + MIDINAMES_Pad_2_warm, + MIDINAMES_Pad_3_polysynth, + MIDINAMES_Pad_4_choir, + MIDINAMES_Pad_5_bowed, + MIDINAMES_Pad_6_metallic, + MIDINAMES_Pad_7_halo, + MIDINAMES_Pad_8_sweep, + MIDINAMES_FX_1_rain, + MIDINAMES_FX_2_soundtrack, + MIDINAMES_FX_3_crystal, + MIDINAMES_FX_4_atmosphere, + MIDINAMES_FX_5_brightness, + MIDINAMES_FX_6_goblins, + MIDINAMES_FX_7_echoes, + MIDINAMES_FX_8_sci_fi, + MIDINAMES_Sitar, + MIDINAMES_Banjo, + MIDINAMES_Shamisen, + MIDINAMES_Koto, + MIDINAMES_Kalimba, + MIDINAMES_Bagpipe, + MIDINAMES_Fiddle, + MIDINAMES_Shanai, + MIDINAMES_Tinkle_Bell, + MIDINAMES_Agogo, + MIDINAMES_Steel_Drums, + MIDINAMES_Woodblock, + MIDINAMES_Taiko_Drum, + MIDINAMES_Melodic_Tom, + MIDINAMES_Synth_Drum, + MIDINAMES_Reverse_Cymbal, + MIDINAMES_Guitar_Fret_Noise, + MIDINAMES_Breath_Noise, + MIDINAMES_Seashore, + MIDINAMES_Bird_Tweet, + MIDINAMES_Telephone_Ring, + MIDINAMES_Helicopter, + MIDINAMES_Applause, + MIDINAMES_Gunshot, + MIDINAMES_Acoustic_Bass_Drum, + MIDINAMES_Bass_Drum_1, + MIDINAMES_Side_Stick, + MIDINAMES_Acoustic_Snare, + MIDINAMES_Hand_Clap, + MIDINAMES_Electric_Snare, + MIDINAMES_Low_Floor_Tom, + MIDINAMES_Closed_Hi_Hat, + MIDINAMES_High_Floor_Tom, + MIDINAMES_Pedal_Hi_Hat, + MIDINAMES_Low_Tom, + MIDINAMES_Open_Hi_Hat, + MIDINAMES_Low_Mid_Tom, + MIDINAMES_Hi_Mid_Tom, + MIDINAMES_Crash_Cymbal_1, + MIDINAMES_High_Tom, + MIDINAMES_Ride_Cymbal_1, + MIDINAMES_Chinese_Cymbal, + MIDINAMES_Ride_Bell, + MIDINAMES_Tambourine, + MIDINAMES_Splash_Cymbal, + MIDINAMES_Cowbell, + MIDINAMES_Crash_Cymbal_2, + MIDINAMES_Vibraslap, + MIDINAMES_Ride_Cymbal_2, + MIDINAMES_Hi_Bongo, + MIDINAMES_Low_Bongo, + MIDINAMES_Mute_Hi_Conga, + MIDINAMES_Open_Hi_Conga, + MIDINAMES_Low_Conga, + MIDINAMES_High_Timbale, + MIDINAMES_Low_Timbale, + MIDINAMES_High_Agogo, + MIDINAMES_Low_Agogo, + MIDINAMES_Cabasa, + MIDINAMES_Maracas, + MIDINAMES_Short_Whistle, + MIDINAMES_Long_Whistle, + MIDINAMES_Short_Guiro, + MIDINAMES_Long_Guiro, + MIDINAMES_Claves, + MIDINAMES_Hi_Wood_Block, + MIDINAMES_Low_Wood_Block, + MIDINAMES_Mute_Cuica, + MIDINAMES_Open_Cuica, + MIDINAMES_Mute_Triangle, + MIDINAMES_Open_Triangle, +}; + +/** + * MEI data.MODE + */ +enum data_MODE { + MODE_NONE = 0, + MODE_major, + MODE_minor, + MODE_dorian, + MODE_phrygian, + MODE_lydian, + MODE_mixolydian, + MODE_aeolian, + MODE_locrian, +}; + +/** + * MEI data.NOTATIONTYPE + */ +enum data_NOTATIONTYPE { + NOTATIONTYPE_NONE = 0, + NOTATIONTYPE_cmn, + NOTATIONTYPE_mensural, + NOTATIONTYPE_mensural_black, + NOTATIONTYPE_mensural_white, + NOTATIONTYPE_neume, + NOTATIONTYPE_tab, +}; + +/** + * MEI data.NOTEHEADMODIFIER.list + */ +enum data_NOTEHEADMODIFIER_list { + NOTEHEADMODIFIER_list_NONE = 0, + NOTEHEADMODIFIER_list_slash, + NOTEHEADMODIFIER_list_backslash, + NOTEHEADMODIFIER_list_vline, + NOTEHEADMODIFIER_list_hline, + NOTEHEADMODIFIER_list_centerdot, + NOTEHEADMODIFIER_list_paren, + NOTEHEADMODIFIER_list_brack, + NOTEHEADMODIFIER_list_box, + NOTEHEADMODIFIER_list_circle, + NOTEHEADMODIFIER_list_dblwhole, +}; + +/** + * MEI data.OTHERSTAFF + */ +enum data_OTHERSTAFF { + OTHERSTAFF_NONE = 0, + OTHERSTAFF_above, + OTHERSTAFF_below, +}; + +/** + * MEI data.PLACE + */ +enum data_PLACE { + PLACE_NONE = 0, + PLACE_above, + PLACE_below, +}; + +/** + * MEI data.ROTATIONDIRECTION + */ +enum data_ROTATIONDIRECTION { + ROTATIONDIRECTION_NONE = 0, + ROTATIONDIRECTION_none, + ROTATIONDIRECTION_down, + ROTATIONDIRECTION_left, + ROTATIONDIRECTION_ne, + ROTATIONDIRECTION_nw, + ROTATIONDIRECTION_se, + ROTATIONDIRECTION_sw, +}; + +/** + * MEI data.SIZE + */ +enum data_SIZE { + SIZE_NONE = 0, + SIZE_normal, + SIZE_cue, +}; + +/** + * MEI data.STAFFREL + */ +enum data_STAFFREL { + STAFFREL_NONE = 0, + STAFFREL_above, + STAFFREL_below, + STAFFREL_within, +}; + +/** + * MEI data.STEMMODIFIER + */ +enum data_STEMMODIFIER { + STEMMODIFIER_NONE = 0, + STEMMODIFIER_none, + STEMMODIFIER_1slash, + STEMMODIFIER_2slash, + STEMMODIFIER_3slash, + STEMMODIFIER_4slash, + STEMMODIFIER_5slash, + STEMMODIFIER_6slash, + STEMMODIFIER_sprech, + STEMMODIFIER_z, +}; + +/** + * MEI data.STEMPOSITION + */ +enum data_STEMPOSITION { + STEMPOSITION_NONE = 0, + STEMPOSITION_left, + STEMPOSITION_right, + STEMPOSITION_center, +}; + +/** + * MEI data.TEMPERAMENT + */ +enum data_TEMPERAMENT { + TEMPERAMENT_NONE = 0, + TEMPERAMENT_equal, + TEMPERAMENT_just, + TEMPERAMENT_mean, + TEMPERAMENT_pythagorean, +}; + +/** + * MEI data.TEXTRENDITIONLIST + */ +enum data_TEXTRENDITIONLIST { + TEXTRENDITIONLIST_NONE = 0, + TEXTRENDITIONLIST_xx_small, + TEXTRENDITIONLIST_x_small, + TEXTRENDITIONLIST_small, + TEXTRENDITIONLIST_medium, + TEXTRENDITIONLIST_large, + TEXTRENDITIONLIST_x_large, + TEXTRENDITIONLIST_xx_large, + TEXTRENDITIONLIST_smaller, + TEXTRENDITIONLIST_larger, + TEXTRENDITIONLIST_italic, + TEXTRENDITIONLIST_oblique, + TEXTRENDITIONLIST_smcaps, + TEXTRENDITIONLIST_bold, + TEXTRENDITIONLIST_bolder, + TEXTRENDITIONLIST_lighter, + TEXTRENDITIONLIST_box, + TEXTRENDITIONLIST_circle, + TEXTRENDITIONLIST_dbox, + TEXTRENDITIONLIST_tbox, + TEXTRENDITIONLIST_bslash, + TEXTRENDITIONLIST_fslash, + TEXTRENDITIONLIST_line_through, + TEXTRENDITIONLIST_none, + TEXTRENDITIONLIST_overline, + TEXTRENDITIONLIST_overstrike, + TEXTRENDITIONLIST_strike, + TEXTRENDITIONLIST_sub, + TEXTRENDITIONLIST_sup, + TEXTRENDITIONLIST_underline, + TEXTRENDITIONLIST_ltr, + TEXTRENDITIONLIST_rtl, + TEXTRENDITIONLIST_lro, + TEXTRENDITIONLIST_rlo, +}; + +/** + * MEI data.UNEUMEFORM + */ +enum data_UNEUMEFORM { + UNEUMEFORM_NONE = 0, + UNEUMEFORM_liquescent1, + UNEUMEFORM_liquescent2, + UNEUMEFORM_liquescent3, + UNEUMEFORM_quilismatic, + UNEUMEFORM_rectangular, + UNEUMEFORM_rhombic, + UNEUMEFORM_tied, +}; + +/** + * MEI data.UNEUMENAME + */ +enum data_UNEUMENAME { + UNEUMENAME_NONE = 0, + UNEUMENAME_punctum, + UNEUMENAME_virga, + UNEUMENAME_pes, + UNEUMENAME_clivis, + UNEUMENAME_torculus, + UNEUMENAME_torculusresupinus, + UNEUMENAME_porrectus, + UNEUMENAME_porrectusflexus, + UNEUMENAME_apostropha, + UNEUMENAME_oriscus, + UNEUMENAME_pressusmaior, + UNEUMENAME_pressusminor, + UNEUMENAME_virgastrata, +}; + +/** + * MEI att.accid.log-func + */ +enum accidLog_FUNC { + accidLog_FUNC_NONE = 0, + accidLog_FUNC_caution, + accidLog_FUNC_edit, +}; + +/** + * MEI att.arpeg.log-order + */ +enum arpegLog_ORDER { + arpegLog_ORDER_NONE = 0, + arpegLog_ORDER_up, + arpegLog_ORDER_down, + arpegLog_ORDER_nonarp, +}; + +/** + * MEI att.bTrem.log-form + */ +enum bTremLog_FORM { + bTremLog_FORM_NONE = 0, + bTremLog_FORM_meas, + bTremLog_FORM_unmeas, +}; + +/** + * MEI att.beaming.vis-beam.rend + */ +enum beamingVis_BEAMREND { + beamingVis_BEAMREND_NONE = 0, + beamingVis_BEAMREND_acc, + beamingVis_BEAMREND_rit, + beamingVis_BEAMREND_norm, +}; + +/** + * MEI att.beamrend-form + */ +enum beamrend_FORM { + beamrend_FORM_NONE = 0, + beamrend_FORM_acc, + beamrend_FORM_mixed, + beamrend_FORM_rit, + beamrend_FORM_norm, +}; + +/** + * MEI att.curvature-curvedir + */ +enum curvature_CURVEDIR { + curvature_CURVEDIR_NONE = 0, + curvature_CURVEDIR_above, + curvature_CURVEDIR_below, + curvature_CURVEDIR_mixed, +}; + +/** + * MEI att.cutout-cutout + */ +enum cutout_CUTOUT { + cutout_CUTOUT_NONE = 0, + cutout_CUTOUT_cutout, +}; + +/** + * MEI att.dot.log-form + */ +enum dotLog_FORM { + dotLog_FORM_NONE = 0, + dotLog_FORM_aug, + dotLog_FORM_div, +}; + +/** + * MEI att.endings-ending.rend + */ +enum endings_ENDINGREND { + endings_ENDINGREND_NONE = 0, + endings_ENDINGREND_top, + endings_ENDINGREND_barred, + endings_ENDINGREND_grouped, +}; + +/** + * MEI att.fTrem.log-form + */ +enum fTremLog_FORM { + fTremLog_FORM_NONE = 0, + fTremLog_FORM_meas, + fTremLog_FORM_unmeas, +}; + +/** + * MEI att.fermata.vis-form + */ +enum fermataVis_FORM { + fermataVis_FORM_NONE = 0, + fermataVis_FORM_inv, + fermataVis_FORM_norm, +}; + +/** + * MEI att.fermata.vis-shape + */ +enum fermataVis_SHAPE { + fermataVis_SHAPE_NONE = 0, + fermataVis_SHAPE_curved, + fermataVis_SHAPE_square, + fermataVis_SHAPE_angular, +}; + +/** + * MEI att.hairpin.log-form + */ +enum hairpinLog_FORM { + hairpinLog_FORM_NONE = 0, + hairpinLog_FORM_cres, + hairpinLog_FORM_dim, +}; + +/** + * MEI att.harm.vis-rendgrid + */ +enum harmVis_RENDGRID { + harmVis_RENDGRID_NONE = 0, + harmVis_RENDGRID_grid, + harmVis_RENDGRID_gridtext, + harmVis_RENDGRID_text, +}; + +/** + * MEI att.harpPedal.log-a + */ +enum harpPedalLog_A { + harpPedalLog_A_NONE = 0, + harpPedalLog_A_f, + harpPedalLog_A_n, + harpPedalLog_A_s, +}; + +/** + * MEI att.harpPedal.log-b + */ +enum harpPedalLog_B { + harpPedalLog_B_NONE = 0, + harpPedalLog_B_f, + harpPedalLog_B_n, + harpPedalLog_B_s, +}; + +/** + * MEI att.harpPedal.log-c + */ +enum harpPedalLog_C { + harpPedalLog_C_NONE = 0, + harpPedalLog_C_f, + harpPedalLog_C_n, + harpPedalLog_C_s, +}; + +/** + * MEI att.harpPedal.log-d + */ +enum harpPedalLog_D { + harpPedalLog_D_NONE = 0, + harpPedalLog_D_f, + harpPedalLog_D_n, + harpPedalLog_D_s, +}; + +/** + * MEI att.harpPedal.log-e + */ +enum harpPedalLog_E { + harpPedalLog_E_NONE = 0, + harpPedalLog_E_f, + harpPedalLog_E_n, + harpPedalLog_E_s, +}; + +/** + * MEI att.harpPedal.log-f + */ +enum harpPedalLog_F { + harpPedalLog_F_NONE = 0, + harpPedalLog_F_f, + harpPedalLog_F_n, + harpPedalLog_F_s, +}; + +/** + * MEI att.harpPedal.log-g + */ +enum harpPedalLog_G { + harpPedalLog_G_NONE = 0, + harpPedalLog_G_f, + harpPedalLog_G_n, + harpPedalLog_G_s, +}; + +/** + * MEI att.meiversion-meiversion + */ +enum meiversion_MEIVERSION { + meiversion_MEIVERSION_NONE = 0, + meiversion_MEIVERSION_3_0_0, +}; + +/** + * MEI att.mensur.vis-form + */ +enum mensurVis_FORM { + mensurVis_FORM_NONE = 0, + mensurVis_FORM_horizontal, + mensurVis_FORM_vertical, +}; + +/** + * MEI att.mensural.vis-mensur.form + */ +enum mensuralVis_MENSURFORM { + mensuralVis_MENSURFORM_NONE = 0, + mensuralVis_MENSURFORM_horizontal, + mensuralVis_MENSURFORM_vertical, +}; + +/** + * MEI att.meterSig.vis-form + */ +enum meterSigVis_FORM { + meterSigVis_FORM_NONE = 0, + meterSigVis_FORM_num, + meterSigVis_FORM_denomsym, + meterSigVis_FORM_norm, + meterSigVis_FORM_invis, +}; + +/** + * MEI att.meterSigDefault.vis-meter.rend + */ +enum meterSigDefaultVis_METERREND { + meterSigDefaultVis_METERREND_NONE = 0, + meterSigDefaultVis_METERREND_num, + meterSigDefaultVis_METERREND_denomsym, + meterSigDefaultVis_METERREND_norm, + meterSigDefaultVis_METERREND_invis, +}; + +/** + * MEI att.meterconformance-metcon + */ +enum meterconformance_METCON { + meterconformance_METCON_NONE = 0, + meterconformance_METCON_c, + meterconformance_METCON_i, + meterconformance_METCON_o, +}; + +/** + * MEI att.mordent.log-form + */ +enum mordentLog_FORM { + mordentLog_FORM_NONE = 0, + mordentLog_FORM_inv, + mordentLog_FORM_norm, +}; + +/** + * MEI att.note.log.mensural-lig + */ +enum noteLogMensural_LIG { + noteLogMensural_LIG_NONE = 0, + noteLogMensural_LIG_recta, + noteLogMensural_LIG_obliqua, +}; + +/** + * MEI att.octave.log-coll + */ +enum octaveLog_COLL { + octaveLog_COLL_NONE = 0, + octaveLog_COLL_coll, +}; + +/** + * MEI att.pb.vis-folium + */ +enum pbVis_FOLIUM { + pbVis_FOLIUM_NONE = 0, + pbVis_FOLIUM_verso, + pbVis_FOLIUM_recto, +}; + +/** + * MEI att.pedal.log-dir + */ +enum pedalLog_DIR { + pedalLog_DIR_NONE = 0, + pedalLog_DIR_down, + pedalLog_DIR_up, + pedalLog_DIR_half, + pedalLog_DIR_bounce, +}; + +/** + * MEI att.pedal.vis-form + */ +enum pedalVis_FORM { + pedalVis_FORM_NONE = 0, + pedalVis_FORM_line, + pedalVis_FORM_pedstar, + pedalVis_FORM_altpedstar, +}; + +/** + * MEI att.pianopedals-pedal.style + */ +enum pianopedals_PEDALSTYLE { + pianopedals_PEDALSTYLE_NONE = 0, + pianopedals_PEDALSTYLE_line, + pianopedals_PEDALSTYLE_pedstar, + pianopedals_PEDALSTYLE_altpedstar, +}; + +/** + * MEI att.plist-evaluate + */ +enum plist_EVALUATE { + plist_EVALUATE_NONE = 0, + plist_EVALUATE_all, + plist_EVALUATE_one, + plist_EVALUATE_none, +}; + +/** + * MEI att.pointing-xlink:actuate + */ +enum pointing_XLINKACTUATE { + pointing_XLINKACTUATE_NONE = 0, + pointing_XLINKACTUATE_onLoad, + pointing_XLINKACTUATE_onRequest, + pointing_XLINKACTUATE_none, + pointing_XLINKACTUATE_other, +}; + +/** + * MEI att.pointing-xlink:show + */ +enum pointing_XLINKSHOW { + pointing_XLINKSHOW_NONE = 0, + pointing_XLINKSHOW_new, + pointing_XLINKSHOW_replace, + pointing_XLINKSHOW_embed, + pointing_XLINKSHOW_none, + pointing_XLINKSHOW_other, +}; + +/** + * MEI att.regularmethod-method + */ +enum regularmethod_METHOD { + regularmethod_METHOD_NONE = 0, + regularmethod_METHOD_silent, + regularmethod_METHOD_tags, +}; + +/** + * MEI att.rehearsal-reh.enclose + */ +enum rehearsal_REHENCLOSE { + rehearsal_REHENCLOSE_NONE = 0, + rehearsal_REHENCLOSE_box, + rehearsal_REHENCLOSE_circle, + rehearsal_REHENCLOSE_none, +}; + +/** + * MEI att.sb.vis-form + */ +enum sbVis_FORM { + sbVis_FORM_NONE = 0, + sbVis_FORM_hash, +}; + +/** + * MEI att.staffgroupingsym-symbol + */ +enum staffgroupingsym_SYMBOL { + staffgroupingsym_SYMBOL_NONE = 0, + staffgroupingsym_SYMBOL_brace, + staffgroupingsym_SYMBOL_bracket, + staffgroupingsym_SYMBOL_bracketsq, + staffgroupingsym_SYMBOL_line, + staffgroupingsym_SYMBOL_none, +}; + +/** + * MEI att.syl.log-con + */ +enum sylLog_CON { + sylLog_CON_NONE = 0, + sylLog_CON_s, + sylLog_CON_d, + sylLog_CON_u, + sylLog_CON_t, + sylLog_CON_c, + sylLog_CON_v, + sylLog_CON_i, + sylLog_CON_b, +}; + +/** + * MEI att.syl.log-wordpos + */ +enum sylLog_WORDPOS { + sylLog_WORDPOS_NONE = 0, + sylLog_WORDPOS_i, + sylLog_WORDPOS_m, + sylLog_WORDPOS_t, +}; + +/** + * MEI att.tuplet.vis-num.format + */ +enum tupletVis_NUMFORMAT { + tupletVis_NUMFORMAT_NONE = 0, + tupletVis_NUMFORMAT_count, + tupletVis_NUMFORMAT_ratio, +}; + +/** + * MEI att.turn.log-form + */ +enum turnLog_FORM { + turnLog_FORM_NONE = 0, + turnLog_FORM_inv, + turnLog_FORM_norm, +}; + +/** + * MEI att.whitespace-xml:space + */ +enum whitespace_XMLSPACE { + whitespace_XMLSPACE_NONE = 0, + whitespace_XMLSPACE_default, + whitespace_XMLSPACE_preserve, +}; + + + +} // vrv namespace + +#endif // __VRV_ATT_DEF_H__ + diff --git a/src/att.cpp b/src/att.cpp index ab0d19e947f..bb7116e89af 100644 --- a/src/att.cpp +++ b/src/att.cpp @@ -23,7 +23,8 @@ namespace vrv { // Att //---------------------------------------------------------------------------- -Att::Att() +Att::Att(): + LibmeiConverter() { } @@ -61,143 +62,6 @@ int Att::StrToInt(std::string value) // Converters for writing and reading -std::string Att::AccidentalExplicitToStr(data_ACCIDENTAL_EXPLICIT data) -{ - std::string value; - switch(data) - { - case ACCIDENTAL_EXPLICIT_s : value = "s"; break; - case ACCIDENTAL_EXPLICIT_f : value = "f"; break; - case ACCIDENTAL_EXPLICIT_ss : value = "ss"; break; - case ACCIDENTAL_EXPLICIT_x : value = "x"; break; - case ACCIDENTAL_EXPLICIT_ff : value = "ff"; break; - case ACCIDENTAL_EXPLICIT_xs : value = "xs"; break; - case ACCIDENTAL_EXPLICIT_ts : value = "ts"; break; - case ACCIDENTAL_EXPLICIT_tf : value = "tf"; break; - case ACCIDENTAL_EXPLICIT_n : value = "n"; break; - case ACCIDENTAL_EXPLICIT_nf : value = "nf"; break; - case ACCIDENTAL_EXPLICIT_ns : value = "ns"; break; - case ACCIDENTAL_EXPLICIT_su : value = "su"; break; - case ACCIDENTAL_EXPLICIT_sd : value = "sd"; break; - case ACCIDENTAL_EXPLICIT_fu : value = "fu"; break; - case ACCIDENTAL_EXPLICIT_fd : value = "fd"; break; - case ACCIDENTAL_EXPLICIT_nu : value = "nu"; break; - case ACCIDENTAL_EXPLICIT_nd : value = "nd"; break; - default: - LogWarning("Unknown accidental explicit '%d'", data); - value = ""; - break; - } - return value; -} - -data_ACCIDENTAL_EXPLICIT Att::StrToAccidentalExplicit(std::string value) -{ - if (value == "s") return ACCIDENTAL_EXPLICIT_s; - else if (value == "f") return ACCIDENTAL_EXPLICIT_f; - else if (value == "ss") return ACCIDENTAL_EXPLICIT_ss; - else if (value == "x") return ACCIDENTAL_EXPLICIT_x; - else if (value == "ff") return ACCIDENTAL_EXPLICIT_ff; - else if (value == "xs") return ACCIDENTAL_EXPLICIT_xs; - else if (value == "ts") return ACCIDENTAL_EXPLICIT_ts; - else if (value == "tf") return ACCIDENTAL_EXPLICIT_tf; - else if (value == "n") return ACCIDENTAL_EXPLICIT_n; - else if (value == "nf") return ACCIDENTAL_EXPLICIT_nf; - else if (value == "ns") return ACCIDENTAL_EXPLICIT_ns; - else if (value == "su") return ACCIDENTAL_EXPLICIT_su; - else if (value == "sd") return ACCIDENTAL_EXPLICIT_sd; - else if (value == "fu") return ACCIDENTAL_EXPLICIT_fu; - else if (value == "fd") return ACCIDENTAL_EXPLICIT_fd; - else if (value == "nu") return ACCIDENTAL_EXPLICIT_nu; - else if (value == "nd") return ACCIDENTAL_EXPLICIT_nd; - else { - LogWarning("Unsupported accidental explicit '%s'", value.c_str() ); - } - return ACCIDENTAL_EXPLICIT_NONE; -} - -std::string Att::AccidentalImplicitToStr(data_ACCIDENTAL_IMPLICIT data) -{ - std::string value; - switch(data) - { - case ACCIDENTAL_IMPLICIT_s : value = "s"; break; - case ACCIDENTAL_IMPLICIT_f : value = "f"; break; - case ACCIDENTAL_IMPLICIT_ss : value = "ss"; break; - case ACCIDENTAL_IMPLICIT_ff : value = "ff"; break; - case ACCIDENTAL_IMPLICIT_n : value = "n"; break; - case ACCIDENTAL_IMPLICIT_su : value = "su"; break; - case ACCIDENTAL_IMPLICIT_sd : value = "sd"; break; - case ACCIDENTAL_IMPLICIT_fu : value = "fu"; break; - case ACCIDENTAL_IMPLICIT_fd : value = "fd"; break; - default: - LogWarning("Unknown accidental implicit '%d'", data); - value = ""; - break; - } - return value; -} - -data_ACCIDENTAL_IMPLICIT Att::StrToAccidentalImplicit(std::string value) -{ - if (value == "s") return ACCIDENTAL_IMPLICIT_s; - else if (value == "f") return ACCIDENTAL_IMPLICIT_f; - else if (value == "ss") return ACCIDENTAL_IMPLICIT_ss; - else if (value == "ff") return ACCIDENTAL_IMPLICIT_ff; - else if (value == "n") return ACCIDENTAL_IMPLICIT_n; - else if (value == "su") return ACCIDENTAL_IMPLICIT_su; - else if (value == "sd") return ACCIDENTAL_IMPLICIT_sd; - else if (value == "fu") return ACCIDENTAL_IMPLICIT_fu; - else if (value == "fd") return ACCIDENTAL_IMPLICIT_fd; - else { - LogWarning("Unsupported accidental implicit '%s'", value.c_str() ); - } - return ACCIDENTAL_IMPLICIT_NONE; -} - -std::string Att::BarRenditionToStr(data_BARRENDITION data) -{ - std::string value; - switch(data) - { - case BARRENDITION_dashed : value = "dashed"; break; - case BARRENDITION_dotted : value = "dotted"; break; - case BARRENDITION_dbl : value = "dbl"; break; - case BARRENDITION_dbldashed : value = "dbldashed"; break; - case BARRENDITION_dbldotted : value = "dbldotted"; break; - case BARRENDITION_end : value = "end"; break; - case BARRENDITION_invis : value = "invis"; break; - case BARRENDITION_rptstart : value = "rptstart"; break; - case BARRENDITION_rptboth : value = "rptboth"; break; - case BARRENDITION_rptend : value = "rptend"; break; - case BARRENDITION_single : value = "single"; break; - default: - LogWarning("Unknown bar rendition '%d'", data); - value = ""; - break; - } - return value; -} - -data_BARRENDITION Att::StrToBarRendition(std::string value) -{ - if (value == "dashed") return BARRENDITION_dashed; - else if (value == "dotted") return BARRENDITION_dotted; - else if (value == "dbl") return BARRENDITION_dbl; - else if (value == "dbldashed") return BARRENDITION_dbldashed; - else if (value == "dbldotted") return BARRENDITION_dbldotted; - else if (value == "end") return BARRENDITION_end; - else if (value == "invis") return BARRENDITION_invis; - else if (value == "rptstart") return BARRENDITION_rptstart; - else if (value == "rptboth") return BARRENDITION_rptboth; - else if (value == "rptend") return BARRENDITION_rptend; - else if (value == "single") return BARRENDITION_single; - else { - LogWarning("Unsupported bar rendition '%s'", value.c_str() ); - } - return BARRENDITION_NONE; -} - std::string Att::BeatrptRendToStr(data_BEATRPT_REND data) { std::string value; @@ -232,128 +96,9 @@ data_BEATRPT_REND Att::StrToBeatrptRend(std::string value) } return BEATRPT_REND_NONE; } - -std::string Att::BoolToStr(data_BOOLEAN data) -{ - std::string value; - switch(data) - { - case BOOLEAN_true : value = "true"; break; - case BOOLEAN_false : value = "false"; break; - default: - LogWarning("Unknown bool '%d'", data); - value = ""; - break; - } - return value; -} -data_BOOLEAN Att::StrToBool(std::string value) -{ - if (value == "true") return BOOLEAN_true; - else if (value == "false") return BOOLEAN_false; - else { - LogWarning("Unsupported bool '%s'", value.c_str() ); - } - return BOOLEAN_NONE; -} -std::string Att::ClefShapeToStr( data_CLEFSHAPE data ) -{ - std::string value; - switch(data) - { - case CLEFSHAPE_G : value = "G"; break; - case CLEFSHAPE_GG : value = "GG"; break; - case CLEFSHAPE_F : value = "F"; break; - case CLEFSHAPE_C : value = "C"; break; - case CLEFSHAPE_perc : value = "perc"; break; - case CLEFSHAPE_TAB : value = "TAB"; break; - default: - LogWarning("Unknown clef shape '%d'", data); - value = ""; - break; - } - return value; -} - -data_CLEFSHAPE Att::StrToClefShape( std::string value ) -{ - data_CLEFSHAPE data = CLEFSHAPE_NONE; - if ( value == "G" ) data = CLEFSHAPE_G; - else if ( value == "F" ) data = CLEFSHAPE_F; - else if ( value == "C" ) data = CLEFSHAPE_C; - else if ( value == "perc" ) data = CLEFSHAPE_perc; - else - { - LogWarning("Unsupported clef shape '%s'", value.c_str()); - } - return data; -} - -std::string Att::ConToStr(data_CON data) -{ - std::string value; - switch(data) - { - case CON_s : value = "s"; break; - case CON_d : value = "d"; break; - case CON_u : value = "u"; break; - case CON_t : value = "t"; break; - case CON_c : value = "c"; break; - case CON_v : value = "v"; break; - case CON_i : value = "i"; break; - case CON_b : value = "b"; break; - default: - LogWarning("Unknown con '%d'", data); - value = ""; - break; - } - return value; -} - -data_CON Att::StrToCon(std::string value) -{ - if (value == "s") return CON_s; - else if (value == "d") return CON_d; - else if (value == "u") return CON_u; - else if (value == "t") return CON_t; - else if (value == "c") return CON_c; - else if (value == "v") return CON_v; - else if (value == "i") return CON_i; - else if (value == "b") return CON_b; - else { - LogWarning("Unsupported con '%s'", value.c_str() ); - } - return CON_NONE; -} - -std::string Att::CurvedirToStr(data_CURVEDIR data) -{ - std::string value; - switch(data) - { - case CURVEDIR_above : value = "above"; break; - case CURVEDIR_below: value = "below"; break; - default: - LogWarning("Unknown curvedir '%d'", data); - value = ""; - break; - } - return value; -} - -data_CURVEDIR Att::StrToCurvedir(std::string value) -{ - if (value == "above") return CURVEDIR_above; - else if (value == "below") return CURVEDIR_below; - else { - LogWarning("Unsupported curvedir '%s'", value.c_str() ); - } - return CURVEDIR_NONE; -} - -std::string Att::DurToStr(data_DURATION data) +std::string Att::DurationToStr(data_DURATION data) { std::string value; if (data == DURATION_maxima) value = "maxima"; @@ -382,7 +127,7 @@ std::string Att::DurToStr(data_DURATION data) return value; } -data_DURATION Att::StrToDur(std::string value) +data_DURATION Att::StrToDuration(std::string value) { data_DURATION dur; if (value == "maxima") dur = DURATION_maxima; @@ -416,111 +161,7 @@ data_DURATION Att::StrToDur(std::string value) return dur; } -std::string Att::FontstyleToStr(data_FONTSTYLE data) -{ - std::string value; - switch(data) - { - case FONTSTYLE_italic : value = "italic"; break; - case FONTSTYLE_normal : value = "normal"; break; - case FONTSTYLE_oblique : value = "oblique"; break; - default: - LogWarning("Unknown fontstyle '%d'", data); - value = ""; - break; - } - return value; -} - -data_FONTSTYLE Att::StrToFontstyle(std::string value) -{ - if (value == "italic") return FONTSTYLE_italic; - else if (value == "normal") return FONTSTYLE_normal; - else if (value == "oblique") return FONTSTYLE_oblique; - else { - LogWarning("Unsupported fontstyle '%s'", value.c_str() ); - } - return FONTSTYLE_NONE; -} - -std::string Att::FontweightToStr(data_FONTWEIGHT data) -{ - std::string value; - switch(data) - { - case FONTWEIGHT_bold : value = "bold"; break; - case FONTWEIGHT_normal : value = "normal"; break; - default: - LogWarning("Unknown fontweight '%d'", data); - value = ""; - break; - } - return value; -} - -data_FONTWEIGHT Att::StrToFontweight(std::string value) -{ - if (value == "bold") return FONTWEIGHT_bold; - else if (value == "normal") return FONTWEIGHT_normal; - else { - LogWarning("Unsupported fontweight '%s'", value.c_str() ); - } - return FONTWEIGHT_NONE; -} - -std::string Att::FuncToStr(data_FUNC data) -{ - std::string value; - switch(data) - { - case FUNC_caution : value = "caution"; break; // - case FUNC_edit : value = "edit"; break; // - default: - LogWarning("Unknown func '%d'", data); - value = ""; - break; - } - return value; -} - -data_FUNC Att::StrToFunc(std::string value) -{ - if (value == "caution") return FUNC_caution; // - else if (value == "edit") return FUNC_edit; // - else { - LogWarning("Unknown func '%s'", value.c_str() ); - } - return FUNC_NONE; -} - -std::string Att::GraceToStr(data_GRACE data) -{ - std::string value; - switch(data) - { - case GRACE_acc : value = "acc"; break; - case GRACE_unacc : value = "unacc"; break; - case GRACE_unknown : value = "unknown"; break; - default: - LogWarning("Unknown grace '%d'", data); - value = ""; - break; - } - return value; -} - -data_GRACE Att::StrToGrace(std::string value) -{ - if (value == "acc") return GRACE_acc; - else if (value == "unacc") return GRACE_unacc; - else if (value == "unknown") return GRACE_unknown; - else { - LogWarning("Unsupported grace '%s'", value.c_str() ); - } - return GRACE_NONE; -} - -std::string Att::KeySignatureToStr(data_KEYSIGNATURE data) +std::string Att::KeysignatureToStr(data_KEYSIGNATURE data) { std::string value; switch(data) @@ -549,7 +190,7 @@ std::string Att::KeySignatureToStr(data_KEYSIGNATURE data) return value; } -data_KEYSIGNATURE Att::StrToKeySignature(std::string value) +data_KEYSIGNATURE Att::StrToKeysignature(std::string value) { if (value == "7f") return KEYSIGNATURE_7f; else if (value == "6f") return KEYSIGNATURE_6f; @@ -572,152 +213,6 @@ data_KEYSIGNATURE Att::StrToKeySignature(std::string value) } return KEYSIGNATURE_NONE; } - -std::string Att::LayerschemeToStr(data_LAYERSCHEME data) -{ - std::string value; - switch(data) - { - case LAYERSCHEME_1 : value = "1"; break; - case LAYERSCHEME_2o : value = "2o"; break; - case LAYERSCHEME_2f : value = "2f"; break; - case LAYERSCHEME_3o : value = "3o"; break; - case LAYERSCHEME_3f : value = "3f"; break; - default: - LogWarning("Unknown layerscheme '%d'", data); - value = ""; - break; - } - return value; -} - -data_LAYERSCHEME Att::StrToLayerscheme(std::string value) -{ - if (value == "1") return LAYERSCHEME_1; - else if (value == "2o") return LAYERSCHEME_2o; - else if (value == "2f") return LAYERSCHEME_2f; - else if (value == "3o") return LAYERSCHEME_3o; - else if (value == "3f") return LAYERSCHEME_3f; - else { - LogWarning("Unsupported layerscheme '%s'", value.c_str() ); - } - return LAYERSCHEME_NONE; -} - -std::string Att::LigatureToStr(data_LIGATURE data) -{ - std::string value; - switch(data) - { - case LIGATURE_recta : value = "recta"; break; - case LIGATURE_obliqua : value = "obliqua"; break; - default: - LogWarning("Unknown ligature '%d'", data); - value = ""; - break; - } - return value; -} - -data_LIGATURE Att::StrToLigature(std::string value) -{ - if (value == "recta") return LIGATURE_recta; - else if (value == "obliqua") return LIGATURE_obliqua; - else { - LogWarning("Unsupported ligature '%s'", value.c_str() ); - } - return LIGATURE_NONE; -} - -std::string Att::MensurationSignToStr( data_MENSURATIONSIGN data ) -{ - std::string value; - switch(data) - { - case MENSURATIONSIGN_C : value = "C"; break; - case MENSURATIONSIGN_O : value = "O"; break; - default: - LogWarning("Unknown mensur sign '%d'", data); - value = ""; - break; - } - return value; -} - -data_MENSURATIONSIGN Att::StrToMensurationSign(std::string value) -{ - if (value == "C") return MENSURATIONSIGN_C; - else if (value == "O") return MENSURATIONSIGN_O; - else { - LogWarning("Unsupported mensur sign '%s'", value.c_str() ); - } - // default - return MENSURATIONSIGN_C; -} - -std::string Att::MeterSignToStr(data_METERSIGN data) -{ - std::string value; - switch(data) - { - case METERSIGN_common : value = "common"; break; - case METERSIGN_cut : value = "cut"; break; - default: - LogWarning("Unknown meter sign '%d'", data); - value = ""; - break; - } - return value; -} - -data_METERSIGN Att::StrToMeterSign(std::string value) -{ - if (value == "common") return METERSIGN_common; - else if (value == "cut") return METERSIGN_cut; - else { - LogWarning("Unsupported meter sign '%s'", value.c_str() ); - } - // default - return METERSIGN_NONE; -} - -std::string Att::ModeToStr(data_MODE data) -{ - std::string value; - switch(data) - { - case MODE_major : value = "major"; break; - case MODE_minor : value = "minor"; break; - case MODE_dorian : value = "dorian"; break; - case MODE_phrygian : value = "phrygian"; break; - case MODE_lydian : value = "lydian"; break; - case MODE_mixolydian : value = "mixolydian"; break; - case MODE_aeolian : value = "aeolian"; break; - case MODE_locrian : value = "locrian"; break; - default: - LogWarning("Unknown mode '%d'", data); - value = ""; - break; - } - return value; -} - -data_MODE Att::StrToMode(std::string value) -{ - if (value == "major") return MODE_major; - else if (value == "minor") return MODE_minor; - else if (value == "dorian") return MODE_dorian; - else if (value == "phrygian") return MODE_phrygian; - else if (value == "lydian") return MODE_lydian; - else if (value == "mixolydian") return MODE_mixolydian; - else if (value == "aeolian") return MODE_aeolian; - else if (value == "locrian") return MODE_locrian; - else { - LogWarning("Unsupported mode '%s'", value.c_str() ); - } - // default - return MODE_NONE; -} std::string Att::ModusmaiorToStr(data_MODUSMAIOR data) { @@ -771,49 +266,40 @@ data_MODUSMINOR Att::StrToModusminor(std::string value) return MODUSMINOR_NONE; } -std::string Att::NumformatToStr(data_NUMFORMAT data) +std::string Att::PitchnameToStr(data_PITCHNAME data) { std::string value; switch(data) { - case NUMFORMAT_count : value = "count"; break; - case NUMFORMAT_ratio : value = "ratio"; break; + case PITCHNAME_c : value = "c"; break; + case PITCHNAME_d : value = "d"; break; + case PITCHNAME_e : value = "e"; break; + case PITCHNAME_f : value = "f"; break; + case PITCHNAME_g : value = "g"; break; + case PITCHNAME_a : value = "a"; break; + case PITCHNAME_b : value = "b"; break; default: - LogWarning("Unknown numformat '%d'", data); + LogWarning("Unknown pitch name '%d'", data); value = ""; break; } return value; } -data_NUMFORMAT Att::StrToNumformat(std::string value) +data_PITCHNAME Att::StrToPitchname(std::string value) { - if (value == "count") return NUMFORMAT_count; - else if (value == "ratio") return NUMFORMAT_ratio; + if (value == "c") return PITCHNAME_c; + else if (value == "d") return PITCHNAME_d; + else if (value == "e") return PITCHNAME_e; + else if (value == "f") return PITCHNAME_f; + else if (value == "g") return PITCHNAME_g; + else if (value == "a") return PITCHNAME_a; + else if (value == "b") return PITCHNAME_b; else { - LogWarning("Unsupported numformat '%s'", value.c_str() ); + LogWarning("Unsupported pitch name '%s'", value.c_str() ); } // default - return NUMFORMAT_NONE; -} - -std::string Att::PercentToStr( data_PERCENT data) -{ - return StringFormat("%d%%", data); -} - -data_PERCENT Att::StrToPercent(std::string value) -{ - int percent = atoi( std::string( value.begin(), value.end() - 1 ).c_str() ); - if (percent > 1000) { - LogWarning("Percent cannot be greater than 1000%"); - return 100; - } - else if (percent < 1) { - LogWarning("Percent has to be greater than 0%"); - return 100; - } - return percent; + return PITCHNAME_NONE; } std::string Att::OctaveDisToStr( data_OCTAVE_DIS data ) @@ -859,78 +345,16 @@ std::string Att::OrientationToStr(data_ORIENTATION data) } return value; } - + data_ORIENTATION Att::StrToOrientation(std::string value) { - if (value == "reversed") return ORIENTATION_reversed; - else if (value == "90CW") return ORIENTATION_90CW; - else if (value == "90CCW") return ORIENTATION_90CCW; - else { - LogWarning("Unsupported orientation '%s'", value.c_str() ); - } - return ORIENTATION_NONE; -} - -std::string Att::PitchNameToStr(data_PITCHNAME data) -{ - std::string value; - switch(data) - { - case PITCHNAME_c : value = "c"; break; - case PITCHNAME_d : value = "d"; break; - case PITCHNAME_e : value = "e"; break; - case PITCHNAME_f : value = "f"; break; - case PITCHNAME_g : value = "g"; break; - case PITCHNAME_a : value = "a"; break; - case PITCHNAME_b : value = "b"; break; - default: - LogWarning("Unknown pitch name '%d'", data); - value = ""; - break; - } - return value; -} - -data_PITCHNAME Att::StrToPitchName(std::string value) -{ - if (value == "c") return PITCHNAME_c; - else if (value == "d") return PITCHNAME_d; - else if (value == "e") return PITCHNAME_e; - else if (value == "f") return PITCHNAME_f; - else if (value == "g") return PITCHNAME_g; - else if (value == "a") return PITCHNAME_a; - else if (value == "b") return PITCHNAME_b; - else { - LogWarning("Unsupported pitch name '%s'", value.c_str() ); - } - // default - return PITCHNAME_NONE; -} - -std::string Att::PlaceToStr( data_PLACE data ) -{ - std::string value; - switch(data) - { - case PLACE_above : value = "above"; break; - case PLACE_below : value = "below"; break; - default: - LogWarning("Unknown place '%d'", data); - value = ""; - break; - } - return value; -} - -data_PLACE Att::StrToPlace(std::string value) -{ - if (value == "below") return PLACE_below; - else if (value == "above") return PLACE_above; + if (value == "reversed") return ORIENTATION_reversed; + else if (value == "90CW") return ORIENTATION_90CW; + else if (value == "90CCW") return ORIENTATION_90CCW; else { - LogWarning("Unsupported place '%s'", value.c_str() ); + LogWarning("Unsupported orientation '%s'", value.c_str() ); } - // default - return PLACE_NONE; + return ORIENTATION_NONE; } std::string Att::ProlatioToStr(data_PROLATIO data) @@ -959,151 +383,33 @@ data_PROLATIO Att::StrToProlatio(std::string value) return PROLATIO_NONE; } -std::string Att::StaffRelToStr( data_STAFFREL data ) +std::string Att::TempusToStr(data_TEMPUS data) { std::string value; switch(data) { - case STAFFREL_above : value = "above"; break; - case STAFFREL_below : value = "below"; break; - case STAFFREL_within : value = "within"; break; + case TEMPUS_2 : value = "2"; break; + case TEMPUS_3 : value = "3"; break; default: - LogWarning("Unknown staff rel '%d'", data); + LogWarning("Unknown tempus '%d'", data); value = ""; break; } return value; } -data_STAFFREL Att::StrToStaffRel(std::string value) +data_TEMPUS Att::StrToTempus(std::string value) { - if (value == "below") return STAFFREL_below; - else if (value == "above") return STAFFREL_above; - else if (value == "within") return STAFFREL_within; + if (value == "2") return TEMPUS_2; + else if (value == "3") return TEMPUS_3; else { - LogWarning("Unsupported staff rel '%s'", value.c_str() ); + LogWarning("Unsupported tempus '%s'", value.c_str() ); } // default - return STAFFREL_NONE; -} - - -std::string Att::StemDirectionToStr(data_STEMDIRECTION data) -{ - std::string value; - switch(data) - { - case STEMDIRECTION_up : value = "up"; break; - case STEMDIRECTION_down : value = "down"; break; - default: - LogWarning("Unknown stem direction '%d'", data); - value = ""; - break; - } - return value; -} - -data_STEMDIRECTION Att::StrToStemDirection(std::string value) -{ - if (value == "up") return STEMDIRECTION_up; - else if (value == "down") return STEMDIRECTION_down; - else { - LogWarning("Unsupported stem direction '%s'", value.c_str() ); - } - return STEMDIRECTION_NONE; -} - -std::string Att::StemModifierToStr(data_STEMMODIFIER data) -{ - std::string value; - switch(data) - { - case STEMMODIFIER_1slash : value = "1slash"; break; - case STEMMODIFIER_2slash : value = "2slash"; break; - case STEMMODIFIER_3slash : value = "3slash"; break; - case STEMMODIFIER_4slash : value = "4slash"; break; - case STEMMODIFIER_5slash : value = "5slash"; break; - case STEMMODIFIER_6slash : value = "6slash"; break; - case STEMMODIFIER_sprech : value = "sprech"; break; - case STEMMODIFIER_z : value = "z"; break; - default: - LogWarning("Unknown mode '%d'", data); - value = ""; - break; - } - return value; -} - -data_STEMMODIFIER Att::StrToStemModifier(std::string value) -{ - if (value == "1slash") return STEMMODIFIER_1slash; - else if (value == "2slash") return STEMMODIFIER_2slash; - else if (value == "3slash") return STEMMODIFIER_3slash; - else if (value == "4slash") return STEMMODIFIER_4slash; - else if (value == "5slash") return STEMMODIFIER_5slash; - else if (value == "6slash") return STEMMODIFIER_6slash; - else if (value == "sprech") return STEMMODIFIER_sprech; - else if (value == "z") return STEMMODIFIER_z; - else { - LogWarning("Unsupported pitch name '%s'", value.c_str() ); - } - return STEMMODIFIER_NONE; -} - -std::string Att::StemPositionToStr(data_STEMPOSITION data) -{ - std::string value; - switch(data) - { - case STEMPOSITION_left : value = "left"; break; - case STEMPOSITION_right : value = "right"; break; - case STEMPOSITION_center : value = "center"; break; - default: - LogWarning("Unknown stem position '%d'", data); - value = ""; - break; - } - return value; -} - -data_STEMPOSITION Att::StrToStemPosition(std::string value) -{ - if (value == "left") return STEMPOSITION_left; - else if (value == "right") return STEMPOSITION_right; - else if (value == "center") return STEMPOSITION_center; - else { - LogWarning("Unsupported stem position '%s'", value.c_str() ); - } - return STEMPOSITION_NONE; -} - -std::string Att::SymbolToStr(data_SYMBOL data) -{ - std::string value; - switch(data) - { - case SYMBOL_brace : value = "brace"; break; - case SYMBOL_bracket: value = "bracket"; break; - case SYMBOL_line: value = "line"; break; - default: - LogWarning("Unknown symbol '%d'", data); - value = ""; - break; - } - return value; -} - -data_SYMBOL Att::StrToSymbol(std::string value) -{ - if (value == "brace") return SYMBOL_brace; - else if (value == "bracket") return SYMBOL_bracket; - else if (value == "line") return SYMBOL_line; - else { - LogWarning("Unsupported symbol '%s'", value.c_str() ); - } - return SYMBOL_NONE; + return TEMPUS_NONE; } - + + std::string Att::TieToStr(data_TIE data) { std::string value; @@ -1130,69 +436,42 @@ data_TIE Att::StrToTie(std::string value) } return TIE_NONE; } - -std::string Att::TempusToStr(data_TEMPUS data) + + +std::string Att::StemdirectionToStr(data_STEMDIRECTION data) { std::string value; switch(data) { - case TEMPUS_2 : value = "2"; break; - case TEMPUS_3 : value = "3"; break; + case STEMDIRECTION_up : value = "up"; break; + case STEMDIRECTION_down : value = "down"; break; default: - LogWarning("Unknown tempus '%d'", data); + LogWarning("Unknown stem direction '%d'", data); value = ""; break; } return value; } -data_TEMPUS Att::StrToTempus(std::string value) +data_STEMDIRECTION Att::StrToStemdirection(std::string value) { - if (value == "2") return TEMPUS_2; - else if (value == "3") return TEMPUS_3; + if (value == "up") return STEMDIRECTION_up; + else if (value == "down") return STEMDIRECTION_down; else { - LogWarning("Unsupported tempus '%s'", value.c_str() ); + LogWarning("Unsupported stem direction '%s'", value.c_str() ); } - // default - return TEMPUS_NONE; + return STEMDIRECTION_NONE; } -std::string Att::Tstamp2ToStr(typedef_TSTAMP2 data) +std::string Att::MeasurebeatToStr(data_MEASUREBEAT data) { return "0m0.0"; } -typedef_TSTAMP2 Att::StrToTstamp2(std::string value) +data_MEASUREBEAT Att::StrToMeasurebeat(std::string value) { return std::make_pair(0, 1.0); } - -std::string Att::WordPosToStr(data_WORDPOS data) -{ - std::string value; - switch(data) - { - case WORDPOS_i : value = "i"; break; - case WORDPOS_m : value = "m"; break; - case WORDPOS_t : value = "t"; break; - default: - LogWarning("Unknown word pos '%d'", data); - value = ""; - break; - } - return value; -} - -data_WORDPOS Att::StrToWordPos(std::string value) -{ - if (value == "i") return WORDPOS_i; - else if (value == "m") return WORDPOS_m; - else if (value == "t") return WORDPOS_t; - else { - LogWarning("Unsupported word pos '%s'", value.c_str() ); - } - return WORDPOS_NONE; -} //---------------------------------------------------------------------------- // AttComparison diff --git a/src/iomusxml.cpp b/src/iomusxml.cpp index 42b618dc0ee..bcf28e2fd2b 100644 --- a/src/iomusxml.cpp +++ b/src/iomusxml.cpp @@ -351,9 +351,9 @@ bool MusicXmlInput::ReadMusicXml(pugi::xml_node root) StaffGrp *staffGrp = new StaffGrp(); // read the group-symbol (MEI @symbol) std::string groupGymbol = GetContentOfChild(xpathNode.node(), "group-symbol"); - if (groupGymbol == "bracket") staffGrp->SetSymbol(SYMBOL_bracket); - else if (groupGymbol == "brace") staffGrp->SetSymbol(SYMBOL_brace); - else if (groupGymbol == "line") staffGrp->SetSymbol(SYMBOL_line); + if (groupGymbol == "bracket") staffGrp->SetSymbol(staffgroupingsym_SYMBOL_bracket); + else if (groupGymbol == "brace") staffGrp->SetSymbol(staffgroupingsym_SYMBOL_brace); + else if (groupGymbol == "line") staffGrp->SetSymbol(staffgroupingsym_SYMBOL_line); // now stack it m_staffGrpStack.back()->AddStaffGrp(staffGrp); m_staffGrpStack.push_back(staffGrp); @@ -379,7 +379,7 @@ bool MusicXmlInput::ReadMusicXml(pugi::xml_node root) // if we have more than one staff in the part we create a new staffGrp if (nbStaves > 1) { partStaffGrp->SetLabel(partName); - partStaffGrp->SetSymbol(SYMBOL_brace); + partStaffGrp->SetSymbol(staffgroupingsym_SYMBOL_brace); partStaffGrp->SetBarthru(BOOLEAN_true); m_staffGrpStack.back()->AddStaffGrp(partStaffGrp); } @@ -481,7 +481,7 @@ int MusicXmlInput::ReadMusicXmlPartAttributesAsStaffDef(pugi::xml_node node, Sta clefSign = it->select_single_node("clef/sign"); } if (clefSign && HasContent(clefSign.node())) { - staffDef->SetClefShape(staffDef->AttCleffingLog::StrToClefShape(GetContent(clefSign.node()))); + staffDef->SetClefShape(staffDef->AttCleffingLog::StrToClefshape(GetContent(clefSign.node()))); } // clef line pugi::xpath_node clefLine; @@ -505,7 +505,7 @@ int MusicXmlInput::ReadMusicXmlPartAttributesAsStaffDef(pugi::xml_node node, Sta std::string value; if (key < 0) value = StringFormat("%df", abs(key)); else value = StringFormat("%ds", key); - staffDef->SetKeySig(staffDef->AttKeySigDefaultLog::StrToKeySignature(value)); + staffDef->SetKeySig(staffDef->AttKeySigDefaultLog::StrToKeysignature(value)); } // time pugi::xpath_node time; @@ -517,7 +517,7 @@ int MusicXmlInput::ReadMusicXmlPartAttributesAsStaffDef(pugi::xml_node node, Sta if (time) { pugi::xpath_node symbol = time.node().select_single_node("symbol"); if (symbol && HasContent(symbol.node())) { - staffDef->SetMeterSym(staffDef->AttMeterSigDefaultVis::StrToMeterSign(symbol.node().text().as_string())); + staffDef->SetMeterSym(staffDef->AttMeterSigDefaultVis::StrToMetersign(symbol.node().text().as_string())); } pugi::xpath_node beats = time.node().select_single_node("beats"); if (beats && HasContent(beats.node())) { @@ -610,7 +610,7 @@ void MusicXmlInput::ReadMusicXmlAttributes(pugi::xml_node node, Measure *measure pugi::xpath_node clefLine = clef.node().select_single_node("line"); if (clefSign && clefLine) { Clef *meiClef = new Clef(); - meiClef->SetShape(meiClef->AttClefshape::StrToClefShape(GetContent(clefSign.node()))); + meiClef->SetShape(meiClef->AttClefshape::StrToClefshape(GetContent(clefSign.node()))); meiClef->SetLine(meiClef->AttClefshape::StrToInt(clefLine.node().text().as_string())); AddLayerElement(layer, meiClef); } @@ -782,14 +782,14 @@ void MusicXmlInput::ReadMusicXmlNote(pugi::xml_node node, Measure *measure, int verse->SetN(lyricNumber); Syl *syl = new Syl(); if (lyric.select_single_node("extend")) { - syl->SetCon(CON_u); + syl->SetCon(sylLog_CON_u); } if (GetContentOfChild(lyric, "syllabic") == "begin") { - syl->SetCon(CON_d); - syl->SetWordpos(WORDPOS_i); + syl->SetCon(sylLog_CON_d); + syl->SetWordpos(sylLog_WORDPOS_i); } else if (GetContentOfChild(lyric, "syllabic") == "end") { - syl->SetWordpos(WORDPOS_t); + syl->SetWordpos(sylLog_WORDPOS_t); } syl->SetText(UTF8to16(textStr.c_str())); @@ -837,8 +837,8 @@ void MusicXmlInput::ReadMusicXmlNote(pugi::xml_node node, Measure *measure, int if (HasAttributeWithValue(slur, "type", "start")) { Slur *meiSlur = new Slur(); // placement - if (HasAttributeWithValue(slur, "placement", "above")) meiSlur->SetCurvedir(CURVEDIR_above); - else if (HasAttributeWithValue(slur, "placement", "below")) meiSlur->SetCurvedir(CURVEDIR_below); + if (HasAttributeWithValue(slur, "placement", "above")) meiSlur->SetCurvedir(curvature_CURVEDIR_above); + else if (HasAttributeWithValue(slur, "placement", "below")) meiSlur->SetCurvedir(curvature_CURVEDIR_below); // add it to the stack m_floatingElements.push_back(std::make_pair(measureNb, meiSlur)); OpenSlur(staff, layer, slurNumber, element, meiSlur); diff --git a/src/syl.cpp b/src/syl.cpp index f4ca020d865..0c72cce8cfc 100644 --- a/src/syl.cpp +++ b/src/syl.cpp @@ -73,21 +73,21 @@ int Syl::PrepareLyrics( ArrayPtrVoid *params ) // At this stage currentSyl is actually the previous one that is ending here if ((*currentSyl)) { // The previous syl was an initial or median -> The note we just parsed is the end - if (((*currentSyl)->GetWordpos() == WORDPOS_i) || ((*currentSyl)->GetWordpos() == WORDPOS_m)) { + if (((*currentSyl)->GetWordpos() == sylLog_WORDPOS_i) || ((*currentSyl)->GetWordpos() == sylLog_WORDPOS_m)) { (*currentSyl)->SetEnd(*lastNote); } // The previous syl was a underscore -> the previous but one was the end - else if ((*currentSyl)->GetCon() == CON_u) { + else if ((*currentSyl)->GetCon() == sylLog_CON_u) { (*currentSyl)->SetEnd(*lastButOneNote); } } // Now decide what to do with the starting syl and check if it has a forward connector - if ((this->GetWordpos() == WORDPOS_i) || (this->GetWordpos() == WORDPOS_m)) { + if ((this->GetWordpos() == sylLog_WORDPOS_i) || (this->GetWordpos() == sylLog_WORDPOS_m)) { (*currentSyl) = this; return FUNCTOR_CONTINUE; } - else if (this->GetCon() == CON_u) { + else if (this->GetCon() == sylLog_CON_u) { (*currentSyl) = this; return FUNCTOR_CONTINUE; } diff --git a/src/view_element.cpp b/src/view_element.cpp index c114f49ebb3..6ae8adc7406 100644 --- a/src/view_element.cpp +++ b/src/view_element.cpp @@ -172,7 +172,7 @@ void View::DrawAccid( DeviceContext *dc, LayerElement *element, Layer *layer, St /************** editorial accidental **************/ - if ( accid->GetFunc() == FUNC_edit ) { + if ( accid->GetFunc() == accidLog_FUNC_edit ) { // position is currently only above the staff int y = staff->GetDrawingY(); // look at the note position and adjust it if necessary @@ -1214,7 +1214,7 @@ void View::DrawNote ( DeviceContext *dc, LayerElement *element, Layer *layer, St if (note->m_drawingAccid) { xAccid = xNote; - if (note->m_drawingAccid->GetFunc() != FUNC_edit) { + if (note->m_drawingAccid->GetFunc() != accidLog_FUNC_edit) { xAccid -= 1.5 * m_doc->GetGlyphWidth(SMUFL_E262_accidentalSharp, staffSize, drawingCueSize); } diff --git a/src/view_floating.cpp b/src/view_floating.cpp index a5c74a8f20e..d1678a44dd3 100644 --- a/src/view_floating.cpp +++ b/src/view_floating.cpp @@ -253,7 +253,7 @@ void View::DrawSlur( DeviceContext *dc, Slur *slur, int x1, int x2, Staff *staff // first should be the tie @curvedir if (slur->HasCurvedir()) { - up = (slur->GetCurvedir() == CURVEDIR_above) ? true : false; + up = (slur->GetCurvedir() == curvature_CURVEDIR_above) ? true : false; } // then layer direction trumps note direction else if (layer1 && layer1->GetDrawingStemDir() != STEMDIRECTION_NONE){ @@ -841,7 +841,7 @@ void View::DrawTie( DeviceContext *dc, Tie *tie, int x1, int x2, Staff *staff, // first should be the tie @curvedir if (tie->HasCurvedir()) { - up = (tie->GetCurvedir() == CURVEDIR_above) ? true : false; + up = (tie->GetCurvedir() == curvature_CURVEDIR_above) ? true : false; } // then layer direction trumps note direction else if (layer1 && layer1->GetDrawingStemDir() != STEMDIRECTION_NONE){ @@ -971,7 +971,7 @@ void View::DrawSylConnector( DeviceContext *dc, Syl *syl, int x1, int x2, Staff void View::DrawSylConnectorLines( DeviceContext *dc, int x1, int x2, int y, Syl *syl, Staff *staff ) { - if (syl->GetCon() == CON_d) { + if (syl->GetCon() == sylLog_CON_d) { y += m_doc->GetDrawingUnit(staff->m_drawingStaffSize) * 2 / 3; // x position of the syl is two units back @@ -1006,7 +1006,7 @@ void View::DrawSylConnectorLines( DeviceContext *dc, int x1, int x2, int y, Syl } } - else if (syl->GetCon() == CON_u) { + else if (syl->GetCon() == sylLog_CON_u) { x1 += (int)m_doc->GetDrawingUnit(staff->m_drawingStaffSize) / 2; DrawFullRectangle(dc, x1, y, x2, y + m_doc->GetDrawingBarLineWidth(staff->m_drawingStaffSize)); } diff --git a/src/view_mensural.cpp b/src/view_mensural.cpp index 86090600be1..b7782ee1ab7 100644 --- a/src/view_mensural.cpp +++ b/src/view_mensural.cpp @@ -88,7 +88,7 @@ void View::DrawMensuralNote ( DeviceContext *dc, LayerElement *element, Layer *l /************** Noteheads: **************/ // Ligature, maxima,longa, brevis, and semibrevis - if ((note->GetLig()!=LIGATURE_NONE) && (drawingDur <= DUR_1)) { + if ((note->GetLig() != noteLogMensural_LIG_NONE) && (drawingDur <= DUR_1)) { DrawLigature ( dc, noteY, element, layer, staff); } else if (drawingDur < DUR_1) { diff --git a/src/view_page.cpp b/src/view_page.cpp index 84f223b73f0..54473c51417 100644 --- a/src/view_page.cpp +++ b/src/view_page.cpp @@ -321,17 +321,17 @@ void View::DrawStaffGrp( DeviceContext *dc, Measure *measure, StaffGrp *staffGrp } // actually draw the line, the brace or the bracket - if ( topStaffGrp && ( (firstDef != lastDef) || (staffGrp->GetSymbol() != SYMBOL_NONE) ) ) { + if ( topStaffGrp && ( (firstDef != lastDef) || (staffGrp->GetSymbol() != staffgroupingsym_SYMBOL_NONE) ) ) { DrawVerticalLine( dc , y_top, y_bottom, x, barLineWidth); } // this will need to be changed with the next version of MEI will line means additional thick line - if ( staffGrp->GetSymbol() == SYMBOL_line ) { + if ( staffGrp->GetSymbol() == staffgroupingsym_SYMBOL_line ) { DrawVerticalLine( dc , y_top, y_bottom, x, barLineWidth); } - else if ( staffGrp->GetSymbol() == SYMBOL_brace ) { + else if ( staffGrp->GetSymbol() == staffgroupingsym_SYMBOL_brace ) { DrawBrace ( dc, x, y_top, y_bottom, last->m_drawingStaffSize ); } - else if ( staffGrp->GetSymbol() == SYMBOL_bracket ) { + else if ( staffGrp->GetSymbol() == staffgroupingsym_SYMBOL_bracket ) { DrawBracket( dc, x, y_top, y_bottom, last->m_drawingStaffSize ); x -= 2 * m_doc->GetDrawingBeamWidth(100, false) - m_doc->GetDrawingBeamWhiteWidth(100, false); } From 853d83477d135b834231f2e17c3abacff8415e67 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 11 Dec 2015 17:52:33 +0100 Subject: [PATCH 012/217] Fixing staffDef / staffGrp label bug --- src/iomei.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/iomei.cpp b/src/iomei.cpp index 6cb459f9af9..7a2f7167b51 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -465,6 +465,7 @@ bool MeiOutput::WriteMeiStaffGrp( pugi::xml_node currentNode, StaffGrp *staffGrp currentNode.append_attribute( "xml:id" ) = UuidToMeiStr( staffGrp ).c_str(); staffGrp->WriteCommon(currentNode); + staffGrp->WriteCommonPart(currentNode); staffGrp->WriteLabelsAddl(currentNode); staffGrp->WriteStaffgroupingsym(currentNode); staffGrp->WriteStaffGrpVis(currentNode); @@ -479,6 +480,7 @@ bool MeiOutput::WriteMeiStaffDef( pugi::xml_node currentNode, StaffDef *staffDef currentNode.append_attribute( "xml:id" ) = UuidToMeiStr( staffDef ).c_str(); staffDef->WriteCommon(currentNode); + staffDef->WriteCommonPart(currentNode); staffDef->WriteLabelsAddl(currentNode); staffDef->WriteScalable(currentNode); staffDef->WriteStaffDefVis(currentNode); @@ -1366,6 +1368,7 @@ bool MeiInput::ReadMeiStaffGrp( Object *parent, pugi::xml_node staffGrp ) SetMeiUuid( staffGrp, vrvStaffGrp ); vrvStaffGrp->ReadCommon(staffGrp); + vrvStaffGrp->ReadCommonPart(staffGrp); vrvStaffGrp->ReadLabelsAddl(staffGrp); vrvStaffGrp->ReadStaffGrpVis(staffGrp); vrvStaffGrp->ReadStaffgroupingsym(staffGrp); @@ -1416,6 +1419,7 @@ bool MeiInput::ReadMeiStaffDef( Object *parent, pugi::xml_node staffDef ) SetMeiUuid( staffDef, vrvStaffDef ); vrvStaffDef->ReadCommon(staffDef); + vrvStaffDef->ReadCommonPart(staffDef); vrvStaffDef->ReadLabelsAddl(staffDef); vrvStaffDef->ReadScalable(staffDef); vrvStaffDef->ReadStaffDefVis(staffDef); From 8df7d8921ea5f43bba4826d4ce7b7af3dd330921 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 11 Dec 2015 18:30:17 +0100 Subject: [PATCH 013/217] Renaming files --- Verovio.xcodeproj/project.pbxproj | 40 +- include/vrv/att.h | 4 +- .../vrv/{att_comparison.h => attcomparison.h} | 0 include/vrv/attdef.h | 6 +- include/vrv/object.h | 2 +- libmei/{libmei_classes.h => attclasses.h} | 0 ...{libmei_converter.cpp => attconverter.cpp} | 805 ++++++++---------- libmei/{libmei_converter.h => attconverter.h} | 12 +- libmei/{libmei_def.h => atttypes.h} | 98 +-- src/att.cpp | 2 +- src/doc.cpp | 2 +- src/iomusxml.cpp | 2 +- src/layerelement.cpp | 2 +- src/page.cpp | 2 +- src/view_floating.cpp | 2 +- src/view_page.cpp | 2 +- 16 files changed, 446 insertions(+), 535 deletions(-) rename include/vrv/{att_comparison.h => attcomparison.h} (100%) rename libmei/{libmei_classes.h => attclasses.h} (100%) rename libmei/{libmei_converter.cpp => attconverter.cpp} (77%) rename libmei/{libmei_converter.h => attconverter.h} (98%) rename libmei/{libmei_def.h => atttypes.h} (94%) diff --git a/Verovio.xcodeproj/project.pbxproj b/Verovio.xcodeproj/project.pbxproj index 60069691d94..a0404ef59cd 100644 --- a/Verovio.xcodeproj/project.pbxproj +++ b/Verovio.xcodeproj/project.pbxproj @@ -29,6 +29,7 @@ 4D4221061998A8CE00963292 /* atts_mensural.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEE29031940BCC100C76319 /* atts_mensural.cpp */; }; 4D4221071998A8CE00963292 /* atts_mensural.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEE29031940BCC100C76319 /* atts_mensural.cpp */; }; 4D43C30C1A9BB22A00EA28F3 /* view_mensural.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D43C30B1A9BB22A00EA28F3 /* view_mensural.cpp */; }; + 4D50B53A1C1B40C90081D56E /* atttypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D50B5391C1B40C90081D56E /* atttypes.h */; }; 4D543E221B80AACF004B823C /* view_floating.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D543E211B80AACF004B823C /* view_floating.cpp */; }; 4D763EC61987D04E003FCAB5 /* metersig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D763EC51987D04D003FCAB5 /* metersig.cpp */; }; 4D763EC71987D04E003FCAB5 /* metersig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D763EC51987D04D003FCAB5 /* metersig.cpp */; }; @@ -89,11 +90,10 @@ 4DF9D2831C18DC490069E8C8 /* atts_mei.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DF9D2811C18DC490069E8C8 /* atts_mei.cpp */; }; 4DF9D2841C18DC490069E8C8 /* atts_mei.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DF9D2811C18DC490069E8C8 /* atts_mei.cpp */; }; 4DF9D2851C18DC490069E8C8 /* atts_mei.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DF9D2821C18DC490069E8C8 /* atts_mei.h */; }; - 4DF9D28E1C19C4A10069E8C8 /* libmei_classes.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DF9D28C1C19C4A10069E8C8 /* libmei_classes.h */; }; - 4DF9D28F1C19C4A10069E8C8 /* libmei_def.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DF9D28D1C19C4A10069E8C8 /* libmei_def.h */; }; - 4DF9D2921C1ADCC80069E8C8 /* libmei_converter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DF9D2901C1ADCC80069E8C8 /* libmei_converter.cpp */; }; - 4DF9D2931C1ADCC80069E8C8 /* libmei_converter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DF9D2901C1ADCC80069E8C8 /* libmei_converter.cpp */; }; - 4DF9D2941C1ADCC80069E8C8 /* libmei_converter.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DF9D2911C1ADCC80069E8C8 /* libmei_converter.h */; }; + 4DF9D2991C1B3F0A0069E8C8 /* attclasses.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DF9D2951C1B3F0A0069E8C8 /* attclasses.h */; }; + 4DF9D29A1C1B3F0A0069E8C8 /* attconverter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DF9D2961C1B3F0A0069E8C8 /* attconverter.cpp */; }; + 4DF9D29B1C1B3F0A0069E8C8 /* attconverter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DF9D2961C1B3F0A0069E8C8 /* attconverter.cpp */; }; + 4DF9D29C1C1B3F0A0069E8C8 /* attconverter.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DF9D2971C1B3F0A0069E8C8 /* attconverter.h */; }; 8F086EE2188539540037FD8E /* aligner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F086EB6188539540037FD8E /* aligner.cpp */; }; 8F086EE4188539540037FD8E /* barline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F086EB8188539540037FD8E /* barline.cpp */; }; 8F086EE5188539540037FD8E /* bboxdevicecontext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F086EB9188539540037FD8E /* bboxdevicecontext.cpp */; }; @@ -246,12 +246,13 @@ 4D422100199805E400963292 /* attdef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = attdef.h; path = include/vrv/attdef.h; sourceTree = ""; }; 4D422103199805F700963292 /* att.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = att.cpp; path = src/att.cpp; sourceTree = ""; }; 4D43C30B1A9BB22A00EA28F3 /* view_mensural.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = view_mensural.cpp; path = src/view_mensural.cpp; sourceTree = ""; }; + 4D50B5391C1B40C90081D56E /* atttypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = atttypes.h; path = libmei/atttypes.h; sourceTree = ""; }; 4D543E211B80AACF004B823C /* view_floating.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = view_floating.cpp; path = src/view_floating.cpp; sourceTree = ""; }; 4D763EC51987D04D003FCAB5 /* metersig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = metersig.cpp; path = src/metersig.cpp; sourceTree = ""; }; 4D763EC81987D067003FCAB5 /* metersig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = metersig.h; path = include/vrv/metersig.h; sourceTree = ""; }; 4D797B041A67C55F007637BD /* devicecontextbase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = devicecontextbase.h; path = include/vrv/devicecontextbase.h; sourceTree = ""; }; 4D798CBC1B8AEDBA007281CA /* drawinginterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = drawinginterface.cpp; path = src/drawinginterface.cpp; sourceTree = ""; }; - 4D9234F11A586AE100763251 /* att_comparison.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = att_comparison.h; path = include/vrv/att_comparison.h; sourceTree = ""; }; + 4D9234F11A586AE100763251 /* attcomparison.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = attcomparison.h; path = include/vrv/attcomparison.h; sourceTree = ""; }; 4D983004192E959E00320037 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = tools/main.cpp; sourceTree = SOURCE_ROOT; }; 4D9A9C16199F560200028D93 /* verse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = verse.h; path = include/vrv/verse.h; sourceTree = ""; }; 4D9A9C18199F561200028D93 /* verse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = verse.cpp; path = src/verse.cpp; sourceTree = ""; }; @@ -323,10 +324,9 @@ 4DF9D2871C18DE270069E8C8 /* atts_performance.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = atts_performance.h; path = libmei/atts_performance.h; sourceTree = ""; }; 4DF9D2881C18DE270069E8C8 /* atts_usersymbols.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = atts_usersymbols.cpp; path = libmei/atts_usersymbols.cpp; sourceTree = ""; }; 4DF9D2891C18DE270069E8C8 /* atts_usersymbols.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = atts_usersymbols.h; path = libmei/atts_usersymbols.h; sourceTree = ""; }; - 4DF9D28C1C19C4A10069E8C8 /* libmei_classes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = libmei_classes.h; path = libmei/libmei_classes.h; sourceTree = ""; }; - 4DF9D28D1C19C4A10069E8C8 /* libmei_def.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = libmei_def.h; path = libmei/libmei_def.h; sourceTree = ""; }; - 4DF9D2901C1ADCC80069E8C8 /* libmei_converter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = libmei_converter.cpp; path = libmei/libmei_converter.cpp; sourceTree = ""; }; - 4DF9D2911C1ADCC80069E8C8 /* libmei_converter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = libmei_converter.h; path = libmei/libmei_converter.h; sourceTree = ""; }; + 4DF9D2951C1B3F0A0069E8C8 /* attclasses.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = attclasses.h; path = libmei/attclasses.h; sourceTree = ""; }; + 4DF9D2961C1B3F0A0069E8C8 /* attconverter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = attconverter.cpp; path = libmei/attconverter.cpp; sourceTree = ""; }; + 4DF9D2971C1B3F0A0069E8C8 /* attconverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = attconverter.h; path = libmei/attconverter.h; sourceTree = ""; }; 8F086EA9188534680037FD8E /* Verovio */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Verovio; sourceTree = BUILT_PRODUCTS_DIR; }; 8F086EB6188539540037FD8E /* aligner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = aligner.cpp; path = src/aligner.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 8F086EB8188539540037FD8E /* barline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = barline.cpp; path = src/barline.cpp; sourceTree = ""; }; @@ -481,6 +481,10 @@ 4DEE28EC1940BCA100C76319 /* libmei */ = { isa = PBXGroup; children = ( + 4DF9D2951C1B3F0A0069E8C8 /* attclasses.h */, + 4DF9D2961C1B3F0A0069E8C8 /* attconverter.cpp */, + 4DF9D2971C1B3F0A0069E8C8 /* attconverter.h */, + 4D50B5391C1B40C90081D56E /* atttypes.h */, 4DEE28ED1940BCC100C76319 /* atts_analysis.cpp */, 4DEE28EE1940BCC100C76319 /* atts_analysis.h */, 4DEE28EF1940BCC100C76319 /* atts_cmn.cpp */, @@ -519,10 +523,6 @@ 4DEE290C1940BCC100C76319 /* atts_tablature.h */, 4DF9D2881C18DE270069E8C8 /* atts_usersymbols.cpp */, 4DF9D2891C18DE270069E8C8 /* atts_usersymbols.h */, - 4DF9D28C1C19C4A10069E8C8 /* libmei_classes.h */, - 4DF9D2901C1ADCC80069E8C8 /* libmei_converter.cpp */, - 4DF9D2911C1ADCC80069E8C8 /* libmei_converter.h */, - 4DF9D28D1C19C4A10069E8C8 /* libmei_def.h */, ); name = libmei; sourceTree = ""; @@ -577,7 +577,7 @@ 8F59290D18854BF800FE51AD /* aligner.h */, 4D422103199805F700963292 /* att.cpp */, 4D4220FF199805E400963292 /* att.h */, - 4D9234F11A586AE100763251 /* att_comparison.h */, + 4D9234F11A586AE100763251 /* attcomparison.h */, 4D422100199805E400963292 /* attdef.h */, 8F086EBD188539540037FD8E /* doc.cpp */, 8F59291418854BF800FE51AD /* doc.h */, @@ -726,14 +726,16 @@ 4D9C53111B52E4AE0003C6EC /* checked.h in Headers */, 8F59293418854BF800FE51AD /* aligner.h in Headers */, 8F59293618854BF800FE51AD /* barline.h in Headers */, + 4D50B53A1C1B40C90081D56E /* atttypes.h in Headers */, 8F59293718854BF800FE51AD /* bboxdevicecontext.h in Headers */, 8F59293818854BF800FE51AD /* beam.h in Headers */, + 4DF9D29C1C1B3F0A0069E8C8 /* attconverter.h in Headers */, 8F59293918854BF800FE51AD /* clef.h in Headers */, 4D1D733E1A1D08CD001E08F6 /* glyph.h in Headers */, 8F59293A18854BF800FE51AD /* devicecontext.h in Headers */, 8F59293B18854BF800FE51AD /* doc.h in Headers */, - 4DF9D2941C1ADCC80069E8C8 /* libmei_converter.h in Headers */, 8F59293C18854BF800FE51AD /* durationinterface.h in Headers */, + 4DF9D2991C1B3F0A0069E8C8 /* attclasses.h in Headers */, 8F59293D18854BF800FE51AD /* toolkit.h in Headers */, 4D1D733C1A1D0390001E08F6 /* smufl.h in Headers */, 4DB726C81B8BB0F30040231B /* trem.h in Headers */, @@ -760,12 +762,10 @@ 8F59294E18854BF800FE51AD /* positioninterface.h in Headers */, 8F59294F18854BF800FE51AD /* rest.h in Headers */, 4DF289FD1A7545CC00BA9F7D /* timeinterface.h in Headers */, - 4DF9D28E1C19C4A10069E8C8 /* libmei_classes.h in Headers */, 8F59295018854BF800FE51AD /* scoredef.h in Headers */, 4DB726C31B8B9F540040231B /* rpt.h in Headers */, 8F59295118854BF800FE51AD /* slur.h in Headers */, 8F59295218854BF800FE51AD /* staff.h in Headers */, - 4DF9D28F1C19C4A10069E8C8 /* libmei_def.h in Headers */, 8F59295318854BF800FE51AD /* svgdevicecontext.h in Headers */, 8F59295518854BF800FE51AD /* system.h in Headers */, 8F59295618854BF800FE51AD /* tie.h in Headers */, @@ -914,7 +914,6 @@ 8F086EFF188539540037FD8E /* slur.cpp in Sources */, 8F086F00188539540037FD8E /* staff.cpp in Sources */, 8F086F01188539540037FD8E /* svgdevicecontext.cpp in Sources */, - 4DF9D2921C1ADCC80069E8C8 /* libmei_converter.cpp in Sources */, 4DA80D961A6ACF5D0089802D /* style.cpp in Sources */, 8F086F03188539540037FD8E /* system.cpp in Sources */, 4D20B5EC1B873A1300EA9EC3 /* scoredefinterface.cpp in Sources */, @@ -940,6 +939,7 @@ 4D4221061998A8CE00963292 /* atts_mensural.cpp in Sources */, 4D9A9C19199F561200028D93 /* verse.cpp in Sources */, 4DF289FF1A7545E500BA9F7D /* timeinterface.cpp in Sources */, + 4DF9D29A1C1B3F0A0069E8C8 /* attconverter.cpp in Sources */, 4D1D73401A1D08DC001E08F6 /* glyph.cpp in Sources */, 4D9A9C1E19A1DE2000028D93 /* syl.cpp in Sources */, 4DA3FCD319B61DB300CBDFE6 /* atts_cmn.cpp in Sources */, @@ -981,7 +981,6 @@ 4D798CBE1B8AEDBA007281CA /* drawinginterface.cpp in Sources */, 8F3DD34818854B2E0051330C /* mensur.cpp in Sources */, 8F3DD34A18854B2E0051330C /* multirest.cpp in Sources */, - 4DF9D2931C1ADCC80069E8C8 /* libmei_converter.cpp in Sources */, 8F3DD34C18854B2E0051330C /* note.cpp in Sources */, 4D8CD8A71B4E927300F0756F /* atts_critapp.cpp in Sources */, 8F3DD34E18854B2E0051330C /* pitchinterface.cpp in Sources */, @@ -1008,6 +1007,7 @@ 8F3DD32218854AFB0051330C /* svgdevicecontext.cpp in Sources */, 4DCA95D91A515D0E008AD7E9 /* editorial.cpp in Sources */, 4DA80D971A6ACF5D0089802D /* style.cpp in Sources */, + 4DF9D29B1C1B3F0A0069E8C8 /* attconverter.cpp in Sources */, 4D22C41A18890E6100D0831F /* mrest.cpp in Sources */, 4D22C4271889214C00D0831F /* pugixml.cpp in Sources */, 4D763EC71987D04E003FCAB5 /* metersig.cpp in Sources */, diff --git a/include/vrv/att.h b/include/vrv/att.h index 9f6778c0390..57425935b0f 100644 --- a/include/vrv/att.h +++ b/include/vrv/att.h @@ -13,7 +13,7 @@ //---------------------------------------------------------------------------- #include "vrvdef.h" -#include "libmei_converter.h" +#include "attconverter.h" namespace vrv { @@ -28,7 +28,7 @@ class Object; * It is not an abstract class but it should not be instanciated directly. * The att classes are generated with the libmei parser for Verovio. */ -class Att: public LibmeiConverter +class Att: public AttConverter { public: /** @name Constructors and destructor */ diff --git a/include/vrv/att_comparison.h b/include/vrv/attcomparison.h similarity index 100% rename from include/vrv/att_comparison.h rename to include/vrv/attcomparison.h diff --git a/include/vrv/attdef.h b/include/vrv/attdef.h index e9f2e71bccd..8f4168b3f48 100644 --- a/include/vrv/attdef.h +++ b/include/vrv/attdef.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: attdef +// Name: attdef.h // Author: Laurent Pugin // Created: 2014 // Copyright (c) Authors and others. All rights reserved. @@ -15,8 +15,8 @@ //---------------------------------------------------------------------------- -#include "libmei_classes.h" -#include "libmei_def.h" +#include "attclasses.h" +#include "atttypes.h" //---------------------------------------------------------------------------- diff --git a/include/vrv/object.h b/include/vrv/object.h index 966f660075f..6aa42eb02ac 100644 --- a/include/vrv/object.h +++ b/include/vrv/object.h @@ -15,7 +15,7 @@ //---------------------------------------------------------------------------- -#include "libmei_classes.h" +#include "attclasses.h" #include "vrvdef.h" namespace vrv { diff --git a/libmei/libmei_classes.h b/libmei/attclasses.h similarity index 100% rename from libmei/libmei_classes.h rename to libmei/attclasses.h diff --git a/libmei/libmei_converter.cpp b/libmei/attconverter.cpp similarity index 77% rename from libmei/libmei_converter.cpp rename to libmei/attconverter.cpp index c2448a7327e..298715d06cb 100644 --- a/libmei/libmei_converter.cpp +++ b/libmei/attconverter.cpp @@ -12,7 +12,7 @@ // should not be edited because changes will be lost. ///////////////////////////////////////////////////////////////////////////// -#include "libmei_converter.h" +#include "attconverter.h" //---------------------------------------------------------------------------- @@ -25,10 +25,10 @@ namespace vrv { //---------------------------------------------------------------------------- -// LibmeiConverter +// AttConverter //---------------------------------------------------------------------------- -std::string LibmeiConverter::AccidentalExplicitToStr(data_ACCIDENTAL_EXPLICIT data) +std::string AttConverter::AccidentalExplicitToStr(data_ACCIDENTAL_EXPLICIT data) { std::string value; switch(data) @@ -55,16 +55,15 @@ std::string LibmeiConverter::AccidentalExplicitToStr(data_ACCIDENTAL_EXPLICIT da case ACCIDENTAL_EXPLICIT_1qs : value = "1qs"; break; case ACCIDENTAL_EXPLICIT_3qs : value = "3qs"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.ACCIDENTAL.EXPLICIT", data); value = ""; break; } return value; } -data_ACCIDENTAL_EXPLICIT LibmeiConverter::StrToAccidentalExplicit(std::string value) +data_ACCIDENTAL_EXPLICIT AttConverter::StrToAccidentalExplicit(std::string value) { - if (value == "s") return ACCIDENTAL_EXPLICIT_s; if (value == "f") return ACCIDENTAL_EXPLICIT_f; if (value == "ss") return ACCIDENTAL_EXPLICIT_ss; @@ -86,11 +85,11 @@ data_ACCIDENTAL_EXPLICIT LibmeiConverter::StrToAccidentalExplicit(std::string va if (value == "3qf") return ACCIDENTAL_EXPLICIT_3qf; if (value == "1qs") return ACCIDENTAL_EXPLICIT_1qs; if (value == "3qs") return ACCIDENTAL_EXPLICIT_3qs; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.ACCIDENTAL.EXPLICIT", value.c_str() ); return ACCIDENTAL_EXPLICIT_NONE; } -std::string LibmeiConverter::AccidentalImplicitToStr(data_ACCIDENTAL_IMPLICIT data) +std::string AttConverter::AccidentalImplicitToStr(data_ACCIDENTAL_IMPLICIT data) { std::string value; switch(data) @@ -105,16 +104,15 @@ std::string LibmeiConverter::AccidentalImplicitToStr(data_ACCIDENTAL_IMPLICIT da case ACCIDENTAL_IMPLICIT_fu : value = "fu"; break; case ACCIDENTAL_IMPLICIT_fd : value = "fd"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.ACCIDENTAL.IMPLICIT", data); value = ""; break; } return value; } -data_ACCIDENTAL_IMPLICIT LibmeiConverter::StrToAccidentalImplicit(std::string value) +data_ACCIDENTAL_IMPLICIT AttConverter::StrToAccidentalImplicit(std::string value) { - if (value == "s") return ACCIDENTAL_IMPLICIT_s; if (value == "f") return ACCIDENTAL_IMPLICIT_f; if (value == "ss") return ACCIDENTAL_IMPLICIT_ss; @@ -124,11 +122,11 @@ data_ACCIDENTAL_IMPLICIT LibmeiConverter::StrToAccidentalImplicit(std::string va if (value == "sd") return ACCIDENTAL_IMPLICIT_sd; if (value == "fu") return ACCIDENTAL_IMPLICIT_fu; if (value == "fd") return ACCIDENTAL_IMPLICIT_fd; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.ACCIDENTAL.IMPLICIT", value.c_str() ); return ACCIDENTAL_IMPLICIT_NONE; } -std::string LibmeiConverter::ArticulationToStr(data_ARTICULATION data) +std::string AttConverter::ArticulationToStr(data_ARTICULATION data) { std::string value; switch(data) @@ -169,16 +167,15 @@ std::string LibmeiConverter::ArticulationToStr(data_ARTICULATION data) case ARTICULATION_dot : value = "dot"; break; case ARTICULATION_stroke : value = "stroke"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.ARTICULATION", data); value = ""; break; } return value; } -data_ARTICULATION LibmeiConverter::StrToArticulation(std::string value) +data_ARTICULATION AttConverter::StrToArticulation(std::string value) { - if (value == "acc") return ARTICULATION_acc; if (value == "stacc") return ARTICULATION_stacc; if (value == "ten") return ARTICULATION_ten; @@ -214,11 +211,11 @@ data_ARTICULATION LibmeiConverter::StrToArticulation(std::string value) if (value == "lhpizz") return ARTICULATION_lhpizz; if (value == "dot") return ARTICULATION_dot; if (value == "stroke") return ARTICULATION_stroke; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.ARTICULATION", value.c_str() ); return ARTICULATION_NONE; } -std::string LibmeiConverter::BarplaceToStr(data_BARPLACE data) +std::string AttConverter::BarplaceToStr(data_BARPLACE data) { std::string value; switch(data) @@ -227,24 +224,23 @@ std::string LibmeiConverter::BarplaceToStr(data_BARPLACE data) case BARPLACE_staff : value = "staff"; break; case BARPLACE_takt : value = "takt"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.BARPLACE", data); value = ""; break; } return value; } -data_BARPLACE LibmeiConverter::StrToBarplace(std::string value) +data_BARPLACE AttConverter::StrToBarplace(std::string value) { - if (value == "mensur") return BARPLACE_mensur; if (value == "staff") return BARPLACE_staff; if (value == "takt") return BARPLACE_takt; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.BARPLACE", value.c_str() ); return BARPLACE_NONE; } -std::string LibmeiConverter::BarrenditionToStr(data_BARRENDITION data) +std::string AttConverter::BarrenditionToStr(data_BARRENDITION data) { std::string value; switch(data) @@ -261,16 +257,15 @@ std::string LibmeiConverter::BarrenditionToStr(data_BARRENDITION data) case BARRENDITION_rptend : value = "rptend"; break; case BARRENDITION_single : value = "single"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.BARRENDITION", data); value = ""; break; } return value; } -data_BARRENDITION LibmeiConverter::StrToBarrendition(std::string value) +data_BARRENDITION AttConverter::StrToBarrendition(std::string value) { - if (value == "dashed") return BARRENDITION_dashed; if (value == "dotted") return BARRENDITION_dotted; if (value == "dbl") return BARRENDITION_dbl; @@ -282,11 +277,11 @@ data_BARRENDITION LibmeiConverter::StrToBarrendition(std::string value) if (value == "rptboth") return BARRENDITION_rptboth; if (value == "rptend") return BARRENDITION_rptend; if (value == "single") return BARRENDITION_single; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.BARRENDITION", value.c_str() ); return BARRENDITION_NONE; } -std::string LibmeiConverter::BetypeToStr(data_BETYPE data) +std::string AttConverter::BetypeToStr(data_BETYPE data) { std::string value; switch(data) @@ -305,16 +300,15 @@ std::string LibmeiConverter::BetypeToStr(data_BETYPE data) case BETYPE_tcf : value = "tcf"; break; case BETYPE_time : value = "time"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.BETYPE", data); value = ""; break; } return value; } -data_BETYPE LibmeiConverter::StrToBetype(std::string value) +data_BETYPE AttConverter::StrToBetype(std::string value) { - if (value == "byte") return BETYPE_byte; if (value == "smil") return BETYPE_smil; if (value == "midi") return BETYPE_midi; @@ -328,11 +322,11 @@ data_BETYPE LibmeiConverter::StrToBetype(std::string value) if (value == "smpte-ndf29.97") return BETYPE_smpte_ndf29_97; if (value == "tcf") return BETYPE_tcf; if (value == "time") return BETYPE_time; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.BETYPE", value.c_str() ); return BETYPE_NONE; } -std::string LibmeiConverter::BooleanToStr(data_BOOLEAN data) +std::string AttConverter::BooleanToStr(data_BOOLEAN data) { std::string value; switch(data) @@ -340,23 +334,22 @@ std::string LibmeiConverter::BooleanToStr(data_BOOLEAN data) case BOOLEAN_true : value = "true"; break; case BOOLEAN_false : value = "false"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.BOOLEAN", data); value = ""; break; } return value; } -data_BOOLEAN LibmeiConverter::StrToBoolean(std::string value) +data_BOOLEAN AttConverter::StrToBoolean(std::string value) { - if (value == "true") return BOOLEAN_true; if (value == "false") return BOOLEAN_false; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.BOOLEAN", value.c_str() ); return BOOLEAN_NONE; } -std::string LibmeiConverter::CertaintyToStr(data_CERTAINTY data) +std::string AttConverter::CertaintyToStr(data_CERTAINTY data) { std::string value; switch(data) @@ -366,25 +359,24 @@ std::string LibmeiConverter::CertaintyToStr(data_CERTAINTY data) case CERTAINTY_low : value = "low"; break; case CERTAINTY_unknown : value = "unknown"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.CERTAINTY", data); value = ""; break; } return value; } -data_CERTAINTY LibmeiConverter::StrToCertainty(std::string value) +data_CERTAINTY AttConverter::StrToCertainty(std::string value) { - if (value == "high") return CERTAINTY_high; if (value == "medium") return CERTAINTY_medium; if (value == "low") return CERTAINTY_low; if (value == "unknown") return CERTAINTY_unknown; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.CERTAINTY", value.c_str() ); return CERTAINTY_NONE; } -std::string LibmeiConverter::ClefshapeToStr(data_CLEFSHAPE data) +std::string AttConverter::ClefshapeToStr(data_CLEFSHAPE data) { std::string value; switch(data) @@ -396,27 +388,26 @@ std::string LibmeiConverter::ClefshapeToStr(data_CLEFSHAPE data) case CLEFSHAPE_perc : value = "perc"; break; case CLEFSHAPE_TAB : value = "TAB"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.CLEFSHAPE", data); value = ""; break; } return value; } -data_CLEFSHAPE LibmeiConverter::StrToClefshape(std::string value) +data_CLEFSHAPE AttConverter::StrToClefshape(std::string value) { - if (value == "G") return CLEFSHAPE_G; if (value == "GG") return CLEFSHAPE_GG; if (value == "F") return CLEFSHAPE_F; if (value == "C") return CLEFSHAPE_C; if (value == "perc") return CLEFSHAPE_perc; if (value == "TAB") return CLEFSHAPE_TAB; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.CLEFSHAPE", value.c_str() ); return CLEFSHAPE_NONE; } -std::string LibmeiConverter::ClusterToStr(data_CLUSTER data) +std::string AttConverter::ClusterToStr(data_CLUSTER data) { std::string value; switch(data) @@ -425,24 +416,23 @@ std::string LibmeiConverter::ClusterToStr(data_CLUSTER data) case CLUSTER_black : value = "black"; break; case CLUSTER_chromatic : value = "chromatic"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.CLUSTER", data); value = ""; break; } return value; } -data_CLUSTER LibmeiConverter::StrToCluster(std::string value) +data_CLUSTER AttConverter::StrToCluster(std::string value) { - if (value == "white") return CLUSTER_white; if (value == "black") return CLUSTER_black; if (value == "chromatic") return CLUSTER_chromatic; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.CLUSTER", value.c_str() ); return CLUSTER_NONE; } -std::string LibmeiConverter::ColornamesToStr(data_COLORNAMES data) +std::string AttConverter::ColornamesToStr(data_COLORNAMES data) { std::string value; switch(data) @@ -464,16 +454,15 @@ std::string LibmeiConverter::ColornamesToStr(data_COLORNAMES data) case COLORNAMES_white : value = "white"; break; case COLORNAMES_yellow : value = "yellow"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.COLORNAMES", data); value = ""; break; } return value; } -data_COLORNAMES LibmeiConverter::StrToColornames(std::string value) +data_COLORNAMES AttConverter::StrToColornames(std::string value) { - if (value == "aqua") return COLORNAMES_aqua; if (value == "black") return COLORNAMES_black; if (value == "blue") return COLORNAMES_blue; @@ -490,11 +479,11 @@ data_COLORNAMES LibmeiConverter::StrToColornames(std::string value) if (value == "teal") return COLORNAMES_teal; if (value == "white") return COLORNAMES_white; if (value == "yellow") return COLORNAMES_yellow; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.COLORNAMES", value.c_str() ); return COLORNAMES_NONE; } -std::string LibmeiConverter::CurverenditionToStr(data_CURVERENDITION data) +std::string AttConverter::CurverenditionToStr(data_CURVERENDITION data) { std::string value; switch(data) @@ -505,26 +494,25 @@ std::string LibmeiConverter::CurverenditionToStr(data_CURVERENDITION data) case CURVERENDITION_dashed : value = "dashed"; break; case CURVERENDITION_dotted : value = "dotted"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.CURVERENDITION", data); value = ""; break; } return value; } -data_CURVERENDITION LibmeiConverter::StrToCurverendition(std::string value) +data_CURVERENDITION AttConverter::StrToCurverendition(std::string value) { - if (value == "narrow") return CURVERENDITION_narrow; if (value == "medium") return CURVERENDITION_medium; if (value == "wide") return CURVERENDITION_wide; if (value == "dashed") return CURVERENDITION_dashed; if (value == "dotted") return CURVERENDITION_dotted; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.CURVERENDITION", value.c_str() ); return CURVERENDITION_NONE; } -std::string LibmeiConverter::EnclosureToStr(data_ENCLOSURE data) +std::string AttConverter::EnclosureToStr(data_ENCLOSURE data) { std::string value; switch(data) @@ -532,23 +520,22 @@ std::string LibmeiConverter::EnclosureToStr(data_ENCLOSURE data) case ENCLOSURE_paren : value = "paren"; break; case ENCLOSURE_brack : value = "brack"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.ENCLOSURE", data); value = ""; break; } return value; } -data_ENCLOSURE LibmeiConverter::StrToEnclosure(std::string value) +data_ENCLOSURE AttConverter::StrToEnclosure(std::string value) { - if (value == "paren") return ENCLOSURE_paren; if (value == "brack") return ENCLOSURE_brack; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.ENCLOSURE", value.c_str() ); return ENCLOSURE_NONE; } -std::string LibmeiConverter::FontstyleToStr(data_FONTSTYLE data) +std::string AttConverter::FontstyleToStr(data_FONTSTYLE data) { std::string value; switch(data) @@ -557,24 +544,23 @@ std::string LibmeiConverter::FontstyleToStr(data_FONTSTYLE data) case FONTSTYLE_normal : value = "normal"; break; case FONTSTYLE_oblique : value = "oblique"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.FONTSTYLE", data); value = ""; break; } return value; } -data_FONTSTYLE LibmeiConverter::StrToFontstyle(std::string value) +data_FONTSTYLE AttConverter::StrToFontstyle(std::string value) { - if (value == "italic") return FONTSTYLE_italic; if (value == "normal") return FONTSTYLE_normal; if (value == "oblique") return FONTSTYLE_oblique; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.FONTSTYLE", value.c_str() ); return FONTSTYLE_NONE; } -std::string LibmeiConverter::FontweightToStr(data_FONTWEIGHT data) +std::string AttConverter::FontweightToStr(data_FONTWEIGHT data) { std::string value; switch(data) @@ -582,23 +568,22 @@ std::string LibmeiConverter::FontweightToStr(data_FONTWEIGHT data) case FONTWEIGHT_bold : value = "bold"; break; case FONTWEIGHT_normal : value = "normal"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.FONTWEIGHT", data); value = ""; break; } return value; } -data_FONTWEIGHT LibmeiConverter::StrToFontweight(std::string value) +data_FONTWEIGHT AttConverter::StrToFontweight(std::string value) { - if (value == "bold") return FONTWEIGHT_bold; if (value == "normal") return FONTWEIGHT_normal; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.FONTWEIGHT", value.c_str() ); return FONTWEIGHT_NONE; } -std::string LibmeiConverter::GlissandoToStr(data_GLISSANDO data) +std::string AttConverter::GlissandoToStr(data_GLISSANDO data) { std::string value; switch(data) @@ -607,24 +592,23 @@ std::string LibmeiConverter::GlissandoToStr(data_GLISSANDO data) case GLISSANDO_m : value = "m"; break; case GLISSANDO_t : value = "t"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.GLISSANDO", data); value = ""; break; } return value; } -data_GLISSANDO LibmeiConverter::StrToGlissando(std::string value) +data_GLISSANDO AttConverter::StrToGlissando(std::string value) { - if (value == "i") return GLISSANDO_i; if (value == "m") return GLISSANDO_m; if (value == "t") return GLISSANDO_t; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.GLISSANDO", value.c_str() ); return GLISSANDO_NONE; } -std::string LibmeiConverter::GraceToStr(data_GRACE data) +std::string AttConverter::GraceToStr(data_GRACE data) { std::string value; switch(data) @@ -633,24 +617,23 @@ std::string LibmeiConverter::GraceToStr(data_GRACE data) case GRACE_unacc : value = "unacc"; break; case GRACE_unknown : value = "unknown"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.GRACE", data); value = ""; break; } return value; } -data_GRACE LibmeiConverter::StrToGrace(std::string value) +data_GRACE AttConverter::StrToGrace(std::string value) { - if (value == "acc") return GRACE_acc; if (value == "unacc") return GRACE_unacc; if (value == "unknown") return GRACE_unknown; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.GRACE", value.c_str() ); return GRACE_NONE; } -std::string LibmeiConverter::HorizontalalignmentToStr(data_HORIZONTALALIGNMENT data) +std::string AttConverter::HorizontalalignmentToStr(data_HORIZONTALALIGNMENT data) { std::string value; switch(data) @@ -660,25 +643,24 @@ std::string LibmeiConverter::HorizontalalignmentToStr(data_HORIZONTALALIGNMENT d case HORIZONTALALIGNMENT_center : value = "center"; break; case HORIZONTALALIGNMENT_justify : value = "justify"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.HORIZONTALALIGNMENT", data); value = ""; break; } return value; } -data_HORIZONTALALIGNMENT LibmeiConverter::StrToHorizontalalignment(std::string value) +data_HORIZONTALALIGNMENT AttConverter::StrToHorizontalalignment(std::string value) { - if (value == "left") return HORIZONTALALIGNMENT_left; if (value == "right") return HORIZONTALALIGNMENT_right; if (value == "center") return HORIZONTALALIGNMENT_center; if (value == "justify") return HORIZONTALALIGNMENT_justify; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.HORIZONTALALIGNMENT", value.c_str() ); return HORIZONTALALIGNMENT_NONE; } -std::string LibmeiConverter::IneumeformToStr(data_INEUMEFORM data) +std::string AttConverter::IneumeformToStr(data_INEUMEFORM data) { std::string value; switch(data) @@ -689,26 +671,25 @@ std::string LibmeiConverter::IneumeformToStr(data_INEUMEFORM data) case INEUMEFORM_tiedliquescent1 : value = "tiedliquescent1"; break; case INEUMEFORM_tiedliquescent2 : value = "tiedliquescent2"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.INEUMEFORM", data); value = ""; break; } return value; } -data_INEUMEFORM LibmeiConverter::StrToIneumeform(std::string value) +data_INEUMEFORM AttConverter::StrToIneumeform(std::string value) { - if (value == "liquescent1") return INEUMEFORM_liquescent1; if (value == "liquescent2") return INEUMEFORM_liquescent2; if (value == "tied") return INEUMEFORM_tied; if (value == "tiedliquescent1") return INEUMEFORM_tiedliquescent1; if (value == "tiedliquescent2") return INEUMEFORM_tiedliquescent2; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.INEUMEFORM", value.c_str() ); return INEUMEFORM_NONE; } -std::string LibmeiConverter::IneumenameToStr(data_INEUMENAME data) +std::string AttConverter::IneumenameToStr(data_INEUMENAME data) { std::string value; switch(data) @@ -721,16 +702,15 @@ std::string LibmeiConverter::IneumenameToStr(data_INEUMENAME data) case INEUMENAME_pressusminor : value = "pressusminor"; break; case INEUMENAME_pressusmaior : value = "pressusmaior"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.INEUMENAME", data); value = ""; break; } return value; } -data_INEUMENAME LibmeiConverter::StrToIneumename(std::string value) +data_INEUMENAME AttConverter::StrToIneumename(std::string value) { - if (value == "pessubpunctis") return INEUMENAME_pessubpunctis; if (value == "climacus") return INEUMENAME_climacus; if (value == "scandicus") return INEUMENAME_scandicus; @@ -738,11 +718,11 @@ data_INEUMENAME LibmeiConverter::StrToIneumename(std::string value) if (value == "tristropha") return INEUMENAME_tristropha; if (value == "pressusminor") return INEUMENAME_pressusminor; if (value == "pressusmaior") return INEUMENAME_pressusmaior; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.INEUMENAME", value.c_str() ); return INEUMENAME_NONE; } -std::string LibmeiConverter::LayerschemeToStr(data_LAYERSCHEME data) +std::string AttConverter::LayerschemeToStr(data_LAYERSCHEME data) { std::string value; switch(data) @@ -753,26 +733,25 @@ std::string LibmeiConverter::LayerschemeToStr(data_LAYERSCHEME data) case LAYERSCHEME_3o : value = "3o"; break; case LAYERSCHEME_3f : value = "3f"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.LAYERSCHEME", data); value = ""; break; } return value; } -data_LAYERSCHEME LibmeiConverter::StrToLayerscheme(std::string value) +data_LAYERSCHEME AttConverter::StrToLayerscheme(std::string value) { - if (value == "1") return LAYERSCHEME_1; if (value == "2o") return LAYERSCHEME_2o; if (value == "2f") return LAYERSCHEME_2f; if (value == "3o") return LAYERSCHEME_3o; if (value == "3f") return LAYERSCHEME_3f; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.LAYERSCHEME", value.c_str() ); return LAYERSCHEME_NONE; } -std::string LibmeiConverter::LigatureformToStr(data_LIGATUREFORM data) +std::string AttConverter::LigatureformToStr(data_LIGATUREFORM data) { std::string value; switch(data) @@ -780,23 +759,22 @@ std::string LibmeiConverter::LigatureformToStr(data_LIGATUREFORM data) case LIGATUREFORM_recta : value = "recta"; break; case LIGATUREFORM_obliqua : value = "obliqua"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.LIGATUREFORM", data); value = ""; break; } return value; } -data_LIGATUREFORM LibmeiConverter::StrToLigatureform(std::string value) +data_LIGATUREFORM AttConverter::StrToLigatureform(std::string value) { - if (value == "recta") return LIGATUREFORM_recta; if (value == "obliqua") return LIGATUREFORM_obliqua; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.LIGATUREFORM", value.c_str() ); return LIGATUREFORM_NONE; } -std::string LibmeiConverter::LineformToStr(data_LINEFORM data) +std::string AttConverter::LineformToStr(data_LINEFORM data) { std::string value; switch(data) @@ -806,25 +784,24 @@ std::string LibmeiConverter::LineformToStr(data_LINEFORM data) case LINEFORM_solid : value = "solid"; break; case LINEFORM_wavy : value = "wavy"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.LINEFORM", data); value = ""; break; } return value; } -data_LINEFORM LibmeiConverter::StrToLineform(std::string value) +data_LINEFORM AttConverter::StrToLineform(std::string value) { - if (value == "dashed") return LINEFORM_dashed; if (value == "dotted") return LINEFORM_dotted; if (value == "solid") return LINEFORM_solid; if (value == "wavy") return LINEFORM_wavy; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.LINEFORM", value.c_str() ); return LINEFORM_NONE; } -std::string LibmeiConverter::LinestartendsymbolToStr(data_LINESTARTENDSYMBOL data) +std::string AttConverter::LinestartendsymbolToStr(data_LINESTARTENDSYMBOL data) { std::string value; switch(data) @@ -840,16 +817,15 @@ std::string LibmeiConverter::LinestartendsymbolToStr(data_LINESTARTENDSYMBOL dat case LINESTARTENDSYMBOL_harpoonright : value = "harpoonright"; break; case LINESTARTENDSYMBOL_none : value = "none"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.LINESTARTENDSYMBOL", data); value = ""; break; } return value; } -data_LINESTARTENDSYMBOL LibmeiConverter::StrToLinestartendsymbol(std::string value) +data_LINESTARTENDSYMBOL AttConverter::StrToLinestartendsymbol(std::string value) { - if (value == "angledown") return LINESTARTENDSYMBOL_angledown; if (value == "angleup") return LINESTARTENDSYMBOL_angleup; if (value == "angleright") return LINESTARTENDSYMBOL_angleright; @@ -860,11 +836,11 @@ data_LINESTARTENDSYMBOL LibmeiConverter::StrToLinestartendsymbol(std::string val if (value == "harpoonleft") return LINESTARTENDSYMBOL_harpoonleft; if (value == "harpoonright") return LINESTARTENDSYMBOL_harpoonright; if (value == "none") return LINESTARTENDSYMBOL_none; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.LINESTARTENDSYMBOL", value.c_str() ); return LINESTARTENDSYMBOL_NONE; } -std::string LibmeiConverter::LinewidthtermToStr(data_LINEWIDTHTERM data) +std::string AttConverter::LinewidthtermToStr(data_LINEWIDTHTERM data) { std::string value; switch(data) @@ -873,24 +849,23 @@ std::string LibmeiConverter::LinewidthtermToStr(data_LINEWIDTHTERM data) case LINEWIDTHTERM_medium : value = "medium"; break; case LINEWIDTHTERM_wide : value = "wide"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.LINEWIDTHTERM", data); value = ""; break; } return value; } -data_LINEWIDTHTERM LibmeiConverter::StrToLinewidthterm(std::string value) +data_LINEWIDTHTERM AttConverter::StrToLinewidthterm(std::string value) { - if (value == "narrow") return LINEWIDTHTERM_narrow; if (value == "medium") return LINEWIDTHTERM_medium; if (value == "wide") return LINEWIDTHTERM_wide; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.LINEWIDTHTERM", value.c_str() ); return LINEWIDTHTERM_NONE; } -std::string LibmeiConverter::MelodicfunctionToStr(data_MELODICFUNCTION data) +std::string AttConverter::MelodicfunctionToStr(data_MELODICFUNCTION data) { std::string value; switch(data) @@ -924,16 +899,15 @@ std::string LibmeiConverter::MelodicfunctionToStr(data_MELODICFUNCTION data) case MELODICFUNCTION_upt : value = "upt"; break; case MELODICFUNCTION_upt7 : value = "upt7"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.MELODICFUNCTION", data); value = ""; break; } return value; } -data_MELODICFUNCTION LibmeiConverter::StrToMelodicfunction(std::string value) +data_MELODICFUNCTION AttConverter::StrToMelodicfunction(std::string value) { - if (value == "aln") return MELODICFUNCTION_aln; if (value == "ant") return MELODICFUNCTION_ant; if (value == "app") return MELODICFUNCTION_app; @@ -962,11 +936,11 @@ data_MELODICFUNCTION LibmeiConverter::StrToMelodicfunction(std::string value) if (value == "un7") return MELODICFUNCTION_un7; if (value == "upt") return MELODICFUNCTION_upt; if (value == "upt7") return MELODICFUNCTION_upt7; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.MELODICFUNCTION", value.c_str() ); return MELODICFUNCTION_NONE; } -std::string LibmeiConverter::MensurationsignToStr(data_MENSURATIONSIGN data) +std::string AttConverter::MensurationsignToStr(data_MENSURATIONSIGN data) { std::string value; switch(data) @@ -974,23 +948,22 @@ std::string LibmeiConverter::MensurationsignToStr(data_MENSURATIONSIGN data) case MENSURATIONSIGN_C : value = "C"; break; case MENSURATIONSIGN_O : value = "O"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.MENSURATIONSIGN", data); value = ""; break; } return value; } -data_MENSURATIONSIGN LibmeiConverter::StrToMensurationsign(std::string value) +data_MENSURATIONSIGN AttConverter::StrToMensurationsign(std::string value) { - if (value == "C") return MENSURATIONSIGN_C; if (value == "O") return MENSURATIONSIGN_O; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.MENSURATIONSIGN", value.c_str() ); return MENSURATIONSIGN_NONE; } -std::string LibmeiConverter::MetersignToStr(data_METERSIGN data) +std::string AttConverter::MetersignToStr(data_METERSIGN data) { std::string value; switch(data) @@ -998,23 +971,22 @@ std::string LibmeiConverter::MetersignToStr(data_METERSIGN data) case METERSIGN_common : value = "common"; break; case METERSIGN_cut : value = "cut"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.METERSIGN", data); value = ""; break; } return value; } -data_METERSIGN LibmeiConverter::StrToMetersign(std::string value) +data_METERSIGN AttConverter::StrToMetersign(std::string value) { - if (value == "common") return METERSIGN_common; if (value == "cut") return METERSIGN_cut; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.METERSIGN", value.c_str() ); return METERSIGN_NONE; } -std::string LibmeiConverter::MidinamesToStr(data_MIDINAMES data) +std::string AttConverter::MidinamesToStr(data_MIDINAMES data) { std::string value; switch(data) @@ -1195,16 +1167,15 @@ std::string LibmeiConverter::MidinamesToStr(data_MIDINAMES data) case MIDINAMES_Mute_Triangle : value = "Mute_Triangle"; break; case MIDINAMES_Open_Triangle : value = "Open_Triangle"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.MIDINAMES", data); value = ""; break; } return value; } -data_MIDINAMES LibmeiConverter::StrToMidinames(std::string value) +data_MIDINAMES AttConverter::StrToMidinames(std::string value) { - if (value == "Acoustic_Grand_Piano") return MIDINAMES_Acoustic_Grand_Piano; if (value == "Bright_Acoustic_Piano") return MIDINAMES_Bright_Acoustic_Piano; if (value == "Electric_Grand_Piano") return MIDINAMES_Electric_Grand_Piano; @@ -1380,11 +1351,11 @@ data_MIDINAMES LibmeiConverter::StrToMidinames(std::string value) if (value == "Open_Cuica") return MIDINAMES_Open_Cuica; if (value == "Mute_Triangle") return MIDINAMES_Mute_Triangle; if (value == "Open_Triangle") return MIDINAMES_Open_Triangle; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.MIDINAMES", value.c_str() ); return MIDINAMES_NONE; } -std::string LibmeiConverter::ModeToStr(data_MODE data) +std::string AttConverter::ModeToStr(data_MODE data) { std::string value; switch(data) @@ -1398,16 +1369,15 @@ std::string LibmeiConverter::ModeToStr(data_MODE data) case MODE_aeolian : value = "aeolian"; break; case MODE_locrian : value = "locrian"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.MODE", data); value = ""; break; } return value; } -data_MODE LibmeiConverter::StrToMode(std::string value) +data_MODE AttConverter::StrToMode(std::string value) { - if (value == "major") return MODE_major; if (value == "minor") return MODE_minor; if (value == "dorian") return MODE_dorian; @@ -1416,11 +1386,11 @@ data_MODE LibmeiConverter::StrToMode(std::string value) if (value == "mixolydian") return MODE_mixolydian; if (value == "aeolian") return MODE_aeolian; if (value == "locrian") return MODE_locrian; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.MODE", value.c_str() ); return MODE_NONE; } -std::string LibmeiConverter::NotationtypeToStr(data_NOTATIONTYPE data) +std::string AttConverter::NotationtypeToStr(data_NOTATIONTYPE data) { std::string value; switch(data) @@ -1432,27 +1402,26 @@ std::string LibmeiConverter::NotationtypeToStr(data_NOTATIONTYPE data) case NOTATIONTYPE_neume : value = "neume"; break; case NOTATIONTYPE_tab : value = "tab"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.NOTATIONTYPE", data); value = ""; break; } return value; } -data_NOTATIONTYPE LibmeiConverter::StrToNotationtype(std::string value) +data_NOTATIONTYPE AttConverter::StrToNotationtype(std::string value) { - if (value == "cmn") return NOTATIONTYPE_cmn; if (value == "mensural") return NOTATIONTYPE_mensural; if (value == "mensural.black") return NOTATIONTYPE_mensural_black; if (value == "mensural.white") return NOTATIONTYPE_mensural_white; if (value == "neume") return NOTATIONTYPE_neume; if (value == "tab") return NOTATIONTYPE_tab; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.NOTATIONTYPE", value.c_str() ); return NOTATIONTYPE_NONE; } -std::string LibmeiConverter::NoteheadmodifierListToStr(data_NOTEHEADMODIFIER_list data) +std::string AttConverter::NoteheadmodifierListToStr(data_NOTEHEADMODIFIER_list data) { std::string value; switch(data) @@ -1468,16 +1437,15 @@ std::string LibmeiConverter::NoteheadmodifierListToStr(data_NOTEHEADMODIFIER_lis case NOTEHEADMODIFIER_list_circle : value = "circle"; break; case NOTEHEADMODIFIER_list_dblwhole : value = "dblwhole"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.NOTEHEADMODIFIER.list", data); value = ""; break; } return value; } -data_NOTEHEADMODIFIER_list LibmeiConverter::StrToNoteheadmodifierList(std::string value) +data_NOTEHEADMODIFIER_list AttConverter::StrToNoteheadmodifierList(std::string value) { - if (value == "slash") return NOTEHEADMODIFIER_list_slash; if (value == "backslash") return NOTEHEADMODIFIER_list_backslash; if (value == "vline") return NOTEHEADMODIFIER_list_vline; @@ -1488,11 +1456,11 @@ data_NOTEHEADMODIFIER_list LibmeiConverter::StrToNoteheadmodifierList(std::strin if (value == "box") return NOTEHEADMODIFIER_list_box; if (value == "circle") return NOTEHEADMODIFIER_list_circle; if (value == "dblwhole") return NOTEHEADMODIFIER_list_dblwhole; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.NOTEHEADMODIFIER.list", value.c_str() ); return NOTEHEADMODIFIER_list_NONE; } -std::string LibmeiConverter::OtherstaffToStr(data_OTHERSTAFF data) +std::string AttConverter::OtherstaffToStr(data_OTHERSTAFF data) { std::string value; switch(data) @@ -1500,23 +1468,22 @@ std::string LibmeiConverter::OtherstaffToStr(data_OTHERSTAFF data) case OTHERSTAFF_above : value = "above"; break; case OTHERSTAFF_below : value = "below"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.OTHERSTAFF", data); value = ""; break; } return value; } -data_OTHERSTAFF LibmeiConverter::StrToOtherstaff(std::string value) +data_OTHERSTAFF AttConverter::StrToOtherstaff(std::string value) { - if (value == "above") return OTHERSTAFF_above; if (value == "below") return OTHERSTAFF_below; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.OTHERSTAFF", value.c_str() ); return OTHERSTAFF_NONE; } -std::string LibmeiConverter::PlaceToStr(data_PLACE data) +std::string AttConverter::PlaceToStr(data_PLACE data) { std::string value; switch(data) @@ -1524,23 +1491,22 @@ std::string LibmeiConverter::PlaceToStr(data_PLACE data) case PLACE_above : value = "above"; break; case PLACE_below : value = "below"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.PLACE", data); value = ""; break; } return value; } -data_PLACE LibmeiConverter::StrToPlace(std::string value) +data_PLACE AttConverter::StrToPlace(std::string value) { - if (value == "above") return PLACE_above; if (value == "below") return PLACE_below; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.PLACE", value.c_str() ); return PLACE_NONE; } -std::string LibmeiConverter::RotationdirectionToStr(data_ROTATIONDIRECTION data) +std::string AttConverter::RotationdirectionToStr(data_ROTATIONDIRECTION data) { std::string value; switch(data) @@ -1553,16 +1519,15 @@ std::string LibmeiConverter::RotationdirectionToStr(data_ROTATIONDIRECTION data) case ROTATIONDIRECTION_se : value = "se"; break; case ROTATIONDIRECTION_sw : value = "sw"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.ROTATIONDIRECTION", data); value = ""; break; } return value; } -data_ROTATIONDIRECTION LibmeiConverter::StrToRotationdirection(std::string value) +data_ROTATIONDIRECTION AttConverter::StrToRotationdirection(std::string value) { - if (value == "none") return ROTATIONDIRECTION_none; if (value == "down") return ROTATIONDIRECTION_down; if (value == "left") return ROTATIONDIRECTION_left; @@ -1570,11 +1535,11 @@ data_ROTATIONDIRECTION LibmeiConverter::StrToRotationdirection(std::string value if (value == "nw") return ROTATIONDIRECTION_nw; if (value == "se") return ROTATIONDIRECTION_se; if (value == "sw") return ROTATIONDIRECTION_sw; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.ROTATIONDIRECTION", value.c_str() ); return ROTATIONDIRECTION_NONE; } -std::string LibmeiConverter::SizeToStr(data_SIZE data) +std::string AttConverter::SizeToStr(data_SIZE data) { std::string value; switch(data) @@ -1582,23 +1547,22 @@ std::string LibmeiConverter::SizeToStr(data_SIZE data) case SIZE_normal : value = "normal"; break; case SIZE_cue : value = "cue"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.SIZE", data); value = ""; break; } return value; } -data_SIZE LibmeiConverter::StrToSize(std::string value) +data_SIZE AttConverter::StrToSize(std::string value) { - if (value == "normal") return SIZE_normal; if (value == "cue") return SIZE_cue; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.SIZE", value.c_str() ); return SIZE_NONE; } -std::string LibmeiConverter::StaffrelToStr(data_STAFFREL data) +std::string AttConverter::StaffrelToStr(data_STAFFREL data) { std::string value; switch(data) @@ -1607,24 +1571,23 @@ std::string LibmeiConverter::StaffrelToStr(data_STAFFREL data) case STAFFREL_below : value = "below"; break; case STAFFREL_within : value = "within"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.STAFFREL", data); value = ""; break; } return value; } -data_STAFFREL LibmeiConverter::StrToStaffrel(std::string value) +data_STAFFREL AttConverter::StrToStaffrel(std::string value) { - if (value == "above") return STAFFREL_above; if (value == "below") return STAFFREL_below; if (value == "within") return STAFFREL_within; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.STAFFREL", value.c_str() ); return STAFFREL_NONE; } -std::string LibmeiConverter::StemmodifierToStr(data_STEMMODIFIER data) +std::string AttConverter::StemmodifierToStr(data_STEMMODIFIER data) { std::string value; switch(data) @@ -1639,16 +1602,15 @@ std::string LibmeiConverter::StemmodifierToStr(data_STEMMODIFIER data) case STEMMODIFIER_sprech : value = "sprech"; break; case STEMMODIFIER_z : value = "z"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.STEMMODIFIER", data); value = ""; break; } return value; } -data_STEMMODIFIER LibmeiConverter::StrToStemmodifier(std::string value) +data_STEMMODIFIER AttConverter::StrToStemmodifier(std::string value) { - if (value == "none") return STEMMODIFIER_none; if (value == "1slash") return STEMMODIFIER_1slash; if (value == "2slash") return STEMMODIFIER_2slash; @@ -1658,11 +1620,11 @@ data_STEMMODIFIER LibmeiConverter::StrToStemmodifier(std::string value) if (value == "6slash") return STEMMODIFIER_6slash; if (value == "sprech") return STEMMODIFIER_sprech; if (value == "z") return STEMMODIFIER_z; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.STEMMODIFIER", value.c_str() ); return STEMMODIFIER_NONE; } -std::string LibmeiConverter::StempositionToStr(data_STEMPOSITION data) +std::string AttConverter::StempositionToStr(data_STEMPOSITION data) { std::string value; switch(data) @@ -1671,24 +1633,23 @@ std::string LibmeiConverter::StempositionToStr(data_STEMPOSITION data) case STEMPOSITION_right : value = "right"; break; case STEMPOSITION_center : value = "center"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.STEMPOSITION", data); value = ""; break; } return value; } -data_STEMPOSITION LibmeiConverter::StrToStemposition(std::string value) +data_STEMPOSITION AttConverter::StrToStemposition(std::string value) { - if (value == "left") return STEMPOSITION_left; if (value == "right") return STEMPOSITION_right; if (value == "center") return STEMPOSITION_center; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.STEMPOSITION", value.c_str() ); return STEMPOSITION_NONE; } -std::string LibmeiConverter::TemperamentToStr(data_TEMPERAMENT data) +std::string AttConverter::TemperamentToStr(data_TEMPERAMENT data) { std::string value; switch(data) @@ -1698,25 +1659,24 @@ std::string LibmeiConverter::TemperamentToStr(data_TEMPERAMENT data) case TEMPERAMENT_mean : value = "mean"; break; case TEMPERAMENT_pythagorean : value = "pythagorean"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.TEMPERAMENT", data); value = ""; break; } return value; } -data_TEMPERAMENT LibmeiConverter::StrToTemperament(std::string value) +data_TEMPERAMENT AttConverter::StrToTemperament(std::string value) { - if (value == "equal") return TEMPERAMENT_equal; if (value == "just") return TEMPERAMENT_just; if (value == "mean") return TEMPERAMENT_mean; if (value == "pythagorean") return TEMPERAMENT_pythagorean; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.TEMPERAMENT", value.c_str() ); return TEMPERAMENT_NONE; } -std::string LibmeiConverter::TextrenditionlistToStr(data_TEXTRENDITIONLIST data) +std::string AttConverter::TextrenditionlistToStr(data_TEXTRENDITIONLIST data) { std::string value; switch(data) @@ -1755,16 +1715,15 @@ std::string LibmeiConverter::TextrenditionlistToStr(data_TEXTRENDITIONLIST data) case TEXTRENDITIONLIST_lro : value = "lro"; break; case TEXTRENDITIONLIST_rlo : value = "rlo"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.TEXTRENDITIONLIST", data); value = ""; break; } return value; } -data_TEXTRENDITIONLIST LibmeiConverter::StrToTextrenditionlist(std::string value) +data_TEXTRENDITIONLIST AttConverter::StrToTextrenditionlist(std::string value) { - if (value == "xx-small") return TEXTRENDITIONLIST_xx_small; if (value == "x-small") return TEXTRENDITIONLIST_x_small; if (value == "small") return TEXTRENDITIONLIST_small; @@ -1798,11 +1757,11 @@ data_TEXTRENDITIONLIST LibmeiConverter::StrToTextrenditionlist(std::string value if (value == "rtl") return TEXTRENDITIONLIST_rtl; if (value == "lro") return TEXTRENDITIONLIST_lro; if (value == "rlo") return TEXTRENDITIONLIST_rlo; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.TEXTRENDITIONLIST", value.c_str() ); return TEXTRENDITIONLIST_NONE; } -std::string LibmeiConverter::UneumeformToStr(data_UNEUMEFORM data) +std::string AttConverter::UneumeformToStr(data_UNEUMEFORM data) { std::string value; switch(data) @@ -1815,16 +1774,15 @@ std::string LibmeiConverter::UneumeformToStr(data_UNEUMEFORM data) case UNEUMEFORM_rhombic : value = "rhombic"; break; case UNEUMEFORM_tied : value = "tied"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.UNEUMEFORM", data); value = ""; break; } return value; } -data_UNEUMEFORM LibmeiConverter::StrToUneumeform(std::string value) +data_UNEUMEFORM AttConverter::StrToUneumeform(std::string value) { - if (value == "liquescent1") return UNEUMEFORM_liquescent1; if (value == "liquescent2") return UNEUMEFORM_liquescent2; if (value == "liquescent3") return UNEUMEFORM_liquescent3; @@ -1832,11 +1790,11 @@ data_UNEUMEFORM LibmeiConverter::StrToUneumeform(std::string value) if (value == "rectangular") return UNEUMEFORM_rectangular; if (value == "rhombic") return UNEUMEFORM_rhombic; if (value == "tied") return UNEUMEFORM_tied; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.UNEUMEFORM", value.c_str() ); return UNEUMEFORM_NONE; } -std::string LibmeiConverter::UneumenameToStr(data_UNEUMENAME data) +std::string AttConverter::UneumenameToStr(data_UNEUMENAME data) { std::string value; switch(data) @@ -1855,16 +1813,15 @@ std::string LibmeiConverter::UneumenameToStr(data_UNEUMENAME data) case UNEUMENAME_pressusminor : value = "pressusminor"; break; case UNEUMENAME_virgastrata : value = "virgastrata"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for data.UNEUMENAME", data); value = ""; break; } return value; } -data_UNEUMENAME LibmeiConverter::StrToUneumename(std::string value) +data_UNEUMENAME AttConverter::StrToUneumename(std::string value) { - if (value == "punctum") return UNEUMENAME_punctum; if (value == "virga") return UNEUMENAME_virga; if (value == "pes") return UNEUMENAME_pes; @@ -1878,11 +1835,11 @@ data_UNEUMENAME LibmeiConverter::StrToUneumename(std::string value) if (value == "pressusmaior") return UNEUMENAME_pressusmaior; if (value == "pressusminor") return UNEUMENAME_pressusminor; if (value == "virgastrata") return UNEUMENAME_virgastrata; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for data.UNEUMENAME", value.c_str() ); return UNEUMENAME_NONE; } -std::string LibmeiConverter::AccidLogFuncToStr(accidLog_FUNC data) +std::string AttConverter::AccidLogFuncToStr(accidLog_FUNC data) { std::string value; switch(data) @@ -1890,23 +1847,22 @@ std::string LibmeiConverter::AccidLogFuncToStr(accidLog_FUNC data) case accidLog_FUNC_caution : value = "caution"; break; case accidLog_FUNC_edit : value = "edit"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.accid.log@func", data); value = ""; break; } return value; } -accidLog_FUNC LibmeiConverter::StrToAccidLogFunc(std::string value) +accidLog_FUNC AttConverter::StrToAccidLogFunc(std::string value) { - if (value == "caution") return accidLog_FUNC_caution; if (value == "edit") return accidLog_FUNC_edit; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.accid.log@func", value.c_str() ); return accidLog_FUNC_NONE; } -std::string LibmeiConverter::ArpegLogOrderToStr(arpegLog_ORDER data) +std::string AttConverter::ArpegLogOrderToStr(arpegLog_ORDER data) { std::string value; switch(data) @@ -1915,24 +1871,23 @@ std::string LibmeiConverter::ArpegLogOrderToStr(arpegLog_ORDER data) case arpegLog_ORDER_down : value = "down"; break; case arpegLog_ORDER_nonarp : value = "nonarp"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.arpeg.log@order", data); value = ""; break; } return value; } -arpegLog_ORDER LibmeiConverter::StrToArpegLogOrder(std::string value) +arpegLog_ORDER AttConverter::StrToArpegLogOrder(std::string value) { - if (value == "up") return arpegLog_ORDER_up; if (value == "down") return arpegLog_ORDER_down; if (value == "nonarp") return arpegLog_ORDER_nonarp; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.arpeg.log@order", value.c_str() ); return arpegLog_ORDER_NONE; } -std::string LibmeiConverter::BTremLogFormToStr(bTremLog_FORM data) +std::string AttConverter::BTremLogFormToStr(bTremLog_FORM data) { std::string value; switch(data) @@ -1940,23 +1895,22 @@ std::string LibmeiConverter::BTremLogFormToStr(bTremLog_FORM data) case bTremLog_FORM_meas : value = "meas"; break; case bTremLog_FORM_unmeas : value = "unmeas"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.bTrem.log@form", data); value = ""; break; } return value; } -bTremLog_FORM LibmeiConverter::StrToBTremLogForm(std::string value) +bTremLog_FORM AttConverter::StrToBTremLogForm(std::string value) { - if (value == "meas") return bTremLog_FORM_meas; if (value == "unmeas") return bTremLog_FORM_unmeas; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.bTrem.log@form", value.c_str() ); return bTremLog_FORM_NONE; } -std::string LibmeiConverter::BeamingVisBeamrendToStr(beamingVis_BEAMREND data) +std::string AttConverter::BeamingVisBeamrendToStr(beamingVis_BEAMREND data) { std::string value; switch(data) @@ -1965,24 +1919,23 @@ std::string LibmeiConverter::BeamingVisBeamrendToStr(beamingVis_BEAMREND data) case beamingVis_BEAMREND_rit : value = "rit"; break; case beamingVis_BEAMREND_norm : value = "norm"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.beaming.vis@beam.rend", data); value = ""; break; } return value; } -beamingVis_BEAMREND LibmeiConverter::StrToBeamingVisBeamrend(std::string value) +beamingVis_BEAMREND AttConverter::StrToBeamingVisBeamrend(std::string value) { - if (value == "acc") return beamingVis_BEAMREND_acc; if (value == "rit") return beamingVis_BEAMREND_rit; if (value == "norm") return beamingVis_BEAMREND_norm; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.beaming.vis@beam.rend", value.c_str() ); return beamingVis_BEAMREND_NONE; } -std::string LibmeiConverter::BeamrendFormToStr(beamrend_FORM data) +std::string AttConverter::BeamrendFormToStr(beamrend_FORM data) { std::string value; switch(data) @@ -1992,25 +1945,24 @@ std::string LibmeiConverter::BeamrendFormToStr(beamrend_FORM data) case beamrend_FORM_rit : value = "rit"; break; case beamrend_FORM_norm : value = "norm"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.beamrend@form", data); value = ""; break; } return value; } -beamrend_FORM LibmeiConverter::StrToBeamrendForm(std::string value) +beamrend_FORM AttConverter::StrToBeamrendForm(std::string value) { - if (value == "acc") return beamrend_FORM_acc; if (value == "mixed") return beamrend_FORM_mixed; if (value == "rit") return beamrend_FORM_rit; if (value == "norm") return beamrend_FORM_norm; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.beamrend@form", value.c_str() ); return beamrend_FORM_NONE; } -std::string LibmeiConverter::CurvatureCurvedirToStr(curvature_CURVEDIR data) +std::string AttConverter::CurvatureCurvedirToStr(curvature_CURVEDIR data) { std::string value; switch(data) @@ -2019,46 +1971,44 @@ std::string LibmeiConverter::CurvatureCurvedirToStr(curvature_CURVEDIR data) case curvature_CURVEDIR_below : value = "below"; break; case curvature_CURVEDIR_mixed : value = "mixed"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.curvature@curvedir", data); value = ""; break; } return value; } -curvature_CURVEDIR LibmeiConverter::StrToCurvatureCurvedir(std::string value) +curvature_CURVEDIR AttConverter::StrToCurvatureCurvedir(std::string value) { - if (value == "above") return curvature_CURVEDIR_above; if (value == "below") return curvature_CURVEDIR_below; if (value == "mixed") return curvature_CURVEDIR_mixed; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.curvature@curvedir", value.c_str() ); return curvature_CURVEDIR_NONE; } -std::string LibmeiConverter::CutoutCutoutToStr(cutout_CUTOUT data) +std::string AttConverter::CutoutCutoutToStr(cutout_CUTOUT data) { std::string value; switch(data) { case cutout_CUTOUT_cutout : value = "cutout"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.cutout@cutout", data); value = ""; break; } return value; } -cutout_CUTOUT LibmeiConverter::StrToCutoutCutout(std::string value) +cutout_CUTOUT AttConverter::StrToCutoutCutout(std::string value) { - if (value == "cutout") return cutout_CUTOUT_cutout; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.cutout@cutout", value.c_str() ); return cutout_CUTOUT_NONE; } -std::string LibmeiConverter::DotLogFormToStr(dotLog_FORM data) +std::string AttConverter::DotLogFormToStr(dotLog_FORM data) { std::string value; switch(data) @@ -2066,23 +2016,22 @@ std::string LibmeiConverter::DotLogFormToStr(dotLog_FORM data) case dotLog_FORM_aug : value = "aug"; break; case dotLog_FORM_div : value = "div"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.dot.log@form", data); value = ""; break; } return value; } -dotLog_FORM LibmeiConverter::StrToDotLogForm(std::string value) +dotLog_FORM AttConverter::StrToDotLogForm(std::string value) { - if (value == "aug") return dotLog_FORM_aug; if (value == "div") return dotLog_FORM_div; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.dot.log@form", value.c_str() ); return dotLog_FORM_NONE; } -std::string LibmeiConverter::EndingsEndingrendToStr(endings_ENDINGREND data) +std::string AttConverter::EndingsEndingrendToStr(endings_ENDINGREND data) { std::string value; switch(data) @@ -2091,24 +2040,23 @@ std::string LibmeiConverter::EndingsEndingrendToStr(endings_ENDINGREND data) case endings_ENDINGREND_barred : value = "barred"; break; case endings_ENDINGREND_grouped : value = "grouped"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.endings@ending.rend", data); value = ""; break; } return value; } -endings_ENDINGREND LibmeiConverter::StrToEndingsEndingrend(std::string value) +endings_ENDINGREND AttConverter::StrToEndingsEndingrend(std::string value) { - if (value == "top") return endings_ENDINGREND_top; if (value == "barred") return endings_ENDINGREND_barred; if (value == "grouped") return endings_ENDINGREND_grouped; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.endings@ending.rend", value.c_str() ); return endings_ENDINGREND_NONE; } -std::string LibmeiConverter::FTremLogFormToStr(fTremLog_FORM data) +std::string AttConverter::FTremLogFormToStr(fTremLog_FORM data) { std::string value; switch(data) @@ -2116,23 +2064,22 @@ std::string LibmeiConverter::FTremLogFormToStr(fTremLog_FORM data) case fTremLog_FORM_meas : value = "meas"; break; case fTremLog_FORM_unmeas : value = "unmeas"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.fTrem.log@form", data); value = ""; break; } return value; } -fTremLog_FORM LibmeiConverter::StrToFTremLogForm(std::string value) +fTremLog_FORM AttConverter::StrToFTremLogForm(std::string value) { - if (value == "meas") return fTremLog_FORM_meas; if (value == "unmeas") return fTremLog_FORM_unmeas; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.fTrem.log@form", value.c_str() ); return fTremLog_FORM_NONE; } -std::string LibmeiConverter::FermataVisFormToStr(fermataVis_FORM data) +std::string AttConverter::FermataVisFormToStr(fermataVis_FORM data) { std::string value; switch(data) @@ -2140,23 +2087,22 @@ std::string LibmeiConverter::FermataVisFormToStr(fermataVis_FORM data) case fermataVis_FORM_inv : value = "inv"; break; case fermataVis_FORM_norm : value = "norm"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.fermata.vis@form", data); value = ""; break; } return value; } -fermataVis_FORM LibmeiConverter::StrToFermataVisForm(std::string value) +fermataVis_FORM AttConverter::StrToFermataVisForm(std::string value) { - if (value == "inv") return fermataVis_FORM_inv; if (value == "norm") return fermataVis_FORM_norm; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.fermata.vis@form", value.c_str() ); return fermataVis_FORM_NONE; } -std::string LibmeiConverter::FermataVisShapeToStr(fermataVis_SHAPE data) +std::string AttConverter::FermataVisShapeToStr(fermataVis_SHAPE data) { std::string value; switch(data) @@ -2165,24 +2111,23 @@ std::string LibmeiConverter::FermataVisShapeToStr(fermataVis_SHAPE data) case fermataVis_SHAPE_square : value = "square"; break; case fermataVis_SHAPE_angular : value = "angular"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.fermata.vis@shape", data); value = ""; break; } return value; } -fermataVis_SHAPE LibmeiConverter::StrToFermataVisShape(std::string value) +fermataVis_SHAPE AttConverter::StrToFermataVisShape(std::string value) { - if (value == "curved") return fermataVis_SHAPE_curved; if (value == "square") return fermataVis_SHAPE_square; if (value == "angular") return fermataVis_SHAPE_angular; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.fermata.vis@shape", value.c_str() ); return fermataVis_SHAPE_NONE; } -std::string LibmeiConverter::HairpinLogFormToStr(hairpinLog_FORM data) +std::string AttConverter::HairpinLogFormToStr(hairpinLog_FORM data) { std::string value; switch(data) @@ -2190,23 +2135,22 @@ std::string LibmeiConverter::HairpinLogFormToStr(hairpinLog_FORM data) case hairpinLog_FORM_cres : value = "cres"; break; case hairpinLog_FORM_dim : value = "dim"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.hairpin.log@form", data); value = ""; break; } return value; } -hairpinLog_FORM LibmeiConverter::StrToHairpinLogForm(std::string value) +hairpinLog_FORM AttConverter::StrToHairpinLogForm(std::string value) { - if (value == "cres") return hairpinLog_FORM_cres; if (value == "dim") return hairpinLog_FORM_dim; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.hairpin.log@form", value.c_str() ); return hairpinLog_FORM_NONE; } -std::string LibmeiConverter::HarmVisRendgridToStr(harmVis_RENDGRID data) +std::string AttConverter::HarmVisRendgridToStr(harmVis_RENDGRID data) { std::string value; switch(data) @@ -2215,24 +2159,23 @@ std::string LibmeiConverter::HarmVisRendgridToStr(harmVis_RENDGRID data) case harmVis_RENDGRID_gridtext : value = "gridtext"; break; case harmVis_RENDGRID_text : value = "text"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.harm.vis@rendgrid", data); value = ""; break; } return value; } -harmVis_RENDGRID LibmeiConverter::StrToHarmVisRendgrid(std::string value) +harmVis_RENDGRID AttConverter::StrToHarmVisRendgrid(std::string value) { - if (value == "grid") return harmVis_RENDGRID_grid; if (value == "gridtext") return harmVis_RENDGRID_gridtext; if (value == "text") return harmVis_RENDGRID_text; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.harm.vis@rendgrid", value.c_str() ); return harmVis_RENDGRID_NONE; } -std::string LibmeiConverter::HarpPedalLogAToStr(harpPedalLog_A data) +std::string AttConverter::HarpPedalLogAToStr(harpPedalLog_A data) { std::string value; switch(data) @@ -2241,24 +2184,23 @@ std::string LibmeiConverter::HarpPedalLogAToStr(harpPedalLog_A data) case harpPedalLog_A_n : value = "n"; break; case harpPedalLog_A_s : value = "s"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.harpPedal.log@a", data); value = ""; break; } return value; } -harpPedalLog_A LibmeiConverter::StrToHarpPedalLogA(std::string value) +harpPedalLog_A AttConverter::StrToHarpPedalLogA(std::string value) { - if (value == "f") return harpPedalLog_A_f; if (value == "n") return harpPedalLog_A_n; if (value == "s") return harpPedalLog_A_s; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.harpPedal.log@a", value.c_str() ); return harpPedalLog_A_NONE; } -std::string LibmeiConverter::HarpPedalLogBToStr(harpPedalLog_B data) +std::string AttConverter::HarpPedalLogBToStr(harpPedalLog_B data) { std::string value; switch(data) @@ -2267,24 +2209,23 @@ std::string LibmeiConverter::HarpPedalLogBToStr(harpPedalLog_B data) case harpPedalLog_B_n : value = "n"; break; case harpPedalLog_B_s : value = "s"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.harpPedal.log@b", data); value = ""; break; } return value; } -harpPedalLog_B LibmeiConverter::StrToHarpPedalLogB(std::string value) +harpPedalLog_B AttConverter::StrToHarpPedalLogB(std::string value) { - if (value == "f") return harpPedalLog_B_f; if (value == "n") return harpPedalLog_B_n; if (value == "s") return harpPedalLog_B_s; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.harpPedal.log@b", value.c_str() ); return harpPedalLog_B_NONE; } -std::string LibmeiConverter::HarpPedalLogCToStr(harpPedalLog_C data) +std::string AttConverter::HarpPedalLogCToStr(harpPedalLog_C data) { std::string value; switch(data) @@ -2293,24 +2234,23 @@ std::string LibmeiConverter::HarpPedalLogCToStr(harpPedalLog_C data) case harpPedalLog_C_n : value = "n"; break; case harpPedalLog_C_s : value = "s"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.harpPedal.log@c", data); value = ""; break; } return value; } -harpPedalLog_C LibmeiConverter::StrToHarpPedalLogC(std::string value) +harpPedalLog_C AttConverter::StrToHarpPedalLogC(std::string value) { - if (value == "f") return harpPedalLog_C_f; if (value == "n") return harpPedalLog_C_n; if (value == "s") return harpPedalLog_C_s; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.harpPedal.log@c", value.c_str() ); return harpPedalLog_C_NONE; } -std::string LibmeiConverter::HarpPedalLogDToStr(harpPedalLog_D data) +std::string AttConverter::HarpPedalLogDToStr(harpPedalLog_D data) { std::string value; switch(data) @@ -2319,24 +2259,23 @@ std::string LibmeiConverter::HarpPedalLogDToStr(harpPedalLog_D data) case harpPedalLog_D_n : value = "n"; break; case harpPedalLog_D_s : value = "s"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.harpPedal.log@d", data); value = ""; break; } return value; } -harpPedalLog_D LibmeiConverter::StrToHarpPedalLogD(std::string value) +harpPedalLog_D AttConverter::StrToHarpPedalLogD(std::string value) { - if (value == "f") return harpPedalLog_D_f; if (value == "n") return harpPedalLog_D_n; if (value == "s") return harpPedalLog_D_s; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.harpPedal.log@d", value.c_str() ); return harpPedalLog_D_NONE; } -std::string LibmeiConverter::HarpPedalLogEToStr(harpPedalLog_E data) +std::string AttConverter::HarpPedalLogEToStr(harpPedalLog_E data) { std::string value; switch(data) @@ -2345,24 +2284,23 @@ std::string LibmeiConverter::HarpPedalLogEToStr(harpPedalLog_E data) case harpPedalLog_E_n : value = "n"; break; case harpPedalLog_E_s : value = "s"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.harpPedal.log@e", data); value = ""; break; } return value; } -harpPedalLog_E LibmeiConverter::StrToHarpPedalLogE(std::string value) +harpPedalLog_E AttConverter::StrToHarpPedalLogE(std::string value) { - if (value == "f") return harpPedalLog_E_f; if (value == "n") return harpPedalLog_E_n; if (value == "s") return harpPedalLog_E_s; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.harpPedal.log@e", value.c_str() ); return harpPedalLog_E_NONE; } -std::string LibmeiConverter::HarpPedalLogFToStr(harpPedalLog_F data) +std::string AttConverter::HarpPedalLogFToStr(harpPedalLog_F data) { std::string value; switch(data) @@ -2371,24 +2309,23 @@ std::string LibmeiConverter::HarpPedalLogFToStr(harpPedalLog_F data) case harpPedalLog_F_n : value = "n"; break; case harpPedalLog_F_s : value = "s"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.harpPedal.log@f", data); value = ""; break; } return value; } -harpPedalLog_F LibmeiConverter::StrToHarpPedalLogF(std::string value) +harpPedalLog_F AttConverter::StrToHarpPedalLogF(std::string value) { - if (value == "f") return harpPedalLog_F_f; if (value == "n") return harpPedalLog_F_n; if (value == "s") return harpPedalLog_F_s; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.harpPedal.log@f", value.c_str() ); return harpPedalLog_F_NONE; } -std::string LibmeiConverter::HarpPedalLogGToStr(harpPedalLog_G data) +std::string AttConverter::HarpPedalLogGToStr(harpPedalLog_G data) { std::string value; switch(data) @@ -2397,46 +2334,44 @@ std::string LibmeiConverter::HarpPedalLogGToStr(harpPedalLog_G data) case harpPedalLog_G_n : value = "n"; break; case harpPedalLog_G_s : value = "s"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.harpPedal.log@g", data); value = ""; break; } return value; } -harpPedalLog_G LibmeiConverter::StrToHarpPedalLogG(std::string value) +harpPedalLog_G AttConverter::StrToHarpPedalLogG(std::string value) { - if (value == "f") return harpPedalLog_G_f; if (value == "n") return harpPedalLog_G_n; if (value == "s") return harpPedalLog_G_s; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.harpPedal.log@g", value.c_str() ); return harpPedalLog_G_NONE; } -std::string LibmeiConverter::MeiversionMeiversionToStr(meiversion_MEIVERSION data) +std::string AttConverter::MeiversionMeiversionToStr(meiversion_MEIVERSION data) { std::string value; switch(data) { case meiversion_MEIVERSION_3_0_0 : value = "3.0.0"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.meiversion@meiversion", data); value = ""; break; } return value; } -meiversion_MEIVERSION LibmeiConverter::StrToMeiversionMeiversion(std::string value) +meiversion_MEIVERSION AttConverter::StrToMeiversionMeiversion(std::string value) { - if (value == "3.0.0") return meiversion_MEIVERSION_3_0_0; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.meiversion@meiversion", value.c_str() ); return meiversion_MEIVERSION_NONE; } -std::string LibmeiConverter::MensurVisFormToStr(mensurVis_FORM data) +std::string AttConverter::MensurVisFormToStr(mensurVis_FORM data) { std::string value; switch(data) @@ -2444,23 +2379,22 @@ std::string LibmeiConverter::MensurVisFormToStr(mensurVis_FORM data) case mensurVis_FORM_horizontal : value = "horizontal"; break; case mensurVis_FORM_vertical : value = "vertical"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.mensur.vis@form", data); value = ""; break; } return value; } -mensurVis_FORM LibmeiConverter::StrToMensurVisForm(std::string value) +mensurVis_FORM AttConverter::StrToMensurVisForm(std::string value) { - if (value == "horizontal") return mensurVis_FORM_horizontal; if (value == "vertical") return mensurVis_FORM_vertical; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.mensur.vis@form", value.c_str() ); return mensurVis_FORM_NONE; } -std::string LibmeiConverter::MensuralVisMensurformToStr(mensuralVis_MENSURFORM data) +std::string AttConverter::MensuralVisMensurformToStr(mensuralVis_MENSURFORM data) { std::string value; switch(data) @@ -2468,23 +2402,22 @@ std::string LibmeiConverter::MensuralVisMensurformToStr(mensuralVis_MENSURFORM d case mensuralVis_MENSURFORM_horizontal : value = "horizontal"; break; case mensuralVis_MENSURFORM_vertical : value = "vertical"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.mensural.vis@mensur.form", data); value = ""; break; } return value; } -mensuralVis_MENSURFORM LibmeiConverter::StrToMensuralVisMensurform(std::string value) +mensuralVis_MENSURFORM AttConverter::StrToMensuralVisMensurform(std::string value) { - if (value == "horizontal") return mensuralVis_MENSURFORM_horizontal; if (value == "vertical") return mensuralVis_MENSURFORM_vertical; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.mensural.vis@mensur.form", value.c_str() ); return mensuralVis_MENSURFORM_NONE; } -std::string LibmeiConverter::MeterSigVisFormToStr(meterSigVis_FORM data) +std::string AttConverter::MeterSigVisFormToStr(meterSigVis_FORM data) { std::string value; switch(data) @@ -2494,25 +2427,24 @@ std::string LibmeiConverter::MeterSigVisFormToStr(meterSigVis_FORM data) case meterSigVis_FORM_norm : value = "norm"; break; case meterSigVis_FORM_invis : value = "invis"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.meterSig.vis@form", data); value = ""; break; } return value; } -meterSigVis_FORM LibmeiConverter::StrToMeterSigVisForm(std::string value) +meterSigVis_FORM AttConverter::StrToMeterSigVisForm(std::string value) { - if (value == "num") return meterSigVis_FORM_num; if (value == "denomsym") return meterSigVis_FORM_denomsym; if (value == "norm") return meterSigVis_FORM_norm; if (value == "invis") return meterSigVis_FORM_invis; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.meterSig.vis@form", value.c_str() ); return meterSigVis_FORM_NONE; } -std::string LibmeiConverter::MeterSigDefaultVisMeterrendToStr(meterSigDefaultVis_METERREND data) +std::string AttConverter::MeterSigDefaultVisMeterrendToStr(meterSigDefaultVis_METERREND data) { std::string value; switch(data) @@ -2522,25 +2454,24 @@ std::string LibmeiConverter::MeterSigDefaultVisMeterrendToStr(meterSigDefaultVis case meterSigDefaultVis_METERREND_norm : value = "norm"; break; case meterSigDefaultVis_METERREND_invis : value = "invis"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.meterSigDefault.vis@meter.rend", data); value = ""; break; } return value; } -meterSigDefaultVis_METERREND LibmeiConverter::StrToMeterSigDefaultVisMeterrend(std::string value) +meterSigDefaultVis_METERREND AttConverter::StrToMeterSigDefaultVisMeterrend(std::string value) { - if (value == "num") return meterSigDefaultVis_METERREND_num; if (value == "denomsym") return meterSigDefaultVis_METERREND_denomsym; if (value == "norm") return meterSigDefaultVis_METERREND_norm; if (value == "invis") return meterSigDefaultVis_METERREND_invis; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.meterSigDefault.vis@meter.rend", value.c_str() ); return meterSigDefaultVis_METERREND_NONE; } -std::string LibmeiConverter::MeterconformanceMetconToStr(meterconformance_METCON data) +std::string AttConverter::MeterconformanceMetconToStr(meterconformance_METCON data) { std::string value; switch(data) @@ -2549,24 +2480,23 @@ std::string LibmeiConverter::MeterconformanceMetconToStr(meterconformance_METCON case meterconformance_METCON_i : value = "i"; break; case meterconformance_METCON_o : value = "o"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.meterconformance@metcon", data); value = ""; break; } return value; } -meterconformance_METCON LibmeiConverter::StrToMeterconformanceMetcon(std::string value) +meterconformance_METCON AttConverter::StrToMeterconformanceMetcon(std::string value) { - if (value == "c") return meterconformance_METCON_c; if (value == "i") return meterconformance_METCON_i; if (value == "o") return meterconformance_METCON_o; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.meterconformance@metcon", value.c_str() ); return meterconformance_METCON_NONE; } -std::string LibmeiConverter::MordentLogFormToStr(mordentLog_FORM data) +std::string AttConverter::MordentLogFormToStr(mordentLog_FORM data) { std::string value; switch(data) @@ -2574,23 +2504,22 @@ std::string LibmeiConverter::MordentLogFormToStr(mordentLog_FORM data) case mordentLog_FORM_inv : value = "inv"; break; case mordentLog_FORM_norm : value = "norm"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.mordent.log@form", data); value = ""; break; } return value; } -mordentLog_FORM LibmeiConverter::StrToMordentLogForm(std::string value) +mordentLog_FORM AttConverter::StrToMordentLogForm(std::string value) { - if (value == "inv") return mordentLog_FORM_inv; if (value == "norm") return mordentLog_FORM_norm; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.mordent.log@form", value.c_str() ); return mordentLog_FORM_NONE; } -std::string LibmeiConverter::NoteLogMensuralLigToStr(noteLogMensural_LIG data) +std::string AttConverter::NoteLogMensuralLigToStr(noteLogMensural_LIG data) { std::string value; switch(data) @@ -2598,45 +2527,43 @@ std::string LibmeiConverter::NoteLogMensuralLigToStr(noteLogMensural_LIG data) case noteLogMensural_LIG_recta : value = "recta"; break; case noteLogMensural_LIG_obliqua : value = "obliqua"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.note.log.mensural@lig", data); value = ""; break; } return value; } -noteLogMensural_LIG LibmeiConverter::StrToNoteLogMensuralLig(std::string value) +noteLogMensural_LIG AttConverter::StrToNoteLogMensuralLig(std::string value) { - if (value == "recta") return noteLogMensural_LIG_recta; if (value == "obliqua") return noteLogMensural_LIG_obliqua; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.note.log.mensural@lig", value.c_str() ); return noteLogMensural_LIG_NONE; } -std::string LibmeiConverter::OctaveLogCollToStr(octaveLog_COLL data) +std::string AttConverter::OctaveLogCollToStr(octaveLog_COLL data) { std::string value; switch(data) { case octaveLog_COLL_coll : value = "coll"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.octave.log@coll", data); value = ""; break; } return value; } -octaveLog_COLL LibmeiConverter::StrToOctaveLogColl(std::string value) +octaveLog_COLL AttConverter::StrToOctaveLogColl(std::string value) { - if (value == "coll") return octaveLog_COLL_coll; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.octave.log@coll", value.c_str() ); return octaveLog_COLL_NONE; } -std::string LibmeiConverter::PbVisFoliumToStr(pbVis_FOLIUM data) +std::string AttConverter::PbVisFoliumToStr(pbVis_FOLIUM data) { std::string value; switch(data) @@ -2644,23 +2571,22 @@ std::string LibmeiConverter::PbVisFoliumToStr(pbVis_FOLIUM data) case pbVis_FOLIUM_verso : value = "verso"; break; case pbVis_FOLIUM_recto : value = "recto"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.pb.vis@folium", data); value = ""; break; } return value; } -pbVis_FOLIUM LibmeiConverter::StrToPbVisFolium(std::string value) +pbVis_FOLIUM AttConverter::StrToPbVisFolium(std::string value) { - if (value == "verso") return pbVis_FOLIUM_verso; if (value == "recto") return pbVis_FOLIUM_recto; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.pb.vis@folium", value.c_str() ); return pbVis_FOLIUM_NONE; } -std::string LibmeiConverter::PedalLogDirToStr(pedalLog_DIR data) +std::string AttConverter::PedalLogDirToStr(pedalLog_DIR data) { std::string value; switch(data) @@ -2670,25 +2596,24 @@ std::string LibmeiConverter::PedalLogDirToStr(pedalLog_DIR data) case pedalLog_DIR_half : value = "half"; break; case pedalLog_DIR_bounce : value = "bounce"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.pedal.log@dir", data); value = ""; break; } return value; } -pedalLog_DIR LibmeiConverter::StrToPedalLogDir(std::string value) +pedalLog_DIR AttConverter::StrToPedalLogDir(std::string value) { - if (value == "down") return pedalLog_DIR_down; if (value == "up") return pedalLog_DIR_up; if (value == "half") return pedalLog_DIR_half; if (value == "bounce") return pedalLog_DIR_bounce; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.pedal.log@dir", value.c_str() ); return pedalLog_DIR_NONE; } -std::string LibmeiConverter::PedalVisFormToStr(pedalVis_FORM data) +std::string AttConverter::PedalVisFormToStr(pedalVis_FORM data) { std::string value; switch(data) @@ -2697,24 +2622,23 @@ std::string LibmeiConverter::PedalVisFormToStr(pedalVis_FORM data) case pedalVis_FORM_pedstar : value = "pedstar"; break; case pedalVis_FORM_altpedstar : value = "altpedstar"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.pedal.vis@form", data); value = ""; break; } return value; } -pedalVis_FORM LibmeiConverter::StrToPedalVisForm(std::string value) +pedalVis_FORM AttConverter::StrToPedalVisForm(std::string value) { - if (value == "line") return pedalVis_FORM_line; if (value == "pedstar") return pedalVis_FORM_pedstar; if (value == "altpedstar") return pedalVis_FORM_altpedstar; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.pedal.vis@form", value.c_str() ); return pedalVis_FORM_NONE; } -std::string LibmeiConverter::PianopedalsPedalstyleToStr(pianopedals_PEDALSTYLE data) +std::string AttConverter::PianopedalsPedalstyleToStr(pianopedals_PEDALSTYLE data) { std::string value; switch(data) @@ -2723,24 +2647,23 @@ std::string LibmeiConverter::PianopedalsPedalstyleToStr(pianopedals_PEDALSTYLE d case pianopedals_PEDALSTYLE_pedstar : value = "pedstar"; break; case pianopedals_PEDALSTYLE_altpedstar : value = "altpedstar"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.pianopedals@pedal.style", data); value = ""; break; } return value; } -pianopedals_PEDALSTYLE LibmeiConverter::StrToPianopedalsPedalstyle(std::string value) +pianopedals_PEDALSTYLE AttConverter::StrToPianopedalsPedalstyle(std::string value) { - if (value == "line") return pianopedals_PEDALSTYLE_line; if (value == "pedstar") return pianopedals_PEDALSTYLE_pedstar; if (value == "altpedstar") return pianopedals_PEDALSTYLE_altpedstar; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.pianopedals@pedal.style", value.c_str() ); return pianopedals_PEDALSTYLE_NONE; } -std::string LibmeiConverter::PlistEvaluateToStr(plist_EVALUATE data) +std::string AttConverter::PlistEvaluateToStr(plist_EVALUATE data) { std::string value; switch(data) @@ -2749,24 +2672,23 @@ std::string LibmeiConverter::PlistEvaluateToStr(plist_EVALUATE data) case plist_EVALUATE_one : value = "one"; break; case plist_EVALUATE_none : value = "none"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.plist@evaluate", data); value = ""; break; } return value; } -plist_EVALUATE LibmeiConverter::StrToPlistEvaluate(std::string value) +plist_EVALUATE AttConverter::StrToPlistEvaluate(std::string value) { - if (value == "all") return plist_EVALUATE_all; if (value == "one") return plist_EVALUATE_one; if (value == "none") return plist_EVALUATE_none; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.plist@evaluate", value.c_str() ); return plist_EVALUATE_NONE; } -std::string LibmeiConverter::PointingXlinkactuateToStr(pointing_XLINKACTUATE data) +std::string AttConverter::PointingXlinkactuateToStr(pointing_XLINKACTUATE data) { std::string value; switch(data) @@ -2776,25 +2698,24 @@ std::string LibmeiConverter::PointingXlinkactuateToStr(pointing_XLINKACTUATE dat case pointing_XLINKACTUATE_none : value = "none"; break; case pointing_XLINKACTUATE_other : value = "other"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.pointing@xlink:actuate", data); value = ""; break; } return value; } -pointing_XLINKACTUATE LibmeiConverter::StrToPointingXlinkactuate(std::string value) +pointing_XLINKACTUATE AttConverter::StrToPointingXlinkactuate(std::string value) { - if (value == "onLoad") return pointing_XLINKACTUATE_onLoad; if (value == "onRequest") return pointing_XLINKACTUATE_onRequest; if (value == "none") return pointing_XLINKACTUATE_none; if (value == "other") return pointing_XLINKACTUATE_other; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.pointing@xlink:actuate", value.c_str() ); return pointing_XLINKACTUATE_NONE; } -std::string LibmeiConverter::PointingXlinkshowToStr(pointing_XLINKSHOW data) +std::string AttConverter::PointingXlinkshowToStr(pointing_XLINKSHOW data) { std::string value; switch(data) @@ -2805,26 +2726,25 @@ std::string LibmeiConverter::PointingXlinkshowToStr(pointing_XLINKSHOW data) case pointing_XLINKSHOW_none : value = "none"; break; case pointing_XLINKSHOW_other : value = "other"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.pointing@xlink:show", data); value = ""; break; } return value; } -pointing_XLINKSHOW LibmeiConverter::StrToPointingXlinkshow(std::string value) +pointing_XLINKSHOW AttConverter::StrToPointingXlinkshow(std::string value) { - if (value == "new") return pointing_XLINKSHOW_new; if (value == "replace") return pointing_XLINKSHOW_replace; if (value == "embed") return pointing_XLINKSHOW_embed; if (value == "none") return pointing_XLINKSHOW_none; if (value == "other") return pointing_XLINKSHOW_other; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.pointing@xlink:show", value.c_str() ); return pointing_XLINKSHOW_NONE; } -std::string LibmeiConverter::RegularmethodMethodToStr(regularmethod_METHOD data) +std::string AttConverter::RegularmethodMethodToStr(regularmethod_METHOD data) { std::string value; switch(data) @@ -2832,23 +2752,22 @@ std::string LibmeiConverter::RegularmethodMethodToStr(regularmethod_METHOD data) case regularmethod_METHOD_silent : value = "silent"; break; case regularmethod_METHOD_tags : value = "tags"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.regularmethod@method", data); value = ""; break; } return value; } -regularmethod_METHOD LibmeiConverter::StrToRegularmethodMethod(std::string value) +regularmethod_METHOD AttConverter::StrToRegularmethodMethod(std::string value) { - if (value == "silent") return regularmethod_METHOD_silent; if (value == "tags") return regularmethod_METHOD_tags; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.regularmethod@method", value.c_str() ); return regularmethod_METHOD_NONE; } -std::string LibmeiConverter::RehearsalRehencloseToStr(rehearsal_REHENCLOSE data) +std::string AttConverter::RehearsalRehencloseToStr(rehearsal_REHENCLOSE data) { std::string value; switch(data) @@ -2857,46 +2776,44 @@ std::string LibmeiConverter::RehearsalRehencloseToStr(rehearsal_REHENCLOSE data) case rehearsal_REHENCLOSE_circle : value = "circle"; break; case rehearsal_REHENCLOSE_none : value = "none"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.rehearsal@reh.enclose", data); value = ""; break; } return value; } -rehearsal_REHENCLOSE LibmeiConverter::StrToRehearsalRehenclose(std::string value) +rehearsal_REHENCLOSE AttConverter::StrToRehearsalRehenclose(std::string value) { - if (value == "box") return rehearsal_REHENCLOSE_box; if (value == "circle") return rehearsal_REHENCLOSE_circle; if (value == "none") return rehearsal_REHENCLOSE_none; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.rehearsal@reh.enclose", value.c_str() ); return rehearsal_REHENCLOSE_NONE; } -std::string LibmeiConverter::SbVisFormToStr(sbVis_FORM data) +std::string AttConverter::SbVisFormToStr(sbVis_FORM data) { std::string value; switch(data) { case sbVis_FORM_hash : value = "hash"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.sb.vis@form", data); value = ""; break; } return value; } -sbVis_FORM LibmeiConverter::StrToSbVisForm(std::string value) +sbVis_FORM AttConverter::StrToSbVisForm(std::string value) { - if (value == "hash") return sbVis_FORM_hash; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.sb.vis@form", value.c_str() ); return sbVis_FORM_NONE; } -std::string LibmeiConverter::StaffgroupingsymSymbolToStr(staffgroupingsym_SYMBOL data) +std::string AttConverter::StaffgroupingsymSymbolToStr(staffgroupingsym_SYMBOL data) { std::string value; switch(data) @@ -2907,26 +2824,25 @@ std::string LibmeiConverter::StaffgroupingsymSymbolToStr(staffgroupingsym_SYMBOL case staffgroupingsym_SYMBOL_line : value = "line"; break; case staffgroupingsym_SYMBOL_none : value = "none"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.staffgroupingsym@symbol", data); value = ""; break; } return value; } -staffgroupingsym_SYMBOL LibmeiConverter::StrToStaffgroupingsymSymbol(std::string value) +staffgroupingsym_SYMBOL AttConverter::StrToStaffgroupingsymSymbol(std::string value) { - if (value == "brace") return staffgroupingsym_SYMBOL_brace; if (value == "bracket") return staffgroupingsym_SYMBOL_bracket; if (value == "bracketsq") return staffgroupingsym_SYMBOL_bracketsq; if (value == "line") return staffgroupingsym_SYMBOL_line; if (value == "none") return staffgroupingsym_SYMBOL_none; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.staffgroupingsym@symbol", value.c_str() ); return staffgroupingsym_SYMBOL_NONE; } -std::string LibmeiConverter::SylLogConToStr(sylLog_CON data) +std::string AttConverter::SylLogConToStr(sylLog_CON data) { std::string value; switch(data) @@ -2940,16 +2856,15 @@ std::string LibmeiConverter::SylLogConToStr(sylLog_CON data) case sylLog_CON_i : value = "i"; break; case sylLog_CON_b : value = "b"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.syl.log@con", data); value = ""; break; } return value; } -sylLog_CON LibmeiConverter::StrToSylLogCon(std::string value) +sylLog_CON AttConverter::StrToSylLogCon(std::string value) { - if (value == "s") return sylLog_CON_s; if (value == "d") return sylLog_CON_d; if (value == "u") return sylLog_CON_u; @@ -2958,11 +2873,11 @@ sylLog_CON LibmeiConverter::StrToSylLogCon(std::string value) if (value == "v") return sylLog_CON_v; if (value == "i") return sylLog_CON_i; if (value == "b") return sylLog_CON_b; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.syl.log@con", value.c_str() ); return sylLog_CON_NONE; } -std::string LibmeiConverter::SylLogWordposToStr(sylLog_WORDPOS data) +std::string AttConverter::SylLogWordposToStr(sylLog_WORDPOS data) { std::string value; switch(data) @@ -2971,24 +2886,23 @@ std::string LibmeiConverter::SylLogWordposToStr(sylLog_WORDPOS data) case sylLog_WORDPOS_m : value = "m"; break; case sylLog_WORDPOS_t : value = "t"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.syl.log@wordpos", data); value = ""; break; } return value; } -sylLog_WORDPOS LibmeiConverter::StrToSylLogWordpos(std::string value) +sylLog_WORDPOS AttConverter::StrToSylLogWordpos(std::string value) { - if (value == "i") return sylLog_WORDPOS_i; if (value == "m") return sylLog_WORDPOS_m; if (value == "t") return sylLog_WORDPOS_t; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.syl.log@wordpos", value.c_str() ); return sylLog_WORDPOS_NONE; } -std::string LibmeiConverter::TupletVisNumformatToStr(tupletVis_NUMFORMAT data) +std::string AttConverter::TupletVisNumformatToStr(tupletVis_NUMFORMAT data) { std::string value; switch(data) @@ -2996,23 +2910,22 @@ std::string LibmeiConverter::TupletVisNumformatToStr(tupletVis_NUMFORMAT data) case tupletVis_NUMFORMAT_count : value = "count"; break; case tupletVis_NUMFORMAT_ratio : value = "ratio"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.tuplet.vis@num.format", data); value = ""; break; } return value; } -tupletVis_NUMFORMAT LibmeiConverter::StrToTupletVisNumformat(std::string value) +tupletVis_NUMFORMAT AttConverter::StrToTupletVisNumformat(std::string value) { - if (value == "count") return tupletVis_NUMFORMAT_count; if (value == "ratio") return tupletVis_NUMFORMAT_ratio; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.tuplet.vis@num.format", value.c_str() ); return tupletVis_NUMFORMAT_NONE; } -std::string LibmeiConverter::TurnLogFormToStr(turnLog_FORM data) +std::string AttConverter::TurnLogFormToStr(turnLog_FORM data) { std::string value; switch(data) @@ -3020,23 +2933,22 @@ std::string LibmeiConverter::TurnLogFormToStr(turnLog_FORM data) case turnLog_FORM_inv : value = "inv"; break; case turnLog_FORM_norm : value = "norm"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.turn.log@form", data); value = ""; break; } return value; } -turnLog_FORM LibmeiConverter::StrToTurnLogForm(std::string value) +turnLog_FORM AttConverter::StrToTurnLogForm(std::string value) { - if (value == "inv") return turnLog_FORM_inv; if (value == "norm") return turnLog_FORM_norm; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.turn.log@form", value.c_str() ); return turnLog_FORM_NONE; } -std::string LibmeiConverter::WhitespaceXmlspaceToStr(whitespace_XMLSPACE data) +std::string AttConverter::WhitespaceXmlspaceToStr(whitespace_XMLSPACE data) { std::string value; switch(data) @@ -3044,19 +2956,18 @@ std::string LibmeiConverter::WhitespaceXmlspaceToStr(whitespace_XMLSPACE data) case whitespace_XMLSPACE_default : value = "default"; break; case whitespace_XMLSPACE_preserve : value = "preserve"; break; default: - LogWarning("Unknown value '%d'", data); + LogWarning("Unknown value '%d' for att.whitespace@xml:space", data); value = ""; break; } return value; } -whitespace_XMLSPACE LibmeiConverter::StrToWhitespaceXmlspace(std::string value) +whitespace_XMLSPACE AttConverter::StrToWhitespaceXmlspace(std::string value) { - if (value == "default") return whitespace_XMLSPACE_default; if (value == "preserve") return whitespace_XMLSPACE_preserve; - LogWarning("Unsupported value '%s'", value.c_str() ); + LogWarning("Unsupported value '%s' for att.whitespace@xml:space", value.c_str() ); return whitespace_XMLSPACE_NONE; } diff --git a/libmei/libmei_converter.h b/libmei/attconverter.h similarity index 98% rename from libmei/libmei_converter.h rename to libmei/attconverter.h index b0bb7f3c8f5..3f71a31b048 100644 --- a/libmei/libmei_converter.h +++ b/libmei/attconverter.h @@ -12,22 +12,22 @@ // should not be edited because changes will be lost. ///////////////////////////////////////////////////////////////////////////// -#ifndef __VRV_LIBMEI_CONVERTER_H__ -#define __VRV_LIBMEI_CONVERTER_H__ +#ifndef __VRV_ATT_CONVERTER_H__ +#define __VRV_ATT_CONVERTER_H__ #include //---------------------------------------------------------------------------- -#include "libmei_def.h" +#include "attdef.h" namespace vrv { //---------------------------------------------------------------------------- -// LibmeiConverter +// AttConverter //---------------------------------------------------------------------------- -class LibmeiConverter +class AttConverter { public: @@ -303,5 +303,5 @@ class LibmeiConverter } // vrv namespace -#endif // __VRV_LIBMEI_CONVERTER_H__ +#endif // __VRV_ATT_CONVERTER_H__ diff --git a/libmei/libmei_def.h b/libmei/atttypes.h similarity index 94% rename from libmei/libmei_def.h rename to libmei/atttypes.h index 96c331bec78..37d860fbed8 100644 --- a/libmei/libmei_def.h +++ b/libmei/atttypes.h @@ -12,8 +12,8 @@ // should not be edited because changes will be lost. ///////////////////////////////////////////////////////////////////////////// -#ifndef __VRV_ATT_DEF_H__ -#define __VRV_ATT_DEF_H__ +#ifndef __VRV_ATT_TYPES_H__ +#define __VRV_ATT_TYPES_H__ //---------------------------------------------------------------------------- @@ -818,7 +818,7 @@ enum data_UNEUMENAME { }; /** - * MEI att.accid.log-func + * MEI att.accid.log@func */ enum accidLog_FUNC { accidLog_FUNC_NONE = 0, @@ -827,7 +827,7 @@ enum accidLog_FUNC { }; /** - * MEI att.arpeg.log-order + * MEI att.arpeg.log@order */ enum arpegLog_ORDER { arpegLog_ORDER_NONE = 0, @@ -837,7 +837,7 @@ enum arpegLog_ORDER { }; /** - * MEI att.bTrem.log-form + * MEI att.bTrem.log@form */ enum bTremLog_FORM { bTremLog_FORM_NONE = 0, @@ -846,7 +846,7 @@ enum bTremLog_FORM { }; /** - * MEI att.beaming.vis-beam.rend + * MEI att.beaming.vis@beam.rend */ enum beamingVis_BEAMREND { beamingVis_BEAMREND_NONE = 0, @@ -856,7 +856,7 @@ enum beamingVis_BEAMREND { }; /** - * MEI att.beamrend-form + * MEI att.beamrend@form */ enum beamrend_FORM { beamrend_FORM_NONE = 0, @@ -867,7 +867,7 @@ enum beamrend_FORM { }; /** - * MEI att.curvature-curvedir + * MEI att.curvature@curvedir */ enum curvature_CURVEDIR { curvature_CURVEDIR_NONE = 0, @@ -877,7 +877,7 @@ enum curvature_CURVEDIR { }; /** - * MEI att.cutout-cutout + * MEI att.cutout@cutout */ enum cutout_CUTOUT { cutout_CUTOUT_NONE = 0, @@ -885,7 +885,7 @@ enum cutout_CUTOUT { }; /** - * MEI att.dot.log-form + * MEI att.dot.log@form */ enum dotLog_FORM { dotLog_FORM_NONE = 0, @@ -894,7 +894,7 @@ enum dotLog_FORM { }; /** - * MEI att.endings-ending.rend + * MEI att.endings@ending.rend */ enum endings_ENDINGREND { endings_ENDINGREND_NONE = 0, @@ -904,7 +904,7 @@ enum endings_ENDINGREND { }; /** - * MEI att.fTrem.log-form + * MEI att.fTrem.log@form */ enum fTremLog_FORM { fTremLog_FORM_NONE = 0, @@ -913,7 +913,7 @@ enum fTremLog_FORM { }; /** - * MEI att.fermata.vis-form + * MEI att.fermata.vis@form */ enum fermataVis_FORM { fermataVis_FORM_NONE = 0, @@ -922,7 +922,7 @@ enum fermataVis_FORM { }; /** - * MEI att.fermata.vis-shape + * MEI att.fermata.vis@shape */ enum fermataVis_SHAPE { fermataVis_SHAPE_NONE = 0, @@ -932,7 +932,7 @@ enum fermataVis_SHAPE { }; /** - * MEI att.hairpin.log-form + * MEI att.hairpin.log@form */ enum hairpinLog_FORM { hairpinLog_FORM_NONE = 0, @@ -941,7 +941,7 @@ enum hairpinLog_FORM { }; /** - * MEI att.harm.vis-rendgrid + * MEI att.harm.vis@rendgrid */ enum harmVis_RENDGRID { harmVis_RENDGRID_NONE = 0, @@ -951,7 +951,7 @@ enum harmVis_RENDGRID { }; /** - * MEI att.harpPedal.log-a + * MEI att.harpPedal.log@a */ enum harpPedalLog_A { harpPedalLog_A_NONE = 0, @@ -961,7 +961,7 @@ enum harpPedalLog_A { }; /** - * MEI att.harpPedal.log-b + * MEI att.harpPedal.log@b */ enum harpPedalLog_B { harpPedalLog_B_NONE = 0, @@ -971,7 +971,7 @@ enum harpPedalLog_B { }; /** - * MEI att.harpPedal.log-c + * MEI att.harpPedal.log@c */ enum harpPedalLog_C { harpPedalLog_C_NONE = 0, @@ -981,7 +981,7 @@ enum harpPedalLog_C { }; /** - * MEI att.harpPedal.log-d + * MEI att.harpPedal.log@d */ enum harpPedalLog_D { harpPedalLog_D_NONE = 0, @@ -991,7 +991,7 @@ enum harpPedalLog_D { }; /** - * MEI att.harpPedal.log-e + * MEI att.harpPedal.log@e */ enum harpPedalLog_E { harpPedalLog_E_NONE = 0, @@ -1001,7 +1001,7 @@ enum harpPedalLog_E { }; /** - * MEI att.harpPedal.log-f + * MEI att.harpPedal.log@f */ enum harpPedalLog_F { harpPedalLog_F_NONE = 0, @@ -1011,7 +1011,7 @@ enum harpPedalLog_F { }; /** - * MEI att.harpPedal.log-g + * MEI att.harpPedal.log@g */ enum harpPedalLog_G { harpPedalLog_G_NONE = 0, @@ -1021,7 +1021,7 @@ enum harpPedalLog_G { }; /** - * MEI att.meiversion-meiversion + * MEI att.meiversion@meiversion */ enum meiversion_MEIVERSION { meiversion_MEIVERSION_NONE = 0, @@ -1029,7 +1029,7 @@ enum meiversion_MEIVERSION { }; /** - * MEI att.mensur.vis-form + * MEI att.mensur.vis@form */ enum mensurVis_FORM { mensurVis_FORM_NONE = 0, @@ -1038,7 +1038,7 @@ enum mensurVis_FORM { }; /** - * MEI att.mensural.vis-mensur.form + * MEI att.mensural.vis@mensur.form */ enum mensuralVis_MENSURFORM { mensuralVis_MENSURFORM_NONE = 0, @@ -1047,7 +1047,7 @@ enum mensuralVis_MENSURFORM { }; /** - * MEI att.meterSig.vis-form + * MEI att.meterSig.vis@form */ enum meterSigVis_FORM { meterSigVis_FORM_NONE = 0, @@ -1058,7 +1058,7 @@ enum meterSigVis_FORM { }; /** - * MEI att.meterSigDefault.vis-meter.rend + * MEI att.meterSigDefault.vis@meter.rend */ enum meterSigDefaultVis_METERREND { meterSigDefaultVis_METERREND_NONE = 0, @@ -1069,7 +1069,7 @@ enum meterSigDefaultVis_METERREND { }; /** - * MEI att.meterconformance-metcon + * MEI att.meterconformance@metcon */ enum meterconformance_METCON { meterconformance_METCON_NONE = 0, @@ -1079,7 +1079,7 @@ enum meterconformance_METCON { }; /** - * MEI att.mordent.log-form + * MEI att.mordent.log@form */ enum mordentLog_FORM { mordentLog_FORM_NONE = 0, @@ -1088,7 +1088,7 @@ enum mordentLog_FORM { }; /** - * MEI att.note.log.mensural-lig + * MEI att.note.log.mensural@lig */ enum noteLogMensural_LIG { noteLogMensural_LIG_NONE = 0, @@ -1097,7 +1097,7 @@ enum noteLogMensural_LIG { }; /** - * MEI att.octave.log-coll + * MEI att.octave.log@coll */ enum octaveLog_COLL { octaveLog_COLL_NONE = 0, @@ -1105,7 +1105,7 @@ enum octaveLog_COLL { }; /** - * MEI att.pb.vis-folium + * MEI att.pb.vis@folium */ enum pbVis_FOLIUM { pbVis_FOLIUM_NONE = 0, @@ -1114,7 +1114,7 @@ enum pbVis_FOLIUM { }; /** - * MEI att.pedal.log-dir + * MEI att.pedal.log@dir */ enum pedalLog_DIR { pedalLog_DIR_NONE = 0, @@ -1125,7 +1125,7 @@ enum pedalLog_DIR { }; /** - * MEI att.pedal.vis-form + * MEI att.pedal.vis@form */ enum pedalVis_FORM { pedalVis_FORM_NONE = 0, @@ -1135,7 +1135,7 @@ enum pedalVis_FORM { }; /** - * MEI att.pianopedals-pedal.style + * MEI att.pianopedals@pedal.style */ enum pianopedals_PEDALSTYLE { pianopedals_PEDALSTYLE_NONE = 0, @@ -1145,7 +1145,7 @@ enum pianopedals_PEDALSTYLE { }; /** - * MEI att.plist-evaluate + * MEI att.plist@evaluate */ enum plist_EVALUATE { plist_EVALUATE_NONE = 0, @@ -1155,7 +1155,7 @@ enum plist_EVALUATE { }; /** - * MEI att.pointing-xlink:actuate + * MEI att.pointing@xlink:actuate */ enum pointing_XLINKACTUATE { pointing_XLINKACTUATE_NONE = 0, @@ -1166,7 +1166,7 @@ enum pointing_XLINKACTUATE { }; /** - * MEI att.pointing-xlink:show + * MEI att.pointing@xlink:show */ enum pointing_XLINKSHOW { pointing_XLINKSHOW_NONE = 0, @@ -1178,7 +1178,7 @@ enum pointing_XLINKSHOW { }; /** - * MEI att.regularmethod-method + * MEI att.regularmethod@method */ enum regularmethod_METHOD { regularmethod_METHOD_NONE = 0, @@ -1187,7 +1187,7 @@ enum regularmethod_METHOD { }; /** - * MEI att.rehearsal-reh.enclose + * MEI att.rehearsal@reh.enclose */ enum rehearsal_REHENCLOSE { rehearsal_REHENCLOSE_NONE = 0, @@ -1197,7 +1197,7 @@ enum rehearsal_REHENCLOSE { }; /** - * MEI att.sb.vis-form + * MEI att.sb.vis@form */ enum sbVis_FORM { sbVis_FORM_NONE = 0, @@ -1205,7 +1205,7 @@ enum sbVis_FORM { }; /** - * MEI att.staffgroupingsym-symbol + * MEI att.staffgroupingsym@symbol */ enum staffgroupingsym_SYMBOL { staffgroupingsym_SYMBOL_NONE = 0, @@ -1217,7 +1217,7 @@ enum staffgroupingsym_SYMBOL { }; /** - * MEI att.syl.log-con + * MEI att.syl.log@con */ enum sylLog_CON { sylLog_CON_NONE = 0, @@ -1232,7 +1232,7 @@ enum sylLog_CON { }; /** - * MEI att.syl.log-wordpos + * MEI att.syl.log@wordpos */ enum sylLog_WORDPOS { sylLog_WORDPOS_NONE = 0, @@ -1242,7 +1242,7 @@ enum sylLog_WORDPOS { }; /** - * MEI att.tuplet.vis-num.format + * MEI att.tuplet.vis@num.format */ enum tupletVis_NUMFORMAT { tupletVis_NUMFORMAT_NONE = 0, @@ -1251,7 +1251,7 @@ enum tupletVis_NUMFORMAT { }; /** - * MEI att.turn.log-form + * MEI att.turn.log@form */ enum turnLog_FORM { turnLog_FORM_NONE = 0, @@ -1260,7 +1260,7 @@ enum turnLog_FORM { }; /** - * MEI att.whitespace-xml:space + * MEI att.whitespace@xml:space */ enum whitespace_XMLSPACE { whitespace_XMLSPACE_NONE = 0, @@ -1272,5 +1272,5 @@ enum whitespace_XMLSPACE { } // vrv namespace -#endif // __VRV_ATT_DEF_H__ +#endif // __VRV_ATT_TYPES_H__ diff --git a/src/att.cpp b/src/att.cpp index bb7116e89af..fe73cd0e3a1 100644 --- a/src/att.cpp +++ b/src/att.cpp @@ -24,7 +24,7 @@ namespace vrv { //---------------------------------------------------------------------------- Att::Att(): - LibmeiConverter() + AttConverter() { } diff --git a/src/doc.cpp b/src/doc.cpp index 04e98099446..8e4d739fbf3 100644 --- a/src/doc.cpp +++ b/src/doc.cpp @@ -15,7 +15,7 @@ //---------------------------------------------------------------------------- -#include "att_comparison.h" +#include "attcomparison.h" #include "barline.h" #include "chord.h" #include "glyph.h" diff --git a/src/iomusxml.cpp b/src/iomusxml.cpp index bcf28e2fd2b..ee4ebd89e72 100644 --- a/src/iomusxml.cpp +++ b/src/iomusxml.cpp @@ -15,7 +15,7 @@ //---------------------------------------------------------------------------- -#include "att_comparison.h" +#include "attcomparison.h" #include "beam.h" #include "chord.h" #include "doc.h" diff --git a/src/layerelement.cpp b/src/layerelement.cpp index 8fbe576c0fe..d3c97716d60 100644 --- a/src/layerelement.cpp +++ b/src/layerelement.cpp @@ -15,7 +15,7 @@ #include "accid.h" #include "aligner.h" -#include "att_comparison.h" +#include "attcomparison.h" #include "barline.h" #include "beam.h" #include "chord.h" diff --git a/src/page.cpp b/src/page.cpp index 24ec3167db1..9e373dbe3ff 100644 --- a/src/page.cpp +++ b/src/page.cpp @@ -14,7 +14,7 @@ //---------------------------------------------------------------------------- -#include "att_comparison.h" +#include "attcomparison.h" #include "bboxdevicecontext.h" #include "doc.h" #include "system.h" diff --git a/src/view_floating.cpp b/src/view_floating.cpp index d1678a44dd3..2d35aa2d5b8 100644 --- a/src/view_floating.cpp +++ b/src/view_floating.cpp @@ -16,7 +16,7 @@ //---------------------------------------------------------------------------- -#include "att_comparison.h" +#include "attcomparison.h" #include "bboxdevicecontext.h" #include "devicecontext.h" #include "doc.h" diff --git a/src/view_page.cpp b/src/view_page.cpp index 54473c51417..0d01b8c9f3e 100644 --- a/src/view_page.cpp +++ b/src/view_page.cpp @@ -14,7 +14,7 @@ //---------------------------------------------------------------------------- -#include "att_comparison.h" +#include "attcomparison.h" #include "beam.h" #include "devicecontext.h" #include "doc.h" From c424bde7788bec79907a95c7dc41b43fb910bd5f Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 11 Dec 2015 18:40:32 +0100 Subject: [PATCH 014/217] Updating makefiles --- emscripten/build.sh | 1 + java/build.sh | 1 + python/setup.py | 3 ++- tools/CMakeLists.txt | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/emscripten/build.sh b/emscripten/build.sh index f0f1b7be56c..a40b8fe3066 100755 --- a/emscripten/build.sh +++ b/emscripten/build.sh @@ -159,6 +159,7 @@ python $EMCC $CHATTY \ $VEROVIO_ROOT/src/view_tuplet.cpp \ $VEROVIO_ROOT/src/vrv.cpp \ $VEROVIO_ROOT/src/pugixml.cpp \ + $VEROVIO_ROOT/libmei/attconverter.cpp \ $VEROVIO_ROOT/libmei/atts_cmn.cpp \ $VEROVIO_ROOT/libmei/atts_critapp.cpp \ $VEROVIO_ROOT/libmei/atts_mei.cpp \ diff --git a/java/build.sh b/java/build.sh index bb9f1b1084a..a3b88b19357 100755 --- a/java/build.sh +++ b/java/build.sh @@ -74,6 +74,7 @@ FILES="../src/accid.cpp \ ../src/view_tuplet.cpp \ ../src/vrv.cpp \ ../src/pugixml.cpp \ + ../libmei/attconverter.cpp \ ../libmei/atts_shared.cpp \ ../libmei/atts_cmn.cpp \ ../libmei/atts_critapp.cpp \ diff --git a/python/setup.py b/python/setup.py index f5c7613affc..d2ecec8ee6b 100755 --- a/python/setup.py +++ b/python/setup.py @@ -78,12 +78,13 @@ '../src/view_tuplet.cpp', '../src/vrv.cpp', '../src/pugixml.cpp', - '../libmei/atts_shared.cpp', + '../libmei/attconverter.cpp', '../libmei/atts_cmn.cpp', '../libmei/atts_critapp.cpp', '../libmei/atts_mei.cpp', '../libmei/atts_mensural.cpp', '../libmei/atts_pagebased.cpp', + '../libmei/atts_shared.cpp', 'verovio.i'], swig_opts=['-c++'], include_dirs=['/usr/local/include', '../include', '../include/vrv', '../libmei'], diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 8d53fc12410..90cd98f95b8 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -83,6 +83,7 @@ add_executable (verovio ../src/view_tuplet.cpp ../src/vrv.cpp ../src/pugixml.cpp + ../libmei/attconverter.cpp #../libmei/atts_analysis.cpp #../libmei/atts_cmnornaments.cpp #../libmei/atts_edittrans.cpp From 10063732365b77be13f67b2b8a1fde49d5aba4ae Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 11 Dec 2015 18:51:56 +0100 Subject: [PATCH 015/217] Making spacing uniform --- include/vrv/att.h | 4 +++- include/vrv/attdef.h | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/vrv/att.h b/include/vrv/att.h index 57425935b0f..25686589185 100644 --- a/include/vrv/att.h +++ b/include/vrv/att.h @@ -5,6 +5,7 @@ // Copyright (c) Authors and others. All rights reserved. ///////////////////////////////////////////////////////////////////////////// + #ifndef __VRV_ATT_H__ #define __VRV_ATT_H__ @@ -103,10 +104,10 @@ class Att: public AttConverter ///@{ double StrToDbl(std::string value); int StrToInt(std::string value); + ///@} /** @name Converters for writing and reading */ ///@{ - std::string BeatrptRendToStr(data_BEATRPT_REND data); data_BEATRPT_REND StrToBeatrptRend(std::string value); @@ -145,6 +146,7 @@ class Att: public AttConverter std::string TieToStr(data_TIE data); data_TIE StrToTie(std::string value); + ///@} }; //---------------------------------------------------------------------------- diff --git a/include/vrv/attdef.h b/include/vrv/attdef.h index 8f4168b3f48..8fd40273078 100644 --- a/include/vrv/attdef.h +++ b/include/vrv/attdef.h @@ -6,8 +6,8 @@ ///////////////////////////////////////////////////////////////////////////// -#ifndef __ATT_DEF_H__ -#define __ATT_DEF_H__ +#ifndef __VRV_ATT_DEF_H__ +#define __VRV_ATT_DEF_H__ #include #include @@ -247,4 +247,4 @@ enum data_TEMPUS { } // namespace vrv -#endif // __ATT_DEF_H__ +#endif // __VRV_ATT_DEF_H__ From deb8bab6a503b3a0de2a9f34124b4681d7d97776 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 11 Dec 2015 18:55:36 +0100 Subject: [PATCH 016/217] Tidying up makefiles --- emscripten/build.sh | 2 +- java/build.sh | 4 ++-- tools/CMakeLists.txt | 15 +-------------- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/emscripten/build.sh b/emscripten/build.sh index a40b8fe3066..98fb065b296 100755 --- a/emscripten/build.sh +++ b/emscripten/build.sh @@ -164,8 +164,8 @@ python $EMCC $CHATTY \ $VEROVIO_ROOT/libmei/atts_critapp.cpp \ $VEROVIO_ROOT/libmei/atts_mei.cpp \ $VEROVIO_ROOT/libmei/atts_mensural.cpp \ - $VEROVIO_ROOT/libmei/atts_shared.cpp \ $VEROVIO_ROOT/libmei/atts_pagebased.cpp \ + $VEROVIO_ROOT/libmei/atts_shared.cpp \ lib/jsonxx/jsonxx.cc \ --embed-file data/ \ -s EXPORTED_FUNCTIONS="[\ diff --git a/java/build.sh b/java/build.sh index a3b88b19357..ca7100fb204 100755 --- a/java/build.sh +++ b/java/build.sh @@ -75,12 +75,12 @@ FILES="../src/accid.cpp \ ../src/vrv.cpp \ ../src/pugixml.cpp \ ../libmei/attconverter.cpp \ - ../libmei/atts_shared.cpp \ ../libmei/atts_cmn.cpp \ ../libmei/atts_critapp.cpp \ ../libmei/atts_mei.cpp \ ../libmei/atts_mensural.cpp \ - ../libmei/atts_pagebased.cpp" + ../libmei/atts_pagebased.cpp \ + ../libmei/atts_shared.cpp" CXXOPTS="-g -fpic -I../include -I../include/vrv -I../libmei -I/opt/local/include/ -I/System/Library/Frameworks/JavaVM.framework/Headers/" g++ -shared -o target/libverovio.jnilib $CXXOPTS $FILES verovio_wrap.cxx diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 90cd98f95b8..1607ea45cc9 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -84,25 +84,12 @@ add_executable (verovio ../src/vrv.cpp ../src/pugixml.cpp ../libmei/attconverter.cpp - #../libmei/atts_analysis.cpp - #../libmei/atts_cmnornaments.cpp - #../libmei/atts_edittrans.cpp - #../libmei/atts_figtable.cpp - #../libmei/atts_header.cpp - #../libmei/atts_lyrics.cpp - #../libmei/atts_midi.cpp - ../libmei/atts_shared.cpp ../libmei/atts_cmn.cpp ../libmei/atts_critapp.cpp - #../libmei/atts_facsimile.cpp - #../libmei/atts_harmony.cpp ../libmei/atts_mei.cpp ../libmei/atts_mensural.cpp ../libmei/atts_pagebased.cpp - #../libmei/atts_performance.cpp - #../libmei/atts_neumes.cpp - #../libmei/atts_tablature.cpp - #../libmei/atts_usersymbols.cpp + ../libmei/atts_shared.cpp ) install (TARGETS verovio DESTINATION /usr/local/bin) From ff7859a78c2661fe2c917b830ca05285efd1d337 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 11 Dec 2015 19:05:04 +0100 Subject: [PATCH 017/217] Adding support for notationtype to staffDef --- Verovio.xcodeproj/project.pbxproj | 2 ++ include/vrv/scoredef.h | 2 ++ src/iomei.cpp | 2 ++ src/scoredef.cpp | 3 +++ 4 files changed, 9 insertions(+) diff --git a/Verovio.xcodeproj/project.pbxproj b/Verovio.xcodeproj/project.pbxproj index a0404ef59cd..a9f046969fc 100644 --- a/Verovio.xcodeproj/project.pbxproj +++ b/Verovio.xcodeproj/project.pbxproj @@ -30,6 +30,7 @@ 4D4221071998A8CE00963292 /* atts_mensural.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEE29031940BCC100C76319 /* atts_mensural.cpp */; }; 4D43C30C1A9BB22A00EA28F3 /* view_mensural.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D43C30B1A9BB22A00EA28F3 /* view_mensural.cpp */; }; 4D50B53A1C1B40C90081D56E /* atttypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D50B5391C1B40C90081D56E /* atttypes.h */; }; + 4D50B53B1C1B47540081D56E /* atts_pagebased.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D3FF8D919BADD7A00B105B5 /* atts_pagebased.cpp */; }; 4D543E221B80AACF004B823C /* view_floating.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D543E211B80AACF004B823C /* view_floating.cpp */; }; 4D763EC61987D04E003FCAB5 /* metersig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D763EC51987D04D003FCAB5 /* metersig.cpp */; }; 4D763EC71987D04E003FCAB5 /* metersig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D763EC51987D04D003FCAB5 /* metersig.cpp */; }; @@ -1014,6 +1015,7 @@ 4D763EEC198BF2D8003FCAB5 /* atts_shared.cpp in Sources */, 4D422105199805F800963292 /* att.cpp in Sources */, 4D4221071998A8CE00963292 /* atts_mensural.cpp in Sources */, + 4D50B53B1C1B47540081D56E /* atts_pagebased.cpp in Sources */, 4D9A9C1A199F561200028D93 /* verse.cpp in Sources */, 4D9A9C1F19A1DE2000028D93 /* syl.cpp in Sources */, 4DF28A061A754DF000BA9F7D /* floatingelement.cpp in Sources */, diff --git a/include/vrv/scoredef.h b/include/vrv/scoredef.h index 5d9abad689a..46ca97e903e 100644 --- a/include/vrv/scoredef.h +++ b/include/vrv/scoredef.h @@ -9,6 +9,7 @@ #ifndef __VRV_SCOREDEF_H__ #define __VRV_SCOREDEF_H__ +#include "atts_mei.h" #include "atts_shared.h" #include "drawinginterface.h" #include "object.h" @@ -264,6 +265,7 @@ class StaffDef: public ScoreDefElement, public StaffDefDrawingInterface, public AttCommon, public AttCommonPart, public AttLabelsAddl, + public AttNotationtype, public AttScalable, public AttStaffDefVis { diff --git a/src/iomei.cpp b/src/iomei.cpp index 7a2f7167b51..d3156cb28f3 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -482,6 +482,7 @@ bool MeiOutput::WriteMeiStaffDef( pugi::xml_node currentNode, StaffDef *staffDef staffDef->WriteCommon(currentNode); staffDef->WriteCommonPart(currentNode); staffDef->WriteLabelsAddl(currentNode); + staffDef->WriteNotationtype(currentNode); staffDef->WriteScalable(currentNode); staffDef->WriteStaffDefVis(currentNode); @@ -1421,6 +1422,7 @@ bool MeiInput::ReadMeiStaffDef( Object *parent, pugi::xml_node staffDef ) vrvStaffDef->ReadCommon(staffDef); vrvStaffDef->ReadCommonPart(staffDef); vrvStaffDef->ReadLabelsAddl(staffDef); + vrvStaffDef->ReadNotationtype(staffDef); vrvStaffDef->ReadScalable(staffDef); vrvStaffDef->ReadStaffDefVis(staffDef); diff --git a/src/scoredef.cpp b/src/scoredef.cpp index a82d39cf3b5..11ea26902e2 100644 --- a/src/scoredef.cpp +++ b/src/scoredef.cpp @@ -416,12 +416,14 @@ StaffDef::StaffDef() : AttCommon(), AttCommonPart(), AttLabelsAddl(), + AttNotationtype(), AttScalable(), AttStaffDefVis() { RegisterAttClass(ATT_COMMON); RegisterAttClass(ATT_COMMONPART); RegisterAttClass(ATT_LABELSADDL); + RegisterAttClass(ATT_NOTATIONTYPE); RegisterAttClass(ATT_SCALABLE); RegisterAttClass(ATT_STAFFDEFVIS); Reset(); @@ -437,6 +439,7 @@ void StaffDef::Reset() ResetCommon(); ResetCommonPart(); ResetLabelsAddl(); + ResetNotationtype(); ResetScalable(); ResetStaffDefVis(); } From 83c6da0a0607d278b5b665c9144403aae81411b9 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 11 Dec 2015 19:14:56 +0100 Subject: [PATCH 018/217] Renaming Barline to BarLine --- include/vrv/attcomparison.h | 2 +- include/vrv/attdef.h | 6 ++++-- include/vrv/barline.h | 26 +++++++++++++------------- include/vrv/beam.h | 2 +- include/vrv/iomei.h | 6 +++--- include/vrv/iomusxml.h | 2 +- include/vrv/iopae.h | 4 ++-- include/vrv/measure.h | 24 ++++++++++++------------ include/vrv/note.h | 1 + include/vrv/style.h | 8 ++++---- include/vrv/view.h | 12 ++++++------ src/barline.cpp | 18 +++++++++--------- src/doc.cpp | 8 ++++---- src/iomei.cpp | 16 ++++++++-------- src/iomusxml.cpp | 4 ++-- src/iopae.cpp | 8 ++++---- src/measure.cpp | 24 ++++++++++++------------ src/object.cpp | 8 ++++---- src/style.cpp | 8 ++++---- src/view_element.cpp | 14 +++++++------- src/view_floating.cpp | 4 ++-- src/view_page.cpp | 34 +++++++++++++++++----------------- 22 files changed, 121 insertions(+), 118 deletions(-) diff --git a/include/vrv/attcomparison.h b/include/vrv/attcomparison.h index feb26bf3dbf..01f4a83f81e 100644 --- a/include/vrv/attcomparison.h +++ b/include/vrv/attcomparison.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: att_comparison.h +// Name: attcomparison.h // Author: Laurent Pugin // Created: 2015 // Copyright (c) Authors and others. All rights reserved. diff --git a/include/vrv/attdef.h b/include/vrv/attdef.h index 8fd40273078..548512ed1a5 100644 --- a/include/vrv/attdef.h +++ b/include/vrv/attdef.h @@ -104,7 +104,7 @@ enum data_DURATION { /** * MEI data.KEYSIGNATURE * The maximum is 255 (unsigned char) - * Order for 7f to 7s should not be changes. This is a special case since we use abs() + * Order from 7f to 7s should not be changes. This is a special case since we use abs() * to get the number of flats or sharps */ enum data_KEYSIGNATURE { @@ -127,7 +127,9 @@ enum data_KEYSIGNATURE { KEYSIGNATURE_mixed }; - +/** + * MEI data.MEASUREBEAT + */ typedef std::pair data_MEASUREBEAT; /** diff --git a/include/vrv/barline.h b/include/vrv/barline.h index 12d66971ce6..180a306f098 100644 --- a/include/vrv/barline.h +++ b/include/vrv/barline.h @@ -15,13 +15,13 @@ namespace vrv { //---------------------------------------------------------------------------- -// Barline +// BarLine //---------------------------------------------------------------------------- /** * This class models the MEI element. */ -class Barline: public LayerElement, +class BarLine: public LayerElement, public AttBarLineLog { public: @@ -30,11 +30,11 @@ class Barline: public LayerElement, * Reset method reset all attribute classes. */ ///@{ - Barline(); - virtual ~Barline(); + BarLine(); + virtual ~BarLine(); virtual void Reset(); - virtual Object* Clone() { return new Barline(*this); }; - virtual std::string GetClassName( ) { return "Barline"; }; + virtual Object* Clone() { return new BarLine(*this); }; + virtual std::string GetClassName( ) { return "BarLine"; }; virtual ClassId Is() { return BARLINE; }; ///@} @@ -42,7 +42,7 @@ class Barline: public LayerElement, virtual bool HasToBeAligned() { return true; }; /** - * Use to set the alignment for the Measure Barline members. + * Use to set the alignment for the Measure BarLine members. * This is as special case where we need to add to the measure aligner. */ void SetAlignment( Alignment *alignment ) { m_alignment = alignment; }; @@ -61,13 +61,13 @@ class Barline: public LayerElement, }; //---------------------------------------------------------------------------- -// BarlineAttr +// BarLineAttr //---------------------------------------------------------------------------- /** * This class models the barLine related attributes of a MEI measure. */ -class BarlineAttr: public Barline +class BarLineAttr: public BarLine { public: /** @@ -76,10 +76,10 @@ class BarlineAttr: public Barline * No Reset() method required. */ ///@{ - BarlineAttr(); - virtual ~BarlineAttr(); - virtual Object* Clone() { return new BarlineAttr(*this); }; - virtual std::string GetClassName( ) { return "BarlineAttr"; }; + BarLineAttr(); + virtual ~BarLineAttr(); + virtual Object* Clone() { return new BarLineAttr(*this); }; + virtual std::string GetClassName( ) { return "BarLineAttr"; }; virtual ClassId Is() { return BARLINE_ATTR; }; ///@} }; diff --git a/include/vrv/beam.h b/include/vrv/beam.h index 4fe189f5256..9908e16faff 100644 --- a/include/vrv/beam.h +++ b/include/vrv/beam.h @@ -4,7 +4,7 @@ // Created: 26/06/2012 // Copyright (c) Authors and others. All rights reserved. ///////////////////////////////////////////////////////////////////////////// -// + #ifndef __VRV_BEAM_H__ #define __VRV_BEAM_H__ diff --git a/include/vrv/iomei.h b/include/vrv/iomei.h index 04490cf472b..6abe4fa39d1 100644 --- a/include/vrv/iomei.h +++ b/include/vrv/iomei.h @@ -21,7 +21,7 @@ namespace vrv { class App; class Accid; class Annot; -class Barline; +class BarLine; class Beam; class BeatRpt; class BTrem; @@ -132,7 +132,7 @@ class MeiOutput: public FileOutputStream */ ///@{ void WriteMeiAccid( pugi::xml_node currentNode, Accid *accid ); - void WriteMeiBarline( pugi::xml_node currentNode, Barline *barLine ); + void WriteMeiBarLine( pugi::xml_node currentNode, BarLine *barLine ); void WriteMeiBeam( pugi::xml_node currentNode, Beam *beam ); void WriteMeiBeatRpt( pugi::xml_node currentNode, BeatRpt *beatRpt ); void WriteMeiBTrem( pugi::xml_node currentNode, BTrem *bTrem ); @@ -301,7 +301,7 @@ class MeiInput: public FileInputStream */ ///@{ bool ReadMeiAccid( Object *parent, pugi::xml_node accid ); - bool ReadMeiBarline( Object *parent, pugi::xml_node barLine ); + bool ReadMeiBarLine( Object *parent, pugi::xml_node barLine ); bool ReadMeiBeam( Object *parent, pugi::xml_node beam ); bool ReadMeiBeatRpt( Object *parent, pugi::xml_node beatRpt ); bool ReadMeiBTrem( Object *parent, pugi::xml_node bTrem ); diff --git a/include/vrv/iomusxml.h b/include/vrv/iomusxml.h index 9670d97a1da..1e6d47b0f16 100644 --- a/include/vrv/iomusxml.h +++ b/include/vrv/iomusxml.h @@ -109,7 +109,7 @@ class MusicXmlInput: public FileInputStream ///@{ void ReadMusicXmlAttributes(pugi::xml_node, Measure *measure, int measureNb); void ReadMusicXmlBackup(pugi::xml_node, Measure *measure, int measureNb); - void ReadMusicXmlBarline(pugi::xml_node, Measure *measure, int measureNb); + void ReadMusicXmlBarLine(pugi::xml_node, Measure *measure, int measureNb); void ReadMusicXmlForward(pugi::xml_node, Measure *measure, int measureNb); void ReadMusicXmlNote(pugi::xml_node, Measure *measure, int measureNb); ///@} diff --git a/include/vrv/iopae.h b/include/vrv/iopae.h index 4a66a0afc10..70acdf7fd7e 100644 --- a/include/vrv/iopae.h +++ b/include/vrv/iopae.h @@ -30,7 +30,7 @@ class Staff; class Tie; class Tuplet; class KeySig; -class Barline; +class BarLine; //---------------------------------------------------------------------------- // namespace for local Plain and Easy classes @@ -238,7 +238,7 @@ class PaeInput: public FileInputStream int getKeyInfo (const char* incipit, KeySig *key, int index = 0); int getTimeInfo (const char* incipit, MeterSig *meter, int index = 0); int getClefInfo (const char* incipit, Clef *mus_clef, int index = 0 ); - int getBarline (const char *incipit, data_BARRENDITION *output, int index ); + int getBarLine (const char *incipit, data_BARRENDITION *output, int index ); int getAccidental (const char* incipit, data_ACCIDENTAL_EXPLICIT *accident, int index = 0); int getOctave (const char* incipit, char *octave, int index = 0 ); int getDurations (const char* incipit, pae::Measure *measure, int index = 0); diff --git a/include/vrv/measure.h b/include/vrv/measure.h index 025edde50d9..a7ab792ec17 100644 --- a/include/vrv/measure.h +++ b/include/vrv/measure.h @@ -67,17 +67,17 @@ class Measure: public DocObject, /** * @name Set and get the left and right barLine types * This somehow conflicts with AttMeasureLog, which are transfered from and to the - * Barline object when reading and writing MEI. See MeiInput::ReadMeiMeasure and + * BarLine object when reading and writing MEI. See MeiInput::ReadMeiMeasure and * MeiOutput::ReadMeiMeasure * Alternatively, we could keep them in sync here: - * data_BARRENDITION GetLeftBarlineType() { m_leftBarline.SetRend( GetRight() ); return m_leftBarline.GetRend(); }; - * void SetLeftBarlineType( data_BARRENDITION type ) { m_leftBarline.SetRend(type); SetLeft(type); }; + * data_BARRENDITION GetLeftBarLineType() { m_leftBarLine.SetRend( GetRight() ); return m_leftBarLine.GetRend(); }; + * void SetLeftBarLineType( data_BARRENDITION type ) { m_leftBarLine.SetRend(type); SetLeft(type); }; */ ///@{ - data_BARRENDITION GetLeftBarlineType() const { return m_leftBarline.GetForm(); }; - void SetLeftBarlineType( data_BARRENDITION type ) { m_leftBarline.SetForm(type); }; - data_BARRENDITION GetRightBarlineType() const { return m_rightBarline.GetForm(); }; - void SetRightBarlineType( data_BARRENDITION type ) { m_rightBarline.SetForm(type); }; + data_BARRENDITION GetLeftBarLineType() const { return m_leftBarLine.GetForm(); }; + void SetLeftBarLineType( data_BARRENDITION type ) { m_leftBarLine.SetForm(type); }; + data_BARRENDITION GetRightBarLineType() const { return m_rightBarLine.GetForm(); }; + void SetRightBarLineType( data_BARRENDITION type ) { m_rightBarLine.SetForm(type); }; ///@} /** @@ -87,8 +87,8 @@ class Measure: public DocObject, * not for creating other measure objects. */ ///@{ - Barline *GetLeftBarline() { return &m_leftBarline; }; - Barline *GetRightBarline() { return &m_rightBarline; }; + BarLine *GetLeftBarLine() { return &m_leftBarLine; }; + BarLine *GetRightBarLine() { return &m_rightBarLine; }; ///@} int GetXRel( ); @@ -101,7 +101,7 @@ class Measure: public DocObject, /** * Return the X rel position of the right barLine (without its width) */ - int GetRightBarlineX( ); + int GetRightBarLineX( ); /** * Return the width of the measure, including the barLine width @@ -191,8 +191,8 @@ class Measure: public DocObject, * @name The measure barlines (left and right) used when drawing */ ///@{ - BarlineAttr m_leftBarline; - BarlineAttr m_rightBarline; + BarLineAttr m_leftBarLine; + BarLineAttr m_rightBarLine; ///@} }; diff --git a/include/vrv/note.h b/include/vrv/note.h index 05e330ae975..5c4e7468f22 100644 --- a/include/vrv/note.h +++ b/include/vrv/note.h @@ -5,6 +5,7 @@ // Copyright (c) Authors and others. All rights reserved. ///////////////////////////////////////////////////////////////////////////// + #ifndef __VRV_NOTE_H__ #define __VRV_NOTE_H__ diff --git a/include/vrv/style.h b/include/vrv/style.h index c82c15bd574..030e6d836d1 100644 --- a/include/vrv/style.h +++ b/include/vrv/style.h @@ -227,8 +227,8 @@ class Style char m_leftPosition; /** The layout left margin by element */ - char m_leftMarginBarline; - char m_leftMarginBarlineAttr; + char m_leftMarginBarLine; + char m_leftMarginBarLineAttr; char m_leftMarginBeatRpt; char m_leftMarginChord; char m_leftMarginClef; @@ -245,8 +245,8 @@ class Style char m_leftMarginDefault; /** The layout right margin by element */ - char m_rightMarginBarline; - char m_rightMarginBarlineAttr; + char m_rightMarginBarLine; + char m_rightMarginBarLineAttr; char m_rightMarginBeatRpt; char m_rightMarginChord; char m_rightMarginClef; diff --git a/include/vrv/view.h b/include/vrv/view.h index 4c7a16d9c4c..5995fcdb0ff 100644 --- a/include/vrv/view.h +++ b/include/vrv/view.h @@ -18,7 +18,7 @@ namespace vrv { class Accid; class Beam; class BeamParams; -class Barline; +class BarLine; class Chord; class DeviceContext; class Doc; @@ -145,14 +145,14 @@ class View ///@{ void DrawSystem( DeviceContext *dc, System *system ); void DrawSystemList( DeviceContext *dc, System *system, const ClassId classId ); - void DrawScoreDef( DeviceContext *dc, ScoreDef *scoreDef, Measure *measure, int x, Barline *barLine = NULL ); + void DrawScoreDef( DeviceContext *dc, ScoreDef *scoreDef, Measure *measure, int x, BarLine *barLine = NULL ); void DrawStaffGrp( DeviceContext *dc, Measure *measure, StaffGrp *staffGrp, int x, bool topStaffGrp = false, bool abbreviations = false ); void DrawStaffDefLabels( DeviceContext *dc, Measure *measure, ScoreDef *scoreDef, bool abbreviations = false ); void DrawBracket ( DeviceContext *dc, int x, int y1, int y2, int staffSize); void DrawBrace ( DeviceContext *dc, int x, int y1, int y2, int staffSize); - void DrawBarlines( DeviceContext *dc, Measure *measure, StaffGrp *staffGrp, Barline *barLine ); - void DrawBarline( DeviceContext *dc, int y_top, int y_bottom, Barline *barLine ); - void DrawBarlineDots ( DeviceContext *dc, StaffDef *staffDef, Staff *staff, Barline *barLine ); + void DrawBarLines( DeviceContext *dc, Measure *measure, StaffGrp *staffGrp, BarLine *barLine ); + void DrawBarLine( DeviceContext *dc, int y_top, int y_bottom, BarLine *barLine ); + void DrawBarLineDots ( DeviceContext *dc, StaffDef *staffDef, Staff *staff, BarLine *barLine ); void DrawMeasure( DeviceContext *dc, Measure *measure, System *system ); void DrawStaff( DeviceContext *dc, Staff *staff, Measure *measure, System *system ); void DrawStaffLines( DeviceContext *dc, Staff *staff, Measure *measure, System *system ); @@ -205,7 +205,7 @@ class View */ ///@{ void DrawAccid( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure, Accid* prevAccid = NULL ); - void DrawBarline( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure ); + void DrawBarLine( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure ); void DrawBeatRpt(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure ); void DrawBTrem(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure ); void DrawChord( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure ); diff --git a/src/barline.cpp b/src/barline.cpp index 542c247c653..3501c52e69c 100644 --- a/src/barline.cpp +++ b/src/barline.cpp @@ -11,10 +11,10 @@ namespace vrv { //---------------------------------------------------------------------------- -// Barline +// BarLine //---------------------------------------------------------------------------- -Barline::Barline(): +BarLine::BarLine(): LayerElement("bline-"), AttBarLineLog() { @@ -22,17 +22,17 @@ Barline::Barline(): Reset(); } -Barline::~Barline() +BarLine::~BarLine() { } -void Barline::Reset() +void BarLine::Reset() { LayerElement::Reset(); ResetBarLineLog(); } -bool Barline::HasRepetitionDots() +bool BarLine::HasRepetitionDots() { if (GetForm() == BARRENDITION_rptstart || GetForm() == BARRENDITION_rptend || GetForm() == BARRENDITION_rptboth) { return true; @@ -41,15 +41,15 @@ bool Barline::HasRepetitionDots() } //---------------------------------------------------------------------------- -// BarlineAttr +// BarLineAttr //---------------------------------------------------------------------------- -BarlineAttr::BarlineAttr(): - Barline() +BarLineAttr::BarLineAttr(): + BarLine() { } -BarlineAttr::~BarlineAttr() +BarLineAttr::~BarLineAttr() { } diff --git a/src/doc.cpp b/src/doc.cpp index 8e4d739fbf3..bdb6dc09e14 100644 --- a/src/doc.cpp +++ b/src/doc.cpp @@ -536,8 +536,8 @@ FontInfo *Doc::GetDrawingLyricFont( int staffSize ) char Doc::GetLeftMargin( const ClassId classId ) { - if (classId == BARLINE) return m_style->m_leftMarginBarline; - else if (classId == BARLINE_ATTR) return m_style->m_leftMarginBarlineAttr; + if (classId == BARLINE) return m_style->m_leftMarginBarLine; + else if (classId == BARLINE_ATTR) return m_style->m_leftMarginBarLineAttr; else if (classId == BEATRPT) return m_style->m_leftMarginBeatRpt; else if (classId == CHORD) return m_style->m_leftMarginChord; else if (classId == CLEF) return m_style->m_leftMarginClef; @@ -555,8 +555,8 @@ char Doc::GetLeftMargin( const ClassId classId ) char Doc::GetRightMargin( const ClassId classId ) { - if (classId == BARLINE) return m_style->m_rightMarginBarline; - else if (classId == BARLINE_ATTR) return m_style->m_rightMarginBarlineAttr; + if (classId == BARLINE) return m_style->m_rightMarginBarLine; + else if (classId == BARLINE_ATTR) return m_style->m_rightMarginBarLineAttr; else if (classId == BEATRPT) return m_style->m_rightMarginBeatRpt; else if (classId == CHORD) return m_style->m_rightMarginChord; else if (classId == CLEF) return m_style->m_rightMarginClef; diff --git a/src/iomei.cpp b/src/iomei.cpp index d3156cb28f3..28759bcedb9 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -207,7 +207,7 @@ bool MeiOutput::WriteObject( Object *object ) } else if (object->Is() == BARLINE) { m_currentNode = m_currentNode.append_child( "barLine" ); - WriteMeiBarline( m_currentNode, dynamic_cast(object) ); + WriteMeiBarLine( m_currentNode, dynamic_cast(object) ); } else if (object->Is() == BEAM) { m_currentNode = m_currentNode.append_child("beam"); @@ -580,7 +580,7 @@ void MeiOutput::WriteMeiAccid( pugi::xml_node currentNode, Accid *accid ) accid->WriteAccidLog(currentNode); } -void MeiOutput::WriteMeiBarline( pugi::xml_node currentNode, Barline *barLine ) +void MeiOutput::WriteMeiBarLine( pugi::xml_node currentNode, BarLine *barLine ) { assert( barLine ); @@ -1655,7 +1655,7 @@ bool MeiInput::ReadMeiLayerChildren( Object *parent, pugi::xml_node parentNode, success = ReadMeiAnnot( parent, xmlElement); } else if ( elementName == "barLine" ) { - success = ReadMeiBarline( parent, xmlElement ); + success = ReadMeiBarLine( parent, xmlElement ); } else if ( elementName == "beam" ) { success = ReadMeiBeam( parent, xmlElement); @@ -1763,14 +1763,14 @@ bool MeiInput::ReadMeiAccid( Object *parent, pugi::xml_node accid ) return true; } -bool MeiInput::ReadMeiBarline( Object *parent, pugi::xml_node barLine ) +bool MeiInput::ReadMeiBarLine( Object *parent, pugi::xml_node barLine ) { - Barline *vrvBarline = new Barline(); - ReadLayerElement(barLine, vrvBarline); + BarLine *vrvBarLine = new BarLine(); + ReadLayerElement(barLine, vrvBarLine); - vrvBarline->ReadBarLineLog(barLine); + vrvBarLine->ReadBarLineLog(barLine); - AddLayerElement(parent, vrvBarline); + AddLayerElement(parent, vrvBarLine); return true; } diff --git a/src/iomusxml.cpp b/src/iomusxml.cpp index ee4ebd89e72..a7a0b92910d 100644 --- a/src/iomusxml.cpp +++ b/src/iomusxml.cpp @@ -587,7 +587,7 @@ bool MusicXmlInput::ReadMusicXmlMeasure(pugi::xml_node node, Measure *measure, ReadMusicXmlAttributes(*it, measure, measureNb); } else if (IsElement(*it, "barline")) { - ReadMusicXmlBarline(*it, measure, measureNb); + ReadMusicXmlBarLine(*it, measure, measureNb); } else if (IsElement(*it, "note")) { ReadMusicXmlNote(*it, measure, measureNb); @@ -621,7 +621,7 @@ void MusicXmlInput::ReadMusicXmlBackup(pugi::xml_node node, Measure *measure, in { } -void MusicXmlInput::ReadMusicXmlBarline(pugi::xml_node node, Measure *measure, int measureNb) +void MusicXmlInput::ReadMusicXmlBarLine(pugi::xml_node node, Measure *measure, int measureNb) { data_BARRENDITION barRendition = BARRENDITION_NONE; std::string barStyle = GetContentOfChild(node, "bar-style"); diff --git a/src/iopae.cpp b/src/iopae.cpp index 5696d3cc0d8..6c1bb605f6d 100644 --- a/src/iopae.cpp +++ b/src/iopae.cpp @@ -277,7 +277,7 @@ void PaeInput::parsePlainAndEasy(std::istream &infile) { //barLine else if ((incipit[i] == ':') || (incipit[i] == '/')) { - i += getBarline(incipit, ¤t_measure.barLine, i); + i += getBarLine(incipit, ¤t_measure.barLine, i); current_measure.abbreviation_offset = 0; // just in case... staff.push_back( current_measure ); current_measure.reset(); @@ -882,7 +882,7 @@ int PaeInput::getWholeRest( const char *incipit, int *wholerest, int index ) { /********************************** * - * getBarline -- read the barLine. + * getBarLine -- read the barLine. * Translation from PAE to verovio representaion: * BARRENDITION_single / @@ -893,7 +893,7 @@ int PaeInput::getWholeRest( const char *incipit, int *wholerest, int index ) { BARRENDITION_dbl // */ -int PaeInput::getBarline( const char *incipit, data_BARRENDITION *output, int index ) { +int PaeInput::getBarLine( const char *incipit, data_BARRENDITION *output, int index ) { regex_t re; regcomp(&re, "^://:", REG_EXTENDED); @@ -1149,7 +1149,7 @@ void PaeInput::convertMeasure(pae::Measure *measure ) { // Set barLine // FIXME use flags for proper barLine identification - Barline *bline = m_measure->GetRightBarline(); + BarLine *bline = m_measure->GetRightBarLine(); bline->SetForm( measure->barLine ); } diff --git a/src/measure.cpp b/src/measure.cpp index 586aaa638bb..e68b569909a 100644 --- a/src/measure.cpp +++ b/src/measure.cpp @@ -59,8 +59,8 @@ void Measure::Reset() m_drawingX = 0; // by default, we have a single barLine on the right (none on the left) - m_rightBarline.SetForm( this->GetRight() ); - m_leftBarline.SetForm( this->GetLeft() ); + m_rightBarLine.SetForm( this->GetRight() ); + m_leftBarLine.SetForm( this->GetLeft() ); if ( !m_measuredMusic ) { m_xAbs = 0; @@ -116,7 +116,7 @@ int Measure::GetXRel() return 0; } -int Measure::GetRightBarlineX() +int Measure::GetRightBarLineX() { if ( m_measureAligner.GetRightAlignment() ) { return m_measureAligner.GetRightAlignment()->GetXRel(); @@ -127,7 +127,7 @@ int Measure::GetRightBarlineX() int Measure::GetWidth() { if ( m_measureAligner.GetRightAlignment() ) { - return GetRightBarlineX() + m_measureAligner.GetRightAlignment()->GetMaxWidth(); + return GetRightBarLineX() + m_measureAligner.GetRightAlignment()->GetMaxWidth(); } return 0; } @@ -151,18 +151,18 @@ int Measure::AlignHorizontally( ArrayPtrVoid *params ) m_measureAligner.Reset(); // here we transfer the @left and @right values to the barLine objects - this->SetLeftBarlineType( this->GetLeft() ); - this->SetRightBarlineType( this->GetRight() ); + this->SetLeftBarLineType( this->GetLeft() ); + this->SetRightBarLineType( this->GetRight() ); // point to it (*measureAligner) = &m_measureAligner; - if ( m_leftBarline.GetForm() != BARRENDITION_NONE ) { - m_leftBarline.SetAlignment( m_measureAligner.GetLeftAlignment() ); + if ( m_leftBarLine.GetForm() != BARRENDITION_NONE ) { + m_leftBarLine.SetAlignment( m_measureAligner.GetLeftAlignment() ); } - if ( m_rightBarline.GetForm() != BARRENDITION_NONE ) { - m_rightBarline.SetAlignment( m_measureAligner.GetRightAlignment() ); + if ( m_rightBarLine.GetForm() != BARRENDITION_NONE ) { + m_rightBarLine.SetAlignment( m_measureAligner.GetRightAlignment() ); } //LogDebug("\n ***** Align measure %d", this->GetN() ); @@ -256,9 +256,9 @@ int Measure::AlignMeasures( ArrayPtrVoid *params ) (*shift) += m_measureAligner.GetRightAlignment()->GetXRel(); // We also need to take into account the measure end (right) barLine with here - if (GetRightBarlineType() != BARRENDITION_NONE) { + if (GetRightBarLineType() != BARRENDITION_NONE) { // shift the next measure of the total with - (*shift) += GetRightBarline()->GetAlignment()->GetMaxWidth(); + (*shift) += GetRightBarLine()->GetAlignment()->GetMaxWidth(); } return FUNCTOR_SIBLINGS; diff --git a/src/object.cpp b/src/object.cpp index 172b1ad25ab..fe8cfb63cf3 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -1064,8 +1064,8 @@ int Object::SetBoundingBoxXShift( ArrayPtrVoid *params ) // we reset the measure width and the minimum position (*measure_width) = 0; (*min_pos) = 0; - if (current_measure->GetLeftBarlineType() != BARRENDITION_NONE) { - current_measure->GetLeftBarline()->SetBoundingBoxXShift( params ); + if (current_measure->GetLeftBarLineType() != BARRENDITION_NONE) { + current_measure->GetLeftBarLine()->SetBoundingBoxXShift( params ); } return FUNCTOR_CONTINUE; } @@ -1178,8 +1178,8 @@ int Object::SetBoundingBoxXShiftEnd( ArrayPtrVoid *params ) assert( current_measure ); // as minimum position of the barLine use the measure width (*min_pos) = (*measure_width); - if (current_measure->GetRightBarlineType() != BARRENDITION_NONE) { - current_measure->GetRightBarline()->SetBoundingBoxXShift( params ); + if (current_measure->GetRightBarLineType() != BARRENDITION_NONE) { + current_measure->GetRightBarLine()->SetBoundingBoxXShift( params ); } return FUNCTOR_CONTINUE; } diff --git a/src/style.cpp b/src/style.cpp index c7ea4c1f1bf..da94219f61d 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -61,8 +61,8 @@ Style::Style() m_leftPosition = DEFAULT_LEFT_POSITION * DEFINITON_FACTOR; /** The layout left margin by element */ - m_leftMarginBarline = DEFAULT_LEFT_MARGIN_BARLINE * DEFINITON_FACTOR; - m_leftMarginBarlineAttr = DEFAULT_LEFT_MARGIN_BARLINE_ATTR * DEFINITON_FACTOR; + m_leftMarginBarLine = DEFAULT_LEFT_MARGIN_BARLINE * DEFINITON_FACTOR; + m_leftMarginBarLineAttr = DEFAULT_LEFT_MARGIN_BARLINE_ATTR * DEFINITON_FACTOR; m_leftMarginBeatRpt = DEFAULT_LEFT_MARGIN_BEATRPT * DEFINITON_FACTOR; m_leftMarginChord = DEFAULT_LEFT_MARGIN_CHORD * DEFINITON_FACTOR; m_leftMarginClef = DEFAULT_LEFT_MARGIN_CLEF * DEFINITON_FACTOR; @@ -79,8 +79,8 @@ Style::Style() m_leftMarginDefault = DEFAULT_LEFT_MARGIN_DEFAULT * DEFINITON_FACTOR; /** The layout right margin by element */ - m_rightMarginBarline = DEFAULT_RIGHT_MARGIN_BARLINE * DEFINITON_FACTOR; - m_rightMarginBarlineAttr = DEFAULT_RIGHT_MARGIN_BARLINE_ATTR * DEFINITON_FACTOR; + m_rightMarginBarLine = DEFAULT_RIGHT_MARGIN_BARLINE * DEFINITON_FACTOR; + m_rightMarginBarLineAttr = DEFAULT_RIGHT_MARGIN_BARLINE_ATTR * DEFINITON_FACTOR; m_rightMarginBeatRpt = DEFAULT_RIGHT_MARGIN_BEATRPT * DEFINITON_FACTOR; m_rightMarginChord = DEFAULT_RIGHT_MARGIN_CHORD * DEFINITON_FACTOR; m_rightMarginClef = DEFAULT_RIGHT_MARGIN_CLEF * DEFINITON_FACTOR; diff --git a/src/view_element.cpp b/src/view_element.cpp index 6ae8adc7406..4259158c354 100644 --- a/src/view_element.cpp +++ b/src/view_element.cpp @@ -68,7 +68,7 @@ void View::DrawLayerElement( DeviceContext *dc, LayerElement *element, Layer *la DrawAccid(dc, element, layer, staff, measure); } else if (element->Is() == BARLINE) { - DrawBarline(dc, element, layer, staff, measure); + DrawBarLine(dc, element, layer, staff, measure); } else if (element->Is() == BEAM) { DrawBeam(dc, element, layer, staff, measure); @@ -237,7 +237,7 @@ void View::DrawAccid( DeviceContext *dc, LayerElement *element, Layer *layer, St dc->EndGraphic(element, this ); } -void View::DrawBarline( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure ) +void View::DrawBarLine( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure ) { assert( dc ); assert( element ); @@ -245,7 +245,7 @@ void View::DrawBarline( DeviceContext *dc, LayerElement *element, Layer *layer, assert( staff ); assert( measure ); - Barline *barLine = dynamic_cast(element); + BarLine *barLine = dynamic_cast(element); assert( barLine ); if (barLine->GetForm() == BARRENDITION_invis) { @@ -256,7 +256,7 @@ void View::DrawBarline( DeviceContext *dc, LayerElement *element, Layer *layer, dc->StartGraphic( element, "", element->GetUuid() ); int y = staff->GetDrawingY(); - DrawBarline( dc, y, y - m_doc->GetDrawingStaffSize(staff->m_drawingStaffSize), barLine ); + DrawBarLine( dc, y, y - m_doc->GetDrawingStaffSize(staff->m_drawingStaffSize), barLine ); dc->EndGraphic(element, this ); } @@ -890,7 +890,7 @@ void View::DrawMRest(DeviceContext *dc, LayerElement *element, Layer *layer, Sta dc->StartGraphic( element, "", element->GetUuid() ); - int width = measure->GetRightBarlineX() - measure->GetNonJustifiableLeftMargin(); + int width = measure->GetRightBarLineX() - measure->GetNonJustifiableLeftMargin(); int xCentered = measure->GetDrawingX() + measure->GetNonJustifiableLeftMargin() + (width / 2); int y = element->GetDrawingY(); @@ -953,7 +953,7 @@ void View::DrawMultiRest(DeviceContext *dc, LayerElement *element, Layer *layer, dc->StartGraphic( element, "", element->GetUuid() ); - int width = measure->GetRightBarlineX() - measure->GetNonJustifiableLeftMargin(); + int width = measure->GetRightBarLineX() - measure->GetNonJustifiableLeftMargin(); int xCentered = measure->GetDrawingX() + measure->GetNonJustifiableLeftMargin() + (width / 2); // We do not support more than three chars @@ -1604,7 +1604,7 @@ void View::DrawMeterSigFigures( DeviceContext *dc, int x, int y, int num, int nu void View::DrawMRptPart(DeviceContext *dc, int x, wchar_t smuflCode, int num, bool line, Staff *staff, Measure *measure ) { - int width = measure->GetRightBarlineX() - measure->GetNonJustifiableLeftMargin(); + int width = measure->GetRightBarLineX() - measure->GetNonJustifiableLeftMargin(); int xCentered = measure->GetDrawingX() + measure->GetNonJustifiableLeftMargin() + (width / 2); int xSymbol = xCentered - m_doc->GetGlyphWidth(smuflCode, staff->m_drawingStaffSize, false) / 2; diff --git a/src/view_floating.cpp b/src/view_floating.cpp index 2d35aa2d5b8..d62dd7b9317 100644 --- a/src/view_floating.cpp +++ b/src/view_floating.cpp @@ -94,7 +94,7 @@ void View::DrawTimeSpanningElement( DeviceContext *dc, DocObject *element, Syste if ( !Check( staff ) ) return; x1 = interface->GetStart()->GetDrawingX(); - x2 = last->GetDrawingX() + last->GetRightBarlineX(); + x2 = last->GetDrawingX() + last->GetRightBarLineX(); graphic = element; spanningType = SPANNING_START; } @@ -145,7 +145,7 @@ void View::DrawTimeSpanningElement( DeviceContext *dc, DocObject *element, Syste } x1 = firstNote ? firstNote->GetDrawingX() - 2 * m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) : first->GetDrawingX(); - x2 = last->GetDrawingX() + last->GetRightBarlineX(); + x2 = last->GetDrawingX() + last->GetRightBarLineX(); spanningType = SPANNING_MIDDLE; } diff --git a/src/view_page.cpp b/src/view_page.cpp index 0d01b8c9f3e..e7c2f0d813b 100644 --- a/src/view_page.cpp +++ b/src/view_page.cpp @@ -150,7 +150,7 @@ void View::DrawSystem( DeviceContext *dc, System *system ) // First get the first measure of the system Measure *measure = dynamic_cast(system->FindChildByType( MEASURE ) ); if ( measure ) { - // NULL for the Barline parameters indicates that we are drawing the scoreDef + // NULL for the BarLine parameters indicates that we are drawing the scoreDef DrawScoreDef( dc, &m_drawingScoreDef, measure, system->GetDrawingX(), NULL ); // Draw mesure number if > 1 // This needs to be improved because we are now using (tuplet) oblique figures. @@ -201,7 +201,7 @@ void View::DrawSystemList( DeviceContext *dc, System *system, const ClassId clas } } -void View::DrawScoreDef( DeviceContext *dc, ScoreDef *scoreDef, Measure *measure, int x, Barline *barLine ) +void View::DrawScoreDef( DeviceContext *dc, ScoreDef *scoreDef, Measure *measure, int x, BarLine *barLine ) { assert( dc ); assert( scoreDef ); @@ -224,7 +224,7 @@ void View::DrawScoreDef( DeviceContext *dc, ScoreDef *scoreDef, Measure *measure else { barLine->SetDrawingX( x ); dc->StartGraphic( barLine, "", barLine->GetUuid() ); - DrawBarlines( dc, measure, staffGrp, barLine ); + DrawBarLines( dc, measure, staffGrp, barLine ); dc->EndGraphic( barLine, this ); } @@ -533,7 +533,7 @@ void View::DrawBrace ( DeviceContext *dc, int x, int y1, int y2, int staffSize) } -void View::DrawBarlines( DeviceContext *dc, Measure *measure, StaffGrp *staffGrp, Barline *barLine ) +void View::DrawBarLines( DeviceContext *dc, Measure *measure, StaffGrp *staffGrp, BarLine *barLine ) { assert( dc ); assert( measure ); @@ -549,21 +549,21 @@ void View::DrawBarlines( DeviceContext *dc, Measure *measure, StaffGrp *staffGrp childStaffGrp = dynamic_cast(staffGrp->GetChild( i )); childStaffDef = dynamic_cast(staffGrp->GetChild( i )); if ( childStaffGrp ) { - DrawBarlines( dc, measure, childStaffGrp, barLine ); + DrawBarLines( dc, measure, childStaffGrp, barLine ); } else if ( childStaffDef ) { AttCommonNComparison comparison( STAFF, childStaffDef->GetN() ); Staff *staff = dynamic_cast(measure->FindChildByAttComparison(&comparison, 1 ) ); if (!staff ) { - LogDebug("Could not get staff (%d) while drawing staffGrp - Vrv::DrawBarlines", childStaffDef->GetN() ); + LogDebug("Could not get staff (%d) while drawing staffGrp - Vrv::DrawBarLines", childStaffDef->GetN() ); continue; } int y_top = staff->GetDrawingY(); // for the bottom position we need to take into account the number of lines and the staff size int y_bottom = staff->GetDrawingY() - (childStaffDef->GetLines() - 1) * m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize); - DrawBarline( dc, y_top, y_bottom, barLine ); + DrawBarLine( dc, y_top, y_bottom, barLine ); if ( barLine->HasRepetitionDots() ) { - DrawBarlineDots( dc, childStaffDef, staff, barLine ); + DrawBarLineDots( dc, childStaffDef, staff, barLine ); } } } @@ -599,7 +599,7 @@ void View::DrawBarlines( DeviceContext *dc, Measure *measure, StaffGrp *staffGrp // for the bottom position we need to take into account the number of lines and the staff size int y_bottom = last->GetDrawingY() - (lastDef->GetLines() - 1) * m_doc->GetDrawingDoubleUnit(last->m_drawingStaffSize); - DrawBarline( dc, y_top, y_bottom, barLine ); + DrawBarLine( dc, y_top, y_bottom, barLine ); // Now we have a barthru barLine, but we have dots so we still need to go through each staff if ( barLine->HasRepetitionDots() ) { @@ -611,17 +611,17 @@ void View::DrawBarlines( DeviceContext *dc, Measure *measure, StaffGrp *staffGrp AttCommonNComparison comparison( STAFF, childStaffDef->GetN() ); Staff *staff = dynamic_cast(measure->FindChildByAttComparison(&comparison, 1)); if (!staff ) { - LogDebug("Could not get staff (%d) while drawing staffGrp - Vrv::DrawBarlines", childStaffDef->GetN() ); + LogDebug("Could not get staff (%d) while drawing staffGrp - Vrv::DrawBarLines", childStaffDef->GetN() ); continue; } - DrawBarlineDots( dc, childStaffDef, staff, barLine ); + DrawBarLineDots( dc, childStaffDef, staff, barLine ); } } } } } -void View::DrawBarline( DeviceContext *dc, int y_top, int y_bottom, Barline *barLine ) +void View::DrawBarLine( DeviceContext *dc, int y_top, int y_bottom, BarLine *barLine ) { assert( dc ); assert( barLine ); @@ -673,7 +673,7 @@ void View::DrawBarline( DeviceContext *dc, int y_top, int y_bottom, Barline *bar } -void View::DrawBarlineDots ( DeviceContext *dc, StaffDef *staffDef, Staff *staff, Barline *barLine ) +void View::DrawBarLineDots ( DeviceContext *dc, StaffDef *staffDef, Staff *staff, BarLine *barLine ) { assert( dc ); assert( staffDef ); @@ -719,11 +719,11 @@ void View::DrawMeasure( DeviceContext *dc, Measure *measure, System *system ) DrawMeasureChildren(dc, measure, measure, system); - if ( measure->GetLeftBarlineType() != BARRENDITION_NONE) { - DrawScoreDef( dc, &m_drawingScoreDef, measure, measure->GetDrawingX(), measure->GetLeftBarline() ); + if ( measure->GetLeftBarLineType() != BARRENDITION_NONE) { + DrawScoreDef( dc, &m_drawingScoreDef, measure, measure->GetDrawingX(), measure->GetLeftBarLine() ); } - if ( measure->GetRightBarlineType() != BARRENDITION_NONE) { - DrawScoreDef( dc, &m_drawingScoreDef, measure, measure->GetDrawingX() + measure->GetRightBarlineX(), measure->GetRightBarline() ); + if ( measure->GetRightBarLineType() != BARRENDITION_NONE) { + DrawScoreDef( dc, &m_drawingScoreDef, measure, measure->GetDrawingX() + measure->GetRightBarLineX(), measure->GetRightBarLine() ); } if ( measure->IsMeasuredMusic()) { From ecb92115f02060e86116daf4784207e587b17268 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 11 Dec 2015 21:10:53 +0100 Subject: [PATCH 019/217] Additional comment on atttypes.h and attdef.h --- include/vrv/attdef.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/vrv/attdef.h b/include/vrv/attdef.h index 548512ed1a5..b9998c2bf4a 100644 --- a/include/vrv/attdef.h +++ b/include/vrv/attdef.h @@ -58,6 +58,13 @@ typedef std::vector > ArrayOfStrAttr; // MEI data defines //---------------------------------------------------------------------------- +/** + * The following defines are hand-coded and were not generated by libmei as + * the ones in ./libmei/atttypes.h. The are generated by hand either because + * the regroup different types (e.g., data_STEMDIRECTION) or because the MEI + * data type is a pattern and not a closed list. + */ + /** * MEI data.BEATRPT_REND */ From 59e15b65d1713bc67e5ec982530b48c3a8da4104 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sun, 13 Dec 2015 11:56:47 +0100 Subject: [PATCH 020/217] Fixes for avoiding compilation warning in non debug mode --- src/chord.cpp | 2 +- src/layerelement.cpp | 3 +++ src/measure.cpp | 2 ++ src/object.cpp | 9 --------- src/page.cpp | 4 ++++ src/scoredefinterface.cpp | 2 +- src/staff.cpp | 3 +++ src/system.cpp | 3 +++ src/view_element.cpp | 12 +++++++++--- 9 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/chord.cpp b/src/chord.cpp index 1ec627c9a43..2240b8cedbb 100644 --- a/src/chord.cpp +++ b/src/chord.cpp @@ -23,7 +23,7 @@ namespace vrv { //---------------------------------------------------------------------------- Chord::Chord( ): - LayerElement("chord-"), StemmedDrawingInterface(), ObjectListInterface(), DurationInterface(), + LayerElement("chord-"), ObjectListInterface(), StemmedDrawingInterface(), DurationInterface(), AttCommon(), AttStems(), AttStemsCmn(), diff --git a/src/layerelement.cpp b/src/layerelement.cpp index d3c97716d60..50613d4cc7f 100644 --- a/src/layerelement.cpp +++ b/src/layerelement.cpp @@ -475,6 +475,9 @@ int LayerElement::SetDrawingXY( ArrayPtrVoid *params ) } } + // For avoiding unused variable warning in non debug mode + doc = NULL; + return FUNCTOR_CONTINUE; } diff --git a/src/measure.cpp b/src/measure.cpp index e68b569909a..f4fc7cb0c69 100644 --- a/src/measure.cpp +++ b/src/measure.cpp @@ -328,6 +328,8 @@ int Measure::SetDrawingXY( ArrayPtrVoid *params ) this->SetDrawingX( this->m_xAbs ); } + // For avoiding unused variable warning in non debug mode + doc = NULL; return FUNCTOR_CONTINUE; } diff --git a/src/object.cpp b/src/object.cpp index fe8cfb63cf3..0862d5ffcc2 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -895,8 +895,6 @@ int Object::SetCurrentScoreDef( ArrayPtrVoid *params ) // starting a new system if (this->Is() == SYSTEM) { - System *system = dynamic_cast(this); - assert( system ); currentScoreDef->SetRedrawFlags( true, true, false, false, false ); return FUNCTOR_CONTINUE; } @@ -1186,8 +1184,6 @@ int Object::SetBoundingBoxXShiftEnd( ArrayPtrVoid *params ) // ending a layer if (this->Is() == LAYER) { - Layer *current_layer = dynamic_cast(this); - assert( current_layer ); // mininimum position is the with the layer // we keep it if is higher than what we had so far // this will be used for shifting the right barLine @@ -1207,8 +1203,6 @@ int Object::SetBoundingBoxYShift( ArrayPtrVoid *params ) // starting a new system if (this->Is() == SYSTEM) { - System *current_system = dynamic_cast(this); - assert( current_system ); // we reset the system height (*system_height) = 0; (*min_pos) = 0; @@ -1266,8 +1260,6 @@ int Object::SetBoundingBoxYShiftEnd( ArrayPtrVoid *params ) // ending a measure if (this->Is() == MEASURE) { - Measure *current_measure = dynamic_cast(this); - assert( current_measure ); // mininimum position is the height for the last (previous) staff // we keep it if it is higher than what we had so far (*system_height) = std::min( (*system_height), (*min_pos) ); @@ -1275,7 +1267,6 @@ int Object::SetBoundingBoxYShiftEnd( ArrayPtrVoid *params ) } // ending a system: see System::SetBoundingBoxYShiftEnd - return FUNCTOR_CONTINUE; } diff --git a/src/page.cpp b/src/page.cpp index 9e373dbe3ff..d45a79d04a2 100644 --- a/src/page.cpp +++ b/src/page.cpp @@ -338,6 +338,10 @@ int Page::GetContentWidth( ) if (!first ) { return 0; } + + // For avoiding unused variable warning in non debug mode + doc = NULL; + // we include the left margin and the right margin return first->m_drawingTotalWidth + first->m_systemLeftMar + first->m_systemRightMar; } diff --git a/src/scoredefinterface.cpp b/src/scoredefinterface.cpp index 8fc03483591..11c9689953c 100644 --- a/src/scoredefinterface.cpp +++ b/src/scoredefinterface.cpp @@ -29,8 +29,8 @@ ScoreDefInterface::ScoreDefInterface(): Interface(), AttCleffingLog(), AttKeySigDefaultLog(), AttKeySigDefaultVis(), - AttMensuralShared(), AttMensuralLog(), + AttMensuralShared(), AttMeterSigDefaultLog(), AttMeterSigDefaultVis(), AttMultinummeasures() diff --git a/src/staff.cpp b/src/staff.cpp index 30519861d05..49f8ddf1b6f 100644 --- a/src/staff.cpp +++ b/src/staff.cpp @@ -224,6 +224,9 @@ int Staff::SetDrawingXY( ArrayPtrVoid *params ) this->SetDrawingY( this->m_yAbs ); } + // For avoiding unused variable warning in non debug mode + doc = NULL; + return FUNCTOR_CONTINUE; } diff --git a/src/system.cpp b/src/system.cpp index 00b9958d9a9..eb61da157b0 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -323,6 +323,9 @@ int System::SetDrawingXY( ArrayPtrVoid *params ) this->SetDrawingY( this->m_yAbs ); } + // For avoiding unused variable warning in non debug mode + doc = NULL; + return FUNCTOR_CONTINUE; } diff --git a/src/view_element.cpp b/src/view_element.cpp index 4259158c354..153fca52a72 100644 --- a/src/view_element.cpp +++ b/src/view_element.cpp @@ -936,6 +936,9 @@ void View::DrawMRpt2(DeviceContext *dc, LayerElement *element, Layer *layer, Sta DrawMRptPart(dc, element->GetDrawingX(), SMUFL_E501_repeat2Bars, 2, true, staff, measure ); dc->EndGraphic(element, this); + + // For avoiding unused variable warning in non debug mode + mRpt2 = NULL; } void View::DrawMultiRest(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure) @@ -1832,6 +1835,9 @@ bool View::CalculateAccidX(Staff *staff, Accid *accid, Chord *chord, bool adjust { std::vector< std::vector > *accidSpace = &chord->m_accidSpace; + // Declared here for avoiding unused variable warning in non debug mode + int listBot, bottomY, accidSpaceSize; + //global drawing variables int fullUnit = m_doc->GetDrawingUnit(staff->m_drawingStaffSize); int halfUnit = fullUnit / 2; @@ -1841,13 +1847,13 @@ bool View::CalculateAccidX(Staff *staff, Accid *accid, Chord *chord, bool adjust int xLength = (int)accidSpace->front().size(); int yHeight = (int)accidSpace->size() - 1; int listTop = chord->m_accidSpaceTop; - int listBot = chord->m_accidSpaceBot; + listBot = chord->m_accidSpaceBot; //drawing variables for the accidental int type = accid->GetAccid(); int centerY = accid->GetDrawingY(); int topY = centerY + (accidHeight / 2); - int bottomY = centerY - (accidHeight / 2); + bottomY = centerY - (accidHeight / 2); //difference between left end and right end of the accidental int accidWidthDiff = ACCID_WIDTH - 1; @@ -1863,7 +1869,7 @@ bool View::CalculateAccidX(Staff *staff, Accid *accid, Chord *chord, bool adjust assert(((int)accidSpace->size() - 1) - ((std::max(0, bottomY - listBot)) / halfUnit) == accidTop + accidHeightDiff); // store it for asserts - int accidSpaceSize = (int)accidSpace->size(); + accidSpaceSize = (int)accidSpace->size(); assert(accidTop >= 0); assert(accidTop < accidSpaceSize); From 5501bd1cf8fa75284e962705a746d66ef6ced4c1 Mon Sep 17 00:00:00 2001 From: Don Byrd Date: Sun, 13 Dec 2015 07:19:58 -0500 Subject: [PATCH 021/217] Correct spelling errors and other minor cleanup. --- src/object.cpp | 8 ++++---- src/toolkit.cpp | 11 +++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/object.cpp b/src/object.cpp index 172b1ad25ab..470624cb8e2 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -993,7 +993,7 @@ int Object::AlignVertically( ArrayPtrVoid *params ) int Object::SetBoundingBoxGraceXShift( ArrayPtrVoid *params ) { - // param 0: the minimu position (i.e., the width of the previous element) + // param 0: the minimum position (i.e., the width of the previous element) // param 1: the Doc int *min_pos = static_cast((*params).at(0)); Doc *doc = static_cast((*params).at(1)); @@ -1050,7 +1050,7 @@ int Object::SetBoundingBoxGraceXShift( ArrayPtrVoid *params ) int Object::SetBoundingBoxXShift( ArrayPtrVoid *params ) { - // param 0: the minimu position (i.e., the width of the previous element) + // param 0: the minimum position (i.e., the width of the previous element) // param 1: the maximum width in the current measure // param 2: the Doc int *min_pos = static_cast((*params).at(0)); @@ -1167,7 +1167,7 @@ int Object::SetBoundingBoxXShift( ArrayPtrVoid *params ) int Object::SetBoundingBoxXShiftEnd( ArrayPtrVoid *params ) { - // param 0: the minimu position (i.e., the width of the previous element) + // param 0: the minimum position (i.e., the width of the previous element) // param 1: the maximum width in the current measure int *min_pos = static_cast((*params).at(0)); int *measure_width = static_cast((*params).at(1)); @@ -1176,7 +1176,7 @@ int Object::SetBoundingBoxXShiftEnd( ArrayPtrVoid *params ) if (this->Is() == MEASURE) { Measure *current_measure = dynamic_cast(this); assert( current_measure ); - // as minimum position of the barLine use the measure width + // use the measure width as minimum position of the barLine (*min_pos) = (*measure_width); if (current_measure->GetRightBarlineType() != BARRENDITION_NONE) { current_measure->GetRightBarline()->SetBoundingBoxXShift( params ); diff --git a/src/toolkit.cpp b/src/toolkit.cpp index f4bd1855448..04a102fc6f8 100644 --- a/src/toolkit.cpp +++ b/src/toolkit.cpp @@ -311,11 +311,10 @@ bool Toolkit::LoadString( const std::string &data ) this->SetNoLayout( true ); } - // do the layout? this depends on the options and of the - // file. PAE and DARMS of no layout information. MEI files - // can have, but this might have been ignored because of the - // --ignore-layout option. We won't do it if --no-layout option - // was set, though. + // Do the layout? this depends on the options and the file. PAE and + // DARMS have no layout information. MEI files _can_ have it, but it + // might have been ignored because of the --ignore-layout option. + // Regardless, we won't do layout if the --no-layout option was set. if (!input->HasLayoutInformation() && !m_noLayout) { //LogElapsedTimeStart(); m_doc.CastOff(); @@ -336,7 +335,7 @@ bool Toolkit::LoadString( const std::string &data ) std::string Toolkit::GetMEI( int pageNo, bool scoreBased ) { - // Page number is one-based - correction to 0-based first + // Page number is one-based - correct to 0-based first pageNo--; MeiOutput meioutput( &m_doc, "" ); From 50579a4ce68a18c046556d0ccc553a7df85f4bc8 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Mon, 14 Dec 2015 07:36:46 +0100 Subject: [PATCH 022/217] Comment update --- include/vrv/attdef.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/vrv/attdef.h b/include/vrv/attdef.h index b9998c2bf4a..41ebdaad1f9 100644 --- a/include/vrv/attdef.h +++ b/include/vrv/attdef.h @@ -61,8 +61,10 @@ typedef std::vector > ArrayOfStrAttr; /** * The following defines are hand-coded and were not generated by libmei as * the ones in ./libmei/atttypes.h. The are generated by hand either because - * the regroup different types (e.g., data_STEMDIRECTION) or because the MEI - * data type is a pattern and not a closed list. + * the regroup different types (e.g., data_STEMDIRECTION), because specific + * values are required (e.g., data_MODUSMAIOR), or because the MEI data type + * is a pattern and not a closed list and cannot be generated automatically + * easily (e.g., data_DURATION) */ /** From 5992106df5a1406891e33753a10673b0d58a4354 Mon Sep 17 00:00:00 2001 From: Don Byrd Date: Wed, 16 Dec 2015 15:27:31 -0500 Subject: [PATCH 023/217] In mensural notation, use the appropriate early-music clef. The only such SMuFL clefs Verovio knows about at the moment are the "Petrucci" ones; I think that's OK for now. --- src/view_element.cpp | 46 +++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/src/view_element.cpp b/src/view_element.cpp index 77bdcc2cc3e..ac407450928 100644 --- a/src/view_element.cpp +++ b/src/view_element.cpp @@ -1243,6 +1243,8 @@ void View::DrawChord( DeviceContext *dc, LayerElement *element, Layer *layer, St dc->ResetBrush(); } +#define MENSURAL true + void View::DrawClef( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure ) { assert( dc ); @@ -1256,62 +1258,64 @@ void View::DrawClef( DeviceContext *dc, LayerElement *element, Layer *layer, Sta dc->StartGraphic( element, "", element->GetUuid() ); - int b = staff->GetDrawingY(); - int a = element->GetDrawingX(); - int sym = SMUFL_E050_gClef; //sSOL, position d'ordre des cles sol fa ut in fonts + int y = staff->GetDrawingY(); + int x = element->GetDrawingX(); + int sym; // = SMUFL_E050_gClef; //sSOL, position d'ordre des cles sol fa ut in fonts /* poser sym=no de position sSOL dans la fonte - * au depart; ne faire operation sur b qu'une fois pour cas semblables, + * au depart; ne faire operation sur y qu'une fois pour cas semblables, * et au palier commun superieur, incrementer sym, sans break. */ switch(clef->GetClefId()) { case C1 : sym = SMUFL_E05C_cClef; - b -= m_doc->GetDrawingStaffSize(staff->m_drawingStaffSize); + y -= m_doc->GetDrawingStaffSize(staff->m_drawingStaffSize); break; case G1 : - b -= m_doc->GetDrawingStaffSize(staff->m_drawingStaffSize); + sym = (MENSURAL? SMUFL_E901_mensuralGclefPetrucci : SMUFL_E050_gClef); + y -= m_doc->GetDrawingStaffSize(staff->m_drawingStaffSize); break; case G2_8va : sym = SMUFL_E053_gClef8va; - b -= m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) * 3; + y -= m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) * 3; break; case G2_8vb : sym = SMUFL_E052_gClef8vb; - b -= m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) * 3; + y -= m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) * 3; break; case C2 : sym = SMUFL_E05C_cClef; - b -= m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) * 3; + y -= m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) * 3; break; case G2 : - b -= m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) * 3; + sym = (MENSURAL? SMUFL_E901_mensuralGclefPetrucci : SMUFL_E050_gClef); + y -= m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) * 3; break; case F3 : sym = SMUFL_E062_fClef; - b -= m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize)*2; + y -= m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize)*2; break; case C3 : - sym = SMUFL_E05C_cClef; - b -= m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize)*2; + sym = (MENSURAL? SMUFL_E909_mensuralCclefPetrucciPosMiddle : SMUFL_E05C_cClef); + y -= m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize)*2; break; case F5 : - sym =SMUFL_E062_fClef; + sym = SMUFL_E062_fClef; break; case F4 : - sym = SMUFL_E062_fClef; - b -= m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize); + sym = (MENSURAL? SMUFL_E904_mensuralFclefPetrucci : SMUFL_E062_fClef); + y -= m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize); break; case C4 : sym = SMUFL_E05C_cClef; - b -= m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize); + y -= m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize); break; case C5 : sym = SMUFL_E05C_cClef; break; case perc : - b -= m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) * 2; + y -= m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) * 2; // FIXME sym = SMUFL_E05C_cClef; break; @@ -1319,14 +1323,16 @@ void View::DrawClef( DeviceContext *dc, LayerElement *element, Layer *layer, Sta break; } + + LogDebug("sym=%d cClefPet=%d cClef=%d\n", sym, SMUFL_E909_mensuralCclefPetrucciPosMiddle, SMUFL_E05C_cClef); bool cueSize = false; // force cue size for intermediate clefs if (clef->GetFirstParent( LAYER )) cueSize = true; //if (!cueSize) - // a -= m_doc->GetDrawingUnit(staff->m_drawingStaffSize) * 2; + // x -= m_doc->GetDrawingUnit(staff->m_drawingStaffSize) * 2; - DrawSmuflCode ( dc, a, b, sym, staff->m_drawingStaffSize, cueSize ); + DrawSmuflCode ( dc, x, y, sym, staff->m_drawingStaffSize, cueSize ); dc->EndGraphic(element, this ); } From 79be1b1734975022cb073ec2ca019b6d3558c00d Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Thu, 17 Dec 2015 14:03:50 +0000 Subject: [PATCH 024/217] Preserving namespace in attribute names (libmei) --- libmei/atts_shared.cpp | 80 +++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/libmei/atts_shared.cpp b/libmei/atts_shared.cpp index 6da92bff5cc..de60fcc33f9 100644 --- a/libmei/atts_shared.cpp +++ b/libmei/atts_shared.cpp @@ -1116,9 +1116,9 @@ bool AttCommonPart::ReadCommonPart( pugi::xml_node element ) { element.remove_attribute("label"); hasAttribute = true; } - if (element.attribute("base")) { - this->SetBase(StrToStr(element.attribute("base").value())); - element.remove_attribute("base"); + if (element.attribute("xml:base")) { + this->SetBase(StrToStr(element.attribute("xml:base").value())); + element.remove_attribute("xml:base"); hasAttribute = true; } return hasAttribute; @@ -1131,7 +1131,7 @@ bool AttCommonPart::WriteCommonPart( pugi::xml_node element ) { wroteAttribute = true; } if (this->HasBase()) { - element.append_attribute("base") = StrToStr(this->GetBase()).c_str(); + element.append_attribute("xml:base") = StrToStr(this->GetBase()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -2759,14 +2759,14 @@ void AttLang::ResetLang() { bool AttLang::ReadLang( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("lang")) { - this->SetLang(StrToStr(element.attribute("lang").value())); - element.remove_attribute("lang"); + if (element.attribute("xml:lang")) { + this->SetLang(StrToStr(element.attribute("xml:lang").value())); + element.remove_attribute("xml:lang"); hasAttribute = true; } - if (element.attribute("translit")) { - this->SetTranslit(StrToStr(element.attribute("translit").value())); - element.remove_attribute("translit"); + if (element.attribute("xml:translit")) { + this->SetTranslit(StrToStr(element.attribute("xml:translit").value())); + element.remove_attribute("xml:translit"); hasAttribute = true; } return hasAttribute; @@ -2775,11 +2775,11 @@ bool AttLang::ReadLang( pugi::xml_node element ) { bool AttLang::WriteLang( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasLang()) { - element.append_attribute("lang") = StrToStr(this->GetLang()).c_str(); + element.append_attribute("xml:lang") = StrToStr(this->GetLang()).c_str(); wroteAttribute = true; } if (this->HasTranslit()) { - element.append_attribute("translit") = StrToStr(this->GetTranslit()).c_str(); + element.append_attribute("xml:translit") = StrToStr(this->GetTranslit()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -5087,34 +5087,34 @@ void AttPointing::ResetPointing() { bool AttPointing::ReadPointing( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("actuate")) { - this->SetActuate(StrToStr(element.attribute("actuate").value())); - element.remove_attribute("actuate"); + if (element.attribute("xlink:actuate")) { + this->SetActuate(StrToStr(element.attribute("xlink:actuate").value())); + element.remove_attribute("xlink:actuate"); hasAttribute = true; } - if (element.attribute("role")) { - this->SetRole(StrToStr(element.attribute("role").value())); - element.remove_attribute("role"); + if (element.attribute("xlink:role")) { + this->SetRole(StrToStr(element.attribute("xlink:role").value())); + element.remove_attribute("xlink:role"); hasAttribute = true; } - if (element.attribute("show")) { - this->SetShow(StrToStr(element.attribute("show").value())); - element.remove_attribute("show"); + if (element.attribute("xlink:show")) { + this->SetShow(StrToStr(element.attribute("xlink:show").value())); + element.remove_attribute("xlink:show"); hasAttribute = true; } - if (element.attribute("target")) { - this->SetTarget(StrToStr(element.attribute("target").value())); - element.remove_attribute("target"); + if (element.attribute("xlink:target")) { + this->SetTarget(StrToStr(element.attribute("xlink:target").value())); + element.remove_attribute("xlink:target"); hasAttribute = true; } - if (element.attribute("targettype")) { - this->SetTargettype(StrToStr(element.attribute("targettype").value())); - element.remove_attribute("targettype"); + if (element.attribute("xlink:targettype")) { + this->SetTargettype(StrToStr(element.attribute("xlink:targettype").value())); + element.remove_attribute("xlink:targettype"); hasAttribute = true; } - if (element.attribute("title")) { - this->SetTitle(StrToStr(element.attribute("title").value())); - element.remove_attribute("title"); + if (element.attribute("xlink:title")) { + this->SetTitle(StrToStr(element.attribute("xlink:title").value())); + element.remove_attribute("xlink:title"); hasAttribute = true; } return hasAttribute; @@ -5123,27 +5123,27 @@ bool AttPointing::ReadPointing( pugi::xml_node element ) { bool AttPointing::WritePointing( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasActuate()) { - element.append_attribute("actuate") = StrToStr(this->GetActuate()).c_str(); + element.append_attribute("xlink:actuate") = StrToStr(this->GetActuate()).c_str(); wroteAttribute = true; } if (this->HasRole()) { - element.append_attribute("role") = StrToStr(this->GetRole()).c_str(); + element.append_attribute("xlink:role") = StrToStr(this->GetRole()).c_str(); wroteAttribute = true; } if (this->HasShow()) { - element.append_attribute("show") = StrToStr(this->GetShow()).c_str(); + element.append_attribute("xlink:show") = StrToStr(this->GetShow()).c_str(); wroteAttribute = true; } if (this->HasTarget()) { - element.append_attribute("target") = StrToStr(this->GetTarget()).c_str(); + element.append_attribute("xlink:target") = StrToStr(this->GetTarget()).c_str(); wroteAttribute = true; } if (this->HasTargettype()) { - element.append_attribute("targettype") = StrToStr(this->GetTargettype()).c_str(); + element.append_attribute("xlink:targettype") = StrToStr(this->GetTargettype()).c_str(); wroteAttribute = true; } if (this->HasTitle()) { - element.append_attribute("title") = StrToStr(this->GetTitle()).c_str(); + element.append_attribute("xlink:title") = StrToStr(this->GetTitle()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -7516,9 +7516,9 @@ void AttWhitespace::ResetWhitespace() { bool AttWhitespace::ReadWhitespace( pugi::xml_node element ) { bool hasAttribute = false; - if (element.attribute("space")) { - this->SetSpace(StrToStr(element.attribute("space").value())); - element.remove_attribute("space"); + if (element.attribute("xml:space")) { + this->SetSpace(StrToStr(element.attribute("xml:space").value())); + element.remove_attribute("xml:space"); hasAttribute = true; } return hasAttribute; @@ -7527,7 +7527,7 @@ bool AttWhitespace::ReadWhitespace( pugi::xml_node element ) { bool AttWhitespace::WriteWhitespace( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasSpace()) { - element.append_attribute("space") = StrToStr(this->GetSpace()).c_str(); + element.append_attribute("xml:space") = StrToStr(this->GetSpace()).c_str(); wroteAttribute = true; } return wroteAttribute; From 8af7eb94009f4c7a14cbc9c94e6ae06bfc79ddac Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Thu, 17 Dec 2015 14:23:29 +0000 Subject: [PATCH 025/217] Fixing attribute names in JS getters and setters (libmei) --- libmei/atts_cmn.cpp | 64 +++--- libmei/atts_mensural.cpp | 40 ++-- libmei/atts_midi.cpp | 36 ++-- libmei/atts_shared.cpp | 412 +++++++++++++++++++------------------- libmei/atts_tablature.cpp | 12 +- 5 files changed, 282 insertions(+), 282 deletions(-) diff --git a/libmei/atts_cmn.cpp b/libmei/atts_cmn.cpp index 8d194ad6116..7f38895a170 100644 --- a/libmei/atts_cmn.cpp +++ b/libmei/atts_cmn.cpp @@ -1792,7 +1792,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) if (element->HasAttClass( ATT_BEAMEDWITH ) ) { AttBeamedwith *att = dynamic_cast(element); assert( att ); - if (attrType == "beamWith") { + if (attrType == "beam.with") { att->SetBeamWith(att->StrToOtherstaff(attrValue)); return true; } @@ -1800,11 +1800,11 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) if (element->HasAttClass( ATT_BEAMINGLOG ) ) { AttBeamingLog *att = dynamic_cast(element); assert( att ); - if (attrType == "beamGroup") { + if (attrType == "beam.group") { att->SetBeamGroup(att->StrToStr(attrValue)); return true; } - if (attrType == "beamRests") { + if (attrType == "beam.rests") { att->SetBeamRests(att->StrToBoolean(attrValue)); return true; } @@ -1896,7 +1896,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) att->SetGrace(att->StrToGrace(attrValue)); return true; } - if (attrType == "graceTime") { + if (attrType == "grace.time") { att->SetGraceTime(att->StrToInt(attrValue)); return true; } @@ -1988,11 +1988,11 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) if (element->HasAttClass( ATT_NUMBERPLACEMENT ) ) { AttNumberplacement *att = dynamic_cast(element); assert( att ); - if (attrType == "numPlace") { + if (attrType == "num.place") { att->SetNumPlace(att->StrToPlace(attrValue)); return true; } - if (attrType == "numVisible") { + if (attrType == "num.visible") { att->SetNumVisible(att->StrToBoolean(attrValue)); return true; } @@ -2024,7 +2024,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) if (element->HasAttClass( ATT_PIANOPEDALS ) ) { AttPianopedals *att = dynamic_cast(element); assert( att ); - if (attrType == "pedalStyle") { + if (attrType == "pedal.style") { att->SetPedalStyle(att->StrToPianopedalsPedalstyle(attrValue)); return true; } @@ -2032,7 +2032,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) if (element->HasAttClass( ATT_REHEARSAL ) ) { AttRehearsal *att = dynamic_cast(element); assert( att ); - if (attrType == "rehEnclose") { + if (attrType == "reh.enclose") { att->SetRehEnclose(att->StrToRehearsalRehenclose(attrValue)); return true; } @@ -2040,7 +2040,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) if (element->HasAttClass( ATT_SCOREDEFVISCMN ) ) { AttScoreDefVisCmn *att = dynamic_cast(element); assert( att ); - if (attrType == "gridShow") { + if (attrType == "grid.show") { att->SetGridShow(att->StrToBoolean(attrValue)); return true; } @@ -2048,7 +2048,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) if (element->HasAttClass( ATT_SLURREND ) ) { AttSlurrend *att = dynamic_cast(element); assert( att ); - if (attrType == "slurRend") { + if (attrType == "slur.rend") { att->SetSlurRend(att->StrToCurverendition(attrValue)); return true; } @@ -2056,7 +2056,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) if (element->HasAttClass( ATT_STEMSCMN ) ) { AttStemsCmn *att = dynamic_cast(element); assert( att ); - if (attrType == "stemWith") { + if (attrType == "stem.with") { att->SetStemWith(att->StrToOtherstaff(attrValue)); return true; } @@ -2064,7 +2064,7 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) if (element->HasAttClass( ATT_TIEREND ) ) { AttTierend *att = dynamic_cast(element); assert( att ); - if (attrType == "tieRend") { + if (attrType == "tie.rend") { att->SetTieRend(att->StrToCurverendition(attrValue)); return true; } @@ -2080,19 +2080,19 @@ bool Att::SetCmn( Object *element, std::string attrType, std::string attrValue ) if (element->HasAttClass( ATT_TUPLETVIS ) ) { AttTupletVis *att = dynamic_cast(element); assert( att ); - if (attrType == "bracketPlace") { + if (attrType == "bracket.place") { att->SetBracketPlace(att->StrToPlace(attrValue)); return true; } - if (attrType == "bracketVisible") { + if (attrType == "bracket.visible") { att->SetBracketVisible(att->StrToBoolean(attrValue)); return true; } - if (attrType == "durVisible") { + if (attrType == "dur.visible") { att->SetDurVisible(att->StrToBoolean(attrValue)); return true; } - if (attrType == "numFormat") { + if (attrType == "num.format") { att->SetNumFormat(att->StrToTupletVisNumformat(attrValue)); return true; } @@ -2134,17 +2134,17 @@ void Att::GetCmn( Object *element, ArrayOfStrAttr *attributes ) { AttBeamedwith *att = dynamic_cast(element); assert( att ); if (att->HasBeamWith()) { - attributes->push_back(std::make_pair("beamWith", att->OtherstaffToStr(att->GetBeamWith()))); + attributes->push_back(std::make_pair("beam.with", att->OtherstaffToStr(att->GetBeamWith()))); } } if (element->HasAttClass( ATT_BEAMINGLOG ) ) { AttBeamingLog *att = dynamic_cast(element); assert( att ); if (att->HasBeamGroup()) { - attributes->push_back(std::make_pair("beamGroup", att->StrToStr(att->GetBeamGroup()))); + attributes->push_back(std::make_pair("beam.group", att->StrToStr(att->GetBeamGroup()))); } if (att->HasBeamRests()) { - attributes->push_back(std::make_pair("beamRests", att->BooleanToStr(att->GetBeamRests()))); + attributes->push_back(std::make_pair("beam.rests", att->BooleanToStr(att->GetBeamRests()))); } } if (element->HasAttClass( ATT_BEAMREND ) ) { @@ -2223,7 +2223,7 @@ void Att::GetCmn( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("grace", att->GraceToStr(att->GetGrace()))); } if (att->HasGraceTime()) { - attributes->push_back(std::make_pair("graceTime", att->IntToStr(att->GetGraceTime()))); + attributes->push_back(std::make_pair("grace.time", att->IntToStr(att->GetGraceTime()))); } } if (element->HasAttClass( ATT_HAIRPINLOG ) ) { @@ -2300,10 +2300,10 @@ void Att::GetCmn( Object *element, ArrayOfStrAttr *attributes ) { AttNumberplacement *att = dynamic_cast(element); assert( att ); if (att->HasNumPlace()) { - attributes->push_back(std::make_pair("numPlace", att->PlaceToStr(att->GetNumPlace()))); + attributes->push_back(std::make_pair("num.place", att->PlaceToStr(att->GetNumPlace()))); } if (att->HasNumVisible()) { - attributes->push_back(std::make_pair("numVisible", att->BooleanToStr(att->GetNumVisible()))); + attributes->push_back(std::make_pair("num.visible", att->BooleanToStr(att->GetNumVisible()))); } } if (element->HasAttClass( ATT_OCTAVELOG ) ) { @@ -2331,42 +2331,42 @@ void Att::GetCmn( Object *element, ArrayOfStrAttr *attributes ) { AttPianopedals *att = dynamic_cast(element); assert( att ); if (att->HasPedalStyle()) { - attributes->push_back(std::make_pair("pedalStyle", att->PianopedalsPedalstyleToStr(att->GetPedalStyle()))); + attributes->push_back(std::make_pair("pedal.style", att->PianopedalsPedalstyleToStr(att->GetPedalStyle()))); } } if (element->HasAttClass( ATT_REHEARSAL ) ) { AttRehearsal *att = dynamic_cast(element); assert( att ); if (att->HasRehEnclose()) { - attributes->push_back(std::make_pair("rehEnclose", att->RehearsalRehencloseToStr(att->GetRehEnclose()))); + attributes->push_back(std::make_pair("reh.enclose", att->RehearsalRehencloseToStr(att->GetRehEnclose()))); } } if (element->HasAttClass( ATT_SCOREDEFVISCMN ) ) { AttScoreDefVisCmn *att = dynamic_cast(element); assert( att ); if (att->HasGridShow()) { - attributes->push_back(std::make_pair("gridShow", att->BooleanToStr(att->GetGridShow()))); + attributes->push_back(std::make_pair("grid.show", att->BooleanToStr(att->GetGridShow()))); } } if (element->HasAttClass( ATT_SLURREND ) ) { AttSlurrend *att = dynamic_cast(element); assert( att ); if (att->HasSlurRend()) { - attributes->push_back(std::make_pair("slurRend", att->CurverenditionToStr(att->GetSlurRend()))); + attributes->push_back(std::make_pair("slur.rend", att->CurverenditionToStr(att->GetSlurRend()))); } } if (element->HasAttClass( ATT_STEMSCMN ) ) { AttStemsCmn *att = dynamic_cast(element); assert( att ); if (att->HasStemWith()) { - attributes->push_back(std::make_pair("stemWith", att->OtherstaffToStr(att->GetStemWith()))); + attributes->push_back(std::make_pair("stem.with", att->OtherstaffToStr(att->GetStemWith()))); } } if (element->HasAttClass( ATT_TIEREND ) ) { AttTierend *att = dynamic_cast(element); assert( att ); if (att->HasTieRend()) { - attributes->push_back(std::make_pair("tieRend", att->CurverenditionToStr(att->GetTieRend()))); + attributes->push_back(std::make_pair("tie.rend", att->CurverenditionToStr(att->GetTieRend()))); } } if (element->HasAttClass( ATT_TREMMEASURED ) ) { @@ -2380,16 +2380,16 @@ void Att::GetCmn( Object *element, ArrayOfStrAttr *attributes ) { AttTupletVis *att = dynamic_cast(element); assert( att ); if (att->HasBracketPlace()) { - attributes->push_back(std::make_pair("bracketPlace", att->PlaceToStr(att->GetBracketPlace()))); + attributes->push_back(std::make_pair("bracket.place", att->PlaceToStr(att->GetBracketPlace()))); } if (att->HasBracketVisible()) { - attributes->push_back(std::make_pair("bracketVisible", att->BooleanToStr(att->GetBracketVisible()))); + attributes->push_back(std::make_pair("bracket.visible", att->BooleanToStr(att->GetBracketVisible()))); } if (att->HasDurVisible()) { - attributes->push_back(std::make_pair("durVisible", att->BooleanToStr(att->GetDurVisible()))); + attributes->push_back(std::make_pair("dur.visible", att->BooleanToStr(att->GetDurVisible()))); } if (att->HasNumFormat()) { - attributes->push_back(std::make_pair("numFormat", att->TupletVisNumformatToStr(att->GetNumFormat()))); + attributes->push_back(std::make_pair("num.format", att->TupletVisNumformatToStr(att->GetNumFormat()))); } } diff --git a/libmei/atts_mensural.cpp b/libmei/atts_mensural.cpp index 8275885422a..84a7c821a97 100644 --- a/libmei/atts_mensural.cpp +++ b/libmei/atts_mensural.cpp @@ -531,23 +531,23 @@ bool Att::SetMensural( Object *element, std::string attrType, std::string attrVa if (element->HasAttClass( ATT_MENSURALLOG ) ) { AttMensuralLog *att = dynamic_cast(element); assert( att ); - if (attrType == "mensurDot") { + if (attrType == "mensur.dot") { att->SetMensurDot(att->StrToBoolean(attrValue)); return true; } - if (attrType == "mensurSign") { + if (attrType == "mensur.sign") { att->SetMensurSign(att->StrToMensurationsign(attrValue)); return true; } - if (attrType == "mensurSlash") { + if (attrType == "mensur.slash") { att->SetMensurSlash(att->StrToInt(attrValue)); return true; } - if (attrType == "proportNum") { + if (attrType == "proport.num") { att->SetProportNum(att->StrToInt(attrValue)); return true; } - if (attrType == "proportNumbase") { + if (attrType == "proport.numbase") { att->SetProportNumbase(att->StrToInt(attrValue)); return true; } @@ -575,23 +575,23 @@ bool Att::SetMensural( Object *element, std::string attrType, std::string attrVa if (element->HasAttClass( ATT_MENSURALVIS ) ) { AttMensuralVis *att = dynamic_cast(element); assert( att ); - if (attrType == "mensurColor") { + if (attrType == "mensur.color") { att->SetMensurColor(att->StrToStr(attrValue)); return true; } - if (attrType == "mensurForm") { + if (attrType == "mensur.form") { att->SetMensurForm(att->StrToMensuralVisMensurform(attrValue)); return true; } - if (attrType == "mensurLoc") { + if (attrType == "mensur.loc") { att->SetMensurLoc(att->StrToInt(attrValue)); return true; } - if (attrType == "mensurOrient") { + if (attrType == "mensur.orient") { att->SetMensurOrient(att->StrToOrientation(attrValue)); return true; } - if (attrType == "mensurSize") { + if (attrType == "mensur.size") { att->SetMensurSize(att->StrToSize(attrValue)); return true; } @@ -638,19 +638,19 @@ void Att::GetMensural( Object *element, ArrayOfStrAttr *attributes ) { AttMensuralLog *att = dynamic_cast(element); assert( att ); if (att->HasMensurDot()) { - attributes->push_back(std::make_pair("mensurDot", att->BooleanToStr(att->GetMensurDot()))); + attributes->push_back(std::make_pair("mensur.dot", att->BooleanToStr(att->GetMensurDot()))); } if (att->HasMensurSign()) { - attributes->push_back(std::make_pair("mensurSign", att->MensurationsignToStr(att->GetMensurSign()))); + attributes->push_back(std::make_pair("mensur.sign", att->MensurationsignToStr(att->GetMensurSign()))); } if (att->HasMensurSlash()) { - attributes->push_back(std::make_pair("mensurSlash", att->IntToStr(att->GetMensurSlash()))); + attributes->push_back(std::make_pair("mensur.slash", att->IntToStr(att->GetMensurSlash()))); } if (att->HasProportNum()) { - attributes->push_back(std::make_pair("proportNum", att->IntToStr(att->GetProportNum()))); + attributes->push_back(std::make_pair("proport.num", att->IntToStr(att->GetProportNum()))); } if (att->HasProportNumbase()) { - attributes->push_back(std::make_pair("proportNumbase", att->IntToStr(att->GetProportNumbase()))); + attributes->push_back(std::make_pair("proport.numbase", att->IntToStr(att->GetProportNumbase()))); } } if (element->HasAttClass( ATT_MENSURALSHARED ) ) { @@ -673,19 +673,19 @@ void Att::GetMensural( Object *element, ArrayOfStrAttr *attributes ) { AttMensuralVis *att = dynamic_cast(element); assert( att ); if (att->HasMensurColor()) { - attributes->push_back(std::make_pair("mensurColor", att->StrToStr(att->GetMensurColor()))); + attributes->push_back(std::make_pair("mensur.color", att->StrToStr(att->GetMensurColor()))); } if (att->HasMensurForm()) { - attributes->push_back(std::make_pair("mensurForm", att->MensuralVisMensurformToStr(att->GetMensurForm()))); + attributes->push_back(std::make_pair("mensur.form", att->MensuralVisMensurformToStr(att->GetMensurForm()))); } if (att->HasMensurLoc()) { - attributes->push_back(std::make_pair("mensurLoc", att->IntToStr(att->GetMensurLoc()))); + attributes->push_back(std::make_pair("mensur.loc", att->IntToStr(att->GetMensurLoc()))); } if (att->HasMensurOrient()) { - attributes->push_back(std::make_pair("mensurOrient", att->OrientationToStr(att->GetMensurOrient()))); + attributes->push_back(std::make_pair("mensur.orient", att->OrientationToStr(att->GetMensurOrient()))); } if (att->HasMensurSize()) { - attributes->push_back(std::make_pair("mensurSize", att->SizeToStr(att->GetMensurSize()))); + attributes->push_back(std::make_pair("mensur.size", att->SizeToStr(att->GetMensurSize()))); } } if (element->HasAttClass( ATT_NOTELOGMENSURAL ) ) { diff --git a/libmei/atts_midi.cpp b/libmei/atts_midi.cpp index be061bf25ea..c61259fb4f1 100644 --- a/libmei/atts_midi.cpp +++ b/libmei/atts_midi.cpp @@ -464,19 +464,19 @@ bool Att::SetMidi( Object *element, std::string attrType, std::string attrValue if (element->HasAttClass( ATT_CHANNELIZED ) ) { AttChannelized *att = dynamic_cast(element); assert( att ); - if (attrType == "midiChannel") { + if (attrType == "midi.channel") { att->SetMidiChannel(att->StrToMidichannel(attrValue)); return true; } - if (attrType == "midiDuty") { + if (attrType == "midi.duty") { att->SetMidiDuty(att->StrToInt(attrValue)); return true; } - if (attrType == "midiPort") { + if (attrType == "midi.port") { att->SetMidiPort(att->StrToMidivalue(attrValue)); return true; } - if (attrType == "midiTrack") { + if (attrType == "midi.track") { att->SetMidiTrack(att->StrToInt(attrValue)); return true; } @@ -484,19 +484,19 @@ bool Att::SetMidi( Object *element, std::string attrType, std::string attrValue if (element->HasAttClass( ATT_MIDIINSTRUMENT ) ) { AttMidiinstrument *att = dynamic_cast(element); assert( att ); - if (attrType == "midiInstrnum") { + if (attrType == "midi.instrnum") { att->SetMidiInstrnum(att->StrToMidivalue(attrValue)); return true; } - if (attrType == "midiInstrname") { + if (attrType == "midi.instrname") { att->SetMidiInstrname(att->StrToMidinames(attrValue)); return true; } - if (attrType == "midiPan") { + if (attrType == "midi.pan") { att->SetMidiPan(att->StrToMidivalue(attrValue)); return true; } - if (attrType == "midiVolume") { + if (attrType == "midi.volume") { att->SetMidiVolume(att->StrToMidivalue(attrValue)); return true; } @@ -512,7 +512,7 @@ bool Att::SetMidi( Object *element, std::string attrType, std::string attrValue if (element->HasAttClass( ATT_MIDITEMPO ) ) { AttMiditempo *att = dynamic_cast(element); assert( att ); - if (attrType == "midiTempo") { + if (attrType == "midi.tempo") { att->SetMidiTempo(att->StrToMiditempo(attrValue)); return true; } @@ -558,32 +558,32 @@ void Att::GetMidi( Object *element, ArrayOfStrAttr *attributes ) { AttChannelized *att = dynamic_cast(element); assert( att ); if (att->HasMidiChannel()) { - attributes->push_back(std::make_pair("midiChannel", att->MidichannelToStr(att->GetMidiChannel()))); + attributes->push_back(std::make_pair("midi.channel", att->MidichannelToStr(att->GetMidiChannel()))); } if (att->HasMidiDuty()) { - attributes->push_back(std::make_pair("midiDuty", att->IntToStr(att->GetMidiDuty()))); + attributes->push_back(std::make_pair("midi.duty", att->IntToStr(att->GetMidiDuty()))); } if (att->HasMidiPort()) { - attributes->push_back(std::make_pair("midiPort", att->MidivalueToStr(att->GetMidiPort()))); + attributes->push_back(std::make_pair("midi.port", att->MidivalueToStr(att->GetMidiPort()))); } if (att->HasMidiTrack()) { - attributes->push_back(std::make_pair("midiTrack", att->IntToStr(att->GetMidiTrack()))); + attributes->push_back(std::make_pair("midi.track", att->IntToStr(att->GetMidiTrack()))); } } if (element->HasAttClass( ATT_MIDIINSTRUMENT ) ) { AttMidiinstrument *att = dynamic_cast(element); assert( att ); if (att->HasMidiInstrnum()) { - attributes->push_back(std::make_pair("midiInstrnum", att->MidivalueToStr(att->GetMidiInstrnum()))); + attributes->push_back(std::make_pair("midi.instrnum", att->MidivalueToStr(att->GetMidiInstrnum()))); } if (att->HasMidiInstrname()) { - attributes->push_back(std::make_pair("midiInstrname", att->MidinamesToStr(att->GetMidiInstrname()))); + attributes->push_back(std::make_pair("midi.instrname", att->MidinamesToStr(att->GetMidiInstrname()))); } if (att->HasMidiPan()) { - attributes->push_back(std::make_pair("midiPan", att->MidivalueToStr(att->GetMidiPan()))); + attributes->push_back(std::make_pair("midi.pan", att->MidivalueToStr(att->GetMidiPan()))); } if (att->HasMidiVolume()) { - attributes->push_back(std::make_pair("midiVolume", att->MidivalueToStr(att->GetMidiVolume()))); + attributes->push_back(std::make_pair("midi.volume", att->MidivalueToStr(att->GetMidiVolume()))); } } if (element->HasAttClass( ATT_MIDINUMBER ) ) { @@ -597,7 +597,7 @@ void Att::GetMidi( Object *element, ArrayOfStrAttr *attributes ) { AttMiditempo *att = dynamic_cast(element); assert( att ); if (att->HasMidiTempo()) { - attributes->push_back(std::make_pair("midiTempo", att->MiditempoToStr(att->GetMidiTempo()))); + attributes->push_back(std::make_pair("midi.tempo", att->MiditempoToStr(att->GetMidiTempo()))); } } if (element->HasAttClass( ATT_MIDIVALUE ) ) { diff --git a/libmei/atts_shared.cpp b/libmei/atts_shared.cpp index de60fcc33f9..82d21dc70cf 100644 --- a/libmei/atts_shared.cpp +++ b/libmei/atts_shared.cpp @@ -7720,7 +7720,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_ACCIDENTALPERFORMED ) ) { AttAccidentalPerformed *att = dynamic_cast(element); assert( att ); - if (attrType == "accidGes") { + if (attrType == "accid.ges") { att->SetAccidGes(att->StrToAccidentalImplicit(attrValue)); return true; } @@ -7736,7 +7736,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_ARTICULATIONPERFORMED ) ) { AttArticulationPerformed *att = dynamic_cast(element); assert( att ); - if (attrType == "articGes") { + if (attrType == "artic.ges") { att->SetArticGes(att->StrToArticulation(attrValue)); return true; } @@ -7784,15 +7784,15 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_BEAMINGVIS ) ) { AttBeamingVis *att = dynamic_cast(element); assert( att ); - if (attrType == "beamColor") { + if (attrType == "beam.color") { att->SetBeamColor(att->StrToStr(attrValue)); return true; } - if (attrType == "beamRend") { + if (attrType == "beam.rend") { att->SetBeamRend(att->StrToBeamingVisBeamrend(attrValue)); return true; } - if (attrType == "beamSlope") { + if (attrType == "beam.slope") { att->SetBeamSlope(att->StrToDbl(attrValue)); return true; } @@ -7848,19 +7848,19 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_CLEFFINGLOG ) ) { AttCleffingLog *att = dynamic_cast(element); assert( att ); - if (attrType == "clefShape") { + if (attrType == "clef.shape") { att->SetClefShape(att->StrToClefshape(attrValue)); return true; } - if (attrType == "clefLine") { + if (attrType == "clef.line") { att->SetClefLine(att->StrToInt(attrValue)); return true; } - if (attrType == "clefDis") { + if (attrType == "clef.dis") { att->SetClefDis(att->StrToOctaveDis(attrValue)); return true; } - if (attrType == "clefDisPlace") { + if (attrType == "clef.dis.place") { att->SetClefDisPlace(att->StrToPlace(attrValue)); return true; } @@ -7868,11 +7868,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_CLEFFINGVIS ) ) { AttCleffingVis *att = dynamic_cast(element); assert( att ); - if (attrType == "clefColor") { + if (attrType == "clef.color") { att->SetClefColor(att->StrToStr(attrValue)); return true; } - if (attrType == "clefVisible") { + if (attrType == "clef.visible") { att->SetClefVisible(att->StrToBoolean(attrValue)); return true; } @@ -7916,7 +7916,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu att->SetLabel(att->StrToStr(attrValue)); return true; } - if (attrType == "base") { + if (attrType == "xml:base") { att->SetBase(att->StrToStr(attrValue)); return true; } @@ -8020,15 +8020,15 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_DISTANCES ) ) { AttDistances *att = dynamic_cast(element); assert( att ); - if (attrType == "dynamDist") { + if (attrType == "dynam.dist") { att->SetDynamDist(att->StrToStr(attrValue)); return true; } - if (attrType == "harmDist") { + if (attrType == "harm.dist") { att->SetHarmDist(att->StrToStr(attrValue)); return true; } - if (attrType == "textDist") { + if (attrType == "text.dist") { att->SetTextDist(att->StrToStr(attrValue)); return true; } @@ -8052,15 +8052,15 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_DURATIONDEFAULT ) ) { AttDurationDefault *att = dynamic_cast(element); assert( att ); - if (attrType == "durDefault") { + if (attrType == "dur.default") { att->SetDurDefault(att->StrToDuration(attrValue)); return true; } - if (attrType == "numDefault") { + if (attrType == "num.default") { att->SetNumDefault(att->StrToInt(attrValue)); return true; } - if (attrType == "numbaseDefault") { + if (attrType == "numbase.default") { att->SetNumbaseDefault(att->StrToInt(attrValue)); return true; } @@ -8076,7 +8076,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_DURATIONPERFORMED ) ) { AttDurationPerformed *att = dynamic_cast(element); assert( att ); - if (attrType == "durGes") { + if (attrType == "dur.ges") { att->SetDurGes(att->StrToDuration(attrValue)); return true; } @@ -8104,7 +8104,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_ENDINGS ) ) { AttEndings *att = dynamic_cast(element); assert( att ); - if (attrType == "endingRend") { + if (attrType == "ending.rend") { att->SetEndingRend(att->StrToEndingsEndingrend(attrValue)); return true; } @@ -8200,23 +8200,23 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_KEYSIGDEFAULTLOG ) ) { AttKeySigDefaultLog *att = dynamic_cast(element); assert( att ); - if (attrType == "keyAccid") { + if (attrType == "key.accid") { att->SetKeyAccid(att->StrToAccidentalImplicit(attrValue)); return true; } - if (attrType == "keyMode") { + if (attrType == "key.mode") { att->SetKeyMode(att->StrToMode(attrValue)); return true; } - if (attrType == "keyPname") { + if (attrType == "key.pname") { att->SetKeyPname(att->StrToPitchname(attrValue)); return true; } - if (attrType == "keySig") { + if (attrType == "key.sig") { att->SetKeySig(att->StrToKeysignature(attrValue)); return true; } - if (attrType == "keySigMixed") { + if (attrType == "key.sig.mixed") { att->SetKeySigMixed(att->StrToStr(attrValue)); return true; } @@ -8224,11 +8224,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_KEYSIGDEFAULTVIS ) ) { AttKeySigDefaultVis *att = dynamic_cast(element); assert( att ); - if (attrType == "keySigShow") { + if (attrType == "key.sig.show") { att->SetKeySigShow(att->StrToBoolean(attrValue)); return true; } - if (attrType == "keySigShowchange") { + if (attrType == "key.sig.showchange") { att->SetKeySigShowchange(att->StrToBoolean(attrValue)); return true; } @@ -8236,7 +8236,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_LABELSADDL ) ) { AttLabelsAddl *att = dynamic_cast(element); assert( att ); - if (attrType == "labelAbbr") { + if (attrType == "label.abbr") { att->SetLabelAbbr(att->StrToStr(attrValue)); return true; } @@ -8244,11 +8244,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_LANG ) ) { AttLang *att = dynamic_cast(element); assert( att ); - if (attrType == "lang") { + if (attrType == "xml:lang") { att->SetLang(att->StrToStr(attrValue)); return true; } - if (attrType == "translit") { + if (attrType == "xml:translit") { att->SetTranslit(att->StrToStr(attrValue)); return true; } @@ -8340,27 +8340,27 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_LYRICSTYLE ) ) { AttLyricstyle *att = dynamic_cast(element); assert( att ); - if (attrType == "lyricAlign") { + if (attrType == "lyric.align") { att->SetLyricAlign(att->StrToStr(attrValue)); return true; } - if (attrType == "lyricFam") { + if (attrType == "lyric.fam") { att->SetLyricFam(att->StrToStr(attrValue)); return true; } - if (attrType == "lyricName") { + if (attrType == "lyric.name") { att->SetLyricName(att->StrToStr(attrValue)); return true; } - if (attrType == "lyricSize") { + if (attrType == "lyric.size") { att->SetLyricSize(att->StrToStr(attrValue)); return true; } - if (attrType == "lyricStyle") { + if (attrType == "lyric.style") { att->SetLyricStyle(att->StrToFontstyle(attrValue)); return true; } - if (attrType == "lyricWeight") { + if (attrType == "lyric.weight") { att->SetLyricWeight(att->StrToFontweight(attrValue)); return true; } @@ -8388,7 +8388,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_MEASURENUMBERS ) ) { AttMeasurenumbers *att = dynamic_cast(element); assert( att ); - if (attrType == "mnumVisible") { + if (attrType == "mnum.visible") { att->SetMnumVisible(att->StrToBoolean(attrValue)); return true; } @@ -8464,11 +8464,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_METERSIGDEFAULTLOG ) ) { AttMeterSigDefaultLog *att = dynamic_cast(element); assert( att ); - if (attrType == "meterCount") { + if (attrType == "meter.count") { att->SetMeterCount(att->StrToInt(attrValue)); return true; } - if (attrType == "meterUnit") { + if (attrType == "meter.unit") { att->SetMeterUnit(att->StrToInt(attrValue)); return true; } @@ -8476,15 +8476,15 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_METERSIGDEFAULTVIS ) ) { AttMeterSigDefaultVis *att = dynamic_cast(element); assert( att ); - if (attrType == "meterRend") { + if (attrType == "meter.rend") { att->SetMeterRend(att->StrToMeterSigDefaultVisMeterrend(attrValue)); return true; } - if (attrType == "meterShowchange") { + if (attrType == "meter.showchange") { att->SetMeterShowchange(att->StrToBoolean(attrValue)); return true; } - if (attrType == "meterSym") { + if (attrType == "meter.sym") { att->SetMeterSym(att->StrToMetersign(attrValue)); return true; } @@ -8516,11 +8516,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu att->SetMm(att->StrToStr(attrValue)); return true; } - if (attrType == "mmUnit") { + if (attrType == "mm.unit") { att->SetMmUnit(att->StrToDuration(attrValue)); return true; } - if (attrType == "mmDots") { + if (attrType == "mm.dots") { att->SetMmDots(att->StrToInt(attrValue)); return true; } @@ -8528,7 +8528,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_MULTINUMMEASURES ) ) { AttMultinummeasures *att = dynamic_cast(element); assert( att ); - if (attrType == "multiNumber") { + if (attrType == "multi.number") { att->SetMultiNumber(att->StrToBoolean(attrValue)); return true; } @@ -8548,11 +8548,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_NOTATIONSTYLE ) ) { AttNotationstyle *att = dynamic_cast(element); assert( att ); - if (attrType == "musicName") { + if (attrType == "music.name") { att->SetMusicName(att->StrToStr(attrValue)); return true; } - if (attrType == "musicSize") { + if (attrType == "music.size") { att->SetMusicSize(att->StrToStr(attrValue)); return true; } @@ -8560,11 +8560,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_NOTEGES ) ) { AttNoteGes *att = dynamic_cast(element); assert( att ); - if (attrType == "octGes") { + if (attrType == "oct.ges") { att->SetOctGes(att->StrToInt(attrValue)); return true; } - if (attrType == "pnameGes") { + if (attrType == "pname.ges") { att->SetPnameGes(att->StrToPitchname(attrValue)); return true; } @@ -8576,31 +8576,31 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_NOTEHEADS ) ) { AttNoteheads *att = dynamic_cast(element); assert( att ); - if (attrType == "headColor") { + if (attrType == "head.color") { att->SetHeadColor(att->StrToStr(attrValue)); return true; } - if (attrType == "headFill") { + if (attrType == "head.fill") { att->SetHeadFill(att->StrToStr(attrValue)); return true; } - if (attrType == "headFillcolor") { + if (attrType == "head.fillcolor") { att->SetHeadFillcolor(att->StrToStr(attrValue)); return true; } - if (attrType == "headMod") { + if (attrType == "head.mod") { att->SetHeadMod(att->StrToStr(attrValue)); return true; } - if (attrType == "headRotation") { + if (attrType == "head.rotation") { att->SetHeadRotation(att->StrToStr(attrValue)); return true; } - if (attrType == "headShape") { + if (attrType == "head.shape") { att->SetHeadShape(att->StrToStr(attrValue)); return true; } - if (attrType == "headVisible") { + if (attrType == "head.visible") { att->SetHeadVisible(att->StrToBoolean(attrValue)); return true; } @@ -8616,7 +8616,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_OCTAVEDEFAULT ) ) { AttOctavedefault *att = dynamic_cast(element); assert( att ); - if (attrType == "octaveDefault") { + if (attrType == "octave.default") { att->SetOctaveDefault(att->StrToInt(attrValue)); return true; } @@ -8628,7 +8628,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu att->SetDis(att->StrToOctaveDis(attrValue)); return true; } - if (attrType == "disPlace") { + if (attrType == "dis.place") { att->SetDisPlace(att->StrToPlace(attrValue)); return true; } @@ -8660,35 +8660,35 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_PAGES ) ) { AttPages *att = dynamic_cast(element); assert( att ); - if (attrType == "pageHeight") { + if (attrType == "page.height") { att->SetPageHeight(att->StrToStr(attrValue)); return true; } - if (attrType == "pageWidth") { + if (attrType == "page.width") { att->SetPageWidth(att->StrToStr(attrValue)); return true; } - if (attrType == "pageTopmar") { + if (attrType == "page.topmar") { att->SetPageTopmar(att->StrToStr(attrValue)); return true; } - if (attrType == "pageBotmar") { + if (attrType == "page.botmar") { att->SetPageBotmar(att->StrToStr(attrValue)); return true; } - if (attrType == "pageLeftmar") { + if (attrType == "page.leftmar") { att->SetPageLeftmar(att->StrToStr(attrValue)); return true; } - if (attrType == "pageRightmar") { + if (attrType == "page.rightmar") { att->SetPageRightmar(att->StrToStr(attrValue)); return true; } - if (attrType == "pagePanels") { + if (attrType == "page.panels") { att->SetPagePanels(att->StrToStr(attrValue)); return true; } - if (attrType == "pageScale") { + if (attrType == "page.scale") { att->SetPageScale(att->StrToStr(attrValue)); return true; } @@ -8732,27 +8732,27 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_POINTING ) ) { AttPointing *att = dynamic_cast(element); assert( att ); - if (attrType == "actuate") { + if (attrType == "xlink:actuate") { att->SetActuate(att->StrToStr(attrValue)); return true; } - if (attrType == "role") { + if (attrType == "xlink:role") { att->SetRole(att->StrToStr(attrValue)); return true; } - if (attrType == "show") { + if (attrType == "xlink:show") { att->SetShow(att->StrToStr(attrValue)); return true; } - if (attrType == "target") { + if (attrType == "xlink:target") { att->SetTarget(att->StrToStr(attrValue)); return true; } - if (attrType == "targettype") { + if (attrType == "xlink:targettype") { att->SetTargettype(att->StrToStr(attrValue)); return true; } - if (attrType == "title") { + if (attrType == "xlink:title") { att->SetTitle(att->StrToStr(attrValue)); return true; } @@ -8800,15 +8800,15 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_SCOREDEFGES ) ) { AttScoreDefGes *att = dynamic_cast(element); assert( att ); - if (attrType == "tunePname") { + if (attrType == "tune.pname") { att->SetTunePname(att->StrToPitchname(attrValue)); return true; } - if (attrType == "tuneHz") { + if (attrType == "tune.Hz") { att->SetTuneHz(att->StrToDbl(attrValue)); return true; } - if (attrType == "tuneTemper") { + if (attrType == "tune.temper") { att->SetTuneTemper(att->StrToTemperament(attrValue)); return true; } @@ -8816,7 +8816,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_SCOREDEFVIS ) ) { AttScoreDefVis *att = dynamic_cast(element); assert( att ); - if (attrType == "vuHeight") { + if (attrType == "vu.height") { att->SetVuHeight(att->StrToStr(attrValue)); return true; } @@ -8864,19 +8864,19 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_SPACING ) ) { AttSpacing *att = dynamic_cast(element); assert( att ); - if (attrType == "spacingPackexp") { + if (attrType == "spacing.packexp") { att->SetSpacingPackexp(att->StrToDbl(attrValue)); return true; } - if (attrType == "spacingPackfact") { + if (attrType == "spacing.packfact") { att->SetSpacingPackfact(att->StrToDbl(attrValue)); return true; } - if (attrType == "spacingStaff") { + if (attrType == "spacing.staff") { att->SetSpacingStaff(att->StrToStr(attrValue)); return true; } - if (attrType == "spacingSystem") { + if (attrType == "spacing.system") { att->SetSpacingSystem(att->StrToStr(attrValue)); return true; } @@ -8892,7 +8892,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_STAFFDEFVIS ) ) { AttStaffDefVis *att = dynamic_cast(element); assert( att ); - if (attrType == "gridShow") { + if (attrType == "grid.show") { att->SetGridShow(att->StrToBoolean(attrValue)); return true; } @@ -8904,11 +8904,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu att->SetLines(att->StrToInt(attrValue)); return true; } - if (attrType == "linesColor") { + if (attrType == "lines.color") { att->SetLinesColor(att->StrToStr(attrValue)); return true; } - if (attrType == "linesVisible") { + if (attrType == "lines.visible") { att->SetLinesVisible(att->StrToBoolean(attrValue)); return true; } @@ -8980,27 +8980,27 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_STEMS ) ) { AttStems *att = dynamic_cast(element); assert( att ); - if (attrType == "stemDir") { + if (attrType == "stem.dir") { att->SetStemDir(att->StrToStemdirection(attrValue)); return true; } - if (attrType == "stemLen") { + if (attrType == "stem.len") { att->SetStemLen(att->StrToStr(attrValue)); return true; } - if (attrType == "stemMod") { + if (attrType == "stem.mod") { att->SetStemMod(att->StrToStemmodifier(attrValue)); return true; } - if (attrType == "stemPos") { + if (attrType == "stem.pos") { att->SetStemPos(att->StrToStemposition(attrValue)); return true; } - if (attrType == "stemX") { + if (attrType == "stem.x") { att->SetStemX(att->StrToDbl(attrValue)); return true; } - if (attrType == "stemY") { + if (attrType == "stem.y") { att->SetStemY(att->StrToDbl(attrValue)); return true; } @@ -9028,19 +9028,19 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_SYSTEMS ) ) { AttSystems *att = dynamic_cast(element); assert( att ); - if (attrType == "systemLeftline") { + if (attrType == "system.leftline") { att->SetSystemLeftline(att->StrToBoolean(attrValue)); return true; } - if (attrType == "systemLeftmar") { + if (attrType == "system.leftmar") { att->SetSystemLeftmar(att->StrToStr(attrValue)); return true; } - if (attrType == "systemRightmar") { + if (attrType == "system.rightmar") { att->SetSystemRightmar(att->StrToStr(attrValue)); return true; } - if (attrType == "systemTopmar") { + if (attrType == "system.topmar") { att->SetSystemTopmar(att->StrToStr(attrValue)); return true; } @@ -9048,23 +9048,23 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_TEXTSTYLE ) ) { AttTextstyle *att = dynamic_cast(element); assert( att ); - if (attrType == "textFam") { + if (attrType == "text.fam") { att->SetTextFam(att->StrToStr(attrValue)); return true; } - if (attrType == "textName") { + if (attrType == "text.name") { att->SetTextName(att->StrToStr(attrValue)); return true; } - if (attrType == "textSize") { + if (attrType == "text.size") { att->SetTextSize(att->StrToStr(attrValue)); return true; } - if (attrType == "textStyle") { + if (attrType == "text.style") { att->SetTextStyle(att->StrToFontstyle(attrValue)); return true; } - if (attrType == "textWeight") { + if (attrType == "text.weight") { att->SetTextWeight(att->StrToFontweight(attrValue)); return true; } @@ -9088,11 +9088,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_TIMESTAMPPERFORMED ) ) { AttTimestampPerformed *att = dynamic_cast(element); assert( att ); - if (attrType == "tstampGes") { + if (attrType == "tstamp.ges") { att->SetTstampGes(att->StrToDuration(attrValue)); return true; } - if (attrType == "tstampReal") { + if (attrType == "tstamp.real") { att->SetTstampReal(att->StrToStr(attrValue)); return true; } @@ -9108,11 +9108,11 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_TRANSPOSITION ) ) { AttTransposition *att = dynamic_cast(element); assert( att ); - if (attrType == "transDiat") { + if (attrType == "trans.diat") { att->SetTransDiat(att->StrToDbl(attrValue)); return true; } - if (attrType == "transSemi") { + if (attrType == "trans.semi") { att->SetTransSemi(att->StrToDbl(attrValue)); return true; } @@ -9232,7 +9232,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu if (element->HasAttClass( ATT_WHITESPACE ) ) { AttWhitespace *att = dynamic_cast(element); assert( att ); - if (attrType == "space") { + if (attrType == "xml:space") { att->SetSpace(att->StrToStr(attrValue)); return true; } @@ -9292,7 +9292,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttAccidentalPerformed *att = dynamic_cast(element); assert( att ); if (att->HasAccidGes()) { - attributes->push_back(std::make_pair("accidGes", att->AccidentalImplicitToStr(att->GetAccidGes()))); + attributes->push_back(std::make_pair("accid.ges", att->AccidentalImplicitToStr(att->GetAccidGes()))); } } if (element->HasAttClass( ATT_ARTICULATION ) ) { @@ -9306,7 +9306,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttArticulationPerformed *att = dynamic_cast(element); assert( att ); if (att->HasArticGes()) { - attributes->push_back(std::make_pair("articGes", att->ArticulationToStr(att->GetArticGes()))); + attributes->push_back(std::make_pair("artic.ges", att->ArticulationToStr(att->GetArticGes()))); } } if (element->HasAttClass( ATT_AUGMENTDOTS ) ) { @@ -9347,13 +9347,13 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttBeamingVis *att = dynamic_cast(element); assert( att ); if (att->HasBeamColor()) { - attributes->push_back(std::make_pair("beamColor", att->StrToStr(att->GetBeamColor()))); + attributes->push_back(std::make_pair("beam.color", att->StrToStr(att->GetBeamColor()))); } if (att->HasBeamRend()) { - attributes->push_back(std::make_pair("beamRend", att->BeamingVisBeamrendToStr(att->GetBeamRend()))); + attributes->push_back(std::make_pair("beam.rend", att->BeamingVisBeamrendToStr(att->GetBeamRend()))); } if (att->HasBeamSlope()) { - attributes->push_back(std::make_pair("beamSlope", att->DblToStr(att->GetBeamSlope()))); + attributes->push_back(std::make_pair("beam.slope", att->DblToStr(att->GetBeamSlope()))); } } if (element->HasAttClass( ATT_BIBL ) ) { @@ -9402,26 +9402,26 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttCleffingLog *att = dynamic_cast(element); assert( att ); if (att->HasClefShape()) { - attributes->push_back(std::make_pair("clefShape", att->ClefshapeToStr(att->GetClefShape()))); + attributes->push_back(std::make_pair("clef.shape", att->ClefshapeToStr(att->GetClefShape()))); } if (att->HasClefLine()) { - attributes->push_back(std::make_pair("clefLine", att->IntToStr(att->GetClefLine()))); + attributes->push_back(std::make_pair("clef.line", att->IntToStr(att->GetClefLine()))); } if (att->HasClefDis()) { - attributes->push_back(std::make_pair("clefDis", att->OctaveDisToStr(att->GetClefDis()))); + attributes->push_back(std::make_pair("clef.dis", att->OctaveDisToStr(att->GetClefDis()))); } if (att->HasClefDisPlace()) { - attributes->push_back(std::make_pair("clefDisPlace", att->PlaceToStr(att->GetClefDisPlace()))); + attributes->push_back(std::make_pair("clef.dis.place", att->PlaceToStr(att->GetClefDisPlace()))); } } if (element->HasAttClass( ATT_CLEFFINGVIS ) ) { AttCleffingVis *att = dynamic_cast(element); assert( att ); if (att->HasClefColor()) { - attributes->push_back(std::make_pair("clefColor", att->StrToStr(att->GetClefColor()))); + attributes->push_back(std::make_pair("clef.color", att->StrToStr(att->GetClefColor()))); } if (att->HasClefVisible()) { - attributes->push_back(std::make_pair("clefVisible", att->BooleanToStr(att->GetClefVisible()))); + attributes->push_back(std::make_pair("clef.visible", att->BooleanToStr(att->GetClefVisible()))); } } if (element->HasAttClass( ATT_CLEFSHAPE ) ) { @@ -9459,7 +9459,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("label", att->StrToStr(att->GetLabel()))); } if (att->HasBase()) { - attributes->push_back(std::make_pair("base", att->StrToStr(att->GetBase()))); + attributes->push_back(std::make_pair("xml:base", att->StrToStr(att->GetBase()))); } } if (element->HasAttClass( ATT_COORDINATED ) ) { @@ -9545,13 +9545,13 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttDistances *att = dynamic_cast(element); assert( att ); if (att->HasDynamDist()) { - attributes->push_back(std::make_pair("dynamDist", att->StrToStr(att->GetDynamDist()))); + attributes->push_back(std::make_pair("dynam.dist", att->StrToStr(att->GetDynamDist()))); } if (att->HasHarmDist()) { - attributes->push_back(std::make_pair("harmDist", att->StrToStr(att->GetHarmDist()))); + attributes->push_back(std::make_pair("harm.dist", att->StrToStr(att->GetHarmDist()))); } if (att->HasTextDist()) { - attributes->push_back(std::make_pair("textDist", att->StrToStr(att->GetTextDist()))); + attributes->push_back(std::make_pair("text.dist", att->StrToStr(att->GetTextDist()))); } } if (element->HasAttClass( ATT_DOTLOG ) ) { @@ -9572,13 +9572,13 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttDurationDefault *att = dynamic_cast(element); assert( att ); if (att->HasDurDefault()) { - attributes->push_back(std::make_pair("durDefault", att->DurationToStr(att->GetDurDefault()))); + attributes->push_back(std::make_pair("dur.default", att->DurationToStr(att->GetDurDefault()))); } if (att->HasNumDefault()) { - attributes->push_back(std::make_pair("numDefault", att->IntToStr(att->GetNumDefault()))); + attributes->push_back(std::make_pair("num.default", att->IntToStr(att->GetNumDefault()))); } if (att->HasNumbaseDefault()) { - attributes->push_back(std::make_pair("numbaseDefault", att->IntToStr(att->GetNumbaseDefault()))); + attributes->push_back(std::make_pair("numbase.default", att->IntToStr(att->GetNumbaseDefault()))); } } if (element->HasAttClass( ATT_DURATIONMUSICAL ) ) { @@ -9592,7 +9592,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttDurationPerformed *att = dynamic_cast(element); assert( att ); if (att->HasDurGes()) { - attributes->push_back(std::make_pair("durGes", att->DurationToStr(att->GetDurGes()))); + attributes->push_back(std::make_pair("dur.ges", att->DurationToStr(att->GetDurGes()))); } } if (element->HasAttClass( ATT_DURATIONRATIO ) ) { @@ -9616,7 +9616,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttEndings *att = dynamic_cast(element); assert( att ); if (att->HasEndingRend()) { - attributes->push_back(std::make_pair("endingRend", att->EndingsEndingrendToStr(att->GetEndingRend()))); + attributes->push_back(std::make_pair("ending.rend", att->EndingsEndingrendToStr(att->GetEndingRend()))); } } if (element->HasAttClass( ATT_EXTENDER ) ) { @@ -9700,46 +9700,46 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttKeySigDefaultLog *att = dynamic_cast(element); assert( att ); if (att->HasKeyAccid()) { - attributes->push_back(std::make_pair("keyAccid", att->AccidentalImplicitToStr(att->GetKeyAccid()))); + attributes->push_back(std::make_pair("key.accid", att->AccidentalImplicitToStr(att->GetKeyAccid()))); } if (att->HasKeyMode()) { - attributes->push_back(std::make_pair("keyMode", att->ModeToStr(att->GetKeyMode()))); + attributes->push_back(std::make_pair("key.mode", att->ModeToStr(att->GetKeyMode()))); } if (att->HasKeyPname()) { - attributes->push_back(std::make_pair("keyPname", att->PitchnameToStr(att->GetKeyPname()))); + attributes->push_back(std::make_pair("key.pname", att->PitchnameToStr(att->GetKeyPname()))); } if (att->HasKeySig()) { - attributes->push_back(std::make_pair("keySig", att->KeysignatureToStr(att->GetKeySig()))); + attributes->push_back(std::make_pair("key.sig", att->KeysignatureToStr(att->GetKeySig()))); } if (att->HasKeySigMixed()) { - attributes->push_back(std::make_pair("keySigMixed", att->StrToStr(att->GetKeySigMixed()))); + attributes->push_back(std::make_pair("key.sig.mixed", att->StrToStr(att->GetKeySigMixed()))); } } if (element->HasAttClass( ATT_KEYSIGDEFAULTVIS ) ) { AttKeySigDefaultVis *att = dynamic_cast(element); assert( att ); if (att->HasKeySigShow()) { - attributes->push_back(std::make_pair("keySigShow", att->BooleanToStr(att->GetKeySigShow()))); + attributes->push_back(std::make_pair("key.sig.show", att->BooleanToStr(att->GetKeySigShow()))); } if (att->HasKeySigShowchange()) { - attributes->push_back(std::make_pair("keySigShowchange", att->BooleanToStr(att->GetKeySigShowchange()))); + attributes->push_back(std::make_pair("key.sig.showchange", att->BooleanToStr(att->GetKeySigShowchange()))); } } if (element->HasAttClass( ATT_LABELSADDL ) ) { AttLabelsAddl *att = dynamic_cast(element); assert( att ); if (att->HasLabelAbbr()) { - attributes->push_back(std::make_pair("labelAbbr", att->StrToStr(att->GetLabelAbbr()))); + attributes->push_back(std::make_pair("label.abbr", att->StrToStr(att->GetLabelAbbr()))); } } if (element->HasAttClass( ATT_LANG ) ) { AttLang *att = dynamic_cast(element); assert( att ); if (att->HasLang()) { - attributes->push_back(std::make_pair("lang", att->StrToStr(att->GetLang()))); + attributes->push_back(std::make_pair("xml:lang", att->StrToStr(att->GetLang()))); } if (att->HasTranslit()) { - attributes->push_back(std::make_pair("translit", att->StrToStr(att->GetTranslit()))); + attributes->push_back(std::make_pair("xml:translit", att->StrToStr(att->GetTranslit()))); } } if (element->HasAttClass( ATT_LAYERLOG ) ) { @@ -9815,22 +9815,22 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttLyricstyle *att = dynamic_cast(element); assert( att ); if (att->HasLyricAlign()) { - attributes->push_back(std::make_pair("lyricAlign", att->StrToStr(att->GetLyricAlign()))); + attributes->push_back(std::make_pair("lyric.align", att->StrToStr(att->GetLyricAlign()))); } if (att->HasLyricFam()) { - attributes->push_back(std::make_pair("lyricFam", att->StrToStr(att->GetLyricFam()))); + attributes->push_back(std::make_pair("lyric.fam", att->StrToStr(att->GetLyricFam()))); } if (att->HasLyricName()) { - attributes->push_back(std::make_pair("lyricName", att->StrToStr(att->GetLyricName()))); + attributes->push_back(std::make_pair("lyric.name", att->StrToStr(att->GetLyricName()))); } if (att->HasLyricSize()) { - attributes->push_back(std::make_pair("lyricSize", att->StrToStr(att->GetLyricSize()))); + attributes->push_back(std::make_pair("lyric.size", att->StrToStr(att->GetLyricSize()))); } if (att->HasLyricStyle()) { - attributes->push_back(std::make_pair("lyricStyle", att->FontstyleToStr(att->GetLyricStyle()))); + attributes->push_back(std::make_pair("lyric.style", att->FontstyleToStr(att->GetLyricStyle()))); } if (att->HasLyricWeight()) { - attributes->push_back(std::make_pair("lyricWeight", att->FontweightToStr(att->GetLyricWeight()))); + attributes->push_back(std::make_pair("lyric.weight", att->FontweightToStr(att->GetLyricWeight()))); } } if (element->HasAttClass( ATT_MEASURELOG ) ) { @@ -9854,7 +9854,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttMeasurenumbers *att = dynamic_cast(element); assert( att ); if (att->HasMnumVisible()) { - attributes->push_back(std::make_pair("mnumVisible", att->BooleanToStr(att->GetMnumVisible()))); + attributes->push_back(std::make_pair("mnum.visible", att->BooleanToStr(att->GetMnumVisible()))); } } if (element->HasAttClass( ATT_MEDIABOUNDS ) ) { @@ -9918,23 +9918,23 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttMeterSigDefaultLog *att = dynamic_cast(element); assert( att ); if (att->HasMeterCount()) { - attributes->push_back(std::make_pair("meterCount", att->IntToStr(att->GetMeterCount()))); + attributes->push_back(std::make_pair("meter.count", att->IntToStr(att->GetMeterCount()))); } if (att->HasMeterUnit()) { - attributes->push_back(std::make_pair("meterUnit", att->IntToStr(att->GetMeterUnit()))); + attributes->push_back(std::make_pair("meter.unit", att->IntToStr(att->GetMeterUnit()))); } } if (element->HasAttClass( ATT_METERSIGDEFAULTVIS ) ) { AttMeterSigDefaultVis *att = dynamic_cast(element); assert( att ); if (att->HasMeterRend()) { - attributes->push_back(std::make_pair("meterRend", att->MeterSigDefaultVisMeterrendToStr(att->GetMeterRend()))); + attributes->push_back(std::make_pair("meter.rend", att->MeterSigDefaultVisMeterrendToStr(att->GetMeterRend()))); } if (att->HasMeterShowchange()) { - attributes->push_back(std::make_pair("meterShowchange", att->BooleanToStr(att->GetMeterShowchange()))); + attributes->push_back(std::make_pair("meter.showchange", att->BooleanToStr(att->GetMeterShowchange()))); } if (att->HasMeterSym()) { - attributes->push_back(std::make_pair("meterSym", att->MetersignToStr(att->GetMeterSym()))); + attributes->push_back(std::make_pair("meter.sym", att->MetersignToStr(att->GetMeterSym()))); } } if (element->HasAttClass( ATT_METERCONFORMANCE ) ) { @@ -9961,17 +9961,17 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("mm", att->StrToStr(att->GetMm()))); } if (att->HasMmUnit()) { - attributes->push_back(std::make_pair("mmUnit", att->DurationToStr(att->GetMmUnit()))); + attributes->push_back(std::make_pair("mm.unit", att->DurationToStr(att->GetMmUnit()))); } if (att->HasMmDots()) { - attributes->push_back(std::make_pair("mmDots", att->IntToStr(att->GetMmDots()))); + attributes->push_back(std::make_pair("mm.dots", att->IntToStr(att->GetMmDots()))); } } if (element->HasAttClass( ATT_MULTINUMMEASURES ) ) { AttMultinummeasures *att = dynamic_cast(element); assert( att ); if (att->HasMultiNumber()) { - attributes->push_back(std::make_pair("multiNumber", att->BooleanToStr(att->GetMultiNumber()))); + attributes->push_back(std::make_pair("multi.number", att->BooleanToStr(att->GetMultiNumber()))); } } if (element->HasAttClass( ATT_NAME ) ) { @@ -9988,20 +9988,20 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttNotationstyle *att = dynamic_cast(element); assert( att ); if (att->HasMusicName()) { - attributes->push_back(std::make_pair("musicName", att->StrToStr(att->GetMusicName()))); + attributes->push_back(std::make_pair("music.name", att->StrToStr(att->GetMusicName()))); } if (att->HasMusicSize()) { - attributes->push_back(std::make_pair("musicSize", att->StrToStr(att->GetMusicSize()))); + attributes->push_back(std::make_pair("music.size", att->StrToStr(att->GetMusicSize()))); } } if (element->HasAttClass( ATT_NOTEGES ) ) { AttNoteGes *att = dynamic_cast(element); assert( att ); if (att->HasOctGes()) { - attributes->push_back(std::make_pair("octGes", att->IntToStr(att->GetOctGes()))); + attributes->push_back(std::make_pair("oct.ges", att->IntToStr(att->GetOctGes()))); } if (att->HasPnameGes()) { - attributes->push_back(std::make_pair("pnameGes", att->PitchnameToStr(att->GetPnameGes()))); + attributes->push_back(std::make_pair("pname.ges", att->PitchnameToStr(att->GetPnameGes()))); } if (att->HasPnum()) { attributes->push_back(std::make_pair("pnum", att->IntToStr(att->GetPnum()))); @@ -10011,25 +10011,25 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttNoteheads *att = dynamic_cast(element); assert( att ); if (att->HasHeadColor()) { - attributes->push_back(std::make_pair("headColor", att->StrToStr(att->GetHeadColor()))); + attributes->push_back(std::make_pair("head.color", att->StrToStr(att->GetHeadColor()))); } if (att->HasHeadFill()) { - attributes->push_back(std::make_pair("headFill", att->StrToStr(att->GetHeadFill()))); + attributes->push_back(std::make_pair("head.fill", att->StrToStr(att->GetHeadFill()))); } if (att->HasHeadFillcolor()) { - attributes->push_back(std::make_pair("headFillcolor", att->StrToStr(att->GetHeadFillcolor()))); + attributes->push_back(std::make_pair("head.fillcolor", att->StrToStr(att->GetHeadFillcolor()))); } if (att->HasHeadMod()) { - attributes->push_back(std::make_pair("headMod", att->StrToStr(att->GetHeadMod()))); + attributes->push_back(std::make_pair("head.mod", att->StrToStr(att->GetHeadMod()))); } if (att->HasHeadRotation()) { - attributes->push_back(std::make_pair("headRotation", att->StrToStr(att->GetHeadRotation()))); + attributes->push_back(std::make_pair("head.rotation", att->StrToStr(att->GetHeadRotation()))); } if (att->HasHeadShape()) { - attributes->push_back(std::make_pair("headShape", att->StrToStr(att->GetHeadShape()))); + attributes->push_back(std::make_pair("head.shape", att->StrToStr(att->GetHeadShape()))); } if (att->HasHeadVisible()) { - attributes->push_back(std::make_pair("headVisible", att->BooleanToStr(att->GetHeadVisible()))); + attributes->push_back(std::make_pair("head.visible", att->BooleanToStr(att->GetHeadVisible()))); } } if (element->HasAttClass( ATT_OCTAVE ) ) { @@ -10043,7 +10043,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttOctavedefault *att = dynamic_cast(element); assert( att ); if (att->HasOctaveDefault()) { - attributes->push_back(std::make_pair("octaveDefault", att->IntToStr(att->GetOctaveDefault()))); + attributes->push_back(std::make_pair("octave.default", att->IntToStr(att->GetOctaveDefault()))); } } if (element->HasAttClass( ATT_OCTAVEDISPLACEMENT ) ) { @@ -10053,7 +10053,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("dis", att->OctaveDisToStr(att->GetDis()))); } if (att->HasDisPlace()) { - attributes->push_back(std::make_pair("disPlace", att->PlaceToStr(att->GetDisPlace()))); + attributes->push_back(std::make_pair("dis.place", att->PlaceToStr(att->GetDisPlace()))); } } if (element->HasAttClass( ATT_ONELINESTAFF ) ) { @@ -10081,28 +10081,28 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttPages *att = dynamic_cast(element); assert( att ); if (att->HasPageHeight()) { - attributes->push_back(std::make_pair("pageHeight", att->StrToStr(att->GetPageHeight()))); + attributes->push_back(std::make_pair("page.height", att->StrToStr(att->GetPageHeight()))); } if (att->HasPageWidth()) { - attributes->push_back(std::make_pair("pageWidth", att->StrToStr(att->GetPageWidth()))); + attributes->push_back(std::make_pair("page.width", att->StrToStr(att->GetPageWidth()))); } if (att->HasPageTopmar()) { - attributes->push_back(std::make_pair("pageTopmar", att->StrToStr(att->GetPageTopmar()))); + attributes->push_back(std::make_pair("page.topmar", att->StrToStr(att->GetPageTopmar()))); } if (att->HasPageBotmar()) { - attributes->push_back(std::make_pair("pageBotmar", att->StrToStr(att->GetPageBotmar()))); + attributes->push_back(std::make_pair("page.botmar", att->StrToStr(att->GetPageBotmar()))); } if (att->HasPageLeftmar()) { - attributes->push_back(std::make_pair("pageLeftmar", att->StrToStr(att->GetPageLeftmar()))); + attributes->push_back(std::make_pair("page.leftmar", att->StrToStr(att->GetPageLeftmar()))); } if (att->HasPageRightmar()) { - attributes->push_back(std::make_pair("pageRightmar", att->StrToStr(att->GetPageRightmar()))); + attributes->push_back(std::make_pair("page.rightmar", att->StrToStr(att->GetPageRightmar()))); } if (att->HasPagePanels()) { - attributes->push_back(std::make_pair("pagePanels", att->StrToStr(att->GetPagePanels()))); + attributes->push_back(std::make_pair("page.panels", att->StrToStr(att->GetPagePanels()))); } if (att->HasPageScale()) { - attributes->push_back(std::make_pair("pageScale", att->StrToStr(att->GetPageScale()))); + attributes->push_back(std::make_pair("page.scale", att->StrToStr(att->GetPageScale()))); } } if (element->HasAttClass( ATT_PBVIS ) ) { @@ -10140,22 +10140,22 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttPointing *att = dynamic_cast(element); assert( att ); if (att->HasActuate()) { - attributes->push_back(std::make_pair("actuate", att->StrToStr(att->GetActuate()))); + attributes->push_back(std::make_pair("xlink:actuate", att->StrToStr(att->GetActuate()))); } if (att->HasRole()) { - attributes->push_back(std::make_pair("role", att->StrToStr(att->GetRole()))); + attributes->push_back(std::make_pair("xlink:role", att->StrToStr(att->GetRole()))); } if (att->HasShow()) { - attributes->push_back(std::make_pair("show", att->StrToStr(att->GetShow()))); + attributes->push_back(std::make_pair("xlink:show", att->StrToStr(att->GetShow()))); } if (att->HasTarget()) { - attributes->push_back(std::make_pair("target", att->StrToStr(att->GetTarget()))); + attributes->push_back(std::make_pair("xlink:target", att->StrToStr(att->GetTarget()))); } if (att->HasTargettype()) { - attributes->push_back(std::make_pair("targettype", att->StrToStr(att->GetTargettype()))); + attributes->push_back(std::make_pair("xlink:targettype", att->StrToStr(att->GetTargettype()))); } if (att->HasTitle()) { - attributes->push_back(std::make_pair("title", att->StrToStr(att->GetTitle()))); + attributes->push_back(std::make_pair("xlink:title", att->StrToStr(att->GetTitle()))); } } if (element->HasAttClass( ATT_QUANTITY ) ) { @@ -10197,20 +10197,20 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttScoreDefGes *att = dynamic_cast(element); assert( att ); if (att->HasTunePname()) { - attributes->push_back(std::make_pair("tunePname", att->PitchnameToStr(att->GetTunePname()))); + attributes->push_back(std::make_pair("tune.pname", att->PitchnameToStr(att->GetTunePname()))); } if (att->HasTuneHz()) { - attributes->push_back(std::make_pair("tuneHz", att->DblToStr(att->GetTuneHz()))); + attributes->push_back(std::make_pair("tune.Hz", att->DblToStr(att->GetTuneHz()))); } if (att->HasTuneTemper()) { - attributes->push_back(std::make_pair("tuneTemper", att->TemperamentToStr(att->GetTuneTemper()))); + attributes->push_back(std::make_pair("tune.temper", att->TemperamentToStr(att->GetTuneTemper()))); } } if (element->HasAttClass( ATT_SCOREDEFVIS ) ) { AttScoreDefVis *att = dynamic_cast(element); assert( att ); if (att->HasVuHeight()) { - attributes->push_back(std::make_pair("vuHeight", att->StrToStr(att->GetVuHeight()))); + attributes->push_back(std::make_pair("vu.height", att->StrToStr(att->GetVuHeight()))); } } if (element->HasAttClass( ATT_SECTIONVIS ) ) { @@ -10252,16 +10252,16 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttSpacing *att = dynamic_cast(element); assert( att ); if (att->HasSpacingPackexp()) { - attributes->push_back(std::make_pair("spacingPackexp", att->DblToStr(att->GetSpacingPackexp()))); + attributes->push_back(std::make_pair("spacing.packexp", att->DblToStr(att->GetSpacingPackexp()))); } if (att->HasSpacingPackfact()) { - attributes->push_back(std::make_pair("spacingPackfact", att->DblToStr(att->GetSpacingPackfact()))); + attributes->push_back(std::make_pair("spacing.packfact", att->DblToStr(att->GetSpacingPackfact()))); } if (att->HasSpacingStaff()) { - attributes->push_back(std::make_pair("spacingStaff", att->StrToStr(att->GetSpacingStaff()))); + attributes->push_back(std::make_pair("spacing.staff", att->StrToStr(att->GetSpacingStaff()))); } if (att->HasSpacingSystem()) { - attributes->push_back(std::make_pair("spacingSystem", att->StrToStr(att->GetSpacingSystem()))); + attributes->push_back(std::make_pair("spacing.system", att->StrToStr(att->GetSpacingSystem()))); } } if (element->HasAttClass( ATT_STAFFLOG ) ) { @@ -10275,7 +10275,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttStaffDefVis *att = dynamic_cast(element); assert( att ); if (att->HasGridShow()) { - attributes->push_back(std::make_pair("gridShow", att->BooleanToStr(att->GetGridShow()))); + attributes->push_back(std::make_pair("grid.show", att->BooleanToStr(att->GetGridShow()))); } if (att->HasLayerscheme()) { attributes->push_back(std::make_pair("layerscheme", att->LayerschemeToStr(att->GetLayerscheme()))); @@ -10284,10 +10284,10 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { attributes->push_back(std::make_pair("lines", att->IntToStr(att->GetLines()))); } if (att->HasLinesColor()) { - attributes->push_back(std::make_pair("linesColor", att->StrToStr(att->GetLinesColor()))); + attributes->push_back(std::make_pair("lines.color", att->StrToStr(att->GetLinesColor()))); } if (att->HasLinesVisible()) { - attributes->push_back(std::make_pair("linesVisible", att->BooleanToStr(att->GetLinesVisible()))); + attributes->push_back(std::make_pair("lines.visible", att->BooleanToStr(att->GetLinesVisible()))); } if (att->HasSpacing()) { attributes->push_back(std::make_pair("spacing", att->StrToStr(att->GetSpacing()))); @@ -10349,22 +10349,22 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttStems *att = dynamic_cast(element); assert( att ); if (att->HasStemDir()) { - attributes->push_back(std::make_pair("stemDir", att->StemdirectionToStr(att->GetStemDir()))); + attributes->push_back(std::make_pair("stem.dir", att->StemdirectionToStr(att->GetStemDir()))); } if (att->HasStemLen()) { - attributes->push_back(std::make_pair("stemLen", att->StrToStr(att->GetStemLen()))); + attributes->push_back(std::make_pair("stem.len", att->StrToStr(att->GetStemLen()))); } if (att->HasStemMod()) { - attributes->push_back(std::make_pair("stemMod", att->StemmodifierToStr(att->GetStemMod()))); + attributes->push_back(std::make_pair("stem.mod", att->StemmodifierToStr(att->GetStemMod()))); } if (att->HasStemPos()) { - attributes->push_back(std::make_pair("stemPos", att->StempositionToStr(att->GetStemPos()))); + attributes->push_back(std::make_pair("stem.pos", att->StempositionToStr(att->GetStemPos()))); } if (att->HasStemX()) { - attributes->push_back(std::make_pair("stemX", att->DblToStr(att->GetStemX()))); + attributes->push_back(std::make_pair("stem.x", att->DblToStr(att->GetStemX()))); } if (att->HasStemY()) { - attributes->push_back(std::make_pair("stemY", att->DblToStr(att->GetStemY()))); + attributes->push_back(std::make_pair("stem.y", att->DblToStr(att->GetStemY()))); } } if (element->HasAttClass( ATT_SYLLOG ) ) { @@ -10388,35 +10388,35 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttSystems *att = dynamic_cast(element); assert( att ); if (att->HasSystemLeftline()) { - attributes->push_back(std::make_pair("systemLeftline", att->BooleanToStr(att->GetSystemLeftline()))); + attributes->push_back(std::make_pair("system.leftline", att->BooleanToStr(att->GetSystemLeftline()))); } if (att->HasSystemLeftmar()) { - attributes->push_back(std::make_pair("systemLeftmar", att->StrToStr(att->GetSystemLeftmar()))); + attributes->push_back(std::make_pair("system.leftmar", att->StrToStr(att->GetSystemLeftmar()))); } if (att->HasSystemRightmar()) { - attributes->push_back(std::make_pair("systemRightmar", att->StrToStr(att->GetSystemRightmar()))); + attributes->push_back(std::make_pair("system.rightmar", att->StrToStr(att->GetSystemRightmar()))); } if (att->HasSystemTopmar()) { - attributes->push_back(std::make_pair("systemTopmar", att->StrToStr(att->GetSystemTopmar()))); + attributes->push_back(std::make_pair("system.topmar", att->StrToStr(att->GetSystemTopmar()))); } } if (element->HasAttClass( ATT_TEXTSTYLE ) ) { AttTextstyle *att = dynamic_cast(element); assert( att ); if (att->HasTextFam()) { - attributes->push_back(std::make_pair("textFam", att->StrToStr(att->GetTextFam()))); + attributes->push_back(std::make_pair("text.fam", att->StrToStr(att->GetTextFam()))); } if (att->HasTextName()) { - attributes->push_back(std::make_pair("textName", att->StrToStr(att->GetTextName()))); + attributes->push_back(std::make_pair("text.name", att->StrToStr(att->GetTextName()))); } if (att->HasTextSize()) { - attributes->push_back(std::make_pair("textSize", att->StrToStr(att->GetTextSize()))); + attributes->push_back(std::make_pair("text.size", att->StrToStr(att->GetTextSize()))); } if (att->HasTextStyle()) { - attributes->push_back(std::make_pair("textStyle", att->FontstyleToStr(att->GetTextStyle()))); + attributes->push_back(std::make_pair("text.style", att->FontstyleToStr(att->GetTextStyle()))); } if (att->HasTextWeight()) { - attributes->push_back(std::make_pair("textWeight", att->FontweightToStr(att->GetTextWeight()))); + attributes->push_back(std::make_pair("text.weight", att->FontweightToStr(att->GetTextWeight()))); } } if (element->HasAttClass( ATT_TIEPRESENT ) ) { @@ -10437,10 +10437,10 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttTimestampPerformed *att = dynamic_cast(element); assert( att ); if (att->HasTstampGes()) { - attributes->push_back(std::make_pair("tstampGes", att->DurationToStr(att->GetTstampGes()))); + attributes->push_back(std::make_pair("tstamp.ges", att->DurationToStr(att->GetTstampGes()))); } if (att->HasTstampReal()) { - attributes->push_back(std::make_pair("tstampReal", att->StrToStr(att->GetTstampReal()))); + attributes->push_back(std::make_pair("tstamp.real", att->StrToStr(att->GetTstampReal()))); } } if (element->HasAttClass( ATT_TIMESTAMP2MUSICAL ) ) { @@ -10454,10 +10454,10 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttTransposition *att = dynamic_cast(element); assert( att ); if (att->HasTransDiat()) { - attributes->push_back(std::make_pair("transDiat", att->DblToStr(att->GetTransDiat()))); + attributes->push_back(std::make_pair("trans.diat", att->DblToStr(att->GetTransDiat()))); } if (att->HasTransSemi()) { - attributes->push_back(std::make_pair("transSemi", att->DblToStr(att->GetTransSemi()))); + attributes->push_back(std::make_pair("trans.semi", att->DblToStr(att->GetTransSemi()))); } } if (element->HasAttClass( ATT_TUPLETPRESENT ) ) { @@ -10558,7 +10558,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttWhitespace *att = dynamic_cast(element); assert( att ); if (att->HasSpace()) { - attributes->push_back(std::make_pair("space", att->StrToStr(att->GetSpace()))); + attributes->push_back(std::make_pair("xml:space", att->StrToStr(att->GetSpace()))); } } if (element->HasAttClass( ATT_WIDTH ) ) { diff --git a/libmei/atts_tablature.cpp b/libmei/atts_tablature.cpp index 731ee8e1d37..6e208c96b6d 100644 --- a/libmei/atts_tablature.cpp +++ b/libmei/atts_tablature.cpp @@ -131,11 +131,11 @@ bool Att::SetTablature( Object *element, std::string attrType, std::string attrV if (element->HasAttClass( ATT_NOTEGESTABLATURE ) ) { AttNoteGesTablature *att = dynamic_cast(element); assert( att ); - if (attrType == "tabFret") { + if (attrType == "tab.fret") { att->SetTabFret(att->StrToFretnumber(attrValue)); return true; } - if (attrType == "tabString") { + if (attrType == "tab.string") { att->SetTabString(att->StrToStringnumber(attrValue)); return true; } @@ -143,7 +143,7 @@ bool Att::SetTablature( Object *element, std::string attrType, std::string attrV if (element->HasAttClass( ATT_STAFFDEFGESTABLATURE ) ) { AttStaffDefGesTablature *att = dynamic_cast(element); assert( att ); - if (attrType == "tabStrings") { + if (attrType == "tab.strings") { att->SetTabStrings(att->StrToStr(attrValue)); return true; } @@ -157,17 +157,17 @@ void Att::GetTablature( Object *element, ArrayOfStrAttr *attributes ) { AttNoteGesTablature *att = dynamic_cast(element); assert( att ); if (att->HasTabFret()) { - attributes->push_back(std::make_pair("tabFret", att->FretnumberToStr(att->GetTabFret()))); + attributes->push_back(std::make_pair("tab.fret", att->FretnumberToStr(att->GetTabFret()))); } if (att->HasTabString()) { - attributes->push_back(std::make_pair("tabString", att->StringnumberToStr(att->GetTabString()))); + attributes->push_back(std::make_pair("tab.string", att->StringnumberToStr(att->GetTabString()))); } } if (element->HasAttClass( ATT_STAFFDEFGESTABLATURE ) ) { AttStaffDefGesTablature *att = dynamic_cast(element); assert( att ); if (att->HasTabStrings()) { - attributes->push_back(std::make_pair("tabStrings", att->StrToStr(att->GetTabStrings()))); + attributes->push_back(std::make_pair("tab.strings", att->StrToStr(att->GetTabStrings()))); } } From 45b2d9cfb5d567fdba6913a1af7f892bd4227faf Mon Sep 17 00:00:00 2001 From: "David M. Weigl" Date: Thu, 17 Dec 2015 16:17:46 +0000 Subject: [PATCH 026/217] Enable AttPointing to measure --- include/vrv/measure.h | 3 ++- src/iomei.cpp | 2 ++ src/measure.cpp | 5 ++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/vrv/measure.h b/include/vrv/measure.h index a7ab792ec17..d84f8a5539a 100644 --- a/include/vrv/measure.h +++ b/include/vrv/measure.h @@ -30,7 +30,8 @@ class FloatingElement; */ class Measure: public DocObject, public AttCommon, - public AttMeasureLog + public AttMeasureLog, + public AttPointing { public: diff --git a/src/iomei.cpp b/src/iomei.cpp index 28759bcedb9..1a765683c73 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -499,6 +499,7 @@ bool MeiOutput::WriteMeiMeasure( pugi::xml_node currentNode, Measure *measure ) measure->WriteCommon(currentNode); measure->WriteMeasureLog(currentNode); + measure->WritePointing(currentNode); return true; } @@ -1454,6 +1455,7 @@ bool MeiInput::ReadMeiMeasure( Object *parent, pugi::xml_node measure ) vrvMeasure->ReadCommon(measure); vrvMeasure->ReadMeasureLog(measure); + vrvMeasure->ReadPointing(measure); // This could me moved to an AddMeasure method for consistency with AddLayerElement if ( parent->Is() == SYSTEM ) { diff --git a/src/measure.cpp b/src/measure.cpp index f4fc7cb0c69..39ae7035620 100644 --- a/src/measure.cpp +++ b/src/measure.cpp @@ -31,10 +31,12 @@ namespace vrv { Measure::Measure( bool measureMusic, int logMeasureNb ): DocObject("measure-"), AttCommon(), - AttMeasureLog() + AttMeasureLog(), + AttPointing() { RegisterAttClass(ATT_COMMON); RegisterAttClass(ATT_MEASURELOG); + RegisterAttClass(ATT_POINTING); m_measuredMusic = measureMusic; // We set parent to it because we want to access the parent doc from the aligners // See Object::SetParentDoc() @@ -51,6 +53,7 @@ void Measure::Reset() DocObject::Reset(); ResetCommon(); ResetMeasureLog(); + ResetPointing(); m_parent = NULL; m_measuredMusic = true; From 8fc0c78703b6aa7e120b7742cbac42116679c55e Mon Sep 17 00:00:00 2001 From: Don Byrd Date: Thu, 17 Dec 2015 15:35:37 -0500 Subject: [PATCH 027/217] Start on code changes so DrawClef() can get the notation type and draw the appropriate clef (modern or other). --- include/vrv/attdef.h | 10 ++++++++++ include/vrv/staff.h | 5 +++++ src/staff.cpp | 3 ++- src/view_page.cpp | 3 ++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/vrv/attdef.h b/include/vrv/attdef.h index 85238119c3a..1af87a9c2d2 100644 --- a/include/vrv/attdef.h +++ b/include/vrv/attdef.h @@ -277,6 +277,16 @@ enum data_LAYERSCHEME { LAYERSCHEME_3f }; +/** + * MEI data.NOTATIONTYPE + */ +enum data_NOTATIONTYPE { + NOTATIONTYPE_NONE = 0, + NOTATIONTYPE_mensural, + NOTATIONTYPE_mensural_white, + NOTATIONTYPE_mensural_black +}; + /** * MEI values for @lig (no datatype in MEI) */ diff --git a/include/vrv/staff.h b/include/vrv/staff.h index 4b9f33e21a0..6b4dca02d1a 100644 --- a/include/vrv/staff.h +++ b/include/vrv/staff.h @@ -123,6 +123,11 @@ class Staff: public DocObject, */ int m_drawingLines; + /** + * Notation type (CMN, mensural, black mensural, etc.), from the staffDef + */ + int m_drawingNotationType; + /** * Total drawing height from top of top line to bottom of bottom line */ diff --git a/src/staff.cpp b/src/staff.cpp index 30519861d05..591e08fe9e3 100644 --- a/src/staff.cpp +++ b/src/staff.cpp @@ -45,11 +45,12 @@ void Staff::Reset() { DocObject::Reset(); ResetCommon(); - notAnc = false; // LP we want modern notation :)) + notAnc = false; // LP we want modern notation :)) ??OR DO WE? CHECK! grise = false; invisible = false; m_drawingStaffSize = 100; m_drawingLines = 5; + m_drawingNotationType = NOTATIONTYPE_NONE; m_yAbs = VRV_UNSET; m_drawingY = 0; m_staffAlignment = NULL; diff --git a/src/view_page.cpp b/src/view_page.cpp index 9aacc3c9fd0..a0c93a57b27 100644 --- a/src/view_page.cpp +++ b/src/view_page.cpp @@ -798,7 +798,8 @@ void View::DrawStaff( DeviceContext *dc, Staff *staff, Measure *measure, System // Doing it here might be problematic with cross-staff, even though the default value will be 5 if ( StaffDef *staffDef = m_drawingScoreDef.GetStaffDef( staff->GetN() ) ) { - staff->m_drawingLines = staffDef->GetLines( ) ; + staff->m_drawingLines = staffDef->GetLines( ); + //staff->m_notationType = staffDef->GetNotationType( ); if (staffDef->HasScale()) { staff->m_drawingStaffSize = staffDef->GetScale(); } From e88e4dd1a7f51b1f9f1886944518bca5fd3cad69 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sun, 20 Dec 2015 18:19:08 +0100 Subject: [PATCH 028/217] Making staffIdent a list and various comment fixes --- include/vrv/att.h | 3 ++ include/vrv/attdef.h | 6 +++ include/vrv/floatingelement.h | 2 +- include/vrv/textdirective.h | 2 +- include/vrv/tie.h | 2 - libmei/atts_shared.cpp | 12 +++--- libmei/atts_shared.h | 6 +-- src/att.cpp | 77 ++++++++++++++++++++++------------- src/floatingelement.cpp | 2 +- src/layerelement.cpp | 8 ++-- src/view_graph.cpp | 2 +- 11 files changed, 75 insertions(+), 47 deletions(-) diff --git a/include/vrv/att.h b/include/vrv/att.h index 25686589185..61c8ff16874 100644 --- a/include/vrv/att.h +++ b/include/vrv/att.h @@ -146,6 +146,9 @@ class Att: public AttConverter std::string TieToStr(data_TIE data); data_TIE StrToTie(std::string value); + + std::string XsdPosintlistToStr(xsd_posIntList data); + xsd_posIntList StrToXsdPosintlist(std::string value); ///@} }; diff --git a/include/vrv/attdef.h b/include/vrv/attdef.h index 41ebdaad1f9..519ef86073d 100644 --- a/include/vrv/attdef.h +++ b/include/vrv/attdef.h @@ -255,6 +255,12 @@ enum data_TEMPUS { TEMPUS_3 }; +/** + * A typedef for a list of positive integer. + * E.g., list { xsd:positiveInteger+ } + */ +typedef std::vector xsd_posIntList; + } // namespace vrv diff --git a/include/vrv/floatingelement.h b/include/vrv/floatingelement.h index a3191d2f33f..2d9e59c6731 100644 --- a/include/vrv/floatingelement.h +++ b/include/vrv/floatingelement.h @@ -18,7 +18,7 @@ namespace vrv { //---------------------------------------------------------------------------- /** - * This class is an interface for elements with duration, such as notes and rests. + * This class is an interface for elements appearing within measure. * It is not an abstract class but should not be instanciate directly. */ class FloatingElement: public DocObject diff --git a/include/vrv/textdirective.h b/include/vrv/textdirective.h index 12f5d2a5631..3d6b0510fb2 100644 --- a/include/vrv/textdirective.h +++ b/include/vrv/textdirective.h @@ -15,7 +15,7 @@ namespace vrv { //---------------------------------------------------------------------------- -// MeasureTempo +// Tempo //---------------------------------------------------------------------------- /** diff --git a/include/vrv/tie.h b/include/vrv/tie.h index ab4d4af7321..6b9983e7d7b 100644 --- a/include/vrv/tie.h +++ b/include/vrv/tie.h @@ -16,8 +16,6 @@ namespace vrv { //---------------------------------------------------------------------------- // Tie -// A TIE class is a simple slur - it takes in account only two notes, the first and second: -// NOTE tie NOTE tie etc //---------------------------------------------------------------------------- class Tie: public FloatingElement, public TimeSpanningInterface, diff --git a/libmei/atts_shared.cpp b/libmei/atts_shared.cpp index 82d21dc70cf..8d663eb2baf 100644 --- a/libmei/atts_shared.cpp +++ b/libmei/atts_shared.cpp @@ -6076,13 +6076,13 @@ AttStaffident::~AttStaffident() { } void AttStaffident::ResetStaffident() { - m_staff = 0; + m_staff = std::vector(); } bool AttStaffident::ReadStaffident( pugi::xml_node element ) { bool hasAttribute = false; if (element.attribute("staff")) { - this->SetStaff(StrToInt(element.attribute("staff").value())); + this->SetStaff(StrToXsdPosintlist(element.attribute("staff").value())); element.remove_attribute("staff"); hasAttribute = true; } @@ -6092,7 +6092,7 @@ bool AttStaffident::ReadStaffident( pugi::xml_node element ) { bool AttStaffident::WriteStaffident( pugi::xml_node element ) { bool wroteAttribute = false; if (this->HasStaff()) { - element.append_attribute("staff") = IntToStr(this->GetStaff()).c_str(); + element.append_attribute("staff") = XsdPosintlistToStr(this->GetStaff()).c_str(); wroteAttribute = true; } return wroteAttribute; @@ -6100,7 +6100,7 @@ bool AttStaffident::WriteStaffident( pugi::xml_node element ) { bool AttStaffident::HasStaff( ) { - return (m_staff != 0); + return (m_staff != std::vector()); } @@ -8937,7 +8937,7 @@ bool Att::SetShared( Object *element, std::string attrType, std::string attrValu AttStaffident *att = dynamic_cast(element); assert( att ); if (attrType == "staff") { - att->SetStaff(att->StrToInt(attrValue)); + att->SetStaff(att->StrToXsdPosintlist(attrValue)); return true; } } @@ -10311,7 +10311,7 @@ void Att::GetShared( Object *element, ArrayOfStrAttr *attributes ) { AttStaffident *att = dynamic_cast(element); assert( att ); if (att->HasStaff()) { - attributes->push_back(std::make_pair("staff", att->IntToStr(att->GetStaff()))); + attributes->push_back(std::make_pair("staff", att->XsdPosintlistToStr(att->GetStaff()))); } } if (element->HasAttClass( ATT_STAFFLOC ) ) { diff --git a/libmei/atts_shared.h b/libmei/atts_shared.h index e14005838a1..a54ff4182dc 100644 --- a/libmei/atts_shared.h +++ b/libmei/atts_shared.h @@ -5143,8 +5143,8 @@ class AttStaffident: public Att * to the default value) **/ ///@{ - void SetStaff(int staff_) { m_staff = staff_; }; - int GetStaff() const { return m_staff; }; + void SetStaff(xsd_posIntList staff_) { m_staff = staff_; }; + xsd_posIntList GetStaff() const { return m_staff; }; bool HasStaff( ); ///@} @@ -5155,7 +5155,7 @@ class AttStaffident: public Att * applies. * Mandatory when applicable. **/ - int m_staff; + xsd_posIntList m_staff; /* include */ }; diff --git a/src/att.cpp b/src/att.cpp index fe73cd0e3a1..3adfb814b02 100644 --- a/src/att.cpp +++ b/src/att.cpp @@ -10,6 +10,7 @@ //---------------------------------------------------------------------------- +#include #include //---------------------------------------------------------------------------- @@ -212,6 +213,16 @@ data_KEYSIGNATURE Att::StrToKeysignature(std::string value) LogWarning("Unsupported key signature '%s'", value.c_str() ); } return KEYSIGNATURE_NONE; +} + +std::string Att::MeasurebeatToStr(data_MEASUREBEAT data) +{ + return "0m0.0"; +} + +data_MEASUREBEAT Att::StrToMeasurebeat(std::string value) +{ + return std::make_pair(0, 1.0); } std::string Att::ModusmaiorToStr(data_MODUSMAIOR data) @@ -381,6 +392,31 @@ data_PROLATIO Att::StrToProlatio(std::string value) } // default return PROLATIO_NONE; +} + +std::string Att::StemdirectionToStr(data_STEMDIRECTION data) +{ + std::string value; + switch(data) + { + case STEMDIRECTION_up : value = "up"; break; + case STEMDIRECTION_down : value = "down"; break; + default: + LogWarning("Unknown stem direction '%d'", data); + value = ""; + break; + } + return value; +} + +data_STEMDIRECTION Att::StrToStemdirection(std::string value) +{ + if (value == "up") return STEMDIRECTION_up; + else if (value == "down") return STEMDIRECTION_down; + else { + LogWarning("Unsupported stem direction '%s'", value.c_str() ); + } + return STEMDIRECTION_NONE; } std::string Att::TempusToStr(data_TEMPUS data) @@ -437,42 +473,27 @@ data_TIE Att::StrToTie(std::string value) return TIE_NONE; } - -std::string Att::StemdirectionToStr(data_STEMDIRECTION data) +std::string Att::XsdPosintlistToStr(xsd_posIntList data) { - std::string value; - switch(data) - { - case STEMDIRECTION_up : value = "up"; break; - case STEMDIRECTION_down : value = "down"; break; - default: - LogWarning("Unknown stem direction '%d'", data); - value = ""; - break; + std::stringstream ss; + for(size_t i = 0; i < data.size(); ++i) { + if(i != 0) ss << " "; + ss << data[i]; } - return value; + return ss.str(); } -data_STEMDIRECTION Att::StrToStemdirection(std::string value) +xsd_posIntList Att::StrToXsdPosintlist(std::string value) { - if (value == "up") return STEMDIRECTION_up; - else if (value == "down") return STEMDIRECTION_down; - else { - LogWarning("Unsupported stem direction '%s'", value.c_str() ); + xsd_posIntList list; + std::stringstream iss( value ); + std::string token; + while( std::getline( iss, token, ' ' )) { + list.push_back(atoi(token.c_str())); } - return STEMDIRECTION_NONE; + return list; } -std::string Att::MeasurebeatToStr(data_MEASUREBEAT data) -{ - return "0m0.0"; -} - -data_MEASUREBEAT Att::StrToMeasurebeat(std::string value) -{ - return std::make_pair(0, 1.0); -} - //---------------------------------------------------------------------------- // AttComparison //---------------------------------------------------------------------------- diff --git a/src/floatingelement.cpp b/src/floatingelement.cpp index bd0515ba410..6685622f4ed 100644 --- a/src/floatingelement.cpp +++ b/src/floatingelement.cpp @@ -23,7 +23,7 @@ namespace vrv { //---------------------------------------------------------------------------- FloatingElement::FloatingElement(): - DocObject("me") + DocObject("fe") { Reset(); } diff --git a/src/layerelement.cpp b/src/layerelement.cpp index 50613d4cc7f..becc39440f3 100644 --- a/src/layerelement.cpp +++ b/src/layerelement.cpp @@ -417,10 +417,10 @@ int LayerElement::SetDrawingXY( ArrayPtrVoid *params ) // If we have one, make is available in m_crossStaff DurationInterface *durElement = dynamic_cast(this); if ( durElement && durElement->HasStaff()) { - AttCommonNComparison comparisonFirst( STAFF, durElement->GetStaff() ); + AttCommonNComparison comparisonFirst( STAFF, durElement->GetStaff().at(0) ); m_crossStaff = dynamic_cast((*currentMeasure)->FindChildByAttComparison(&comparisonFirst, 1)); if (m_crossStaff) { - if (m_crossStaff == (*currentStaff)) LogWarning("The cross staff reference '%d' for element '%s' seems to be identical to the parent staff", durElement->GetStaff(), this->GetUuid().c_str()); + if (m_crossStaff == (*currentStaff)) LogWarning("The cross staff reference '%d' for element '%s' seems to be identical to the parent staff", durElement->GetStaff().at(0), this->GetUuid().c_str()); // Now try to get the corresponding layer - for now look for the same layer @n int layerN = (*currentLayer)->GetN(); // When we will have allowed @layer in , we will have to do: @@ -432,10 +432,10 @@ int LayerElement::SetDrawingXY( ArrayPtrVoid *params ) layerElementY = m_crossLayer->GetAtPos( this->GetDrawingX() ); } else { - LogWarning("Could not get the layer with cross-staff reference '%d' for element '%s'", durElement->GetStaff(), this->GetUuid().c_str()); + LogWarning("Could not get the layer with cross-staff reference '%d' for element '%s'", durElement->GetStaff().at(0), this->GetUuid().c_str()); } } else { - LogWarning("Could not get the cross staff reference '%d' for element '%s'", durElement->GetStaff(), this->GetUuid().c_str()); + LogWarning("Could not get the cross staff reference '%d' for element '%s'", durElement->GetStaff().at(0), this->GetUuid().c_str()); } // If we have a @layer we probably also want to change the layer element (for getting the right clef if different) } else { diff --git a/src/view_graph.cpp b/src/view_graph.cpp index 72fffd73ce6..4d2a2675a28 100755 --- a/src/view_graph.cpp +++ b/src/view_graph.cpp @@ -177,7 +177,7 @@ void View::DrawLyricString ( DeviceContext *dc, int x, int y, std::wstring s, in dc->StartText( ToDeviceContextX( x ), ToDeviceContextY( y ) ); - std::wistringstream iss( s ); + std::wistringstream iss( s ); std::wstring token; while( std::getline( iss, token, L'_' )) { From a6a7e51e25412ea07cdb22002043eb03b481ee29 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Mon, 21 Dec 2015 22:57:49 +0100 Subject: [PATCH 029/217] Basic tempo indication handling --- include/vrv/attcomparison.h | 32 ++++++++++++++++++ include/vrv/measure.h | 7 ++-- include/vrv/timeinterface.h | 2 +- include/vrv/view.h | 3 ++ src/svgdevicecontext.cpp | 7 +++- src/view_element.cpp | 10 ++++++ src/view_floating.cpp | 65 ++++++++++++++++++++++++++++++++++++- 7 files changed, 121 insertions(+), 5 deletions(-) diff --git a/include/vrv/attcomparison.h b/include/vrv/attcomparison.h index 01f4a83f81e..eb38d11b523 100644 --- a/include/vrv/attcomparison.h +++ b/include/vrv/attcomparison.h @@ -8,6 +8,7 @@ #ifndef __VRV_ATT_COMPARISON_H__ #define __VRV_ATT_COMPARISON_H__ +#include "aligner.h" #include "atts_shared.h" #include "durationinterface.h" #include "object.h" @@ -98,6 +99,37 @@ class AttDurExtreme: public AttComparison }; +//---------------------------------------------------------------------------- +// AttMeasureAlignerType +//---------------------------------------------------------------------------- + +/** + * This class evaluates if the object is an Alignment of a certain type + */ +class AttMeasureAlignerType: public AttComparison +{ + +public: + AttMeasureAlignerType( const AlignmentType type ): + AttComparison( OBJECT ) + { + m_type = type; + }; + + void SetType( AlignmentType type ) { m_type = type; } + + virtual bool operator() (Object *object) + { + Alignment *alignment = dynamic_cast(object); + if (!alignment) return false; + return (alignment->GetType() == m_type); + } + +private: + AlignmentType m_type; + +}; + } // namespace vrv #endif diff --git a/include/vrv/measure.h b/include/vrv/measure.h index d84f8a5539a..b27b340402b 100644 --- a/include/vrv/measure.h +++ b/include/vrv/measure.h @@ -183,11 +183,14 @@ class Measure: public DocObject, */ int m_drawingXRel; + /** + * The measure aligner that holds the x positions of the content of the measure + */ + MeasureAligner m_measureAligner; + private: bool m_measuredMusic; - MeasureAligner m_measureAligner; - /** * @name The measure barlines (left and right) used when drawing */ diff --git a/include/vrv/timeinterface.h b/include/vrv/timeinterface.h index fe3b2a90ea4..cddd676b10c 100644 --- a/include/vrv/timeinterface.h +++ b/include/vrv/timeinterface.h @@ -22,7 +22,7 @@ class LayerElement; //---------------------------------------------------------------------------- /** - * This class is an interface for elements with duration, such as notes and rests. + * This class is an interface for spanning elements, such as slur, hairpin, etc.. * It is not an abstract class but should not be instanciate directly. */ class TimeSpanningInterface: public Interface, diff --git a/include/vrv/view.h b/include/vrv/view.h index 5995fcdb0ff..b32af7903e7 100644 --- a/include/vrv/view.h +++ b/include/vrv/view.h @@ -32,6 +32,7 @@ class Slur; class Staff; class Syl; class System; +class Tempo; class Tie; class Tuplet; class Verse; @@ -273,6 +274,7 @@ class View void DrawTimeSpanningElement( DeviceContext *dc, DocObject *object, System *system ); void DrawSlur( DeviceContext *dc, Slur *slur, int x1, int x2, Staff *staff, char spanningType, DocObject *graphic = NULL ); + void DrawTempo( DeviceContext *dc, Tempo *tempo, Measure *measure, System *system ); void DrawTie( DeviceContext *dc, Tie *tie, int x1, int x2, Staff *staff, char spanningType, DocObject *graphic = NULL ); @@ -348,6 +350,7 @@ class View std::wstring IntToSmuflFigures(unsigned short number, int offset); bool OneBeamInTuplet(Tuplet* tuplet); int GetSylY( Syl* syl, Staff *staff ); + int GetTempoY( Staff *staff ); ///@} /** diff --git a/src/svgdevicecontext.cpp b/src/svgdevicecontext.cpp index 743ecbc01ba..03b6921e94c 100644 --- a/src/svgdevicecontext.cpp +++ b/src/svgdevicecontext.cpp @@ -503,7 +503,7 @@ void SvgDeviceContext::DrawText(const std::string& text, const std::wstring wtex if ( m_fontStack.top()->GetPointSize() != 0 ) { textChild.append_attribute("font-size") = StringFormat("%dpx", m_fontStack.top()->GetPointSize() ).c_str(); } - if ( m_fontStack.top()->GetStyle() != FONTWEIGHT_NONE ) { + if ( m_fontStack.top()->GetStyle() != FONTSTYLE_NONE ) { if ( m_fontStack.top()->GetStyle() == FONTSTYLE_italic ) { textChild.append_attribute("font-style") = "italic"; } @@ -514,6 +514,11 @@ void SvgDeviceContext::DrawText(const std::string& text, const std::wstring wtex textChild.append_attribute("font-style") = "oblique"; } } + if ( m_fontStack.top()->GetWeight() != FONTWEIGHT_NONE ) { + if ( m_fontStack.top()->GetWeight() == FONTWEIGHT_bold ) { + textChild.append_attribute("font-weight") = "bold"; + } + } textChild.append_child(pugi::node_pcdata).set_value(text.c_str()); } diff --git a/src/view_element.cpp b/src/view_element.cpp index 153fca52a72..d1ad3019736 100644 --- a/src/view_element.cpp +++ b/src/view_element.cpp @@ -2023,6 +2023,16 @@ int View::GetSylY( Syl *syl, Staff *staff ) } return y; } + +int View::GetTempoY(Staff *staff ) +{ + assert( staff ); + + // Temporary basic method for positionning tempo elements + int y = staff->GetDrawingY() + m_doc->GetDrawingUnit(staff->m_drawingStaffSize); + y += staff->m_contentBB_y2; + return y; +} bool View::IsOnStaffLine ( int y, Staff *staff) { diff --git a/src/view_floating.cpp b/src/view_floating.cpp index d62dd7b9317..0b6ad592f4a 100644 --- a/src/view_floating.cpp +++ b/src/view_floating.cpp @@ -30,6 +30,7 @@ #include "style.h" #include "syl.h" #include "system.h" +#include "textdirective.h" #include "tie.h" #include "timeinterface.h" #include "vrv.h" @@ -53,6 +54,11 @@ void View::DrawFloatingElement( DeviceContext *dc, FloatingElement *element, Mea dc->EndGraphic( element, this); system->AddToDrawingList(element); } + else if (element->Is() == TEMPO) { + Tempo *tempo = dynamic_cast(element); + assert(tempo); + DrawTempo( dc, tempo, measure, system); + } } void View::DrawTimeSpanningElement( DeviceContext *dc, DocObject *element, System *system ) @@ -1012,6 +1018,63 @@ void View::DrawSylConnectorLines( DeviceContext *dc, int x1, int x2, int y, Syl } } + +void View::DrawTempo( DeviceContext *dc, Tempo *tempo, Measure *measure, System *system) +{ + assert( dc ); + assert( system ); + assert( measure ); + assert( tempo ); + + dc->StartGraphic(tempo, "", tempo->GetUuid()); + + // Use Romam bold for tempo + FontInfo tempoTxt; + tempoTxt.SetFaceName("Roman"); + tempoTxt.SetWeight(FONTWEIGHT_bold); + tempoTxt.SetPointSize( m_doc->GetDrawingLyricFont(100)->GetPointSize() ); + + // If we have not timestamp + int x = measure->GetDrawingX(); + // First try to see if we have a meter sig attribute for this measure + AttMeasureAlignerType alignmentComparison( ALIGNMENT_METERSIG_ATTR ); + Alignment *pos = dynamic_cast(measure->m_measureAligner.FindChildByAttComparison(&alignmentComparison, 1)); + if (!pos) { + // if not, try to get the first beat element + alignmentComparison.SetType( ALIGNMENT_DEFAULT ); + pos = dynamic_cast(measure->m_measureAligner.FindChildByAttComparison(&alignmentComparison, 1)); + } + // if we found one, use it + if (pos) { + x += pos->GetXRel(); + } + + std::vector::iterator iter; + std::vector staffList = tempo->GetStaff(); + for (iter = staffList.begin(); iter != staffList.end(); iter++) { + AttCommonNComparison comparison( STAFF, *iter ); + Staff *staff = dynamic_cast(measure->FindChildByAttComparison(&comparison, 1)); + if (!staff) { + LogWarning("Staff with @n '%d' not found in measure '%s'", *iter, measure->GetUuid().c_str()); + continue; + } + + // Basic method that use bounding box + int y = GetTempoY( staff ); + + dc->SetBrush( m_currentColour, AxSOLID ); + dc->SetFont( &tempoTxt ); + + dc->StartText( ToDeviceContextX( x ), ToDeviceContextY( y ), LEFT ); + dc->DrawText( UTF16to8( tempo->GetText().c_str() ), tempo->GetText() ); + dc->EndText( ); + + dc->ResetFont(); + dc->ResetBrush(); + } + + dc->EndGraphic(tempo, this); +} -} // namespace vrv +} // namespace vrv From 7c18abe3ae4a3fb3c0c077fb9b13f765ff0c958f Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Wed, 23 Dec 2015 16:55:00 +0100 Subject: [PATCH 030/217] Basic mixed content support --- Verovio.xcodeproj/project.pbxproj | 38 ++++++--- include/vrv/editorial.h | 2 + include/vrv/iomei.h | 27 +++++- include/vrv/object.h | 1 + include/vrv/text.h | 100 ++++++++++++++++++++++ include/vrv/textdirective.h | 8 ++ include/vrv/textelement.h | 46 ++++++++++ include/vrv/trem.h | 18 ---- include/vrv/vrvdef.h | 8 +- src/editorial.cpp | 8 ++ src/iomei.cpp | 135 +++++++++++++++++++++++++++--- src/text.cpp | 78 +++++++++++++++++ src/textdirective.cpp | 12 +++ src/textelement.cpp | 44 ++++++++++ src/trem.cpp | 13 --- 15 files changed, 483 insertions(+), 55 deletions(-) create mode 100644 include/vrv/text.h create mode 100644 include/vrv/textelement.h delete mode 100644 include/vrv/trem.h create mode 100644 src/text.cpp create mode 100644 src/textelement.cpp delete mode 100644 src/trem.cpp diff --git a/Verovio.xcodeproj/project.pbxproj b/Verovio.xcodeproj/project.pbxproj index a9f046969fc..3e7d4d7db8f 100644 --- a/Verovio.xcodeproj/project.pbxproj +++ b/Verovio.xcodeproj/project.pbxproj @@ -51,6 +51,9 @@ 4D9C53121B52E4AE0003C6EC /* core.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D9C530E1B52E4AE0003C6EC /* core.h */; }; 4D9C53131B52E4AE0003C6EC /* unchecked.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D9C530F1B52E4AE0003C6EC /* unchecked.h */; }; 4D9C53141B52E4AE0003C6EC /* utf8.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D9C53101B52E4AE0003C6EC /* utf8.h */; }; + 4DA1448A1C2AB28700CB7CEE /* textelement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DA144891C2AB28700CB7CEE /* textelement.cpp */; }; + 4DA1448B1C2AB28700CB7CEE /* textelement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DA144891C2AB28700CB7CEE /* textelement.cpp */; }; + 4DA1448D1C2AB29400CB7CEE /* textelement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DA1448C1C2AB29400CB7CEE /* textelement.h */; }; 4DA3FCD319B61DB300CBDFE6 /* atts_cmn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEE28EF1940BCC100C76319 /* atts_cmn.cpp */; }; 4DA3FCD419B61DB400CBDFE6 /* atts_cmn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEE28EF1940BCC100C76319 /* atts_cmn.cpp */; }; 4DA60EE01B6307A8006E2DFC /* textdirective.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DA60EDE1B6307A8006E2DFC /* textdirective.h */; }; @@ -65,9 +68,9 @@ 4DB726C01B8B9F480040231B /* rpt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DB726BF1B8B9F480040231B /* rpt.cpp */; }; 4DB726C11B8B9F480040231B /* rpt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DB726BF1B8B9F480040231B /* rpt.cpp */; }; 4DB726C31B8B9F540040231B /* rpt.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DB726C21B8B9F540040231B /* rpt.h */; }; - 4DB726C51B8BB0E80040231B /* trem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DB726C41B8BB0E80040231B /* trem.cpp */; }; - 4DB726C61B8BB0E80040231B /* trem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DB726C41B8BB0E80040231B /* trem.cpp */; }; - 4DB726C81B8BB0F30040231B /* trem.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DB726C71B8BB0F30040231B /* trem.h */; }; + 4DB726C51B8BB0E80040231B /* text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DB726C41B8BB0E80040231B /* text.cpp */; }; + 4DB726C61B8BB0E80040231B /* text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DB726C41B8BB0E80040231B /* text.cpp */; }; + 4DB726C81B8BB0F30040231B /* text.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DB726C71B8BB0F30040231B /* text.h */; }; 4DC34BA219BC4A71006175CD /* accid.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DC34B9F19BC4A70006175CD /* accid.h */; }; 4DC34BA319BC4A71006175CD /* custos.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DC34BA019BC4A70006175CD /* custos.h */; }; 4DC34BA419BC4A71006175CD /* dot.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DC34BA119BC4A70006175CD /* dot.h */; }; @@ -264,6 +267,8 @@ 4D9C530F1B52E4AE0003C6EC /* unchecked.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = unchecked.h; path = include/utf8/unchecked.h; sourceTree = ""; }; 4D9C53101B52E4AE0003C6EC /* utf8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = utf8.h; path = include/utf8.h; sourceTree = ""; }; 4D9C5F3A1ADBBBEB005D3031 /* git_commit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = git_commit.h; path = include/vrv/git_commit.h; sourceTree = SOURCE_ROOT; }; + 4DA144891C2AB28700CB7CEE /* textelement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = textelement.cpp; path = src/textelement.cpp; sourceTree = ""; }; + 4DA1448C1C2AB29400CB7CEE /* textelement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = textelement.h; path = include/vrv/textelement.h; sourceTree = ""; }; 4DA60EDE1B6307A8006E2DFC /* textdirective.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = textdirective.h; path = include/vrv/textdirective.h; sourceTree = ""; }; 4DA60EDF1B6307A8006E2DFC /* textdirinterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = textdirinterface.h; path = include/vrv/textdirinterface.h; sourceTree = ""; }; 4DA60EE21B6307B9006E2DFC /* textdirective.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = textdirective.cpp; path = src/textdirective.cpp; sourceTree = ""; }; @@ -274,8 +279,8 @@ 4DB3072E1AC9ED2500EE0982 /* space.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = space.cpp; path = src/space.cpp; sourceTree = ""; }; 4DB726BF1B8B9F480040231B /* rpt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = rpt.cpp; path = src/rpt.cpp; sourceTree = ""; }; 4DB726C21B8B9F540040231B /* rpt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = rpt.h; path = include/vrv/rpt.h; sourceTree = ""; }; - 4DB726C41B8BB0E80040231B /* trem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = trem.cpp; path = src/trem.cpp; sourceTree = ""; }; - 4DB726C71B8BB0F30040231B /* trem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = trem.h; path = include/vrv/trem.h; sourceTree = ""; }; + 4DB726C41B8BB0E80040231B /* text.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = text.cpp; path = src/text.cpp; sourceTree = ""; }; + 4DB726C71B8BB0F30040231B /* text.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = text.h; path = include/vrv/text.h; sourceTree = ""; }; 4DC34B9F19BC4A70006175CD /* accid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = accid.h; path = include/vrv/accid.h; sourceTree = ""; }; 4DC34BA019BC4A70006175CD /* custos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = custos.h; path = include/vrv/custos.h; sourceTree = ""; }; 4DC34BA119BC4A70006175CD /* dot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = dot.h; path = include/vrv/dot.h; sourceTree = ""; }; @@ -447,6 +452,17 @@ path = tinyxml; sourceTree = ""; }; + 4DA144881C2AB24400CB7CEE /* textelements */ = { + isa = PBXGroup; + children = ( + 4DB726C41B8BB0E80040231B /* text.cpp */, + 4DB726C71B8BB0F30040231B /* text.h */, + 4DA144891C2AB28700CB7CEE /* textelement.cpp */, + 4DA1448C1C2AB29400CB7CEE /* textelement.h */, + ); + name = textelements; + sourceTree = ""; + }; 4DBC09271B51960100B1832C /* utf8 */ = { isa = PBXGroup; children = ( @@ -572,6 +588,7 @@ 8F086F38188539F00037FD8E /* containers */, 8F086F3A18853A540037FD8E /* elements */, 4DF28A011A754DAA00BA9F7D /* floatingelements */, + 4DA144881C2AB24400CB7CEE /* textelements */, 4DC34B9E19BC33A0006175CD /* interfaces */, 8F086F3918853A190037FD8E /* view */, 8F086EB6188539540037FD8E /* aligner.cpp */, @@ -707,8 +724,6 @@ 4DB3072D1AC9ED1800EE0982 /* space.h */, 4D9A9C1D19A1DE2000028D93 /* syl.cpp */, 4D9A9C1B199F576100028D93 /* syl.h */, - 4DB726C41B8BB0E80040231B /* trem.cpp */, - 4DB726C71B8BB0F30040231B /* trem.h */, 8F086ED9188539540037FD8E /* tuplet.cpp */, 8F59293018854BF800FE51AD /* tuplet.h */, 4D9A9C18199F561200028D93 /* verse.cpp */, @@ -739,7 +754,7 @@ 4DF9D2991C1B3F0A0069E8C8 /* attclasses.h in Headers */, 8F59293D18854BF800FE51AD /* toolkit.h in Headers */, 4D1D733C1A1D0390001E08F6 /* smufl.h in Headers */, - 4DB726C81B8BB0F30040231B /* trem.h in Headers */, + 4DB726C81B8BB0F30040231B /* text.h in Headers */, 8F59293E18854BF800FE51AD /* io.h in Headers */, 8F59293F18854BF800FE51AD /* iodarms.h in Headers */, 8F59294018854BF800FE51AD /* iomei.h in Headers */, @@ -752,6 +767,7 @@ 8F59294518854BF800FE51AD /* layerelement.h in Headers */, 8F59294718854BF800FE51AD /* measure.h in Headers */, 8F59294818854BF800FE51AD /* mensur.h in Headers */, + 4DA1448D1C2AB29400CB7CEE /* textelement.h in Headers */, 8F59294918854BF800FE51AD /* multirest.h in Headers */, 8F59294A18854BF800FE51AD /* note.h in Headers */, 8F59294B18854BF800FE51AD /* object.h in Headers */, @@ -902,7 +918,7 @@ 8F086EF3188539540037FD8E /* layerelement.cpp in Sources */, 8F086EF5188539540037FD8E /* measure.cpp in Sources */, 8F086EF6188539540037FD8E /* mensur.cpp in Sources */, - 4DB726C51B8BB0E80040231B /* trem.cpp in Sources */, + 4DB726C51B8BB0E80040231B /* text.cpp in Sources */, 4D798CBD1B8AEDBA007281CA /* drawinginterface.cpp in Sources */, 8F086EF7188539540037FD8E /* multirest.cpp in Sources */, 8F086EF8188539540037FD8E /* note.cpp in Sources */, @@ -914,6 +930,7 @@ 8F086EFE188539540037FD8E /* scoredef.cpp in Sources */, 8F086EFF188539540037FD8E /* slur.cpp in Sources */, 8F086F00188539540037FD8E /* staff.cpp in Sources */, + 4DA1448A1C2AB28700CB7CEE /* textelement.cpp in Sources */, 8F086F01188539540037FD8E /* svgdevicecontext.cpp in Sources */, 4DA80D961A6ACF5D0089802D /* style.cpp in Sources */, 8F086F03188539540037FD8E /* system.cpp in Sources */, @@ -969,7 +986,7 @@ 4D1D73411A1D08DC001E08F6 /* glyph.cpp in Sources */, 8F3DD36418854B390051330C /* view_page.cpp in Sources */, 8F3DD36518854B390051330C /* view_tuplet.cpp in Sources */, - 4DB726C61B8BB0E80040231B /* trem.cpp in Sources */, + 4DB726C61B8BB0E80040231B /* text.cpp in Sources */, 8F3DD33C18854B2E0051330C /* barline.cpp in Sources */, 8F3DD33E18854B2E0051330C /* beam.cpp in Sources */, 8F3DD34018854B2E0051330C /* clef.cpp in Sources */, @@ -985,6 +1002,7 @@ 8F3DD34C18854B2E0051330C /* note.cpp in Sources */, 4D8CD8A71B4E927300F0756F /* atts_critapp.cpp in Sources */, 8F3DD34E18854B2E0051330C /* pitchinterface.cpp in Sources */, + 4DA1448B1C2AB28700CB7CEE /* textelement.cpp in Sources */, 8F3DD35018854B2E0051330C /* positioninterface.cpp in Sources */, 8F3DD35218854B2E0051330C /* rest.cpp in Sources */, 8F3DD35418854B2E0051330C /* slur.cpp in Sources */, diff --git a/include/vrv/editorial.h b/include/vrv/editorial.h index 1124cacf155..379ea85c5be 100644 --- a/include/vrv/editorial.h +++ b/include/vrv/editorial.h @@ -25,6 +25,7 @@ class ScoreDef; class Staff; class StaffDef; class StaffGrp; +class TextElement; enum VisibilityType { Hidden = 0, @@ -62,6 +63,7 @@ class EditorialElement: public DocObject, ///@{ void AddFloatingElement( FloatingElement *child ); void AddLayerElement( LayerElement *child ); + void AddTextElement( TextElement *child ); void AddLayer( Layer *child ); void AddMeasure( Measure *child ); void AddScoreDef( ScoreDef *child ); diff --git a/include/vrv/iomei.h b/include/vrv/iomei.h index 6abe4fa39d1..240ec3e53c2 100644 --- a/include/vrv/iomei.h +++ b/include/vrv/iomei.h @@ -48,6 +48,7 @@ class PitchInterface; class PositionInterface; class Proport; class Rdg; +class Rend; class Rest; class ScoreDef; class ScoreDefInterface; @@ -58,7 +59,9 @@ class Supplied; class Syl; class System; class Tempo; +class Text; class TextDirInterface; +class TextElement; class Tie; class TimeSpanningInterface; class Tuplet; @@ -113,7 +116,7 @@ class MeiOutput: public FileOutputStream bool WriteMeiDoc( Doc *doc ); /** - * @name Methods for wrinting MEI containers (measures, staff, etc) scoreDef and related. + * @name Methods for writing MEI containers (measures, staff, etc) scoreDef and related. */ ///@{ bool WriteMeiPage( pugi::xml_node currentNode, Page *page ); @@ -127,7 +130,7 @@ class MeiOutput: public FileOutputStream ///@} /** - * @name Methods for wrinting LayerElement children. + * @name Methods for writing LayerElement children. * Called from WriteLayerElement. */ ///@{ @@ -157,7 +160,7 @@ class MeiOutput: public FileOutputStream ///@} /** - * @name Methods for wrining FloatingElement + * @name Methods for writing FloatingElement */ ///@{ void WriteMeiSlur( pugi::xml_node currentNode, Slur *slur ); @@ -165,6 +168,14 @@ class MeiOutput: public FileOutputStream void WriteMeiTie( pugi::xml_node currentNode, Tie *tie ); ///@} + /** + * @name Methods for writing TextElement + */ + ///@{ + void WriteMeiRend( pugi::xml_node currentNode, Rend *rend ); + void WriteMeiText( pugi::xml_node currentNode, Text *text ); + ///@} + /** * @name Methods for writing editorial markup */ @@ -294,6 +305,7 @@ class MeiInput: public FileInputStream bool ReadMeiStaffChildren( Object *parent, pugi::xml_node parentNode ); bool ReadMeiLayer( Object *parent, pugi::xml_node layer ); bool ReadMeiLayerChildren( Object *parent, pugi::xml_node parentNode, Object *filter = NULL ); + bool ReadMeiTextChildren( Object *parent, pugi::xml_node parentNode, Object *filter = NULL ); ///@} /** @@ -335,6 +347,14 @@ class MeiInput: public FileInputStream bool ReadMeiTempo( Object *parent, pugi::xml_node tempo ); bool ReadMeiTie( Object *parent, pugi::xml_node tie ); ///@} + + /** + * @name Methods for reading MEI text elements + */ + ///@{ + bool ReadMeiRend( Object *parent, pugi::xml_node rend ); + bool ReadMeiText( Object *parent, pugi::xml_node text ); + ///@} /** * @name Methods for reading critical apparatus, other editorial markup and . @@ -399,6 +419,7 @@ class MeiInput: public FileInputStream ///@{ void AddLayerElement( Object *parent, LayerElement *element ); void AddFloatingElement( Object *parent, FloatingElement *element ); + void AddTextElement( Object *parent, TextElement *element ); void AddScoreDef( Object *parent, ScoreDef *element ); void AddStaffGrp( Object *parent, StaffGrp *element ); ///@} diff --git a/include/vrv/object.h b/include/vrv/object.h index 6aa42eb02ac..edb96e932c2 100644 --- a/include/vrv/object.h +++ b/include/vrv/object.h @@ -86,6 +86,7 @@ class Object bool IsLayerElement() { return (this->Is() > LAYER_ELEMENT && this->Is() < LAYER_ELEMENT_max); }; bool IsFloatingElement() { return (this->Is() > FLOATING_ELEMENT && this->Is() < FLOATING_ELEMENT_max); }; bool IsScoreDefElement() { return (this->Is() > SCOREDEF_ELEMENT && this->Is() < SCOREDEF_ELEMENT_max); }; + bool IsTextElement() { return (this->Is() > TEXT_ELEMENT && this->Is() < TEXT_ELEMENT_max); }; ///@} /** diff --git a/include/vrv/text.h b/include/vrv/text.h new file mode 100644 index 00000000000..c526031227a --- /dev/null +++ b/include/vrv/text.h @@ -0,0 +1,100 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: text.h +// Author: Laurent Pugin +// Created: 2015 +// Copyright (c) Authors and others. All rights reserved. +///////////////////////////////////////////////////////////////////////////// + + +#ifndef __VRV_TEXT_H__ +#define __VRV_TEXT_H__ + +#include "atts_shared.h" +#include "textelement.h" + +namespace vrv { + +//---------------------------------------------------------------------------- +// Rend +//---------------------------------------------------------------------------- + +/** + * This class models the MEI + */ +class Rend: public TextElement, + public AttCommon, + public AttTypography +{ +public: + /** + * @name Constructors, destructors, reset and class name methods + * Reset method reset all attribute classes + */ + ///@{ + Rend(); + virtual ~Rend(); + virtual void Reset(); + virtual std::string GetClassName( ){ return "Rend"; }; ; + virtual ClassId Is() { return REND; }; + ///@} + + /** + * Add an element (text, rend. etc.) to a rend. + * Only supported elements will be actually added to the child list. + */ + void AddTextElement(TextElement *element); + +private: + +public: + +private: + +}; + +//---------------------------------------------------------------------------- +// Text +//---------------------------------------------------------------------------- + +/** + * This class models CDATA (text) + */ +class Text: public TextElement +{ +public: + /** + * @name Constructors, destructors, reset and class name methods + * Reset method reset all attribute classes + */ + ///@{ + Text( ); + virtual ~Text(); + virtual void Reset(); + virtual std::string GetClassName( ){ return "Text"; }; ; + virtual ClassId Is() { return TEXT; }; + ///@} + + /** + * @name Set and get the text content. + * The text content is a std::wstring that needs to be converted to UTF16. + * See MeiInput::ReadText and MeiInput ::WriteText + */ + ///@{ + void SetText( std::wstring text ) { m_text = text; }; + std::wstring GetText() const { return m_text; }; + ///@} + +private: + +public: + +protected: + std::wstring m_text; + +private: + +}; + +} // namespace vrv + +#endif diff --git a/include/vrv/textdirective.h b/include/vrv/textdirective.h index 3d6b0510fb2..b4b880866ef 100644 --- a/include/vrv/textdirective.h +++ b/include/vrv/textdirective.h @@ -14,6 +14,8 @@ namespace vrv { +class TextElement; + //---------------------------------------------------------------------------- // Tempo //---------------------------------------------------------------------------- @@ -36,6 +38,12 @@ class Tempo: public FloatingElement, public TextDirInterface virtual ClassId Is() { return TEMPO; }; ///@} + /** + * Add an element (text, rend. etc.) to a tempo. + * Only supported elements will be actually added to the child list. + */ + void AddTextElement(TextElement *element); + protected: private: diff --git a/include/vrv/textelement.h b/include/vrv/textelement.h new file mode 100644 index 00000000000..a2ede293c48 --- /dev/null +++ b/include/vrv/textelement.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: textelement.h +// Author: Laurent Pugin +// Created: 2015 +// Copyright (c) Authors and others. All rights reserved. +///////////////////////////////////////////////////////////////////////////// + + +#ifndef __VRV_TEXT_ELEMENT_H__ +#define __VRV_TEXT_ELEMENT_H__ + +#include "object.h" + +namespace vrv { + +//---------------------------------------------------------------------------- +// TextElement +//---------------------------------------------------------------------------- + +class TextElement: public DocObject +{ +public: + /** + * @name Constructors, destructors, and other standard methods + * Reset method reset all attribute classes + */ + ///@{ + TextElement(); + TextElement(std::string classid); + virtual ~TextElement(); + virtual void Reset(); + virtual std::string GetClassName( ) { return "TextElement"; }; + virtual ClassId Is() { return TEXT_ELEMENT; }; + ///@} + +private: + +public: + +private: + +}; + +} // namespace vrv + +#endif diff --git a/include/vrv/trem.h b/include/vrv/trem.h deleted file mode 100644 index 8349c8c0b6c..00000000000 --- a/include/vrv/trem.h +++ /dev/null @@ -1,18 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: trem.h -// Author: Laurent Pugin -// Created: 2015 -// Copyright (c) Authors and others. All rights reserved. -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __VRV_TREM_H__ -#define __VRV_TREM_H__ - -#include "layerelement.h" - -namespace vrv { - -} // namespace vrv - -#endif diff --git a/include/vrv/vrvdef.h b/include/vrv/vrvdef.h index 404abb6a44b..3f095b9b460 100644 --- a/include/vrv/vrvdef.h +++ b/include/vrv/vrvdef.h @@ -138,6 +138,11 @@ enum ClassId { SCOREDEF, STAFFDEF, SCOREDEF_ELEMENT_max, + // Ids for TextElement child classes + TEXT_ELEMENT, + REND, + TEXT, + TEXT_ELEMENT_max, // UNSPECIFIED }; @@ -231,7 +236,8 @@ enum EditorialLevel { EDITORIAL_MEASURE, EDITORIAL_STAFF, EDITORIAL_LAYER, - EDITORIAL_NOTE + EDITORIAL_NOTE, + EDITORIAL_TEXT }; //---------------------------------------------------------------------------- diff --git a/src/editorial.cpp b/src/editorial.cpp index e13badf9688..05da2d1b736 100644 --- a/src/editorial.cpp +++ b/src/editorial.cpp @@ -19,6 +19,7 @@ #include "scoredef.h" #include "staff.h" #include "system.h" +#include "textelement.h" #include "vrv.h" namespace vrv { @@ -63,6 +64,13 @@ void EditorialElement::AddFloatingElement( FloatingElement *child ) } +void EditorialElement::AddTextElement( TextElement *child ) +{ + child->SetParent( this ); + m_children.push_back( child ); + Modify(); +} + void EditorialElement::AddLayer( Layer *child ) { child->SetParent( this ); diff --git a/src/iomei.cpp b/src/iomei.cpp index 1a765683c73..4fdac3ba6df 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -39,8 +39,8 @@ #include "syl.h" #include "system.h" #include "textdirective.h" +#include "text.h" #include "tie.h" -#include "trem.h" #include "tuplet.h" #include "verse.h" #include "vrv.h" @@ -289,19 +289,26 @@ bool MeiOutput::WriteObject( Object *object ) m_currentNode = m_currentNode.append_child("space"); WriteMeiSpace( m_currentNode, dynamic_cast(object) ); } + else if (object->Is() == SYL) { + m_currentNode = m_currentNode.append_child("syl"); + WriteMeiSyl( m_currentNode, dynamic_cast(object) ); + } else if (object->Is() == TUPLET) { m_currentNode = m_currentNode.append_child("tuplet"); WriteMeiTuplet( m_currentNode, dynamic_cast(object) ); } - - // others else if (object->Is() == VERSE) { m_currentNode = m_currentNode.append_child("verse"); WriteMeiVerse( m_currentNode, dynamic_cast(object) ); } - else if (object->Is() == SYL) { - m_currentNode = m_currentNode.append_child("syl"); - WriteMeiSyl( m_currentNode, dynamic_cast(object) ); + + // Text elements + else if (object->Is() == REND) { + m_currentNode = m_currentNode.append_child("rend"); + WriteMeiRend( m_currentNode, dynamic_cast(object) ); + } + else if (object->Is() == TEXT) { + WriteMeiText( m_currentNode, dynamic_cast(object) ); } // Editorial markup @@ -816,9 +823,27 @@ void MeiOutput::WriteMeiTempo( pugi::xml_node currentNode, Tempo *tempo ) currentNode.append_attribute( "xml:id" ) = UuidToMeiStr( tempo ).c_str(); WriteTextDirInterface( currentNode, tempo); - WriteText( currentNode, tempo ); + //WriteText( currentNode, tempo ); return; } + +void MeiOutput::WriteMeiRend( pugi::xml_node currentNode, Rend *rend ) +{ + assert( rend ); + + currentNode.append_attribute( "xml:id" ) = UuidToMeiStr( rend ).c_str(); + rend->WriteCommon(currentNode); + rend->WriteTypography(currentNode); + return; +} + +void MeiOutput::WriteMeiText( pugi::xml_node element, Text *text ) +{ + if ( !text->GetText().empty() ) { + pugi::xml_node nodechild = element.append_child(pugi::node_pcdata); + nodechild.text() = UTF16to8(text->GetText().c_str() ).c_str(); + } +} void MeiOutput::WriteDurationInterface(pugi::xml_node element, vrv::DurationInterface *interface) { @@ -2082,11 +2107,11 @@ bool MeiInput::ReadMeiTempo(Object *parent, pugi::xml_node tempo) SetMeiUuid(tempo, vrvTempo); ReadTextDirInterface(tempo, vrvTempo); - ReadText( tempo, vrvTempo ); + //ReadText( tempo, vrvTempo ); AddFloatingElement(parent, vrvTempo); - - return true; + + return ReadMeiTextChildren(vrvTempo, tempo); } bool MeiInput::ReadDurationInterface(pugi::xml_node element, DurationInterface *interface) @@ -2128,6 +2153,65 @@ bool MeiInput::ReadScoreDefInterface(pugi::xml_node element, ScoreDefInterface * return true; } + +bool MeiInput::ReadMeiTextChildren( Object *parent, pugi::xml_node parentNode, Object *filter ) +{ + bool success = true; + pugi::xml_node xmlElement; + std::string elementName; + for( xmlElement = parentNode.first_child( ); xmlElement; xmlElement = xmlElement.next_sibling( ) ) { + if (!success) { + break; + } + elementName = std::string( xmlElement.name() ); + if ( !IsAllowed( elementName, filter ) ) { + LogDebug("Element <%s> within %s ignored", xmlElement.name(), filter->GetClassName().c_str() ); + continue; + } + else if ( elementName == "rend" ) { + success = ReadMeiRend( parent, xmlElement ); + } + else if ( elementName == "app" ) { + success = ReadMeiApp( parent, xmlElement, EDITORIAL_TEXT, filter); + } + else if ( elementName == "supplied" ) { + success = ReadMeiSupplied( parent, xmlElement, EDITORIAL_TEXT, filter ); + } + else if ( xmlElement.text() ) { + success = ReadMeiText( parent, xmlElement ); + } + // unknown + else { + LogDebug("Element %s ignored", xmlElement.name() ); + } + } + + return success; +} + +bool MeiInput::ReadMeiRend( Object *parent, pugi::xml_node rend ) +{ + Rend *vrvRend = new Rend(); + + vrvRend->ReadCommon( rend ); + vrvRend->ReadTypography( rend ); + + AddTextElement(parent, vrvRend); + + return ReadMeiTextChildren(vrvRend, rend); +} + +bool MeiInput::ReadMeiText( Object *parent, pugi::xml_node text ) +{ + Text *vrvText = new Text(); + + assert( text.text() ); + vrvText->SetText(UTF8to16( text.text().as_string() )); + + AddTextElement(parent, vrvText); + return true; +} + bool MeiInput::ReadTextDirInterface(pugi::xml_node element, TextDirInterface *interface) { interface->ReadCommon(element); @@ -2316,6 +2400,9 @@ bool MeiInput::ReadMeiEditorialChildren( Object *parent, pugi::xml_node parentNo else if (level == EDITORIAL_LAYER) { return ReadMeiLayerChildren(parent, parentNode, filter); } + else if (level == EDITORIAL_TEXT) { + return ReadMeiTextChildren(parent, parentNode, filter); + } else { return false; } @@ -2452,6 +2539,34 @@ void MeiInput::AddFloatingElement(Object *parent, FloatingElement *element) delete element; } } + +void MeiInput::AddTextElement(Object *parent, TextElement *element) +{ + if ( parent->IsEditorialElement() ) { + EditorialElement *editorialElement = dynamic_cast( parent ); + assert( editorialElement ); + editorialElement->AddTextElement( element ); + } + else if ( parent->Is() == SYL ) { + Syl *syl = dynamic_cast( parent ); + assert( syl ); + //syl->AddTextElement( element ); + } + else if ( parent->Is() == TEMPO ) { + Tempo *tempo = dynamic_cast( parent ); + assert( tempo ); + tempo->AddTextElement( element ); + } + else if ( parent->Is() == REND ) { + Rend *rend = dynamic_cast( parent ); + assert( rend ); + rend->AddTextElement( element ); + } + else { + LogWarning("'%s' not supported within '%s'", element->GetClassName().c_str(), parent->GetClassName().c_str() ); + delete element; + } +} bool MeiInput::ReadScoreBasedMei( pugi::xml_node element ) { diff --git a/src/text.cpp b/src/text.cpp new file mode 100644 index 00000000000..ed00c2babce --- /dev/null +++ b/src/text.cpp @@ -0,0 +1,78 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: text.cpp +// Author: Laurent Pugin +// Created: 2015 +// Copyright (c) Authors and others. All rights reserved. +///////////////////////////////////////////////////////////////////////////// + + +#include "text.h" + +//---------------------------------------------------------------------------- + +#include + +//---------------------------------------------------------------------------- + +#include "editorial.h" + +namespace vrv { + +//---------------------------------------------------------------------------- +// Rend +//---------------------------------------------------------------------------- + +Rend::Rend( ): + TextElement("rend-"), + AttCommon(), + AttTypography() + +{ + RegisterAttClass(ATT_COMMON); + RegisterAttClass(ATT_TYPOGRAPHY); + + Reset(); +} + +Rend::~Rend() +{ +} + +void Rend::Reset() +{ + TextElement::Reset(); + + ResetCommon(); + ResetTypography(); +} + +void Rend::AddTextElement(TextElement *element) +{ + assert(dynamic_cast(element) + || dynamic_cast(element) + || dynamic_cast(element) ); + element->SetParent( this ); + m_children.push_back(element); + Modify(); +} + +//---------------------------------------------------------------------------- +// Text +//---------------------------------------------------------------------------- + +Text::Text( ): + TextElement("text-") +{ + Reset(); +} + +Text::~Text() +{ +} + +void Text::Reset() +{ + TextElement::Reset(); +} + +} // namespace vrv diff --git a/src/textdirective.cpp b/src/textdirective.cpp index 66509c23137..57a19ad8e9d 100644 --- a/src/textdirective.cpp +++ b/src/textdirective.cpp @@ -14,7 +14,9 @@ //---------------------------------------------------------------------------- +#include "editorial.h" #include "floatingelement.h" +#include "text.h" namespace vrv { @@ -40,5 +42,15 @@ void Tempo::Reset() FloatingElement::Reset(); TextDirInterface::Reset(); } + +void Tempo::AddTextElement(TextElement *element) +{ + assert(dynamic_cast(element) + || dynamic_cast(element) + || dynamic_cast(element) ); + element->SetParent( this ); + m_children.push_back(element); + Modify(); +} } // namespace vrv diff --git a/src/textelement.cpp b/src/textelement.cpp new file mode 100644 index 00000000000..225134712f3 --- /dev/null +++ b/src/textelement.cpp @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: textelement.cpp +// Author: Laurent Pugin +// Created: 2015 +// Copyright (c) Authors and others. All rights reserved. +///////////////////////////////////////////////////////////////////////////// + + +#include "textelement.h" + +//---------------------------------------------------------------------------- + +#include + +//---------------------------------------------------------------------------- + +namespace vrv { + +//---------------------------------------------------------------------------- +// TextElement +//---------------------------------------------------------------------------- + +TextElement::TextElement(): + DocObject("te-") +{ + Reset(); +} + +TextElement::TextElement(std::string classid): + DocObject(classid) +{ + Reset(); +} + +TextElement::~TextElement() +{ +} + +void TextElement::Reset() +{ + DocObject::Reset(); +} + +} // namespace vrv diff --git a/src/trem.cpp b/src/trem.cpp deleted file mode 100644 index 4f57dad4237..00000000000 --- a/src/trem.cpp +++ /dev/null @@ -1,13 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: trem.cpp -// Author: Laurent Pugin -// Created: 2015 -// Copyright (c) Authors and others. All rights reserved. -///////////////////////////////////////////////////////////////////////////// - - -#include "trem.h" - -namespace vrv { - -} // namespace vrv From 0d8366aad54d2f7bab263fdcba7906b161ea1620 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 25 Dec 2015 11:44:42 +0100 Subject: [PATCH 031/217] Updating pugixml --- include/vrv/pugiconfig.hpp | 146 +- include/vrv/pugixml.hpp | 2755 ++-- src/pugixml.cpp | 23928 ++++++++++++++++++----------------- 3 files changed, 13918 insertions(+), 12911 deletions(-) diff --git a/include/vrv/pugiconfig.hpp b/include/vrv/pugiconfig.hpp index 1c216e3abbe..8f610c71f25 100644 --- a/include/vrv/pugiconfig.hpp +++ b/include/vrv/pugiconfig.hpp @@ -1,72 +1,74 @@ -/** - * pugixml parser - version 1.5 - * -------------------------------------------------------- - * Copyright (C) 2006-2014, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) - * Report bugs and download new versions at http://pugixml.org/ - * - * This library is distributed under the MIT License. See notice at the end - * of this file. - * - * This work is based on the pugxml parser, which is: - * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) - */ - -#ifndef HEADER_PUGICONFIG_HPP -#define HEADER_PUGICONFIG_HPP - -// Uncomment this to enable wchar_t mode -// #define PUGIXML_WCHAR_MODE - -// Uncomment this to disable XPath -// #define PUGIXML_NO_XPATH - -// Uncomment this to disable STL -// #define PUGIXML_NO_STL - -// Uncomment this to disable exceptions -// #define PUGIXML_NO_EXCEPTIONS - -// Set this to control attributes for public classes/functions, i.e.: -// #define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL -// #define PUGIXML_CLASS __declspec(dllimport) // to import all classes from DLL -// #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall -// In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead - -// Tune these constants to adjust memory-related behavior -// #define PUGIXML_MEMORY_PAGE_SIZE 32768 -// #define PUGIXML_MEMORY_OUTPUT_STACK 10240 -// #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096 - -// Uncomment this to switch to header-only version -// #define PUGIXML_HEADER_ONLY -// #include "pugixml.cpp" - -// Uncomment this to enable long long support -// #define PUGIXML_HAS_LONG_LONG - -#endif - -/** - * Copyright (c) 2006-2014 Arseny Kapoulkine - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ +/** + * pugixml parser - version 1.7 + * -------------------------------------------------------- + * Copyright (C) 2006-2015, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) + * Report bugs and download new versions at http://pugixml.org/ + * + * This library is distributed under the MIT License. See notice at the end + * of this file. + * + * This work is based on the pugxml parser, which is: + * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) + */ + +#ifndef HEADER_PUGICONFIG_HPP +#define HEADER_PUGICONFIG_HPP + +// Uncomment this to enable wchar_t mode +// #define PUGIXML_WCHAR_MODE + +// Uncomment this to enable compact mode +// #define PUGIXML_COMPACT + +// Uncomment this to disable XPath +// #define PUGIXML_NO_XPATH + +// Uncomment this to disable STL +// #define PUGIXML_NO_STL + +// Uncomment this to disable exceptions +// #define PUGIXML_NO_EXCEPTIONS + +// Set this to control attributes for public classes/functions, i.e.: +// #define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL +// #define PUGIXML_CLASS __declspec(dllimport) // to import all classes from DLL +// #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall +// In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead + +// Tune these constants to adjust memory-related behavior +// #define PUGIXML_MEMORY_PAGE_SIZE 32768 +// #define PUGIXML_MEMORY_OUTPUT_STACK 10240 +// #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096 + +// Uncomment this to switch to header-only version +// #define PUGIXML_HEADER_ONLY + +// Uncomment this to enable long long support +// #define PUGIXML_HAS_LONG_LONG + +#endif + +/** + * Copyright (c) 2006-2015 Arseny Kapoulkine + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ diff --git a/include/vrv/pugixml.hpp b/include/vrv/pugixml.hpp index 917ef4aa77f..3d5b2bced9b 100644 --- a/include/vrv/pugixml.hpp +++ b/include/vrv/pugixml.hpp @@ -1,1355 +1,1400 @@ -/** - * pugixml parser - version 1.5 - * -------------------------------------------------------- - * Copyright (C) 2006-2014, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) - * Report bugs and download new versions at http://pugixml.org/ - * - * This library is distributed under the MIT License. See notice at the end - * of this file. - * - * This work is based on the pugxml parser, which is: - * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) - */ - -#ifndef PUGIXML_VERSION -// Define version macro; evaluates to major * 100 + minor so that it's safe to use in less-than comparisons -# define PUGIXML_VERSION 150 -#endif - -// Include user configuration file (this can define various configuration macros) -#include "pugiconfig.hpp" - -#ifndef HEADER_PUGIXML_HPP -#define HEADER_PUGIXML_HPP - -// Include stddef.h for size_t and ptrdiff_t -#include - -// Include exception header for XPath -#if !defined(PUGIXML_NO_XPATH) && !defined(PUGIXML_NO_EXCEPTIONS) -# include -#endif - -// Include STL headers -#ifndef PUGIXML_NO_STL -# include -# include -# include -#endif - -// Macro for deprecated features -#ifndef PUGIXML_DEPRECATED -# if defined(__GNUC__) -# define PUGIXML_DEPRECATED __attribute__((deprecated)) -# elif defined(_MSC_VER) && _MSC_VER >= 1300 -# define PUGIXML_DEPRECATED __declspec(deprecated) -# else -# define PUGIXML_DEPRECATED -# endif -#endif - -// If no API is defined, assume default -#ifndef PUGIXML_API -# define PUGIXML_API -#endif - -// If no API for classes is defined, assume default -#ifndef PUGIXML_CLASS -# define PUGIXML_CLASS PUGIXML_API -#endif - -// If no API for functions is defined, assume default -#ifndef PUGIXML_FUNCTION -# define PUGIXML_FUNCTION PUGIXML_API -#endif - -// If the platform is known to have long long support, enable long long functions -#ifndef PUGIXML_HAS_LONG_LONG -# if defined(__cplusplus) && __cplusplus >= 201103 -# define PUGIXML_HAS_LONG_LONG -# elif defined(_MSC_VER) && _MSC_VER >= 1400 -# define PUGIXML_HAS_LONG_LONG -# endif -#endif - -// Character interface macros -#ifdef PUGIXML_WCHAR_MODE -# define PUGIXML_TEXT(t) L ## t -# define PUGIXML_CHAR wchar_t -#else -# define PUGIXML_TEXT(t) t -# define PUGIXML_CHAR char -#endif - -namespace pugi -{ - // Character type used for all internal storage and operations; depends on PUGIXML_WCHAR_MODE - typedef PUGIXML_CHAR char_t; - -#ifndef PUGIXML_NO_STL - // String type used for operations that work with STL string; depends on PUGIXML_WCHAR_MODE - typedef std::basic_string, std::allocator > string_t; -#endif -} - -// The PugiXML namespace -namespace pugi -{ - // Tree node types - enum xml_node_type - { - node_null, // Empty (null) node handle - node_document, // A document tree's absolute root - node_element, // Element tag, i.e. '' - node_pcdata, // Plain character data, i.e. 'text' - node_cdata, // Character data, i.e. '' - node_comment, // Comment tag, i.e. '' - node_pi, // Processing instruction, i.e. '' - node_declaration, // Document declaration, i.e. '' - node_doctype // Document type declaration, i.e. '' - }; - - // Parsing options - - // Minimal parsing mode (equivalent to turning all other flags off). - // Only elements and PCDATA sections are added to the DOM tree, no text conversions are performed. - const unsigned int parse_minimal = 0x0000; - - // This flag determines if processing instructions (node_pi) are added to the DOM tree. This flag is off by default. - const unsigned int parse_pi = 0x0001; - - // This flag determines if comments (node_comment) are added to the DOM tree. This flag is off by default. - const unsigned int parse_comments = 0x0002; - - // This flag determines if CDATA sections (node_cdata) are added to the DOM tree. This flag is on by default. - const unsigned int parse_cdata = 0x0004; - - // This flag determines if plain character data (node_pcdata) that consist only of whitespace are added to the DOM tree. - // This flag is off by default; turning it on usually results in slower parsing and more memory consumption. - const unsigned int parse_ws_pcdata = 0x0008; - - // This flag determines if character and entity references are expanded during parsing. This flag is on by default. - const unsigned int parse_escapes = 0x0010; - - // This flag determines if EOL characters are normalized (converted to #xA) during parsing. This flag is on by default. - const unsigned int parse_eol = 0x0020; - - // This flag determines if attribute values are normalized using CDATA normalization rules during parsing. This flag is on by default. - const unsigned int parse_wconv_attribute = 0x0040; - - // This flag determines if attribute values are normalized using NMTOKENS normalization rules during parsing. This flag is off by default. - const unsigned int parse_wnorm_attribute = 0x0080; - - // This flag determines if document declaration (node_declaration) is added to the DOM tree. This flag is off by default. - const unsigned int parse_declaration = 0x0100; - - // This flag determines if document type declaration (node_doctype) is added to the DOM tree. This flag is off by default. - const unsigned int parse_doctype = 0x0200; - - // This flag determines if plain character data (node_pcdata) that is the only child of the parent node and that consists only - // of whitespace is added to the DOM tree. - // This flag is off by default; turning it on may result in slower parsing and more memory consumption. - const unsigned int parse_ws_pcdata_single = 0x0400; - - // This flag determines if leading and trailing whitespace is to be removed from plain character data. This flag is off by default. - const unsigned int parse_trim_pcdata = 0x0800; - - // This flag determines if plain character data that does not have a parent node is added to the DOM tree, and if an empty document - // is a valid document. This flag is off by default. - const unsigned int parse_fragment = 0x1000; - - // The default parsing mode. - // Elements, PCDATA and CDATA sections are added to the DOM tree, character/reference entities are expanded, - // End-of-Line characters are normalized, attribute values are normalized using CDATA normalization rules. - const unsigned int parse_default = parse_cdata | parse_escapes | parse_wconv_attribute | parse_eol; - - // The full parsing mode. - // Nodes of all types are added to the DOM tree, character/reference entities are expanded, - // End-of-Line characters are normalized, attribute values are normalized using CDATA normalization rules. - const unsigned int parse_full = parse_default | parse_pi | parse_comments | parse_declaration | parse_doctype; - - // These flags determine the encoding of input data for XML document - enum xml_encoding - { - encoding_auto, // Auto-detect input encoding using BOM or < / class xml_object_range - { - public: - typedef It const_iterator; - typedef It iterator; - - xml_object_range(It b, It e): _begin(b), _end(e) - { - } - - It begin() const { return _begin; } - It end() const { return _end; } - - private: - It _begin, _end; - }; - - // Writer interface for node printing (see xml_node::print) - class PUGIXML_CLASS xml_writer - { - public: - virtual ~xml_writer() {} - - // Write memory chunk into stream/file/whatever - virtual void write(const void* data, size_t size) = 0; - }; - - // xml_writer implementation for FILE* - class PUGIXML_CLASS xml_writer_file: public xml_writer - { - public: - // Construct writer from a FILE* object; void* is used to avoid header dependencies on stdio - xml_writer_file(void* file); - - virtual void write(const void* data, size_t size); - - private: - void* file; - }; - - #ifndef PUGIXML_NO_STL - // xml_writer implementation for streams - class PUGIXML_CLASS xml_writer_stream: public xml_writer - { - public: - // Construct writer from an output stream object - xml_writer_stream(std::basic_ostream >& stream); - xml_writer_stream(std::basic_ostream >& stream); - - virtual void write(const void* data, size_t size); - - private: - std::basic_ostream >* narrow_stream; - std::basic_ostream >* wide_stream; - }; - #endif - - // A light-weight handle for manipulating attributes in DOM tree - class PUGIXML_CLASS xml_attribute - { - friend class xml_attribute_iterator; - friend class xml_node; - - private: - xml_attribute_struct* _attr; - - typedef void (*unspecified_bool_type)(xml_attribute***); - - public: - // Default constructor. Constructs an empty attribute. - xml_attribute(); - - // Constructs attribute from internal pointer - explicit xml_attribute(xml_attribute_struct* attr); - - // Safe bool conversion operator - operator unspecified_bool_type() const; - - // Borland C++ workaround - bool operator!() const; - - // Comparison operators (compares wrapped attribute pointers) - bool operator==(const xml_attribute& r) const; - bool operator!=(const xml_attribute& r) const; - bool operator<(const xml_attribute& r) const; - bool operator>(const xml_attribute& r) const; - bool operator<=(const xml_attribute& r) const; - bool operator>=(const xml_attribute& r) const; - - // Check if attribute is empty - bool empty() const; - - // Get attribute name/value, or "" if attribute is empty - const char_t* name() const; - const char_t* value() const; - - // Get attribute value, or the default value if attribute is empty - const char_t* as_string(const char_t* def = PUGIXML_TEXT("")) const; - - // Get attribute value as a number, or the default value if conversion did not succeed or attribute is empty - int as_int(int def = 0) const; - unsigned int as_uint(unsigned int def = 0) const; - double as_double(double def = 0) const; - float as_float(float def = 0) const; - - #ifdef PUGIXML_HAS_LONG_LONG - long long as_llong(long long def = 0) const; - unsigned long long as_ullong(unsigned long long def = 0) const; - #endif - - // Get attribute value as bool (returns true if first character is in '1tTyY' set), or the default value if attribute is empty - bool as_bool(bool def = false) const; - - // Set attribute name/value (returns false if attribute is empty or there is not enough memory) - bool set_name(const char_t* rhs); - bool set_value(const char_t* rhs); - - // Set attribute value with type conversion (numbers are converted to strings, boolean is converted to "true"/"false") - bool set_value(int rhs); - bool set_value(unsigned int rhs); - bool set_value(double rhs); - bool set_value(bool rhs); - - #ifdef PUGIXML_HAS_LONG_LONG - bool set_value(long long rhs); - bool set_value(unsigned long long rhs); - #endif - - // Set attribute value (equivalent to set_value without error checking) - xml_attribute& operator=(const char_t* rhs); - xml_attribute& operator=(int rhs); - xml_attribute& operator=(unsigned int rhs); - xml_attribute& operator=(double rhs); - xml_attribute& operator=(bool rhs); - - #ifdef PUGIXML_HAS_LONG_LONG - xml_attribute& operator=(long long rhs); - xml_attribute& operator=(unsigned long long rhs); - #endif - - // Get next/previous attribute in the attribute list of the parent node - xml_attribute next_attribute() const; - xml_attribute previous_attribute() const; - - // Get hash value (unique for handles to the same object) - size_t hash_value() const; - - // Get internal pointer - xml_attribute_struct* internal_object() const; - }; - -#ifdef __BORLANDC__ - // Borland C++ workaround - bool PUGIXML_FUNCTION operator&&(const xml_attribute& lhs, bool rhs); - bool PUGIXML_FUNCTION operator||(const xml_attribute& lhs, bool rhs); -#endif - - // A light-weight handle for manipulating nodes in DOM tree - class PUGIXML_CLASS xml_node - { - friend class xml_attribute_iterator; - friend class xml_node_iterator; - friend class xml_named_node_iterator; - - protected: - xml_node_struct* _root; - - typedef void (*unspecified_bool_type)(xml_node***); - - public: - // Default constructor. Constructs an empty node. - xml_node(); - - // Constructs node from internal pointer - explicit xml_node(xml_node_struct* p); - - // Safe bool conversion operator - operator unspecified_bool_type() const; - - // Borland C++ workaround - bool operator!() const; - - // Comparison operators (compares wrapped node pointers) - bool operator==(const xml_node& r) const; - bool operator!=(const xml_node& r) const; - bool operator<(const xml_node& r) const; - bool operator>(const xml_node& r) const; - bool operator<=(const xml_node& r) const; - bool operator>=(const xml_node& r) const; - - // Check if node is empty. - bool empty() const; - - // Get node type - xml_node_type type() const; - - // Get node name, or "" if node is empty or it has no name - const char_t* name() const; - - // Get node value, or "" if node is empty or it has no value - // Note: For text node.value() does not return "text"! Use child_value() or text() methods to access text inside nodes. - const char_t* value() const; - - // Get attribute list - xml_attribute first_attribute() const; - xml_attribute last_attribute() const; - - // Get children list - xml_node first_child() const; - xml_node last_child() const; - - // Get next/previous sibling in the children list of the parent node - xml_node next_sibling() const; - xml_node previous_sibling() const; - - // Get parent node - xml_node parent() const; - - // Get root of DOM tree this node belongs to - xml_node root() const; - - // Get text object for the current node - xml_text text() const; - - // Get child, attribute or next/previous sibling with the specified name - xml_node child(const char_t* name) const; - xml_attribute attribute(const char_t* name) const; - xml_node next_sibling(const char_t* name) const; - xml_node previous_sibling(const char_t* name) const; - - // Get child value of current node; that is, value of the first child node of type PCDATA/CDATA - const char_t* child_value() const; - - // Get child value of child with specified name. Equivalent to child(name).child_value(). - const char_t* child_value(const char_t* name) const; - - // Set node name/value (returns false if node is empty, there is not enough memory, or node can not have name/value) - bool set_name(const char_t* rhs); - bool set_value(const char_t* rhs); - - // Add attribute with specified name. Returns added attribute, or empty attribute on errors. - xml_attribute append_attribute(const char_t* name); - xml_attribute prepend_attribute(const char_t* name); - xml_attribute insert_attribute_after(const char_t* name, const xml_attribute& attr); - xml_attribute insert_attribute_before(const char_t* name, const xml_attribute& attr); - - // Add a copy of the specified attribute. Returns added attribute, or empty attribute on errors. - xml_attribute append_copy(const xml_attribute& proto); - xml_attribute prepend_copy(const xml_attribute& proto); - xml_attribute insert_copy_after(const xml_attribute& proto, const xml_attribute& attr); - xml_attribute insert_copy_before(const xml_attribute& proto, const xml_attribute& attr); - - // Add child node with specified type. Returns added node, or empty node on errors. - xml_node append_child(xml_node_type type = node_element); - xml_node prepend_child(xml_node_type type = node_element); - xml_node insert_child_after(xml_node_type type, const xml_node& node); - xml_node insert_child_before(xml_node_type type, const xml_node& node); - - // Add child element with specified name. Returns added node, or empty node on errors. - xml_node append_child(const char_t* name); - xml_node prepend_child(const char_t* name); - xml_node insert_child_after(const char_t* name, const xml_node& node); - xml_node insert_child_before(const char_t* name, const xml_node& node); - - // Add a copy of the specified node as a child. Returns added node, or empty node on errors. - xml_node append_copy(const xml_node& proto); - xml_node prepend_copy(const xml_node& proto); - xml_node insert_copy_after(const xml_node& proto, const xml_node& node); - xml_node insert_copy_before(const xml_node& proto, const xml_node& node); - - // Move the specified node to become a child of this node. Returns moved node, or empty node on errors. - xml_node append_move(const xml_node& moved); - xml_node prepend_move(const xml_node& moved); - xml_node insert_move_after(const xml_node& moved, const xml_node& node); - xml_node insert_move_before(const xml_node& moved, const xml_node& node); - - // Remove specified attribute - bool remove_attribute(const xml_attribute& a); - bool remove_attribute(const char_t* name); - - // Remove specified child - bool remove_child(const xml_node& n); - bool remove_child(const char_t* name); - - // Parses buffer as an XML document fragment and appends all nodes as children of the current node. - // Copies/converts the buffer, so it may be deleted or changed after the function returns. - // Note: append_buffer allocates memory that has the lifetime of the owning document; removing the appended nodes does not immediately reclaim that memory. - xml_parse_result append_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - - // Find attribute using predicate. Returns first attribute for which predicate returned true. - template xml_attribute find_attribute(Predicate pred) const - { - if (!_root) return xml_attribute(); - - for (xml_attribute attrib = first_attribute(); attrib; attrib = attrib.next_attribute()) - if (pred(attrib)) - return attrib; - - return xml_attribute(); - } - - // Find child node using predicate. Returns first child for which predicate returned true. - template xml_node find_child(Predicate pred) const - { - if (!_root) return xml_node(); - - for (xml_node node = first_child(); node; node = node.next_sibling()) - if (pred(node)) - return node; - - return xml_node(); - } - - // Find node from subtree using predicate. Returns first node from subtree (depth-first), for which predicate returned true. - template xml_node find_node(Predicate pred) const - { - if (!_root) return xml_node(); - - xml_node cur = first_child(); - - while (cur._root && cur._root != _root) - { - if (pred(cur)) return cur; - - if (cur.first_child()) cur = cur.first_child(); - else if (cur.next_sibling()) cur = cur.next_sibling(); - else - { - while (!cur.next_sibling() && cur._root != _root) cur = cur.parent(); - - if (cur._root != _root) cur = cur.next_sibling(); - } - } - - return xml_node(); - } - - // Find child node by attribute name/value - xml_node find_child_by_attribute(const char_t* name, const char_t* attr_name, const char_t* attr_value) const; - xml_node find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const; - - #ifndef PUGIXML_NO_STL - // Get the absolute node path from root as a text string. - string_t path(char_t delimiter = '/') const; - #endif - - // Search for a node by path consisting of node names and . or .. elements. - xml_node first_element_by_path(const char_t* path, char_t delimiter = '/') const; - - // Recursively traverse subtree with xml_tree_walker - bool traverse(xml_tree_walker& walker); - - #ifndef PUGIXML_NO_XPATH - // Select single node by evaluating XPath query. Returns first node from the resulting node set. - xpath_node select_node(const char_t* query, xpath_variable_set* variables = 0) const; - xpath_node select_node(const xpath_query& query) const; - - // Select node set by evaluating XPath query - xpath_node_set select_nodes(const char_t* query, xpath_variable_set* variables = 0) const; - xpath_node_set select_nodes(const xpath_query& query) const; - - // (deprecated: use select_node instead) Select single node by evaluating XPath query. - xpath_node select_single_node(const char_t* query, xpath_variable_set* variables = 0) const; - xpath_node select_single_node(const xpath_query& query) const; - - #endif - - // Print subtree using a writer object - void print(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const; - - #ifndef PUGIXML_NO_STL - // Print subtree to stream - void print(std::basic_ostream >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const; - void print(std::basic_ostream >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, unsigned int depth = 0) const; - #endif - - // Child nodes iterators - typedef xml_node_iterator iterator; - - iterator begin() const; - iterator end() const; - - // Attribute iterators - typedef xml_attribute_iterator attribute_iterator; - - attribute_iterator attributes_begin() const; - attribute_iterator attributes_end() const; - - // Range-based for support - xml_object_range children() const; - xml_object_range children(const char_t* name) const; - xml_object_range attributes() const; - - // Get node offset in parsed file/string (in char_t units) for debugging purposes - ptrdiff_t offset_debug() const; - - // Get hash value (unique for handles to the same object) - size_t hash_value() const; - - // Get internal pointer - xml_node_struct* internal_object() const; - }; - -#ifdef __BORLANDC__ - // Borland C++ workaround - bool PUGIXML_FUNCTION operator&&(const xml_node& lhs, bool rhs); - bool PUGIXML_FUNCTION operator||(const xml_node& lhs, bool rhs); -#endif - - // A helper for working with text inside PCDATA nodes - class PUGIXML_CLASS xml_text - { - friend class xml_node; - - xml_node_struct* _root; - - typedef void (*unspecified_bool_type)(xml_text***); - - explicit xml_text(xml_node_struct* root); - - xml_node_struct* _data_new(); - xml_node_struct* _data() const; - - public: - // Default constructor. Constructs an empty object. - xml_text(); - - // Safe bool conversion operator - operator unspecified_bool_type() const; - - // Borland C++ workaround - bool operator!() const; - - // Check if text object is empty - bool empty() const; - - // Get text, or "" if object is empty - const char_t* get() const; - - // Get text, or the default value if object is empty - const char_t* as_string(const char_t* def = PUGIXML_TEXT("")) const; - - // Get text as a number, or the default value if conversion did not succeed or object is empty - int as_int(int def = 0) const; - unsigned int as_uint(unsigned int def = 0) const; - double as_double(double def = 0) const; - float as_float(float def = 0) const; - - #ifdef PUGIXML_HAS_LONG_LONG - long long as_llong(long long def = 0) const; - unsigned long long as_ullong(unsigned long long def = 0) const; - #endif - - // Get text as bool (returns true if first character is in '1tTyY' set), or the default value if object is empty - bool as_bool(bool def = false) const; - - // Set text (returns false if object is empty or there is not enough memory) - bool set(const char_t* rhs); - - // Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false") - bool set(int rhs); - bool set(unsigned int rhs); - bool set(double rhs); - bool set(bool rhs); - - #ifdef PUGIXML_HAS_LONG_LONG - bool set(long long rhs); - bool set(unsigned long long rhs); - #endif - - // Set text (equivalent to set without error checking) - xml_text& operator=(const char_t* rhs); - xml_text& operator=(int rhs); - xml_text& operator=(unsigned int rhs); - xml_text& operator=(double rhs); - xml_text& operator=(bool rhs); - - #ifdef PUGIXML_HAS_LONG_LONG - xml_text& operator=(long long rhs); - xml_text& operator=(unsigned long long rhs); - #endif - - // Get the data node (node_pcdata or node_cdata) for this object - xml_node data() const; - }; - -#ifdef __BORLANDC__ - // Borland C++ workaround - bool PUGIXML_FUNCTION operator&&(const xml_text& lhs, bool rhs); - bool PUGIXML_FUNCTION operator||(const xml_text& lhs, bool rhs); -#endif - - // Child node iterator (a bidirectional iterator over a collection of xml_node) - class PUGIXML_CLASS xml_node_iterator - { - friend class xml_node; - - private: - mutable xml_node _wrap; - xml_node _parent; - - xml_node_iterator(xml_node_struct* ref, xml_node_struct* parent); - - public: - // Iterator traits - typedef ptrdiff_t difference_type; - typedef xml_node value_type; - typedef xml_node* pointer; - typedef xml_node& reference; - - #ifndef PUGIXML_NO_STL - typedef std::bidirectional_iterator_tag iterator_category; - #endif - - // Default constructor - xml_node_iterator(); - - // Construct an iterator which points to the specified node - xml_node_iterator(const xml_node& node); - - // Iterator operators - bool operator==(const xml_node_iterator& rhs) const; - bool operator!=(const xml_node_iterator& rhs) const; - - xml_node& operator*() const; - xml_node* operator->() const; - - const xml_node_iterator& operator++(); - xml_node_iterator operator++(int); - - const xml_node_iterator& operator--(); - xml_node_iterator operator--(int); - }; - - // Attribute iterator (a bidirectional iterator over a collection of xml_attribute) - class PUGIXML_CLASS xml_attribute_iterator - { - friend class xml_node; - - private: - mutable xml_attribute _wrap; - xml_node _parent; - - xml_attribute_iterator(xml_attribute_struct* ref, xml_node_struct* parent); - - public: - // Iterator traits - typedef ptrdiff_t difference_type; - typedef xml_attribute value_type; - typedef xml_attribute* pointer; - typedef xml_attribute& reference; - - #ifndef PUGIXML_NO_STL - typedef std::bidirectional_iterator_tag iterator_category; - #endif - - // Default constructor - xml_attribute_iterator(); - - // Construct an iterator which points to the specified attribute - xml_attribute_iterator(const xml_attribute& attr, const xml_node& parent); - - // Iterator operators - bool operator==(const xml_attribute_iterator& rhs) const; - bool operator!=(const xml_attribute_iterator& rhs) const; - - xml_attribute& operator*() const; - xml_attribute* operator->() const; - - const xml_attribute_iterator& operator++(); - xml_attribute_iterator operator++(int); - - const xml_attribute_iterator& operator--(); - xml_attribute_iterator operator--(int); - }; - - // Named node range helper - class PUGIXML_CLASS xml_named_node_iterator - { - friend class xml_node; - - public: - // Iterator traits - typedef ptrdiff_t difference_type; - typedef xml_node value_type; - typedef xml_node* pointer; - typedef xml_node& reference; - - #ifndef PUGIXML_NO_STL - typedef std::bidirectional_iterator_tag iterator_category; - #endif - - // Default constructor - xml_named_node_iterator(); - - // Construct an iterator which points to the specified node - xml_named_node_iterator(const xml_node& node, const char_t* name); - - // Iterator operators - bool operator==(const xml_named_node_iterator& rhs) const; - bool operator!=(const xml_named_node_iterator& rhs) const; - - xml_node& operator*() const; - xml_node* operator->() const; - - const xml_named_node_iterator& operator++(); - xml_named_node_iterator operator++(int); - - const xml_named_node_iterator& operator--(); - xml_named_node_iterator operator--(int); - - private: - mutable xml_node _wrap; - xml_node _parent; - const char_t* _name; - - xml_named_node_iterator(xml_node_struct* ref, xml_node_struct* parent, const char_t* name); - }; - - // Abstract tree walker class (see xml_node::traverse) - class PUGIXML_CLASS xml_tree_walker - { - friend class xml_node; - - private: - int _depth; - - protected: - // Get current traversal depth - int depth() const; - - public: - xml_tree_walker(); - virtual ~xml_tree_walker(); - - // Callback that is called when traversal begins - virtual bool begin(xml_node& node); - - // Callback that is called for each node traversed - virtual bool for_each(xml_node& node) = 0; - - // Callback that is called when traversal ends - virtual bool end(xml_node& node); - }; - - // Parsing status, returned as part of xml_parse_result object - enum xml_parse_status - { - status_ok = 0, // No error - - status_file_not_found, // File was not found during load_file() - status_io_error, // Error reading from file/stream - status_out_of_memory, // Could not allocate memory - status_internal_error, // Internal error occurred - - status_unrecognized_tag, // Parser could not determine tag type - - status_bad_pi, // Parsing error occurred while parsing document declaration/processing instruction - status_bad_comment, // Parsing error occurred while parsing comment - status_bad_cdata, // Parsing error occurred while parsing CDATA section - status_bad_doctype, // Parsing error occurred while parsing document type declaration - status_bad_pcdata, // Parsing error occurred while parsing PCDATA section - status_bad_start_element, // Parsing error occurred while parsing start element tag - status_bad_attribute, // Parsing error occurred while parsing element attribute - status_bad_end_element, // Parsing error occurred while parsing end element tag - status_end_element_mismatch,// There was a mismatch of start-end tags (closing tag had incorrect name, some tag was not closed or there was an excessive closing tag) - - status_append_invalid_root, // Unable to append nodes since root type is not node_element or node_document (exclusive to xml_node::append_buffer) - - status_no_document_element // Parsing resulted in a document without element nodes - }; - - // Parsing result - struct PUGIXML_CLASS xml_parse_result - { - // Parsing status (see xml_parse_status) - xml_parse_status status; - - // Last parsed offset (in char_t units from start of input data) - ptrdiff_t offset; - - // Source document encoding - xml_encoding encoding; - - // Default constructor, initializes object to failed state - xml_parse_result(); - - // Cast to bool operator - operator bool() const; - - // Get error description - const char* description() const; - }; - - // Document class (DOM tree root) - class PUGIXML_CLASS xml_document: public xml_node - { - private: - char_t* _buffer; - - char _memory[192]; - - // Non-copyable semantics - xml_document(const xml_document&); - const xml_document& operator=(const xml_document&); - - void create(); - void destroy(); - - public: - // Default constructor, makes empty document - xml_document(); - - // Destructor, invalidates all node/attribute handles to this document - ~xml_document(); - - // Removes all nodes, leaving the empty document - void reset(); - - // Removes all nodes, then copies the entire contents of the specified document - void reset(const xml_document& proto); - - #ifndef PUGIXML_NO_STL - // Load document from stream. - xml_parse_result load(std::basic_istream >& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - xml_parse_result load(std::basic_istream >& stream, unsigned int options = parse_default); - #endif - - // (deprecated: use load_string instead) Load document from zero-terminated string. No encoding conversions are applied. - xml_parse_result load(const char_t* contents, unsigned int options = parse_default); - - // Load document from zero-terminated string. No encoding conversions are applied. - xml_parse_result load_string(const char_t* contents, unsigned int options = parse_default); - - // Load document from file - xml_parse_result load_file(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - xml_parse_result load_file(const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - - // Load document from buffer. Copies/converts the buffer, so it may be deleted or changed after the function returns. - xml_parse_result load_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - - // Load document from buffer, using the buffer for in-place parsing (the buffer is modified and used for storage of document data). - // You should ensure that buffer data will persist throughout the document's lifetime, and free the buffer memory manually once document is destroyed. - xml_parse_result load_buffer_inplace(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - - // Load document from buffer, using the buffer for in-place parsing (the buffer is modified and used for storage of document data). - // You should allocate the buffer with pugixml allocation function; document will free the buffer when it is no longer needed (you can't use it anymore). - xml_parse_result load_buffer_inplace_own(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - - // Save XML document to writer (semantics is slightly different from xml_node::print, see documentation for details). - void save(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; - - #ifndef PUGIXML_NO_STL - // Save XML document to stream (semantics is slightly different from xml_node::print, see documentation for details). - void save(std::basic_ostream >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; - void save(std::basic_ostream >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default) const; - #endif - - // Save XML to file - bool save_file(const char* path, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; - bool save_file(const wchar_t* path, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; - - // Get document element - xml_node document_element() const; - }; - -#ifndef PUGIXML_NO_XPATH - // XPath query return type - enum xpath_value_type - { - xpath_type_none, // Unknown type (query failed to compile) - xpath_type_node_set, // Node set (xpath_node_set) - xpath_type_number, // Number - xpath_type_string, // String - xpath_type_boolean // Boolean - }; - - // XPath parsing result - struct PUGIXML_CLASS xpath_parse_result - { - // Error message (0 if no error) - const char* error; - - // Last parsed offset (in char_t units from string start) - ptrdiff_t offset; - - // Default constructor, initializes object to failed state - xpath_parse_result(); - - // Cast to bool operator - operator bool() const; - - // Get error description - const char* description() const; - }; - - // A single XPath variable - class PUGIXML_CLASS xpath_variable - { - friend class xpath_variable_set; - - protected: - xpath_value_type _type; - xpath_variable* _next; - - xpath_variable(); - - // Non-copyable semantics - xpath_variable(const xpath_variable&); - xpath_variable& operator=(const xpath_variable&); - - public: - // Get variable name - const char_t* name() const; - - // Get variable type - xpath_value_type type() const; - - // Get variable value; no type conversion is performed, default value (false, NaN, empty string, empty node set) is returned on type mismatch error - bool get_boolean() const; - double get_number() const; - const char_t* get_string() const; - const xpath_node_set& get_node_set() const; - - // Set variable value; no type conversion is performed, false is returned on type mismatch error - bool set(bool value); - bool set(double value); - bool set(const char_t* value); - bool set(const xpath_node_set& value); - }; - - // A set of XPath variables - class PUGIXML_CLASS xpath_variable_set - { - private: - xpath_variable* _data[64]; - - // Non-copyable semantics - xpath_variable_set(const xpath_variable_set&); - xpath_variable_set& operator=(const xpath_variable_set&); - - xpath_variable* find(const char_t* name) const; - - public: - // Default constructor/destructor - xpath_variable_set(); - ~xpath_variable_set(); - - // Add a new variable or get the existing one, if the types match - xpath_variable* add(const char_t* name, xpath_value_type type); - - // Set value of an existing variable; no type conversion is performed, false is returned if there is no such variable or if types mismatch - bool set(const char_t* name, bool value); - bool set(const char_t* name, double value); - bool set(const char_t* name, const char_t* value); - bool set(const char_t* name, const xpath_node_set& value); - - // Get existing variable by name - xpath_variable* get(const char_t* name); - const xpath_variable* get(const char_t* name) const; - }; - - // A compiled XPath query object - class PUGIXML_CLASS xpath_query - { - private: - void* _impl; - xpath_parse_result _result; - - typedef void (*unspecified_bool_type)(xpath_query***); - - // Non-copyable semantics - xpath_query(const xpath_query&); - xpath_query& operator=(const xpath_query&); - - public: - // Construct a compiled object from XPath expression. - // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on compilation errors. - explicit xpath_query(const char_t* query, xpath_variable_set* variables = 0); - - // Destructor - ~xpath_query(); - - // Get query expression return type - xpath_value_type return_type() const; - - // Evaluate expression as boolean value in the specified context; performs type conversion if necessary. - // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors. - bool evaluate_boolean(const xpath_node& n) const; - - // Evaluate expression as double value in the specified context; performs type conversion if necessary. - // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors. - double evaluate_number(const xpath_node& n) const; - - #ifndef PUGIXML_NO_STL - // Evaluate expression as string value in the specified context; performs type conversion if necessary. - // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors. - string_t evaluate_string(const xpath_node& n) const; - #endif - - // Evaluate expression as string value in the specified context; performs type conversion if necessary. - // At most capacity characters are written to the destination buffer, full result size is returned (includes terminating zero). - // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors. - // If PUGIXML_NO_EXCEPTIONS is defined, returns empty set instead. - size_t evaluate_string(char_t* buffer, size_t capacity, const xpath_node& n) const; - - // Evaluate expression as node set in the specified context. - // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on type mismatch and std::bad_alloc on out of memory errors. - // If PUGIXML_NO_EXCEPTIONS is defined, returns empty node set instead. - xpath_node_set evaluate_node_set(const xpath_node& n) const; - - // Evaluate expression as node set in the specified context. - // Return first node in document order, or empty node if node set is empty. - // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on type mismatch and std::bad_alloc on out of memory errors. - // If PUGIXML_NO_EXCEPTIONS is defined, returns empty node instead. - xpath_node evaluate_node(const xpath_node& n) const; - - // Get parsing result (used to get compilation errors in PUGIXML_NO_EXCEPTIONS mode) - const xpath_parse_result& result() const; - - // Safe bool conversion operator - operator unspecified_bool_type() const; - - // Borland C++ workaround - bool operator!() const; - }; - - #ifndef PUGIXML_NO_EXCEPTIONS - // XPath exception class - class PUGIXML_CLASS xpath_exception: public std::exception - { - private: - xpath_parse_result _result; - - public: - // Construct exception from parse result - explicit xpath_exception(const xpath_parse_result& result); - - // Get error message - virtual const char* what() const throw(); - - // Get parse result - const xpath_parse_result& result() const; - }; - #endif - - // XPath node class (either xml_node or xml_attribute) - class PUGIXML_CLASS xpath_node - { - private: - xml_node _node; - xml_attribute _attribute; - - typedef void (*unspecified_bool_type)(xpath_node***); - - public: - // Default constructor; constructs empty XPath node - xpath_node(); - - // Construct XPath node from XML node/attribute - xpath_node(const xml_node& node); - xpath_node(const xml_attribute& attribute, const xml_node& parent); - - // Get node/attribute, if any - xml_node node() const; - xml_attribute attribute() const; - - // Get parent of contained node/attribute - xml_node parent() const; - - // Safe bool conversion operator - operator unspecified_bool_type() const; - - // Borland C++ workaround - bool operator!() const; - - // Comparison operators - bool operator==(const xpath_node& n) const; - bool operator!=(const xpath_node& n) const; - }; - -#ifdef __BORLANDC__ - // Borland C++ workaround - bool PUGIXML_FUNCTION operator&&(const xpath_node& lhs, bool rhs); - bool PUGIXML_FUNCTION operator||(const xpath_node& lhs, bool rhs); -#endif - - // A fixed-size collection of XPath nodes - class PUGIXML_CLASS xpath_node_set - { - public: - // Collection type - enum type_t - { - type_unsorted, // Not ordered - type_sorted, // Sorted by document order (ascending) - type_sorted_reverse // Sorted by document order (descending) - }; - - // Constant iterator type - typedef const xpath_node* const_iterator; - - // We define non-constant iterator to be the same as constant iterator so that various generic algorithms (i.e. boost foreach) work - typedef const xpath_node* iterator; - - // Default constructor. Constructs empty set. - xpath_node_set(); - - // Constructs a set from iterator range; data is not checked for duplicates and is not sorted according to provided type, so be careful - xpath_node_set(const_iterator begin, const_iterator end, type_t type = type_unsorted); - - // Destructor - ~xpath_node_set(); - - // Copy constructor/assignment operator - xpath_node_set(const xpath_node_set& ns); - xpath_node_set& operator=(const xpath_node_set& ns); - - // Get collection type - type_t type() const; - - // Get collection size - size_t size() const; - - // Indexing operator - const xpath_node& operator[](size_t index) const; - - // Collection iterators - const_iterator begin() const; - const_iterator end() const; - - // Sort the collection in ascending/descending order by document order - void sort(bool reverse = false); - - // Get first node in the collection by document order - xpath_node first() const; - - // Check if collection is empty - bool empty() const; - - private: - type_t _type; - - xpath_node _storage; - - xpath_node* _begin; - xpath_node* _end; - - void _assign(const_iterator begin, const_iterator end); - }; -#endif - -#ifndef PUGIXML_NO_STL - // Convert wide string to UTF8 - std::basic_string, std::allocator > PUGIXML_FUNCTION as_utf8(const wchar_t* str); - std::basic_string, std::allocator > PUGIXML_FUNCTION as_utf8(const std::basic_string, std::allocator >& str); - - // Convert UTF8 to wide string - std::basic_string, std::allocator > PUGIXML_FUNCTION as_wide(const char* str); - std::basic_string, std::allocator > PUGIXML_FUNCTION as_wide(const std::basic_string, std::allocator >& str); -#endif - - // Memory allocation function interface; returns pointer to allocated memory or NULL on failure - typedef void* (*allocation_function)(size_t size); - - // Memory deallocation function interface - typedef void (*deallocation_function)(void* ptr); - - // Override default memory management functions. All subsequent allocations/deallocations will be performed via supplied functions. - void PUGIXML_FUNCTION set_memory_management_functions(allocation_function allocate, deallocation_function deallocate); - - // Get current memory management functions - allocation_function PUGIXML_FUNCTION get_memory_allocation_function(); - deallocation_function PUGIXML_FUNCTION get_memory_deallocation_function(); -} - -#if !defined(PUGIXML_NO_STL) && (defined(_MSC_VER) || defined(__ICC)) -namespace std -{ - // Workarounds for (non-standard) iterator category detection for older versions (MSVC7/IC8 and earlier) - std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_node_iterator&); - std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_attribute_iterator&); - std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_named_node_iterator&); -} -#endif - -#if !defined(PUGIXML_NO_STL) && defined(__SUNPRO_CC) -namespace std -{ - // Workarounds for (non-standard) iterator category detection - std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_node_iterator&); - std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_attribute_iterator&); - std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_named_node_iterator&); -} -#endif - -#endif - -/** - * Copyright (c) 2006-2014 Arseny Kapoulkine - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ +/** + * pugixml parser - version 1.7 + * -------------------------------------------------------- + * Copyright (C) 2006-2015, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) + * Report bugs and download new versions at http://pugixml.org/ + * + * This library is distributed under the MIT License. See notice at the end + * of this file. + * + * This work is based on the pugxml parser, which is: + * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) + */ + +#ifndef PUGIXML_VERSION +// Define version macro; evaluates to major * 100 + minor so that it's safe to use in less-than comparisons +# define PUGIXML_VERSION 170 +#endif + +// Include user configuration file (this can define various configuration macros) +#include "pugiconfig.hpp" + +#ifndef HEADER_PUGIXML_HPP +#define HEADER_PUGIXML_HPP + +// Include stddef.h for size_t and ptrdiff_t +#include + +// Include exception header for XPath +#if !defined(PUGIXML_NO_XPATH) && !defined(PUGIXML_NO_EXCEPTIONS) +# include +#endif + +// Include STL headers +#ifndef PUGIXML_NO_STL +# include +# include +# include +#endif + +// Macro for deprecated features +#ifndef PUGIXML_DEPRECATED +# if defined(__GNUC__) +# define PUGIXML_DEPRECATED __attribute__((deprecated)) +# elif defined(_MSC_VER) && _MSC_VER >= 1300 +# define PUGIXML_DEPRECATED __declspec(deprecated) +# else +# define PUGIXML_DEPRECATED +# endif +#endif + +// If no API is defined, assume default +#ifndef PUGIXML_API +# define PUGIXML_API +#endif + +// If no API for classes is defined, assume default +#ifndef PUGIXML_CLASS +# define PUGIXML_CLASS PUGIXML_API +#endif + +// If no API for functions is defined, assume default +#ifndef PUGIXML_FUNCTION +# define PUGIXML_FUNCTION PUGIXML_API +#endif + +// If the platform is known to have long long support, enable long long functions +#ifndef PUGIXML_HAS_LONG_LONG +# if __cplusplus >= 201103 +# define PUGIXML_HAS_LONG_LONG +# elif defined(_MSC_VER) && _MSC_VER >= 1400 +# define PUGIXML_HAS_LONG_LONG +# endif +#endif + +// Character interface macros +#ifdef PUGIXML_WCHAR_MODE +# define PUGIXML_TEXT(t) L ## t +# define PUGIXML_CHAR wchar_t +#else +# define PUGIXML_TEXT(t) t +# define PUGIXML_CHAR char +#endif + +namespace pugi +{ + // Character type used for all internal storage and operations; depends on PUGIXML_WCHAR_MODE + typedef PUGIXML_CHAR char_t; + +#ifndef PUGIXML_NO_STL + // String type used for operations that work with STL string; depends on PUGIXML_WCHAR_MODE + typedef std::basic_string, std::allocator > string_t; +#endif +} + +// The PugiXML namespace +namespace pugi +{ + // Tree node types + enum xml_node_type + { + node_null, // Empty (null) node handle + node_document, // A document tree's absolute root + node_element, // Element tag, i.e. '' + node_pcdata, // Plain character data, i.e. 'text' + node_cdata, // Character data, i.e. '' + node_comment, // Comment tag, i.e. '' + node_pi, // Processing instruction, i.e. '' + node_declaration, // Document declaration, i.e. '' + node_doctype // Document type declaration, i.e. '' + }; + + // Parsing options + + // Minimal parsing mode (equivalent to turning all other flags off). + // Only elements and PCDATA sections are added to the DOM tree, no text conversions are performed. + const unsigned int parse_minimal = 0x0000; + + // This flag determines if processing instructions (node_pi) are added to the DOM tree. This flag is off by default. + const unsigned int parse_pi = 0x0001; + + // This flag determines if comments (node_comment) are added to the DOM tree. This flag is off by default. + const unsigned int parse_comments = 0x0002; + + // This flag determines if CDATA sections (node_cdata) are added to the DOM tree. This flag is on by default. + const unsigned int parse_cdata = 0x0004; + + // This flag determines if plain character data (node_pcdata) that consist only of whitespace are added to the DOM tree. + // This flag is off by default; turning it on usually results in slower parsing and more memory consumption. + const unsigned int parse_ws_pcdata = 0x0008; + + // This flag determines if character and entity references are expanded during parsing. This flag is on by default. + const unsigned int parse_escapes = 0x0010; + + // This flag determines if EOL characters are normalized (converted to #xA) during parsing. This flag is on by default. + const unsigned int parse_eol = 0x0020; + + // This flag determines if attribute values are normalized using CDATA normalization rules during parsing. This flag is on by default. + const unsigned int parse_wconv_attribute = 0x0040; + + // This flag determines if attribute values are normalized using NMTOKENS normalization rules during parsing. This flag is off by default. + const unsigned int parse_wnorm_attribute = 0x0080; + + // This flag determines if document declaration (node_declaration) is added to the DOM tree. This flag is off by default. + const unsigned int parse_declaration = 0x0100; + + // This flag determines if document type declaration (node_doctype) is added to the DOM tree. This flag is off by default. + const unsigned int parse_doctype = 0x0200; + + // This flag determines if plain character data (node_pcdata) that is the only child of the parent node and that consists only + // of whitespace is added to the DOM tree. + // This flag is off by default; turning it on may result in slower parsing and more memory consumption. + const unsigned int parse_ws_pcdata_single = 0x0400; + + // This flag determines if leading and trailing whitespace is to be removed from plain character data. This flag is off by default. + const unsigned int parse_trim_pcdata = 0x0800; + + // This flag determines if plain character data that does not have a parent node is added to the DOM tree, and if an empty document + // is a valid document. This flag is off by default. + const unsigned int parse_fragment = 0x1000; + + // The default parsing mode. + // Elements, PCDATA and CDATA sections are added to the DOM tree, character/reference entities are expanded, + // End-of-Line characters are normalized, attribute values are normalized using CDATA normalization rules. + const unsigned int parse_default = parse_cdata | parse_escapes | parse_wconv_attribute | parse_eol; + + // The full parsing mode. + // Nodes of all types are added to the DOM tree, character/reference entities are expanded, + // End-of-Line characters are normalized, attribute values are normalized using CDATA normalization rules. + const unsigned int parse_full = parse_default | parse_pi | parse_comments | parse_declaration | parse_doctype; + + // These flags determine the encoding of input data for XML document + enum xml_encoding + { + encoding_auto, // Auto-detect input encoding using BOM or < / class xml_object_range + { + public: + typedef It const_iterator; + typedef It iterator; + + xml_object_range(It b, It e): _begin(b), _end(e) + { + } + + It begin() const { return _begin; } + It end() const { return _end; } + + private: + It _begin, _end; + }; + + // Writer interface for node printing (see xml_node::print) + class PUGIXML_CLASS xml_writer + { + public: + virtual ~xml_writer() {} + + // Write memory chunk into stream/file/whatever + virtual void write(const void* data, size_t size) = 0; + }; + + // xml_writer implementation for FILE* + class PUGIXML_CLASS xml_writer_file: public xml_writer + { + public: + // Construct writer from a FILE* object; void* is used to avoid header dependencies on stdio + xml_writer_file(void* file); + + virtual void write(const void* data, size_t size); + + private: + void* file; + }; + + #ifndef PUGIXML_NO_STL + // xml_writer implementation for streams + class PUGIXML_CLASS xml_writer_stream: public xml_writer + { + public: + // Construct writer from an output stream object + xml_writer_stream(std::basic_ostream >& stream); + xml_writer_stream(std::basic_ostream >& stream); + + virtual void write(const void* data, size_t size); + + private: + std::basic_ostream >* narrow_stream; + std::basic_ostream >* wide_stream; + }; + #endif + + // A light-weight handle for manipulating attributes in DOM tree + class PUGIXML_CLASS xml_attribute + { + friend class xml_attribute_iterator; + friend class xml_node; + + private: + xml_attribute_struct* _attr; + + typedef void (*unspecified_bool_type)(xml_attribute***); + + public: + // Default constructor. Constructs an empty attribute. + xml_attribute(); + + // Constructs attribute from internal pointer + explicit xml_attribute(xml_attribute_struct* attr); + + // Safe bool conversion operator + operator unspecified_bool_type() const; + + // Borland C++ workaround + bool operator!() const; + + // Comparison operators (compares wrapped attribute pointers) + bool operator==(const xml_attribute& r) const; + bool operator!=(const xml_attribute& r) const; + bool operator<(const xml_attribute& r) const; + bool operator>(const xml_attribute& r) const; + bool operator<=(const xml_attribute& r) const; + bool operator>=(const xml_attribute& r) const; + + // Check if attribute is empty + bool empty() const; + + // Get attribute name/value, or "" if attribute is empty + const char_t* name() const; + const char_t* value() const; + + // Get attribute value, or the default value if attribute is empty + const char_t* as_string(const char_t* def = PUGIXML_TEXT("")) const; + + // Get attribute value as a number, or the default value if conversion did not succeed or attribute is empty + int as_int(int def = 0) const; + unsigned int as_uint(unsigned int def = 0) const; + double as_double(double def = 0) const; + float as_float(float def = 0) const; + + #ifdef PUGIXML_HAS_LONG_LONG + long long as_llong(long long def = 0) const; + unsigned long long as_ullong(unsigned long long def = 0) const; + #endif + + // Get attribute value as bool (returns true if first character is in '1tTyY' set), or the default value if attribute is empty + bool as_bool(bool def = false) const; + + // Set attribute name/value (returns false if attribute is empty or there is not enough memory) + bool set_name(const char_t* rhs); + bool set_value(const char_t* rhs); + + // Set attribute value with type conversion (numbers are converted to strings, boolean is converted to "true"/"false") + bool set_value(int rhs); + bool set_value(unsigned int rhs); + bool set_value(double rhs); + bool set_value(float rhs); + bool set_value(bool rhs); + + #ifdef PUGIXML_HAS_LONG_LONG + bool set_value(long long rhs); + bool set_value(unsigned long long rhs); + #endif + + // Set attribute value (equivalent to set_value without error checking) + xml_attribute& operator=(const char_t* rhs); + xml_attribute& operator=(int rhs); + xml_attribute& operator=(unsigned int rhs); + xml_attribute& operator=(double rhs); + xml_attribute& operator=(float rhs); + xml_attribute& operator=(bool rhs); + + #ifdef PUGIXML_HAS_LONG_LONG + xml_attribute& operator=(long long rhs); + xml_attribute& operator=(unsigned long long rhs); + #endif + + // Get next/previous attribute in the attribute list of the parent node + xml_attribute next_attribute() const; + xml_attribute previous_attribute() const; + + // Get hash value (unique for handles to the same object) + size_t hash_value() const; + + // Get internal pointer + xml_attribute_struct* internal_object() const; + }; + +#ifdef __BORLANDC__ + // Borland C++ workaround + bool PUGIXML_FUNCTION operator&&(const xml_attribute& lhs, bool rhs); + bool PUGIXML_FUNCTION operator||(const xml_attribute& lhs, bool rhs); +#endif + + // A light-weight handle for manipulating nodes in DOM tree + class PUGIXML_CLASS xml_node + { + friend class xml_attribute_iterator; + friend class xml_node_iterator; + friend class xml_named_node_iterator; + + protected: + xml_node_struct* _root; + + typedef void (*unspecified_bool_type)(xml_node***); + + public: + // Default constructor. Constructs an empty node. + xml_node(); + + // Constructs node from internal pointer + explicit xml_node(xml_node_struct* p); + + // Safe bool conversion operator + operator unspecified_bool_type() const; + + // Borland C++ workaround + bool operator!() const; + + // Comparison operators (compares wrapped node pointers) + bool operator==(const xml_node& r) const; + bool operator!=(const xml_node& r) const; + bool operator<(const xml_node& r) const; + bool operator>(const xml_node& r) const; + bool operator<=(const xml_node& r) const; + bool operator>=(const xml_node& r) const; + + // Check if node is empty. + bool empty() const; + + // Get node type + xml_node_type type() const; + + // Get node name, or "" if node is empty or it has no name + const char_t* name() const; + + // Get node value, or "" if node is empty or it has no value + // Note: For text node.value() does not return "text"! Use child_value() or text() methods to access text inside nodes. + const char_t* value() const; + + // Get attribute list + xml_attribute first_attribute() const; + xml_attribute last_attribute() const; + + // Get children list + xml_node first_child() const; + xml_node last_child() const; + + // Get next/previous sibling in the children list of the parent node + xml_node next_sibling() const; + xml_node previous_sibling() const; + + // Get parent node + xml_node parent() const; + + // Get root of DOM tree this node belongs to + xml_node root() const; + + // Get text object for the current node + xml_text text() const; + + // Get child, attribute or next/previous sibling with the specified name + xml_node child(const char_t* name) const; + xml_attribute attribute(const char_t* name) const; + xml_node next_sibling(const char_t* name) const; + xml_node previous_sibling(const char_t* name) const; + + // Get attribute, starting the search from a hint (and updating hint so that searching for a sequence of attributes is fast) + xml_attribute attribute(const char_t* name, xml_attribute& hint) const; + + // Get child value of current node; that is, value of the first child node of type PCDATA/CDATA + const char_t* child_value() const; + + // Get child value of child with specified name. Equivalent to child(name).child_value(). + const char_t* child_value(const char_t* name) const; + + // Set node name/value (returns false if node is empty, there is not enough memory, or node can not have name/value) + bool set_name(const char_t* rhs); + bool set_value(const char_t* rhs); + + // Add attribute with specified name. Returns added attribute, or empty attribute on errors. + xml_attribute append_attribute(const char_t* name); + xml_attribute prepend_attribute(const char_t* name); + xml_attribute insert_attribute_after(const char_t* name, const xml_attribute& attr); + xml_attribute insert_attribute_before(const char_t* name, const xml_attribute& attr); + + // Add a copy of the specified attribute. Returns added attribute, or empty attribute on errors. + xml_attribute append_copy(const xml_attribute& proto); + xml_attribute prepend_copy(const xml_attribute& proto); + xml_attribute insert_copy_after(const xml_attribute& proto, const xml_attribute& attr); + xml_attribute insert_copy_before(const xml_attribute& proto, const xml_attribute& attr); + + // Add child node with specified type. Returns added node, or empty node on errors. + xml_node append_child(xml_node_type type = node_element); + xml_node prepend_child(xml_node_type type = node_element); + xml_node insert_child_after(xml_node_type type, const xml_node& node); + xml_node insert_child_before(xml_node_type type, const xml_node& node); + + // Add child element with specified name. Returns added node, or empty node on errors. + xml_node append_child(const char_t* name); + xml_node prepend_child(const char_t* name); + xml_node insert_child_after(const char_t* name, const xml_node& node); + xml_node insert_child_before(const char_t* name, const xml_node& node); + + // Add a copy of the specified node as a child. Returns added node, or empty node on errors. + xml_node append_copy(const xml_node& proto); + xml_node prepend_copy(const xml_node& proto); + xml_node insert_copy_after(const xml_node& proto, const xml_node& node); + xml_node insert_copy_before(const xml_node& proto, const xml_node& node); + + // Move the specified node to become a child of this node. Returns moved node, or empty node on errors. + xml_node append_move(const xml_node& moved); + xml_node prepend_move(const xml_node& moved); + xml_node insert_move_after(const xml_node& moved, const xml_node& node); + xml_node insert_move_before(const xml_node& moved, const xml_node& node); + + // Remove specified attribute + bool remove_attribute(const xml_attribute& a); + bool remove_attribute(const char_t* name); + + // Remove specified child + bool remove_child(const xml_node& n); + bool remove_child(const char_t* name); + + // Parses buffer as an XML document fragment and appends all nodes as children of the current node. + // Copies/converts the buffer, so it may be deleted or changed after the function returns. + // Note: append_buffer allocates memory that has the lifetime of the owning document; removing the appended nodes does not immediately reclaim that memory. + xml_parse_result append_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); + + // Find attribute using predicate. Returns first attribute for which predicate returned true. + template xml_attribute find_attribute(Predicate pred) const + { + if (!_root) return xml_attribute(); + + for (xml_attribute attrib = first_attribute(); attrib; attrib = attrib.next_attribute()) + if (pred(attrib)) + return attrib; + + return xml_attribute(); + } + + // Find child node using predicate. Returns first child for which predicate returned true. + template xml_node find_child(Predicate pred) const + { + if (!_root) return xml_node(); + + for (xml_node node = first_child(); node; node = node.next_sibling()) + if (pred(node)) + return node; + + return xml_node(); + } + + // Find node from subtree using predicate. Returns first node from subtree (depth-first), for which predicate returned true. + template xml_node find_node(Predicate pred) const + { + if (!_root) return xml_node(); + + xml_node cur = first_child(); + + while (cur._root && cur._root != _root) + { + if (pred(cur)) return cur; + + if (cur.first_child()) cur = cur.first_child(); + else if (cur.next_sibling()) cur = cur.next_sibling(); + else + { + while (!cur.next_sibling() && cur._root != _root) cur = cur.parent(); + + if (cur._root != _root) cur = cur.next_sibling(); + } + } + + return xml_node(); + } + + // Find child node by attribute name/value + xml_node find_child_by_attribute(const char_t* name, const char_t* attr_name, const char_t* attr_value) const; + xml_node find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const; + + #ifndef PUGIXML_NO_STL + // Get the absolute node path from root as a text string. + string_t path(char_t delimiter = '/') const; + #endif + + // Search for a node by path consisting of node names and . or .. elements. + xml_node first_element_by_path(const char_t* path, char_t delimiter = '/') const; + + // Recursively traverse subtree with xml_tree_walker + bool traverse(xml_tree_walker& walker); + + #ifndef PUGIXML_NO_XPATH + // Select single node by evaluating XPath query. Returns first node from the resulting node set. + xpath_node select_node(const char_t* query, xpath_variable_set* variables = 0) const; + xpath_node select_node(const xpath_query& query) const; + + // Select node set by evaluating XPath query + xpath_node_set select_nodes(const char_t* query, xpath_variable_set* variables = 0) const; + xpath_node_set select_nodes(const xpath_query& query) const; + + // (deprecated: use select_node instead) Select single node by evaluating XPath query. + xpath_node select_single_node(const char_t* query, xpath_variable_set* variables = 0) const; + xpath_node select_single_node(const xpath_query& query) const; + + #endif + + // Print subtree using a writer object + void print(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const; + + #ifndef PUGIXML_NO_STL + // Print subtree to stream + void print(std::basic_ostream >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const; + void print(std::basic_ostream >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, unsigned int depth = 0) const; + #endif + + // Child nodes iterators + typedef xml_node_iterator iterator; + + iterator begin() const; + iterator end() const; + + // Attribute iterators + typedef xml_attribute_iterator attribute_iterator; + + attribute_iterator attributes_begin() const; + attribute_iterator attributes_end() const; + + // Range-based for support + xml_object_range children() const; + xml_object_range children(const char_t* name) const; + xml_object_range attributes() const; + + // Get node offset in parsed file/string (in char_t units) for debugging purposes + ptrdiff_t offset_debug() const; + + // Get hash value (unique for handles to the same object) + size_t hash_value() const; + + // Get internal pointer + xml_node_struct* internal_object() const; + }; + +#ifdef __BORLANDC__ + // Borland C++ workaround + bool PUGIXML_FUNCTION operator&&(const xml_node& lhs, bool rhs); + bool PUGIXML_FUNCTION operator||(const xml_node& lhs, bool rhs); +#endif + + // A helper for working with text inside PCDATA nodes + class PUGIXML_CLASS xml_text + { + friend class xml_node; + + xml_node_struct* _root; + + typedef void (*unspecified_bool_type)(xml_text***); + + explicit xml_text(xml_node_struct* root); + + xml_node_struct* _data_new(); + xml_node_struct* _data() const; + + public: + // Default constructor. Constructs an empty object. + xml_text(); + + // Safe bool conversion operator + operator unspecified_bool_type() const; + + // Borland C++ workaround + bool operator!() const; + + // Check if text object is empty + bool empty() const; + + // Get text, or "" if object is empty + const char_t* get() const; + + // Get text, or the default value if object is empty + const char_t* as_string(const char_t* def = PUGIXML_TEXT("")) const; + + // Get text as a number, or the default value if conversion did not succeed or object is empty + int as_int(int def = 0) const; + unsigned int as_uint(unsigned int def = 0) const; + double as_double(double def = 0) const; + float as_float(float def = 0) const; + + #ifdef PUGIXML_HAS_LONG_LONG + long long as_llong(long long def = 0) const; + unsigned long long as_ullong(unsigned long long def = 0) const; + #endif + + // Get text as bool (returns true if first character is in '1tTyY' set), or the default value if object is empty + bool as_bool(bool def = false) const; + + // Set text (returns false if object is empty or there is not enough memory) + bool set(const char_t* rhs); + + // Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false") + bool set(int rhs); + bool set(unsigned int rhs); + bool set(double rhs); + bool set(float rhs); + bool set(bool rhs); + + #ifdef PUGIXML_HAS_LONG_LONG + bool set(long long rhs); + bool set(unsigned long long rhs); + #endif + + // Set text (equivalent to set without error checking) + xml_text& operator=(const char_t* rhs); + xml_text& operator=(int rhs); + xml_text& operator=(unsigned int rhs); + xml_text& operator=(double rhs); + xml_text& operator=(float rhs); + xml_text& operator=(bool rhs); + + #ifdef PUGIXML_HAS_LONG_LONG + xml_text& operator=(long long rhs); + xml_text& operator=(unsigned long long rhs); + #endif + + // Get the data node (node_pcdata or node_cdata) for this object + xml_node data() const; + }; + +#ifdef __BORLANDC__ + // Borland C++ workaround + bool PUGIXML_FUNCTION operator&&(const xml_text& lhs, bool rhs); + bool PUGIXML_FUNCTION operator||(const xml_text& lhs, bool rhs); +#endif + + // Child node iterator (a bidirectional iterator over a collection of xml_node) + class PUGIXML_CLASS xml_node_iterator + { + friend class xml_node; + + private: + mutable xml_node _wrap; + xml_node _parent; + + xml_node_iterator(xml_node_struct* ref, xml_node_struct* parent); + + public: + // Iterator traits + typedef ptrdiff_t difference_type; + typedef xml_node value_type; + typedef xml_node* pointer; + typedef xml_node& reference; + + #ifndef PUGIXML_NO_STL + typedef std::bidirectional_iterator_tag iterator_category; + #endif + + // Default constructor + xml_node_iterator(); + + // Construct an iterator which points to the specified node + xml_node_iterator(const xml_node& node); + + // Iterator operators + bool operator==(const xml_node_iterator& rhs) const; + bool operator!=(const xml_node_iterator& rhs) const; + + xml_node& operator*() const; + xml_node* operator->() const; + + const xml_node_iterator& operator++(); + xml_node_iterator operator++(int); + + const xml_node_iterator& operator--(); + xml_node_iterator operator--(int); + }; + + // Attribute iterator (a bidirectional iterator over a collection of xml_attribute) + class PUGIXML_CLASS xml_attribute_iterator + { + friend class xml_node; + + private: + mutable xml_attribute _wrap; + xml_node _parent; + + xml_attribute_iterator(xml_attribute_struct* ref, xml_node_struct* parent); + + public: + // Iterator traits + typedef ptrdiff_t difference_type; + typedef xml_attribute value_type; + typedef xml_attribute* pointer; + typedef xml_attribute& reference; + + #ifndef PUGIXML_NO_STL + typedef std::bidirectional_iterator_tag iterator_category; + #endif + + // Default constructor + xml_attribute_iterator(); + + // Construct an iterator which points to the specified attribute + xml_attribute_iterator(const xml_attribute& attr, const xml_node& parent); + + // Iterator operators + bool operator==(const xml_attribute_iterator& rhs) const; + bool operator!=(const xml_attribute_iterator& rhs) const; + + xml_attribute& operator*() const; + xml_attribute* operator->() const; + + const xml_attribute_iterator& operator++(); + xml_attribute_iterator operator++(int); + + const xml_attribute_iterator& operator--(); + xml_attribute_iterator operator--(int); + }; + + // Named node range helper + class PUGIXML_CLASS xml_named_node_iterator + { + friend class xml_node; + + public: + // Iterator traits + typedef ptrdiff_t difference_type; + typedef xml_node value_type; + typedef xml_node* pointer; + typedef xml_node& reference; + + #ifndef PUGIXML_NO_STL + typedef std::bidirectional_iterator_tag iterator_category; + #endif + + // Default constructor + xml_named_node_iterator(); + + // Construct an iterator which points to the specified node + xml_named_node_iterator(const xml_node& node, const char_t* name); + + // Iterator operators + bool operator==(const xml_named_node_iterator& rhs) const; + bool operator!=(const xml_named_node_iterator& rhs) const; + + xml_node& operator*() const; + xml_node* operator->() const; + + const xml_named_node_iterator& operator++(); + xml_named_node_iterator operator++(int); + + const xml_named_node_iterator& operator--(); + xml_named_node_iterator operator--(int); + + private: + mutable xml_node _wrap; + xml_node _parent; + const char_t* _name; + + xml_named_node_iterator(xml_node_struct* ref, xml_node_struct* parent, const char_t* name); + }; + + // Abstract tree walker class (see xml_node::traverse) + class PUGIXML_CLASS xml_tree_walker + { + friend class xml_node; + + private: + int _depth; + + protected: + // Get current traversal depth + int depth() const; + + public: + xml_tree_walker(); + virtual ~xml_tree_walker(); + + // Callback that is called when traversal begins + virtual bool begin(xml_node& node); + + // Callback that is called for each node traversed + virtual bool for_each(xml_node& node) = 0; + + // Callback that is called when traversal ends + virtual bool end(xml_node& node); + }; + + // Parsing status, returned as part of xml_parse_result object + enum xml_parse_status + { + status_ok = 0, // No error + + status_file_not_found, // File was not found during load_file() + status_io_error, // Error reading from file/stream + status_out_of_memory, // Could not allocate memory + status_internal_error, // Internal error occurred + + status_unrecognized_tag, // Parser could not determine tag type + + status_bad_pi, // Parsing error occurred while parsing document declaration/processing instruction + status_bad_comment, // Parsing error occurred while parsing comment + status_bad_cdata, // Parsing error occurred while parsing CDATA section + status_bad_doctype, // Parsing error occurred while parsing document type declaration + status_bad_pcdata, // Parsing error occurred while parsing PCDATA section + status_bad_start_element, // Parsing error occurred while parsing start element tag + status_bad_attribute, // Parsing error occurred while parsing element attribute + status_bad_end_element, // Parsing error occurred while parsing end element tag + status_end_element_mismatch,// There was a mismatch of start-end tags (closing tag had incorrect name, some tag was not closed or there was an excessive closing tag) + + status_append_invalid_root, // Unable to append nodes since root type is not node_element or node_document (exclusive to xml_node::append_buffer) + + status_no_document_element // Parsing resulted in a document without element nodes + }; + + // Parsing result + struct PUGIXML_CLASS xml_parse_result + { + // Parsing status (see xml_parse_status) + xml_parse_status status; + + // Last parsed offset (in char_t units from start of input data) + ptrdiff_t offset; + + // Source document encoding + xml_encoding encoding; + + // Default constructor, initializes object to failed state + xml_parse_result(); + + // Cast to bool operator + operator bool() const; + + // Get error description + const char* description() const; + }; + + // Document class (DOM tree root) + class PUGIXML_CLASS xml_document: public xml_node + { + private: + char_t* _buffer; + + char _memory[192]; + + // Non-copyable semantics + xml_document(const xml_document&); + xml_document& operator=(const xml_document&); + + void create(); + void destroy(); + + public: + // Default constructor, makes empty document + xml_document(); + + // Destructor, invalidates all node/attribute handles to this document + ~xml_document(); + + // Removes all nodes, leaving the empty document + void reset(); + + // Removes all nodes, then copies the entire contents of the specified document + void reset(const xml_document& proto); + + #ifndef PUGIXML_NO_STL + // Load document from stream. + xml_parse_result load(std::basic_istream >& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); + xml_parse_result load(std::basic_istream >& stream, unsigned int options = parse_default); + #endif + + // (deprecated: use load_string instead) Load document from zero-terminated string. No encoding conversions are applied. + xml_parse_result load(const char_t* contents, unsigned int options = parse_default); + + // Load document from zero-terminated string. No encoding conversions are applied. + xml_parse_result load_string(const char_t* contents, unsigned int options = parse_default); + + // Load document from file + xml_parse_result load_file(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); + xml_parse_result load_file(const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); + + // Load document from buffer. Copies/converts the buffer, so it may be deleted or changed after the function returns. + xml_parse_result load_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); + + // Load document from buffer, using the buffer for in-place parsing (the buffer is modified and used for storage of document data). + // You should ensure that buffer data will persist throughout the document's lifetime, and free the buffer memory manually once document is destroyed. + xml_parse_result load_buffer_inplace(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); + + // Load document from buffer, using the buffer for in-place parsing (the buffer is modified and used for storage of document data). + // You should allocate the buffer with pugixml allocation function; document will free the buffer when it is no longer needed (you can't use it anymore). + xml_parse_result load_buffer_inplace_own(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); + + // Save XML document to writer (semantics is slightly different from xml_node::print, see documentation for details). + void save(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; + + #ifndef PUGIXML_NO_STL + // Save XML document to stream (semantics is slightly different from xml_node::print, see documentation for details). + void save(std::basic_ostream >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; + void save(std::basic_ostream >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default) const; + #endif + + // Save XML to file + bool save_file(const char* path, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; + bool save_file(const wchar_t* path, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; + + // Get document element + xml_node document_element() const; + }; + +#ifndef PUGIXML_NO_XPATH + // XPath query return type + enum xpath_value_type + { + xpath_type_none, // Unknown type (query failed to compile) + xpath_type_node_set, // Node set (xpath_node_set) + xpath_type_number, // Number + xpath_type_string, // String + xpath_type_boolean // Boolean + }; + + // XPath parsing result + struct PUGIXML_CLASS xpath_parse_result + { + // Error message (0 if no error) + const char* error; + + // Last parsed offset (in char_t units from string start) + ptrdiff_t offset; + + // Default constructor, initializes object to failed state + xpath_parse_result(); + + // Cast to bool operator + operator bool() const; + + // Get error description + const char* description() const; + }; + + // A single XPath variable + class PUGIXML_CLASS xpath_variable + { + friend class xpath_variable_set; + + protected: + xpath_value_type _type; + xpath_variable* _next; + + xpath_variable(xpath_value_type type); + + // Non-copyable semantics + xpath_variable(const xpath_variable&); + xpath_variable& operator=(const xpath_variable&); + + public: + // Get variable name + const char_t* name() const; + + // Get variable type + xpath_value_type type() const; + + // Get variable value; no type conversion is performed, default value (false, NaN, empty string, empty node set) is returned on type mismatch error + bool get_boolean() const; + double get_number() const; + const char_t* get_string() const; + const xpath_node_set& get_node_set() const; + + // Set variable value; no type conversion is performed, false is returned on type mismatch error + bool set(bool value); + bool set(double value); + bool set(const char_t* value); + bool set(const xpath_node_set& value); + }; + + // A set of XPath variables + class PUGIXML_CLASS xpath_variable_set + { + private: + xpath_variable* _data[64]; + + void _assign(const xpath_variable_set& rhs); + void _swap(xpath_variable_set& rhs); + + xpath_variable* _find(const char_t* name) const; + + static bool _clone(xpath_variable* var, xpath_variable** out_result); + static void _destroy(xpath_variable* var); + + public: + // Default constructor/destructor + xpath_variable_set(); + ~xpath_variable_set(); + + // Copy constructor/assignment operator + xpath_variable_set(const xpath_variable_set& rhs); + xpath_variable_set& operator=(const xpath_variable_set& rhs); + + #if __cplusplus >= 201103 + // Move semantics support + xpath_variable_set(xpath_variable_set&& rhs); + xpath_variable_set& operator=(xpath_variable_set&& rhs); + #endif + + // Add a new variable or get the existing one, if the types match + xpath_variable* add(const char_t* name, xpath_value_type type); + + // Set value of an existing variable; no type conversion is performed, false is returned if there is no such variable or if types mismatch + bool set(const char_t* name, bool value); + bool set(const char_t* name, double value); + bool set(const char_t* name, const char_t* value); + bool set(const char_t* name, const xpath_node_set& value); + + // Get existing variable by name + xpath_variable* get(const char_t* name); + const xpath_variable* get(const char_t* name) const; + }; + + // A compiled XPath query object + class PUGIXML_CLASS xpath_query + { + private: + void* _impl; + xpath_parse_result _result; + + typedef void (*unspecified_bool_type)(xpath_query***); + + // Non-copyable semantics + xpath_query(const xpath_query&); + xpath_query& operator=(const xpath_query&); + + public: + // Construct a compiled object from XPath expression. + // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on compilation errors. + explicit xpath_query(const char_t* query, xpath_variable_set* variables = 0); + + // Constructor + xpath_query(); + + // Destructor + ~xpath_query(); + + #if __cplusplus >= 201103 + // Move semantics support + xpath_query(xpath_query&& rhs); + xpath_query& operator=(xpath_query&& rhs); + #endif + + // Get query expression return type + xpath_value_type return_type() const; + + // Evaluate expression as boolean value in the specified context; performs type conversion if necessary. + // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors. + bool evaluate_boolean(const xpath_node& n) const; + + // Evaluate expression as double value in the specified context; performs type conversion if necessary. + // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors. + double evaluate_number(const xpath_node& n) const; + + #ifndef PUGIXML_NO_STL + // Evaluate expression as string value in the specified context; performs type conversion if necessary. + // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors. + string_t evaluate_string(const xpath_node& n) const; + #endif + + // Evaluate expression as string value in the specified context; performs type conversion if necessary. + // At most capacity characters are written to the destination buffer, full result size is returned (includes terminating zero). + // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors. + // If PUGIXML_NO_EXCEPTIONS is defined, returns empty set instead. + size_t evaluate_string(char_t* buffer, size_t capacity, const xpath_node& n) const; + + // Evaluate expression as node set in the specified context. + // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on type mismatch and std::bad_alloc on out of memory errors. + // If PUGIXML_NO_EXCEPTIONS is defined, returns empty node set instead. + xpath_node_set evaluate_node_set(const xpath_node& n) const; + + // Evaluate expression as node set in the specified context. + // Return first node in document order, or empty node if node set is empty. + // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on type mismatch and std::bad_alloc on out of memory errors. + // If PUGIXML_NO_EXCEPTIONS is defined, returns empty node instead. + xpath_node evaluate_node(const xpath_node& n) const; + + // Get parsing result (used to get compilation errors in PUGIXML_NO_EXCEPTIONS mode) + const xpath_parse_result& result() const; + + // Safe bool conversion operator + operator unspecified_bool_type() const; + + // Borland C++ workaround + bool operator!() const; + }; + + #ifndef PUGIXML_NO_EXCEPTIONS + // XPath exception class + class PUGIXML_CLASS xpath_exception: public std::exception + { + private: + xpath_parse_result _result; + + public: + // Construct exception from parse result + explicit xpath_exception(const xpath_parse_result& result); + + // Get error message + virtual const char* what() const throw(); + + // Get parse result + const xpath_parse_result& result() const; + }; + #endif + + // XPath node class (either xml_node or xml_attribute) + class PUGIXML_CLASS xpath_node + { + private: + xml_node _node; + xml_attribute _attribute; + + typedef void (*unspecified_bool_type)(xpath_node***); + + public: + // Default constructor; constructs empty XPath node + xpath_node(); + + // Construct XPath node from XML node/attribute + xpath_node(const xml_node& node); + xpath_node(const xml_attribute& attribute, const xml_node& parent); + + // Get node/attribute, if any + xml_node node() const; + xml_attribute attribute() const; + + // Get parent of contained node/attribute + xml_node parent() const; + + // Safe bool conversion operator + operator unspecified_bool_type() const; + + // Borland C++ workaround + bool operator!() const; + + // Comparison operators + bool operator==(const xpath_node& n) const; + bool operator!=(const xpath_node& n) const; + }; + +#ifdef __BORLANDC__ + // Borland C++ workaround + bool PUGIXML_FUNCTION operator&&(const xpath_node& lhs, bool rhs); + bool PUGIXML_FUNCTION operator||(const xpath_node& lhs, bool rhs); +#endif + + // A fixed-size collection of XPath nodes + class PUGIXML_CLASS xpath_node_set + { + public: + // Collection type + enum type_t + { + type_unsorted, // Not ordered + type_sorted, // Sorted by document order (ascending) + type_sorted_reverse // Sorted by document order (descending) + }; + + // Constant iterator type + typedef const xpath_node* const_iterator; + + // We define non-constant iterator to be the same as constant iterator so that various generic algorithms (i.e. boost foreach) work + typedef const xpath_node* iterator; + + // Default constructor. Constructs empty set. + xpath_node_set(); + + // Constructs a set from iterator range; data is not checked for duplicates and is not sorted according to provided type, so be careful + xpath_node_set(const_iterator begin, const_iterator end, type_t type = type_unsorted); + + // Destructor + ~xpath_node_set(); + + // Copy constructor/assignment operator + xpath_node_set(const xpath_node_set& ns); + xpath_node_set& operator=(const xpath_node_set& ns); + + #if __cplusplus >= 201103 + // Move semantics support + xpath_node_set(xpath_node_set&& rhs); + xpath_node_set& operator=(xpath_node_set&& rhs); + #endif + + // Get collection type + type_t type() const; + + // Get collection size + size_t size() const; + + // Indexing operator + const xpath_node& operator[](size_t index) const; + + // Collection iterators + const_iterator begin() const; + const_iterator end() const; + + // Sort the collection in ascending/descending order by document order + void sort(bool reverse = false); + + // Get first node in the collection by document order + xpath_node first() const; + + // Check if collection is empty + bool empty() const; + + private: + type_t _type; + + xpath_node _storage; + + xpath_node* _begin; + xpath_node* _end; + + void _assign(const_iterator begin, const_iterator end, type_t type); + void _move(xpath_node_set& rhs); + }; +#endif + +#ifndef PUGIXML_NO_STL + // Convert wide string to UTF8 + std::basic_string, std::allocator > PUGIXML_FUNCTION as_utf8(const wchar_t* str); + std::basic_string, std::allocator > PUGIXML_FUNCTION as_utf8(const std::basic_string, std::allocator >& str); + + // Convert UTF8 to wide string + std::basic_string, std::allocator > PUGIXML_FUNCTION as_wide(const char* str); + std::basic_string, std::allocator > PUGIXML_FUNCTION as_wide(const std::basic_string, std::allocator >& str); +#endif + + // Memory allocation function interface; returns pointer to allocated memory or NULL on failure + typedef void* (*allocation_function)(size_t size); + + // Memory deallocation function interface + typedef void (*deallocation_function)(void* ptr); + + // Override default memory management functions. All subsequent allocations/deallocations will be performed via supplied functions. + void PUGIXML_FUNCTION set_memory_management_functions(allocation_function allocate, deallocation_function deallocate); + + // Get current memory management functions + allocation_function PUGIXML_FUNCTION get_memory_allocation_function(); + deallocation_function PUGIXML_FUNCTION get_memory_deallocation_function(); +} + +#if !defined(PUGIXML_NO_STL) && (defined(_MSC_VER) || defined(__ICC)) +namespace std +{ + // Workarounds for (non-standard) iterator category detection for older versions (MSVC7/IC8 and earlier) + std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_node_iterator&); + std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_attribute_iterator&); + std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_named_node_iterator&); +} +#endif + +#if !defined(PUGIXML_NO_STL) && defined(__SUNPRO_CC) +namespace std +{ + // Workarounds for (non-standard) iterator category detection + std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_node_iterator&); + std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_attribute_iterator&); + std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_named_node_iterator&); +} +#endif + +#endif + +// Make sure implementation is included in header-only mode +// Use macro expansion in #include to work around QMake (QTBUG-11923) +#if defined(PUGIXML_HEADER_ONLY) && !defined(PUGIXML_SOURCE) +# define PUGIXML_SOURCE "pugixml.cpp" +# include PUGIXML_SOURCE +#endif + +/** + * Copyright (c) 2006-2015 Arseny Kapoulkine + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ diff --git a/src/pugixml.cpp b/src/pugixml.cpp index dd3f4274e2c..854ff8c63ed 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -1,11484 +1,12444 @@ -/** - * pugixml parser - version 1.5 - * -------------------------------------------------------- - * Copyright (C) 2006-2014, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) - * Report bugs and download new versions at http://pugixml.org/ - * - * This library is distributed under the MIT License. See notice at the end - * of this file. - * - * This work is based on the pugxml parser, which is: - * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) - */ - -#ifndef SOURCE_PUGIXML_CPP -#define SOURCE_PUGIXML_CPP - -#include "pugixml.hpp" - -#include -#include -#include -#include - -#ifdef PUGIXML_WCHAR_MODE -# include -#endif - -#ifndef PUGIXML_NO_XPATH -# include -# include -# ifdef PUGIXML_NO_EXCEPTIONS -# include -# endif -#endif - -#ifndef PUGIXML_NO_STL -# include -# include -# include -#endif - -// For placement new -#include - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable: 4127) // conditional expression is constant -# pragma warning(disable: 4324) // structure was padded due to __declspec(align()) -# pragma warning(disable: 4611) // interaction between '_setjmp' and C++ object destruction is non-portable -# pragma warning(disable: 4702) // unreachable code -# pragma warning(disable: 4996) // this function or variable may be unsafe -# pragma warning(disable: 4793) // function compiled as native: presence of '_setjmp' makes a function unmanaged -#endif - -#ifdef __INTEL_COMPILER -# pragma warning(disable: 177) // function was declared but never referenced -# pragma warning(disable: 279) // controlling expression is constant -# pragma warning(disable: 1478 1786) // function was declared "deprecated" -# pragma warning(disable: 1684) // conversion from pointer to same-sized integral type -#endif - -#if defined(__BORLANDC__) && defined(PUGIXML_HEADER_ONLY) -# pragma warn -8080 // symbol is declared but never used; disabling this inside push/pop bracket does not make the warning go away -#endif - -#ifdef __BORLANDC__ -# pragma option push -# pragma warn -8008 // condition is always false -# pragma warn -8066 // unreachable code -#endif - -#ifdef __SNC__ -// Using diag_push/diag_pop does not disable the warnings inside templates due to a compiler bug -# pragma diag_suppress=178 // function was declared but never referenced -# pragma diag_suppress=237 // controlling expression is constant -#endif - -// Inlining controls -#if defined(_MSC_VER) && _MSC_VER >= 1300 -# define PUGI__NO_INLINE __declspec(noinline) -#elif defined(__GNUC__) -# define PUGI__NO_INLINE __attribute__((noinline)) -#else -# define PUGI__NO_INLINE -#endif - -// Branch weight controls -#if defined(__GNUC__) -# define PUGI__UNLIKELY(cond) __builtin_expect(cond, 0) -#else -# define PUGI__UNLIKELY(cond) (cond) -#endif - -// Simple static assertion -#define PUGI__STATIC_ASSERT(cond) { static const char condition_failed[(cond) ? 1 : -1] = {0}; (void)condition_failed[0]; } - -// Digital Mars C++ bug workaround for passing char loaded from memory via stack -#ifdef __DMC__ -# define PUGI__DMC_VOLATILE volatile -#else -# define PUGI__DMC_VOLATILE -#endif - -// Borland C++ bug workaround for not defining ::memcpy depending on header include order (can't always use std::memcpy because some compilers don't have it at all) -#if defined(__BORLANDC__) && !defined(__MEM_H_USING_LIST) -using std::memcpy; -using std::memmove; -#endif - -// In some environments MSVC is a compiler but the CRT lacks certain MSVC-specific features -#if defined(_MSC_VER) && !defined(__S3E__) -# define PUGI__MSVC_CRT_VERSION _MSC_VER -#endif - -#ifdef PUGIXML_HEADER_ONLY -# define PUGI__NS_BEGIN namespace pugi { namespace impl { -# define PUGI__NS_END } } -# define PUGI__FN inline -# define PUGI__FN_NO_INLINE inline -#else -# if defined(_MSC_VER) && _MSC_VER < 1300 // MSVC6 seems to have an amusing bug with anonymous namespaces inside namespaces -# define PUGI__NS_BEGIN namespace pugi { namespace impl { -# define PUGI__NS_END } } -# else -# define PUGI__NS_BEGIN namespace pugi { namespace impl { namespace { -# define PUGI__NS_END } } } -# endif -# define PUGI__FN -# define PUGI__FN_NO_INLINE PUGI__NO_INLINE -#endif - -// uintptr_t -#if !defined(_MSC_VER) || _MSC_VER >= 1600 -# include -#else -# ifndef _UINTPTR_T_DEFINED -// No native uintptr_t in MSVC6 and in some WinCE versions -typedef size_t uintptr_t; -#define _UINTPTR_T_DEFINED -# endif -PUGI__NS_BEGIN - typedef unsigned __int8 uint8_t; - typedef unsigned __int16 uint16_t; - typedef unsigned __int32 uint32_t; -PUGI__NS_END -#endif - -// Memory allocation -PUGI__NS_BEGIN - PUGI__FN void* default_allocate(size_t size) - { - return malloc(size); - } - - PUGI__FN void default_deallocate(void* ptr) - { - free(ptr); - } - - template - struct xml_memory_management_function_storage - { - static allocation_function allocate; - static deallocation_function deallocate; - }; - - // Global allocation functions are stored in class statics so that in header mode linker deduplicates them - // Without a template<> we'll get multiple definitions of the same static - template allocation_function xml_memory_management_function_storage::allocate = default_allocate; - template deallocation_function xml_memory_management_function_storage::deallocate = default_deallocate; - - typedef xml_memory_management_function_storage xml_memory; -PUGI__NS_END - -// String utilities -PUGI__NS_BEGIN - // Get string length - PUGI__FN size_t strlength(const char_t* s) - { - assert(s); - - #ifdef PUGIXML_WCHAR_MODE - return wcslen(s); - #else - return strlen(s); - #endif - } - - // Compare two strings - PUGI__FN bool strequal(const char_t* src, const char_t* dst) - { - assert(src && dst); - - #ifdef PUGIXML_WCHAR_MODE - return wcscmp(src, dst) == 0; - #else - return strcmp(src, dst) == 0; - #endif - } - - // Compare lhs with [rhs_begin, rhs_end) - PUGI__FN bool strequalrange(const char_t* lhs, const char_t* rhs, size_t count) - { - for (size_t i = 0; i < count; ++i) - if (lhs[i] != rhs[i]) - return false; - - return lhs[count] == 0; - } - - // Get length of wide string, even if CRT lacks wide character support - PUGI__FN size_t strlength_wide(const wchar_t* s) - { - assert(s); - - #ifdef PUGIXML_WCHAR_MODE - return wcslen(s); - #else - const wchar_t* end = s; - while (*end) end++; - return static_cast(end - s); - #endif - } - -#ifdef PUGIXML_WCHAR_MODE - // Convert string to wide string, assuming all symbols are ASCII - PUGI__FN void widen_ascii(wchar_t* dest, const char* source) - { - for (const char* i = source; *i; ++i) *dest++ = *i; - *dest = 0; - } -#endif -PUGI__NS_END - -#if !defined(PUGIXML_NO_STL) || !defined(PUGIXML_NO_XPATH) -// auto_ptr-like buffer holder for exception recovery -PUGI__NS_BEGIN - struct buffer_holder - { - void* data; - void (*deleter)(void*); - - buffer_holder(void* data_, void (*deleter_)(void*)): data(data_), deleter(deleter_) - { - } - - ~buffer_holder() - { - if (data) deleter(data); - } - - void* release() - { - void* result = data; - data = 0; - return result; - } - }; -PUGI__NS_END -#endif - -PUGI__NS_BEGIN - static const size_t xml_memory_page_size = - #ifdef PUGIXML_MEMORY_PAGE_SIZE - PUGIXML_MEMORY_PAGE_SIZE - #else - 32768 - #endif - ; - - static const uintptr_t xml_memory_page_alignment = 64; - static const uintptr_t xml_memory_page_pointer_mask = ~(xml_memory_page_alignment - 1); - static const uintptr_t xml_memory_page_contents_shared_mask = 32; - static const uintptr_t xml_memory_page_name_allocated_mask = 16; - static const uintptr_t xml_memory_page_value_allocated_mask = 8; - static const uintptr_t xml_memory_page_type_mask = 7; - static const uintptr_t xml_memory_page_name_allocated_or_shared_mask = xml_memory_page_name_allocated_mask | xml_memory_page_contents_shared_mask; - static const uintptr_t xml_memory_page_value_allocated_or_shared_mask = xml_memory_page_value_allocated_mask | xml_memory_page_contents_shared_mask; - - #define PUGI__NODETYPE(n) static_cast(((n)->header & impl::xml_memory_page_type_mask) + 1) - - struct xml_allocator; - - struct xml_memory_page - { - static xml_memory_page* construct(void* memory) - { - xml_memory_page* result = static_cast(memory); - - result->allocator = 0; - result->prev = 0; - result->next = 0; - result->busy_size = 0; - result->freed_size = 0; - - return result; - } - - xml_allocator* allocator; - - xml_memory_page* prev; - xml_memory_page* next; - - size_t busy_size; - size_t freed_size; - }; - - struct xml_memory_string_header - { - uint16_t page_offset; // offset from page->data - uint16_t full_size; // 0 if string occupies whole page - }; - - struct xml_allocator - { - xml_allocator(xml_memory_page* root): _root(root), _busy_size(root->busy_size) - { - } - - xml_memory_page* allocate_page(size_t data_size) - { - size_t size = sizeof(xml_memory_page) + data_size; - - // allocate block with some alignment, leaving memory for worst-case padding - void* memory = xml_memory::allocate(size + xml_memory_page_alignment); - if (!memory) return 0; - - // align to next page boundary (note: this guarantees at least 1 usable byte before the page) - char* page_memory = reinterpret_cast((reinterpret_cast(memory) + xml_memory_page_alignment) & ~(xml_memory_page_alignment - 1)); - - // prepare page structure - xml_memory_page* page = xml_memory_page::construct(page_memory); - assert(page); - - page->allocator = _root->allocator; - - // record the offset for freeing the memory block - assert(page_memory > memory && page_memory - static_cast(memory) <= 127); - page_memory[-1] = static_cast(page_memory - static_cast(memory)); - - return page; - } - - static void deallocate_page(xml_memory_page* page) - { - char* page_memory = reinterpret_cast(page); - - xml_memory::deallocate(page_memory - page_memory[-1]); - } - - void* allocate_memory_oob(size_t size, xml_memory_page*& out_page); - - void* allocate_memory(size_t size, xml_memory_page*& out_page) - { - if (_busy_size + size > xml_memory_page_size) return allocate_memory_oob(size, out_page); - - void* buf = reinterpret_cast(_root) + sizeof(xml_memory_page) + _busy_size; - - _busy_size += size; - - out_page = _root; - - return buf; - } - - void deallocate_memory(void* ptr, size_t size, xml_memory_page* page) - { - if (page == _root) page->busy_size = _busy_size; - - assert(ptr >= reinterpret_cast(page) + sizeof(xml_memory_page) && ptr < reinterpret_cast(page) + sizeof(xml_memory_page) + page->busy_size); - (void)!ptr; - - page->freed_size += size; - assert(page->freed_size <= page->busy_size); - - if (page->freed_size == page->busy_size) - { - if (page->next == 0) - { - assert(_root == page); - - // top page freed, just reset sizes - page->busy_size = page->freed_size = 0; - _busy_size = 0; - } - else - { - assert(_root != page); - assert(page->prev); - - // remove from the list - page->prev->next = page->next; - page->next->prev = page->prev; - - // deallocate - deallocate_page(page); - } - } - } - - char_t* allocate_string(size_t length) - { - PUGI__STATIC_ASSERT(xml_memory_page_size <= (1 << 16)); - - // allocate memory for string and header block - size_t size = sizeof(xml_memory_string_header) + length * sizeof(char_t); - - // round size up to pointer alignment boundary - size_t full_size = (size + (sizeof(void*) - 1)) & ~(sizeof(void*) - 1); - - xml_memory_page* page; - xml_memory_string_header* header = static_cast(allocate_memory(full_size, page)); - - if (!header) return 0; - - // setup header - ptrdiff_t page_offset = reinterpret_cast(header) - reinterpret_cast(page) - sizeof(xml_memory_page); - - assert(page_offset >= 0 && page_offset < (1 << 16)); - header->page_offset = static_cast(page_offset); - - // full_size == 0 for large strings that occupy the whole page - assert(full_size < (1 << 16) || (page->busy_size == full_size && page_offset == 0)); - header->full_size = static_cast(full_size < (1 << 16) ? full_size : 0); - - // round-trip through void* to avoid 'cast increases required alignment of target type' warning - // header is guaranteed a pointer-sized alignment, which should be enough for char_t - return static_cast(static_cast(header + 1)); - } - - void deallocate_string(char_t* string) - { - // this function casts pointers through void* to avoid 'cast increases required alignment of target type' warnings - // we're guaranteed the proper (pointer-sized) alignment on the input string if it was allocated via allocate_string - - // get header - xml_memory_string_header* header = static_cast(static_cast(string)) - 1; - assert(header); - - // deallocate - size_t page_offset = sizeof(xml_memory_page) + header->page_offset; - xml_memory_page* page = reinterpret_cast(static_cast(reinterpret_cast(header) - page_offset)); - - // if full_size == 0 then this string occupies the whole page - size_t full_size = header->full_size == 0 ? page->busy_size : header->full_size; - - deallocate_memory(header, full_size, page); - } - - xml_memory_page* _root; - size_t _busy_size; - }; - - PUGI__FN_NO_INLINE void* xml_allocator::allocate_memory_oob(size_t size, xml_memory_page*& out_page) - { - const size_t large_allocation_threshold = xml_memory_page_size / 4; - - xml_memory_page* page = allocate_page(size <= large_allocation_threshold ? xml_memory_page_size : size); - out_page = page; - - if (!page) return 0; - - if (size <= large_allocation_threshold) - { - _root->busy_size = _busy_size; - - // insert page at the end of linked list - page->prev = _root; - _root->next = page; - _root = page; - - _busy_size = size; - } - else - { - // insert page before the end of linked list, so that it is deleted as soon as possible - // the last page is not deleted even if it's empty (see deallocate_memory) - assert(_root->prev); - - page->prev = _root->prev; - page->next = _root; - - _root->prev->next = page; - _root->prev = page; - } - - // allocate inside page - page->busy_size = size; - - return reinterpret_cast(page) + sizeof(xml_memory_page); - } -PUGI__NS_END - -namespace pugi -{ - /// A 'name=value' XML attribute structure. - struct xml_attribute_struct - { - /// Default ctor - xml_attribute_struct(impl::xml_memory_page* page): header(reinterpret_cast(page)), name(0), value(0), prev_attribute_c(0), next_attribute(0) - { - } - - uintptr_t header; - - char_t* name; ///< Pointer to attribute name. - char_t* value; ///< Pointer to attribute value. - - xml_attribute_struct* prev_attribute_c; ///< Previous attribute (cyclic list) - xml_attribute_struct* next_attribute; ///< Next attribute - }; - - /// An XML document tree node. - struct xml_node_struct - { - /// Default ctor - /// \param type - node type - xml_node_struct(impl::xml_memory_page* page, xml_node_type type): header(reinterpret_cast(page) | (type - 1)), parent(0), name(0), value(0), first_child(0), prev_sibling_c(0), next_sibling(0), first_attribute(0) - { - } - - uintptr_t header; - - xml_node_struct* parent; ///< Pointer to parent - - char_t* name; ///< Pointer to element name. - char_t* value; ///< Pointer to any associated string data. - - xml_node_struct* first_child; ///< First child - - xml_node_struct* prev_sibling_c; ///< Left brother (cyclic list) - xml_node_struct* next_sibling; ///< Right brother - - xml_attribute_struct* first_attribute; ///< First attribute - }; -} - -PUGI__NS_BEGIN - struct xml_extra_buffer - { - char_t* buffer; - xml_extra_buffer* next; - }; - - struct xml_document_struct: public xml_node_struct, public xml_allocator - { - xml_document_struct(xml_memory_page* page): xml_node_struct(page, node_document), xml_allocator(page), buffer(0), extra_buffers(0) - { - } - - const char_t* buffer; - - xml_extra_buffer* extra_buffers; - }; - - inline xml_allocator& get_allocator(const xml_node_struct* node) - { - assert(node); - - return *reinterpret_cast(node->header & xml_memory_page_pointer_mask)->allocator; - } - - template inline xml_document_struct& get_document(const Object* object) - { - assert(object); - - return *static_cast(reinterpret_cast(object->header & xml_memory_page_pointer_mask)->allocator); - } -PUGI__NS_END - -// Low-level DOM operations -PUGI__NS_BEGIN - inline xml_attribute_struct* allocate_attribute(xml_allocator& alloc) - { - xml_memory_page* page; - void* memory = alloc.allocate_memory(sizeof(xml_attribute_struct), page); - - return new (memory) xml_attribute_struct(page); - } - - inline xml_node_struct* allocate_node(xml_allocator& alloc, xml_node_type type) - { - xml_memory_page* page; - void* memory = alloc.allocate_memory(sizeof(xml_node_struct), page); - - return new (memory) xml_node_struct(page, type); - } - - inline void destroy_attribute(xml_attribute_struct* a, xml_allocator& alloc) - { - uintptr_t header = a->header; - - if (header & impl::xml_memory_page_name_allocated_mask) alloc.deallocate_string(a->name); - if (header & impl::xml_memory_page_value_allocated_mask) alloc.deallocate_string(a->value); - - alloc.deallocate_memory(a, sizeof(xml_attribute_struct), reinterpret_cast(header & xml_memory_page_pointer_mask)); - } - - inline void destroy_node(xml_node_struct* n, xml_allocator& alloc) - { - uintptr_t header = n->header; - - if (header & impl::xml_memory_page_name_allocated_mask) alloc.deallocate_string(n->name); - if (header & impl::xml_memory_page_value_allocated_mask) alloc.deallocate_string(n->value); - - for (xml_attribute_struct* attr = n->first_attribute; attr; ) - { - xml_attribute_struct* next = attr->next_attribute; - - destroy_attribute(attr, alloc); - - attr = next; - } - - for (xml_node_struct* child = n->first_child; child; ) - { - xml_node_struct* next = child->next_sibling; - - destroy_node(child, alloc); - - child = next; - } - - alloc.deallocate_memory(n, sizeof(xml_node_struct), reinterpret_cast(header & xml_memory_page_pointer_mask)); - } - - inline void append_node(xml_node_struct* child, xml_node_struct* node) - { - child->parent = node; - - xml_node_struct* head = node->first_child; - - if (head) - { - xml_node_struct* tail = head->prev_sibling_c; - - tail->next_sibling = child; - child->prev_sibling_c = tail; - head->prev_sibling_c = child; - } - else - { - node->first_child = child; - child->prev_sibling_c = child; - } - } - - inline void prepend_node(xml_node_struct* child, xml_node_struct* node) - { - child->parent = node; - - xml_node_struct* head = node->first_child; - - if (head) - { - child->prev_sibling_c = head->prev_sibling_c; - head->prev_sibling_c = child; - } - else - child->prev_sibling_c = child; - - child->next_sibling = head; - node->first_child = child; - } - - inline void insert_node_after(xml_node_struct* child, xml_node_struct* node) - { - xml_node_struct* parent = node->parent; - - child->parent = parent; - - if (node->next_sibling) - node->next_sibling->prev_sibling_c = child; - else - parent->first_child->prev_sibling_c = child; - - child->next_sibling = node->next_sibling; - child->prev_sibling_c = node; - - node->next_sibling = child; - } - - inline void insert_node_before(xml_node_struct* child, xml_node_struct* node) - { - xml_node_struct* parent = node->parent; - - child->parent = parent; - - if (node->prev_sibling_c->next_sibling) - node->prev_sibling_c->next_sibling = child; - else - parent->first_child = child; - - child->prev_sibling_c = node->prev_sibling_c; - child->next_sibling = node; - - node->prev_sibling_c = child; - } - - inline void remove_node(xml_node_struct* node) - { - xml_node_struct* parent = node->parent; - - if (node->next_sibling) - node->next_sibling->prev_sibling_c = node->prev_sibling_c; - else - parent->first_child->prev_sibling_c = node->prev_sibling_c; - - if (node->prev_sibling_c->next_sibling) - node->prev_sibling_c->next_sibling = node->next_sibling; - else - parent->first_child = node->next_sibling; - - node->parent = 0; - node->prev_sibling_c = 0; - node->next_sibling = 0; - } - - inline void append_attribute(xml_attribute_struct* attr, xml_node_struct* node) - { - xml_attribute_struct* head = node->first_attribute; - - if (head) - { - xml_attribute_struct* tail = head->prev_attribute_c; - - tail->next_attribute = attr; - attr->prev_attribute_c = tail; - head->prev_attribute_c = attr; - } - else - { - node->first_attribute = attr; - attr->prev_attribute_c = attr; - } - } - - inline void prepend_attribute(xml_attribute_struct* attr, xml_node_struct* node) - { - xml_attribute_struct* head = node->first_attribute; - - if (head) - { - attr->prev_attribute_c = head->prev_attribute_c; - head->prev_attribute_c = attr; - } - else - attr->prev_attribute_c = attr; - - attr->next_attribute = head; - node->first_attribute = attr; - } - - inline void insert_attribute_after(xml_attribute_struct* attr, xml_attribute_struct* place, xml_node_struct* node) - { - if (place->next_attribute) - place->next_attribute->prev_attribute_c = attr; - else - node->first_attribute->prev_attribute_c = attr; - - attr->next_attribute = place->next_attribute; - attr->prev_attribute_c = place; - place->next_attribute = attr; - } - - inline void insert_attribute_before(xml_attribute_struct* attr, xml_attribute_struct* place, xml_node_struct* node) - { - if (place->prev_attribute_c->next_attribute) - place->prev_attribute_c->next_attribute = attr; - else - node->first_attribute = attr; - - attr->prev_attribute_c = place->prev_attribute_c; - attr->next_attribute = place; - place->prev_attribute_c = attr; - } - - inline void remove_attribute(xml_attribute_struct* attr, xml_node_struct* node) - { - if (attr->next_attribute) - attr->next_attribute->prev_attribute_c = attr->prev_attribute_c; - else - node->first_attribute->prev_attribute_c = attr->prev_attribute_c; - - if (attr->prev_attribute_c->next_attribute) - attr->prev_attribute_c->next_attribute = attr->next_attribute; - else - node->first_attribute = attr->next_attribute; - - attr->prev_attribute_c = 0; - attr->next_attribute = 0; - } - - PUGI__FN_NO_INLINE xml_node_struct* append_new_node(xml_node_struct* node, xml_allocator& alloc, xml_node_type type = node_element) - { - xml_node_struct* child = allocate_node(alloc, type); - if (!child) return 0; - - append_node(child, node); - - return child; - } - - PUGI__FN_NO_INLINE xml_attribute_struct* append_new_attribute(xml_node_struct* node, xml_allocator& alloc) - { - xml_attribute_struct* attr = allocate_attribute(alloc); - if (!attr) return 0; - - append_attribute(attr, node); - - return attr; - } -PUGI__NS_END - -// Helper classes for code generation -PUGI__NS_BEGIN - struct opt_false - { - enum { value = 0 }; - }; - - struct opt_true - { - enum { value = 1 }; - }; -PUGI__NS_END - -// Unicode utilities -PUGI__NS_BEGIN - inline uint16_t endian_swap(uint16_t value) - { - return static_cast(((value & 0xff) << 8) | (value >> 8)); - } - - inline uint32_t endian_swap(uint32_t value) - { - return ((value & 0xff) << 24) | ((value & 0xff00) << 8) | ((value & 0xff0000) >> 8) | (value >> 24); - } - - struct utf8_counter - { - typedef size_t value_type; - - static value_type low(value_type result, uint32_t ch) - { - // U+0000..U+007F - if (ch < 0x80) return result + 1; - // U+0080..U+07FF - else if (ch < 0x800) return result + 2; - // U+0800..U+FFFF - else return result + 3; - } - - static value_type high(value_type result, uint32_t) - { - // U+10000..U+10FFFF - return result + 4; - } - }; - - struct utf8_writer - { - typedef uint8_t* value_type; - - static value_type low(value_type result, uint32_t ch) - { - // U+0000..U+007F - if (ch < 0x80) - { - *result = static_cast(ch); - return result + 1; - } - // U+0080..U+07FF - else if (ch < 0x800) - { - result[0] = static_cast(0xC0 | (ch >> 6)); - result[1] = static_cast(0x80 | (ch & 0x3F)); - return result + 2; - } - // U+0800..U+FFFF - else - { - result[0] = static_cast(0xE0 | (ch >> 12)); - result[1] = static_cast(0x80 | ((ch >> 6) & 0x3F)); - result[2] = static_cast(0x80 | (ch & 0x3F)); - return result + 3; - } - } - - static value_type high(value_type result, uint32_t ch) - { - // U+10000..U+10FFFF - result[0] = static_cast(0xF0 | (ch >> 18)); - result[1] = static_cast(0x80 | ((ch >> 12) & 0x3F)); - result[2] = static_cast(0x80 | ((ch >> 6) & 0x3F)); - result[3] = static_cast(0x80 | (ch & 0x3F)); - return result + 4; - } - - static value_type any(value_type result, uint32_t ch) - { - return (ch < 0x10000) ? low(result, ch) : high(result, ch); - } - }; - - struct utf16_counter - { - typedef size_t value_type; - - static value_type low(value_type result, uint32_t) - { - return result + 1; - } - - static value_type high(value_type result, uint32_t) - { - return result + 2; - } - }; - - struct utf16_writer - { - typedef uint16_t* value_type; - - static value_type low(value_type result, uint32_t ch) - { - *result = static_cast(ch); - - return result + 1; - } - - static value_type high(value_type result, uint32_t ch) - { - uint32_t msh = static_cast(ch - 0x10000) >> 10; - uint32_t lsh = static_cast(ch - 0x10000) & 0x3ff; - - result[0] = static_cast(0xD800 + msh); - result[1] = static_cast(0xDC00 + lsh); - - return result + 2; - } - - static value_type any(value_type result, uint32_t ch) - { - return (ch < 0x10000) ? low(result, ch) : high(result, ch); - } - }; - - struct utf32_counter - { - typedef size_t value_type; - - static value_type low(value_type result, uint32_t) - { - return result + 1; - } - - static value_type high(value_type result, uint32_t) - { - return result + 1; - } - }; - - struct utf32_writer - { - typedef uint32_t* value_type; - - static value_type low(value_type result, uint32_t ch) - { - *result = ch; - - return result + 1; - } - - static value_type high(value_type result, uint32_t ch) - { - *result = ch; - - return result + 1; - } - - static value_type any(value_type result, uint32_t ch) - { - *result = ch; - - return result + 1; - } - }; - - struct latin1_writer - { - typedef uint8_t* value_type; - - static value_type low(value_type result, uint32_t ch) - { - *result = static_cast(ch > 255 ? '?' : ch); - - return result + 1; - } - - static value_type high(value_type result, uint32_t ch) - { - (void)ch; - - *result = '?'; - - return result + 1; - } - }; - - template struct wchar_selector; - - template <> struct wchar_selector<2> - { - typedef uint16_t type; - typedef utf16_counter counter; - typedef utf16_writer writer; - }; - - template <> struct wchar_selector<4> - { - typedef uint32_t type; - typedef utf32_counter counter; - typedef utf32_writer writer; - }; - - typedef wchar_selector::counter wchar_counter; - typedef wchar_selector::writer wchar_writer; - - template struct utf_decoder - { - static inline typename Traits::value_type decode_utf8_block(const uint8_t* data, size_t size, typename Traits::value_type result) - { - const uint8_t utf8_byte_mask = 0x3f; - - while (size) - { - uint8_t lead = *data; - - // 0xxxxxxx -> U+0000..U+007F - if (lead < 0x80) - { - result = Traits::low(result, lead); - data += 1; - size -= 1; - - // process aligned single-byte (ascii) blocks - if ((reinterpret_cast(data) & 3) == 0) - { - // round-trip through void* to silence 'cast increases required alignment of target type' warnings - while (size >= 4 && (*static_cast(static_cast(data)) & 0x80808080) == 0) - { - result = Traits::low(result, data[0]); - result = Traits::low(result, data[1]); - result = Traits::low(result, data[2]); - result = Traits::low(result, data[3]); - data += 4; - size -= 4; - } - } - } - // 110xxxxx -> U+0080..U+07FF - else if (static_cast(lead - 0xC0) < 0x20 && size >= 2 && (data[1] & 0xc0) == 0x80) - { - result = Traits::low(result, ((lead & ~0xC0) << 6) | (data[1] & utf8_byte_mask)); - data += 2; - size -= 2; - } - // 1110xxxx -> U+0800-U+FFFF - else if (static_cast(lead - 0xE0) < 0x10 && size >= 3 && (data[1] & 0xc0) == 0x80 && (data[2] & 0xc0) == 0x80) - { - result = Traits::low(result, ((lead & ~0xE0) << 12) | ((data[1] & utf8_byte_mask) << 6) | (data[2] & utf8_byte_mask)); - data += 3; - size -= 3; - } - // 11110xxx -> U+10000..U+10FFFF - else if (static_cast(lead - 0xF0) < 0x08 && size >= 4 && (data[1] & 0xc0) == 0x80 && (data[2] & 0xc0) == 0x80 && (data[3] & 0xc0) == 0x80) - { - result = Traits::high(result, ((lead & ~0xF0) << 18) | ((data[1] & utf8_byte_mask) << 12) | ((data[2] & utf8_byte_mask) << 6) | (data[3] & utf8_byte_mask)); - data += 4; - size -= 4; - } - // 10xxxxxx or 11111xxx -> invalid - else - { - data += 1; - size -= 1; - } - } - - return result; - } - - static inline typename Traits::value_type decode_utf16_block(const uint16_t* data, size_t size, typename Traits::value_type result) - { - const uint16_t* end = data + size; - - while (data < end) - { - unsigned int lead = opt_swap::value ? endian_swap(*data) : *data; - - // U+0000..U+D7FF - if (lead < 0xD800) - { - result = Traits::low(result, lead); - data += 1; - } - // U+E000..U+FFFF - else if (static_cast(lead - 0xE000) < 0x2000) - { - result = Traits::low(result, lead); - data += 1; - } - // surrogate pair lead - else if (static_cast(lead - 0xD800) < 0x400 && data + 1 < end) - { - uint16_t next = opt_swap::value ? endian_swap(data[1]) : data[1]; - - if (static_cast(next - 0xDC00) < 0x400) - { - result = Traits::high(result, 0x10000 + ((lead & 0x3ff) << 10) + (next & 0x3ff)); - data += 2; - } - else - { - data += 1; - } - } - else - { - data += 1; - } - } - - return result; - } - - static inline typename Traits::value_type decode_utf32_block(const uint32_t* data, size_t size, typename Traits::value_type result) - { - const uint32_t* end = data + size; - - while (data < end) - { - uint32_t lead = opt_swap::value ? endian_swap(*data) : *data; - - // U+0000..U+FFFF - if (lead < 0x10000) - { - result = Traits::low(result, lead); - data += 1; - } - // U+10000..U+10FFFF - else - { - result = Traits::high(result, lead); - data += 1; - } - } - - return result; - } - - static inline typename Traits::value_type decode_latin1_block(const uint8_t* data, size_t size, typename Traits::value_type result) - { - for (size_t i = 0; i < size; ++i) - { - result = Traits::low(result, data[i]); - } - - return result; - } - - static inline typename Traits::value_type decode_wchar_block_impl(const uint16_t* data, size_t size, typename Traits::value_type result) - { - return decode_utf16_block(data, size, result); - } - - static inline typename Traits::value_type decode_wchar_block_impl(const uint32_t* data, size_t size, typename Traits::value_type result) - { - return decode_utf32_block(data, size, result); - } - - static inline typename Traits::value_type decode_wchar_block(const wchar_t* data, size_t size, typename Traits::value_type result) - { - return decode_wchar_block_impl(reinterpret_cast::type*>(data), size, result); - } - }; - - template PUGI__FN void convert_utf_endian_swap(T* result, const T* data, size_t length) - { - for (size_t i = 0; i < length; ++i) result[i] = endian_swap(data[i]); - } - -#ifdef PUGIXML_WCHAR_MODE - PUGI__FN void convert_wchar_endian_swap(wchar_t* result, const wchar_t* data, size_t length) - { - for (size_t i = 0; i < length; ++i) result[i] = static_cast(endian_swap(static_cast::type>(data[i]))); - } -#endif -PUGI__NS_END - -PUGI__NS_BEGIN - enum chartype_t - { - ct_parse_pcdata = 1, // \0, &, \r, < - ct_parse_attr = 2, // \0, &, \r, ', " - ct_parse_attr_ws = 4, // \0, &, \r, ', ", \n, tab - ct_space = 8, // \r, \n, space, tab - ct_parse_cdata = 16, // \0, ], >, \r - ct_parse_comment = 32, // \0, -, >, \r - ct_symbol = 64, // Any symbol > 127, a-z, A-Z, 0-9, _, :, -, . - ct_start_symbol = 128 // Any symbol > 127, a-z, A-Z, _, : - }; - - static const unsigned char chartype_table[256] = - { - 55, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 0, 0, 63, 0, 0, // 0-15 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16-31 - 8, 0, 6, 0, 0, 0, 7, 6, 0, 0, 0, 0, 0, 96, 64, 0, // 32-47 - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 192, 0, 1, 0, 48, 0, // 48-63 - 0, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, // 64-79 - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 0, 0, 16, 0, 192, // 80-95 - 0, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, // 96-111 - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 0, 0, 0, 0, 0, // 112-127 - - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, // 128+ - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192 - }; - - enum chartypex_t - { - ctx_special_pcdata = 1, // Any symbol >= 0 and < 32 (except \t, \r, \n), &, <, > - ctx_special_attr = 2, // Any symbol >= 0 and < 32 (except \t), &, <, >, " - ctx_start_symbol = 4, // Any symbol > 127, a-z, A-Z, _ - ctx_digit = 8, // 0-9 - ctx_symbol = 16 // Any symbol > 127, a-z, A-Z, 0-9, _, -, . - }; - - static const unsigned char chartypex_table[256] = - { - 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 2, 3, 3, 2, 3, 3, // 0-15 - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 16-31 - 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 16, 16, 0, // 32-47 - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 3, 0, 3, 0, // 48-63 - - 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, // 64-79 - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 20, // 80-95 - 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, // 96-111 - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, // 112-127 - - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, // 128+ - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20 - }; - -#ifdef PUGIXML_WCHAR_MODE - #define PUGI__IS_CHARTYPE_IMPL(c, ct, table) ((static_cast(c) < 128 ? table[static_cast(c)] : table[128]) & (ct)) -#else - #define PUGI__IS_CHARTYPE_IMPL(c, ct, table) (table[static_cast(c)] & (ct)) -#endif - - #define PUGI__IS_CHARTYPE(c, ct) PUGI__IS_CHARTYPE_IMPL(c, ct, chartype_table) - #define PUGI__IS_CHARTYPEX(c, ct) PUGI__IS_CHARTYPE_IMPL(c, ct, chartypex_table) - - PUGI__FN bool is_little_endian() - { - unsigned int ui = 1; - - return *reinterpret_cast(&ui) == 1; - } - - PUGI__FN xml_encoding get_wchar_encoding() - { - PUGI__STATIC_ASSERT(sizeof(wchar_t) == 2 || sizeof(wchar_t) == 4); - - if (sizeof(wchar_t) == 2) - return is_little_endian() ? encoding_utf16_le : encoding_utf16_be; - else - return is_little_endian() ? encoding_utf32_le : encoding_utf32_be; - } - - PUGI__FN xml_encoding guess_buffer_encoding(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3) - { - // look for BOM in first few bytes - if (d0 == 0 && d1 == 0 && d2 == 0xfe && d3 == 0xff) return encoding_utf32_be; - if (d0 == 0xff && d1 == 0xfe && d2 == 0 && d3 == 0) return encoding_utf32_le; - if (d0 == 0xfe && d1 == 0xff) return encoding_utf16_be; - if (d0 == 0xff && d1 == 0xfe) return encoding_utf16_le; - if (d0 == 0xef && d1 == 0xbb && d2 == 0xbf) return encoding_utf8; - - // look for <, (contents); - - PUGI__DMC_VOLATILE uint8_t d0 = data[0], d1 = data[1], d2 = data[2], d3 = data[3]; - - return guess_buffer_encoding(d0, d1, d2, d3); - } - - PUGI__FN bool get_mutable_buffer(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, bool is_mutable) - { - size_t length = size / sizeof(char_t); - - if (is_mutable) - { - out_buffer = static_cast(const_cast(contents)); - out_length = length; - } - else - { - char_t* buffer = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); - if (!buffer) return false; - - if (contents) - memcpy(buffer, contents, length * sizeof(char_t)); - else - assert(length == 0); - - buffer[length] = 0; - - out_buffer = buffer; - out_length = length + 1; - } - - return true; - } - -#ifdef PUGIXML_WCHAR_MODE - PUGI__FN bool need_endian_swap_utf(xml_encoding le, xml_encoding re) - { - return (le == encoding_utf16_be && re == encoding_utf16_le) || (le == encoding_utf16_le && re == encoding_utf16_be) || - (le == encoding_utf32_be && re == encoding_utf32_le) || (le == encoding_utf32_le && re == encoding_utf32_be); - } - - PUGI__FN bool convert_buffer_endian_swap(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, bool is_mutable) - { - const char_t* data = static_cast(contents); - size_t length = size / sizeof(char_t); - - if (is_mutable) - { - char_t* buffer = const_cast(data); - - convert_wchar_endian_swap(buffer, data, length); - - out_buffer = buffer; - out_length = length; - } - else - { - char_t* buffer = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); - if (!buffer) return false; - - convert_wchar_endian_swap(buffer, data, length); - buffer[length] = 0; - - out_buffer = buffer; - out_length = length + 1; - } - - return true; - } - - PUGI__FN bool convert_buffer_utf8(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size) - { - const uint8_t* data = static_cast(contents); - size_t data_length = size; - - // first pass: get length in wchar_t units - size_t length = utf_decoder::decode_utf8_block(data, data_length, 0); - - // allocate buffer of suitable length - char_t* buffer = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); - if (!buffer) return false; - - // second pass: convert utf8 input to wchar_t - wchar_writer::value_type obegin = reinterpret_cast(buffer); - wchar_writer::value_type oend = utf_decoder::decode_utf8_block(data, data_length, obegin); - - assert(oend == obegin + length); - *oend = 0; - - out_buffer = buffer; - out_length = length + 1; - - return true; - } - - template PUGI__FN bool convert_buffer_utf16(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, opt_swap) - { - const uint16_t* data = static_cast(contents); - size_t data_length = size / sizeof(uint16_t); - - // first pass: get length in wchar_t units - size_t length = utf_decoder::decode_utf16_block(data, data_length, 0); - - // allocate buffer of suitable length - char_t* buffer = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); - if (!buffer) return false; - - // second pass: convert utf16 input to wchar_t - wchar_writer::value_type obegin = reinterpret_cast(buffer); - wchar_writer::value_type oend = utf_decoder::decode_utf16_block(data, data_length, obegin); - - assert(oend == obegin + length); - *oend = 0; - - out_buffer = buffer; - out_length = length + 1; - - return true; - } - - template PUGI__FN bool convert_buffer_utf32(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, opt_swap) - { - const uint32_t* data = static_cast(contents); - size_t data_length = size / sizeof(uint32_t); - - // first pass: get length in wchar_t units - size_t length = utf_decoder::decode_utf32_block(data, data_length, 0); - - // allocate buffer of suitable length - char_t* buffer = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); - if (!buffer) return false; - - // second pass: convert utf32 input to wchar_t - wchar_writer::value_type obegin = reinterpret_cast(buffer); - wchar_writer::value_type oend = utf_decoder::decode_utf32_block(data, data_length, obegin); - - assert(oend == obegin + length); - *oend = 0; - - out_buffer = buffer; - out_length = length + 1; - - return true; - } - - PUGI__FN bool convert_buffer_latin1(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size) - { - const uint8_t* data = static_cast(contents); - size_t data_length = size; - - // get length in wchar_t units - size_t length = data_length; - - // allocate buffer of suitable length - char_t* buffer = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); - if (!buffer) return false; - - // convert latin1 input to wchar_t - wchar_writer::value_type obegin = reinterpret_cast(buffer); - wchar_writer::value_type oend = utf_decoder::decode_latin1_block(data, data_length, obegin); - - assert(oend == obegin + length); - *oend = 0; - - out_buffer = buffer; - out_length = length + 1; - - return true; - } - - PUGI__FN bool convert_buffer(char_t*& out_buffer, size_t& out_length, xml_encoding encoding, const void* contents, size_t size, bool is_mutable) - { - // get native encoding - xml_encoding wchar_encoding = get_wchar_encoding(); - - // fast path: no conversion required - if (encoding == wchar_encoding) return get_mutable_buffer(out_buffer, out_length, contents, size, is_mutable); - - // only endian-swapping is required - if (need_endian_swap_utf(encoding, wchar_encoding)) return convert_buffer_endian_swap(out_buffer, out_length, contents, size, is_mutable); - - // source encoding is utf8 - if (encoding == encoding_utf8) return convert_buffer_utf8(out_buffer, out_length, contents, size); - - // source encoding is utf16 - if (encoding == encoding_utf16_be || encoding == encoding_utf16_le) - { - xml_encoding native_encoding = is_little_endian() ? encoding_utf16_le : encoding_utf16_be; - - return (native_encoding == encoding) ? - convert_buffer_utf16(out_buffer, out_length, contents, size, opt_false()) : - convert_buffer_utf16(out_buffer, out_length, contents, size, opt_true()); - } - - // source encoding is utf32 - if (encoding == encoding_utf32_be || encoding == encoding_utf32_le) - { - xml_encoding native_encoding = is_little_endian() ? encoding_utf32_le : encoding_utf32_be; - - return (native_encoding == encoding) ? - convert_buffer_utf32(out_buffer, out_length, contents, size, opt_false()) : - convert_buffer_utf32(out_buffer, out_length, contents, size, opt_true()); - } - - // source encoding is latin1 - if (encoding == encoding_latin1) return convert_buffer_latin1(out_buffer, out_length, contents, size); - - assert(!"Invalid encoding"); - return false; - } -#else - template PUGI__FN bool convert_buffer_utf16(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, opt_swap) - { - const uint16_t* data = static_cast(contents); - size_t data_length = size / sizeof(uint16_t); - - // first pass: get length in utf8 units - size_t length = utf_decoder::decode_utf16_block(data, data_length, 0); - - // allocate buffer of suitable length - char_t* buffer = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); - if (!buffer) return false; - - // second pass: convert utf16 input to utf8 - uint8_t* obegin = reinterpret_cast(buffer); - uint8_t* oend = utf_decoder::decode_utf16_block(data, data_length, obegin); - - assert(oend == obegin + length); - *oend = 0; - - out_buffer = buffer; - out_length = length + 1; - - return true; - } - - template PUGI__FN bool convert_buffer_utf32(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, opt_swap) - { - const uint32_t* data = static_cast(contents); - size_t data_length = size / sizeof(uint32_t); - - // first pass: get length in utf8 units - size_t length = utf_decoder::decode_utf32_block(data, data_length, 0); - - // allocate buffer of suitable length - char_t* buffer = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); - if (!buffer) return false; - - // second pass: convert utf32 input to utf8 - uint8_t* obegin = reinterpret_cast(buffer); - uint8_t* oend = utf_decoder::decode_utf32_block(data, data_length, obegin); - - assert(oend == obegin + length); - *oend = 0; - - out_buffer = buffer; - out_length = length + 1; - - return true; - } - - PUGI__FN size_t get_latin1_7bit_prefix_length(const uint8_t* data, size_t size) - { - for (size_t i = 0; i < size; ++i) - if (data[i] > 127) - return i; - - return size; - } - - PUGI__FN bool convert_buffer_latin1(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, bool is_mutable) - { - const uint8_t* data = static_cast(contents); - size_t data_length = size; - - // get size of prefix that does not need utf8 conversion - size_t prefix_length = get_latin1_7bit_prefix_length(data, data_length); - assert(prefix_length <= data_length); - - const uint8_t* postfix = data + prefix_length; - size_t postfix_length = data_length - prefix_length; - - // if no conversion is needed, just return the original buffer - if (postfix_length == 0) return get_mutable_buffer(out_buffer, out_length, contents, size, is_mutable); - - // first pass: get length in utf8 units - size_t length = prefix_length + utf_decoder::decode_latin1_block(postfix, postfix_length, 0); - - // allocate buffer of suitable length - char_t* buffer = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); - if (!buffer) return false; - - // second pass: convert latin1 input to utf8 - memcpy(buffer, data, prefix_length); - - uint8_t* obegin = reinterpret_cast(buffer); - uint8_t* oend = utf_decoder::decode_latin1_block(postfix, postfix_length, obegin + prefix_length); - - assert(oend == obegin + length); - *oend = 0; - - out_buffer = buffer; - out_length = length + 1; - - return true; - } - - PUGI__FN bool convert_buffer(char_t*& out_buffer, size_t& out_length, xml_encoding encoding, const void* contents, size_t size, bool is_mutable) - { - // fast path: no conversion required - if (encoding == encoding_utf8) return get_mutable_buffer(out_buffer, out_length, contents, size, is_mutable); - - // source encoding is utf16 - if (encoding == encoding_utf16_be || encoding == encoding_utf16_le) - { - xml_encoding native_encoding = is_little_endian() ? encoding_utf16_le : encoding_utf16_be; - - return (native_encoding == encoding) ? - convert_buffer_utf16(out_buffer, out_length, contents, size, opt_false()) : - convert_buffer_utf16(out_buffer, out_length, contents, size, opt_true()); - } - - // source encoding is utf32 - if (encoding == encoding_utf32_be || encoding == encoding_utf32_le) - { - xml_encoding native_encoding = is_little_endian() ? encoding_utf32_le : encoding_utf32_be; - - return (native_encoding == encoding) ? - convert_buffer_utf32(out_buffer, out_length, contents, size, opt_false()) : - convert_buffer_utf32(out_buffer, out_length, contents, size, opt_true()); - } - - // source encoding is latin1 - if (encoding == encoding_latin1) return convert_buffer_latin1(out_buffer, out_length, contents, size, is_mutable); - - assert(!"Invalid encoding"); - return false; - } -#endif - - PUGI__FN size_t as_utf8_begin(const wchar_t* str, size_t length) - { - // get length in utf8 characters - return utf_decoder::decode_wchar_block(str, length, 0); - } - - PUGI__FN void as_utf8_end(char* buffer, size_t size, const wchar_t* str, size_t length) - { - // convert to utf8 - uint8_t* begin = reinterpret_cast(buffer); - uint8_t* end = utf_decoder::decode_wchar_block(str, length, begin); - - assert(begin + size == end); - (void)!end; - - // zero-terminate - buffer[size] = 0; - } - -#ifndef PUGIXML_NO_STL - PUGI__FN std::string as_utf8_impl(const wchar_t* str, size_t length) - { - // first pass: get length in utf8 characters - size_t size = as_utf8_begin(str, length); - - // allocate resulting string - std::string result; - result.resize(size); - - // second pass: convert to utf8 - if (size > 0) as_utf8_end(&result[0], size, str, length); - - return result; - } - - PUGI__FN std::basic_string as_wide_impl(const char* str, size_t size) - { - const uint8_t* data = reinterpret_cast(str); - - // first pass: get length in wchar_t units - size_t length = utf_decoder::decode_utf8_block(data, size, 0); - - // allocate resulting string - std::basic_string result; - result.resize(length); - - // second pass: convert to wchar_t - if (length > 0) - { - wchar_writer::value_type begin = reinterpret_cast(&result[0]); - wchar_writer::value_type end = utf_decoder::decode_utf8_block(data, size, begin); - - assert(begin + length == end); - (void)!end; - } - - return result; - } -#endif - - inline bool strcpy_insitu_allow(size_t length, uintptr_t header, uintptr_t header_mask, char_t* target) - { - // never reuse shared memory - if (header & xml_memory_page_contents_shared_mask) return false; - - size_t target_length = strlength(target); - - // always reuse document buffer memory if possible - if ((header & header_mask) == 0) return target_length >= length; - - // reuse heap memory if waste is not too great - const size_t reuse_threshold = 32; - - return target_length >= length && (target_length < reuse_threshold || target_length - length < target_length / 2); - } - - PUGI__FN bool strcpy_insitu(char_t*& dest, uintptr_t& header, uintptr_t header_mask, const char_t* source) - { - assert(header); - - size_t source_length = strlength(source); - - if (source_length == 0) - { - // empty string and null pointer are equivalent, so just deallocate old memory - xml_allocator* alloc = reinterpret_cast(header & xml_memory_page_pointer_mask)->allocator; - - if (header & header_mask) alloc->deallocate_string(dest); - - // mark the string as not allocated - dest = 0; - header &= ~header_mask; - - return true; - } - else if (dest && strcpy_insitu_allow(source_length, header, header_mask, dest)) - { - // we can reuse old buffer, so just copy the new data (including zero terminator) - memcpy(dest, source, (source_length + 1) * sizeof(char_t)); - - return true; - } - else - { - xml_allocator* alloc = reinterpret_cast(header & xml_memory_page_pointer_mask)->allocator; - - // allocate new buffer - char_t* buf = alloc->allocate_string(source_length + 1); - if (!buf) return false; - - // copy the string (including zero terminator) - memcpy(buf, source, (source_length + 1) * sizeof(char_t)); - - // deallocate old buffer (*after* the above to protect against overlapping memory and/or allocation failures) - if (header & header_mask) alloc->deallocate_string(dest); - - // the string is now allocated, so set the flag - dest = buf; - header |= header_mask; - - return true; - } - } - - struct gap - { - char_t* end; - size_t size; - - gap(): end(0), size(0) - { - } - - // Push new gap, move s count bytes further (skipping the gap). - // Collapse previous gap. - void push(char_t*& s, size_t count) - { - if (end) // there was a gap already; collapse it - { - // Move [old_gap_end, new_gap_start) to [old_gap_start, ...) - assert(s >= end); - memmove(end - size, end, reinterpret_cast(s) - reinterpret_cast(end)); - } - - s += count; // end of current gap - - // "merge" two gaps - end = s; - size += count; - } - - // Collapse all gaps, return past-the-end pointer - char_t* flush(char_t* s) - { - if (end) - { - // Move [old_gap_end, current_pos) to [old_gap_start, ...) - assert(s >= end); - memmove(end - size, end, reinterpret_cast(s) - reinterpret_cast(end)); - - return s - size; - } - else return s; - } - }; - - PUGI__FN char_t* strconv_escape(char_t* s, gap& g) - { - char_t* stre = s + 1; - - switch (*stre) - { - case '#': // &#... - { - unsigned int ucsc = 0; - - if (stre[1] == 'x') // &#x... (hex code) - { - stre += 2; - - char_t ch = *stre; - - if (ch == ';') return stre; - - for (;;) - { - if (static_cast(ch - '0') <= 9) - ucsc = 16 * ucsc + (ch - '0'); - else if (static_cast((ch | ' ') - 'a') <= 5) - ucsc = 16 * ucsc + ((ch | ' ') - 'a' + 10); - else if (ch == ';') - break; - else // cancel - return stre; - - ch = *++stre; - } - - ++stre; - } - else // &#... (dec code) - { - char_t ch = *++stre; - - if (ch == ';') return stre; - - for (;;) - { - if (static_cast(static_cast(ch) - '0') <= 9) - ucsc = 10 * ucsc + (ch - '0'); - else if (ch == ';') - break; - else // cancel - return stre; - - ch = *++stre; - } - - ++stre; - } - - #ifdef PUGIXML_WCHAR_MODE - s = reinterpret_cast(wchar_writer::any(reinterpret_cast(s), ucsc)); - #else - s = reinterpret_cast(utf8_writer::any(reinterpret_cast(s), ucsc)); - #endif - - g.push(s, stre - s); - return stre; - } - - case 'a': // &a - { - ++stre; - - if (*stre == 'm') // &am - { - if (*++stre == 'p' && *++stre == ';') // & - { - *s++ = '&'; - ++stre; - - g.push(s, stre - s); - return stre; - } - } - else if (*stre == 'p') // &ap - { - if (*++stre == 'o' && *++stre == 's' && *++stre == ';') // ' - { - *s++ = '\''; - ++stre; - - g.push(s, stre - s); - return stre; - } - } - break; - } - - case 'g': // &g - { - if (*++stre == 't' && *++stre == ';') // > - { - *s++ = '>'; - ++stre; - - g.push(s, stre - s); - return stre; - } - break; - } - - case 'l': // &l - { - if (*++stre == 't' && *++stre == ';') // < - { - *s++ = '<'; - ++stre; - - g.push(s, stre - s); - return stre; - } - break; - } - - case 'q': // &q - { - if (*++stre == 'u' && *++stre == 'o' && *++stre == 't' && *++stre == ';') // " - { - *s++ = '"'; - ++stre; - - g.push(s, stre - s); - return stre; - } - break; - } - - default: - break; - } - - return stre; - } - - // Parser utilities - #define PUGI__ENDSWITH(c, e) ((c) == (e) || ((c) == 0 && endch == (e))) - #define PUGI__SKIPWS() { while (PUGI__IS_CHARTYPE(*s, ct_space)) ++s; } - #define PUGI__OPTSET(OPT) ( optmsk & (OPT) ) - #define PUGI__PUSHNODE(TYPE) { cursor = append_new_node(cursor, alloc, TYPE); if (!cursor) PUGI__THROW_ERROR(status_out_of_memory, s); } - #define PUGI__POPNODE() { cursor = cursor->parent; } - #define PUGI__SCANFOR(X) { while (*s != 0 && !(X)) ++s; } - #define PUGI__SCANWHILE(X) { while (X) ++s; } - #define PUGI__SCANWHILE_UNROLL(X) { for (;;) { char_t ss = s[0]; if (PUGI__UNLIKELY(!(X))) { break; } ss = s[1]; if (PUGI__UNLIKELY(!(X))) { s += 1; break; } ss = s[2]; if (PUGI__UNLIKELY(!(X))) { s += 2; break; } ss = s[3]; if (PUGI__UNLIKELY(!(X))) { s += 3; break; } s += 4; } } - #define PUGI__ENDSEG() { ch = *s; *s = 0; ++s; } - #define PUGI__THROW_ERROR(err, m) return error_offset = m, error_status = err, static_cast(0) - #define PUGI__CHECK_ERROR(err, m) { if (*s == 0) PUGI__THROW_ERROR(err, m); } - - PUGI__FN char_t* strconv_comment(char_t* s, char_t endch) - { - gap g; - - while (true) - { - PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(ss, ct_parse_comment)); - - if (*s == '\r') // Either a single 0x0d or 0x0d 0x0a pair - { - *s++ = '\n'; // replace first one with 0x0a - - if (*s == '\n') g.push(s, 1); - } - else if (s[0] == '-' && s[1] == '-' && PUGI__ENDSWITH(s[2], '>')) // comment ends here - { - *g.flush(s) = 0; - - return s + (s[2] == '>' ? 3 : 2); - } - else if (*s == 0) - { - return 0; - } - else ++s; - } - } - - PUGI__FN char_t* strconv_cdata(char_t* s, char_t endch) - { - gap g; - - while (true) - { - PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(ss, ct_parse_cdata)); - - if (*s == '\r') // Either a single 0x0d or 0x0d 0x0a pair - { - *s++ = '\n'; // replace first one with 0x0a - - if (*s == '\n') g.push(s, 1); - } - else if (s[0] == ']' && s[1] == ']' && PUGI__ENDSWITH(s[2], '>')) // CDATA ends here - { - *g.flush(s) = 0; - - return s + 1; - } - else if (*s == 0) - { - return 0; - } - else ++s; - } - } - - typedef char_t* (*strconv_pcdata_t)(char_t*); - - template struct strconv_pcdata_impl - { - static char_t* parse(char_t* s) - { - gap g; - - char_t* begin = s; - - while (true) - { - PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(ss, ct_parse_pcdata)); - - if (*s == '<') // PCDATA ends here - { - char_t* end = g.flush(s); - - if (opt_trim::value) - while (end > begin && PUGI__IS_CHARTYPE(end[-1], ct_space)) - --end; - - *end = 0; - - return s + 1; - } - else if (opt_eol::value && *s == '\r') // Either a single 0x0d or 0x0d 0x0a pair - { - *s++ = '\n'; // replace first one with 0x0a - - if (*s == '\n') g.push(s, 1); - } - else if (opt_escape::value && *s == '&') - { - s = strconv_escape(s, g); - } - else if (*s == 0) - { - char_t* end = g.flush(s); - - if (opt_trim::value) - while (end > begin && PUGI__IS_CHARTYPE(end[-1], ct_space)) - --end; - - *end = 0; - - return s; - } - else ++s; - } - } - }; - - PUGI__FN strconv_pcdata_t get_strconv_pcdata(unsigned int optmask) - { - PUGI__STATIC_ASSERT(parse_escapes == 0x10 && parse_eol == 0x20 && parse_trim_pcdata == 0x0800); - - switch (((optmask >> 4) & 3) | ((optmask >> 9) & 4)) // get bitmask for flags (eol escapes trim) - { - case 0: return strconv_pcdata_impl::parse; - case 1: return strconv_pcdata_impl::parse; - case 2: return strconv_pcdata_impl::parse; - case 3: return strconv_pcdata_impl::parse; - case 4: return strconv_pcdata_impl::parse; - case 5: return strconv_pcdata_impl::parse; - case 6: return strconv_pcdata_impl::parse; - case 7: return strconv_pcdata_impl::parse; - default: assert(false); return 0; // should not get here - } - } - - typedef char_t* (*strconv_attribute_t)(char_t*, char_t); - - template struct strconv_attribute_impl - { - static char_t* parse_wnorm(char_t* s, char_t end_quote) - { - gap g; - - // trim leading whitespaces - if (PUGI__IS_CHARTYPE(*s, ct_space)) - { - char_t* str = s; - - do ++str; - while (PUGI__IS_CHARTYPE(*str, ct_space)); - - g.push(s, str - s); - } - - while (true) - { - PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(ss, ct_parse_attr_ws | ct_space)); - - if (*s == end_quote) - { - char_t* str = g.flush(s); - - do *str-- = 0; - while (PUGI__IS_CHARTYPE(*str, ct_space)); - - return s + 1; - } - else if (PUGI__IS_CHARTYPE(*s, ct_space)) - { - *s++ = ' '; - - if (PUGI__IS_CHARTYPE(*s, ct_space)) - { - char_t* str = s + 1; - while (PUGI__IS_CHARTYPE(*str, ct_space)) ++str; - - g.push(s, str - s); - } - } - else if (opt_escape::value && *s == '&') - { - s = strconv_escape(s, g); - } - else if (!*s) - { - return 0; - } - else ++s; - } - } - - static char_t* parse_wconv(char_t* s, char_t end_quote) - { - gap g; - - while (true) - { - PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(ss, ct_parse_attr_ws)); - - if (*s == end_quote) - { - *g.flush(s) = 0; - - return s + 1; - } - else if (PUGI__IS_CHARTYPE(*s, ct_space)) - { - if (*s == '\r') - { - *s++ = ' '; - - if (*s == '\n') g.push(s, 1); - } - else *s++ = ' '; - } - else if (opt_escape::value && *s == '&') - { - s = strconv_escape(s, g); - } - else if (!*s) - { - return 0; - } - else ++s; - } - } - - static char_t* parse_eol(char_t* s, char_t end_quote) - { - gap g; - - while (true) - { - PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(ss, ct_parse_attr)); - - if (*s == end_quote) - { - *g.flush(s) = 0; - - return s + 1; - } - else if (*s == '\r') - { - *s++ = '\n'; - - if (*s == '\n') g.push(s, 1); - } - else if (opt_escape::value && *s == '&') - { - s = strconv_escape(s, g); - } - else if (!*s) - { - return 0; - } - else ++s; - } - } - - static char_t* parse_simple(char_t* s, char_t end_quote) - { - gap g; - - while (true) - { - PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(ss, ct_parse_attr)); - - if (*s == end_quote) - { - *g.flush(s) = 0; - - return s + 1; - } - else if (opt_escape::value && *s == '&') - { - s = strconv_escape(s, g); - } - else if (!*s) - { - return 0; - } - else ++s; - } - } - }; - - PUGI__FN strconv_attribute_t get_strconv_attribute(unsigned int optmask) - { - PUGI__STATIC_ASSERT(parse_escapes == 0x10 && parse_eol == 0x20 && parse_wconv_attribute == 0x40 && parse_wnorm_attribute == 0x80); - - switch ((optmask >> 4) & 15) // get bitmask for flags (wconv wnorm eol escapes) - { - case 0: return strconv_attribute_impl::parse_simple; - case 1: return strconv_attribute_impl::parse_simple; - case 2: return strconv_attribute_impl::parse_eol; - case 3: return strconv_attribute_impl::parse_eol; - case 4: return strconv_attribute_impl::parse_wconv; - case 5: return strconv_attribute_impl::parse_wconv; - case 6: return strconv_attribute_impl::parse_wconv; - case 7: return strconv_attribute_impl::parse_wconv; - case 8: return strconv_attribute_impl::parse_wnorm; - case 9: return strconv_attribute_impl::parse_wnorm; - case 10: return strconv_attribute_impl::parse_wnorm; - case 11: return strconv_attribute_impl::parse_wnorm; - case 12: return strconv_attribute_impl::parse_wnorm; - case 13: return strconv_attribute_impl::parse_wnorm; - case 14: return strconv_attribute_impl::parse_wnorm; - case 15: return strconv_attribute_impl::parse_wnorm; - default: assert(false); return 0; // should not get here - } - } - - inline xml_parse_result make_parse_result(xml_parse_status status, ptrdiff_t offset = 0) - { - xml_parse_result result; - result.status = status; - result.offset = offset; - - return result; - } - - struct xml_parser - { - xml_allocator alloc; - char_t* error_offset; - xml_parse_status error_status; - - xml_parser(const xml_allocator& alloc_): alloc(alloc_), error_offset(0), error_status(status_ok) - { - } - - // DOCTYPE consists of nested sections of the following possible types: - // , , "...", '...' - // - // - // First group can not contain nested groups - // Second group can contain nested groups of the same type - // Third group can contain all other groups - char_t* parse_doctype_primitive(char_t* s) - { - if (*s == '"' || *s == '\'') - { - // quoted string - char_t ch = *s++; - PUGI__SCANFOR(*s == ch); - if (!*s) PUGI__THROW_ERROR(status_bad_doctype, s); - - s++; - } - else if (s[0] == '<' && s[1] == '?') - { - // - s += 2; - PUGI__SCANFOR(s[0] == '?' && s[1] == '>'); // no need for ENDSWITH because ?> can't terminate proper doctype - if (!*s) PUGI__THROW_ERROR(status_bad_doctype, s); - - s += 2; - } - else if (s[0] == '<' && s[1] == '!' && s[2] == '-' && s[3] == '-') - { - s += 4; - PUGI__SCANFOR(s[0] == '-' && s[1] == '-' && s[2] == '>'); // no need for ENDSWITH because --> can't terminate proper doctype - if (!*s) PUGI__THROW_ERROR(status_bad_doctype, s); - - s += 4; - } - else PUGI__THROW_ERROR(status_bad_doctype, s); - - return s; - } - - char_t* parse_doctype_ignore(char_t* s) - { - assert(s[0] == '<' && s[1] == '!' && s[2] == '['); - s++; - - while (*s) - { - if (s[0] == '<' && s[1] == '!' && s[2] == '[') - { - // nested ignore section - s = parse_doctype_ignore(s); - if (!s) return s; - } - else if (s[0] == ']' && s[1] == ']' && s[2] == '>') - { - // ignore section end - s += 3; - - return s; - } - else s++; - } - - PUGI__THROW_ERROR(status_bad_doctype, s); - } - - char_t* parse_doctype_group(char_t* s, char_t endch, bool toplevel) - { - assert((s[0] == '<' || s[0] == 0) && s[1] == '!'); - s++; - - while (*s) - { - if (s[0] == '<' && s[1] == '!' && s[2] != '-') - { - if (s[2] == '[') - { - // ignore - s = parse_doctype_ignore(s); - if (!s) return s; - } - else - { - // some control group - s = parse_doctype_group(s, endch, false); - if (!s) return s; - - // skip > - assert(*s == '>'); - s++; - } - } - else if (s[0] == '<' || s[0] == '"' || s[0] == '\'') - { - // unknown tag (forbidden), or some primitive group - s = parse_doctype_primitive(s); - if (!s) return s; - } - else if (*s == '>') - { - return s; - } - else s++; - } - - if (!toplevel || endch != '>') PUGI__THROW_ERROR(status_bad_doctype, s); - - return s; - } - - char_t* parse_exclamation(char_t* s, xml_node_struct* cursor, unsigned int optmsk, char_t endch) - { - // parse node contents, starting with exclamation mark - ++s; - - if (*s == '-') // 'value = s; // Save the offset. - } - - if (PUGI__OPTSET(parse_eol) && PUGI__OPTSET(parse_comments)) - { - s = strconv_comment(s, endch); - - if (!s) PUGI__THROW_ERROR(status_bad_comment, cursor->value); - } - else - { - // Scan for terminating '-->'. - PUGI__SCANFOR(s[0] == '-' && s[1] == '-' && PUGI__ENDSWITH(s[2], '>')); - PUGI__CHECK_ERROR(status_bad_comment, s); - - if (PUGI__OPTSET(parse_comments)) - *s = 0; // Zero-terminate this segment at the first terminating '-'. - - s += (s[2] == '>' ? 3 : 2); // Step over the '\0->'. - } - } - else PUGI__THROW_ERROR(status_bad_comment, s); - } - else if (*s == '[') - { - // 'value = s; // Save the offset. - - if (PUGI__OPTSET(parse_eol)) - { - s = strconv_cdata(s, endch); - - if (!s) PUGI__THROW_ERROR(status_bad_cdata, cursor->value); - } - else - { - // Scan for terminating ']]>'. - PUGI__SCANFOR(s[0] == ']' && s[1] == ']' && PUGI__ENDSWITH(s[2], '>')); - PUGI__CHECK_ERROR(status_bad_cdata, s); - - *s++ = 0; // Zero-terminate this segment. - } - } - else // Flagged for discard, but we still have to scan for the terminator. - { - // Scan for terminating ']]>'. - PUGI__SCANFOR(s[0] == ']' && s[1] == ']' && PUGI__ENDSWITH(s[2], '>')); - PUGI__CHECK_ERROR(status_bad_cdata, s); - - ++s; - } - - s += (s[1] == '>' ? 2 : 1); // Step over the last ']>'. - } - else PUGI__THROW_ERROR(status_bad_cdata, s); - } - else if (s[0] == 'D' && s[1] == 'O' && s[2] == 'C' && s[3] == 'T' && s[4] == 'Y' && s[5] == 'P' && PUGI__ENDSWITH(s[6], 'E')) - { - s -= 2; - - if (cursor->parent) PUGI__THROW_ERROR(status_bad_doctype, s); - - char_t* mark = s + 9; - - s = parse_doctype_group(s, endch, true); - if (!s) return s; - - assert((*s == 0 && endch == '>') || *s == '>'); - if (*s) *s++ = 0; - - if (PUGI__OPTSET(parse_doctype)) - { - while (PUGI__IS_CHARTYPE(*mark, ct_space)) ++mark; - - PUGI__PUSHNODE(node_doctype); - - cursor->value = mark; - } - } - else if (*s == 0 && endch == '-') PUGI__THROW_ERROR(status_bad_comment, s); - else if (*s == 0 && endch == '[') PUGI__THROW_ERROR(status_bad_cdata, s); - else PUGI__THROW_ERROR(status_unrecognized_tag, s); - - return s; - } - - char_t* parse_question(char_t* s, xml_node_struct*& ref_cursor, unsigned int optmsk, char_t endch) - { - // load into registers - xml_node_struct* cursor = ref_cursor; - char_t ch = 0; - - // parse node contents, starting with question mark - ++s; - - // read PI target - char_t* target = s; - - if (!PUGI__IS_CHARTYPE(*s, ct_start_symbol)) PUGI__THROW_ERROR(status_bad_pi, s); - - PUGI__SCANWHILE(PUGI__IS_CHARTYPE(*s, ct_symbol)); - PUGI__CHECK_ERROR(status_bad_pi, s); - - // determine node type; stricmp / strcasecmp is not portable - bool declaration = (target[0] | ' ') == 'x' && (target[1] | ' ') == 'm' && (target[2] | ' ') == 'l' && target + 3 == s; - - if (declaration ? PUGI__OPTSET(parse_declaration) : PUGI__OPTSET(parse_pi)) - { - if (declaration) - { - // disallow non top-level declarations - if (cursor->parent) PUGI__THROW_ERROR(status_bad_pi, s); - - PUGI__PUSHNODE(node_declaration); - } - else - { - PUGI__PUSHNODE(node_pi); - } - - cursor->name = target; - - PUGI__ENDSEG(); - - // parse value/attributes - if (ch == '?') - { - // empty node - if (!PUGI__ENDSWITH(*s, '>')) PUGI__THROW_ERROR(status_bad_pi, s); - s += (*s == '>'); - - PUGI__POPNODE(); - } - else if (PUGI__IS_CHARTYPE(ch, ct_space)) - { - PUGI__SKIPWS(); - - // scan for tag end - char_t* value = s; - - PUGI__SCANFOR(s[0] == '?' && PUGI__ENDSWITH(s[1], '>')); - PUGI__CHECK_ERROR(status_bad_pi, s); - - if (declaration) - { - // replace ending ? with / so that 'element' terminates properly - *s = '/'; - - // we exit from this function with cursor at node_declaration, which is a signal to parse() to go to LOC_ATTRIBUTES - s = value; - } - else - { - // store value and step over > - cursor->value = value; - PUGI__POPNODE(); - - PUGI__ENDSEG(); - - s += (*s == '>'); - } - } - else PUGI__THROW_ERROR(status_bad_pi, s); - } - else - { - // scan for tag end - PUGI__SCANFOR(s[0] == '?' && PUGI__ENDSWITH(s[1], '>')); - PUGI__CHECK_ERROR(status_bad_pi, s); - - s += (s[1] == '>' ? 2 : 1); - } - - // store from registers - ref_cursor = cursor; - - return s; - } - - char_t* parse_tree(char_t* s, xml_node_struct* root, unsigned int optmsk, char_t endch) - { - strconv_attribute_t strconv_attribute = get_strconv_attribute(optmsk); - strconv_pcdata_t strconv_pcdata = get_strconv_pcdata(optmsk); - - char_t ch = 0; - xml_node_struct* cursor = root; - char_t* mark = s; - - while (*s != 0) - { - if (*s == '<') - { - ++s; - - LOC_TAG: - if (PUGI__IS_CHARTYPE(*s, ct_start_symbol)) // '<#...' - { - PUGI__PUSHNODE(node_element); // Append a new node to the tree. - - cursor->name = s; - - PUGI__SCANWHILE_UNROLL(PUGI__IS_CHARTYPE(ss, ct_symbol)); // Scan for a terminator. - PUGI__ENDSEG(); // Save char in 'ch', terminate & step over. - - if (ch == '>') - { - // end of tag - } - else if (PUGI__IS_CHARTYPE(ch, ct_space)) - { - LOC_ATTRIBUTES: - while (true) - { - PUGI__SKIPWS(); // Eat any whitespace. - - if (PUGI__IS_CHARTYPE(*s, ct_start_symbol)) // <... #... - { - xml_attribute_struct* a = append_new_attribute(cursor, alloc); // Make space for this attribute. - if (!a) PUGI__THROW_ERROR(status_out_of_memory, s); - - a->name = s; // Save the offset. - - PUGI__SCANWHILE_UNROLL(PUGI__IS_CHARTYPE(ss, ct_symbol)); // Scan for a terminator. - PUGI__ENDSEG(); // Save char in 'ch', terminate & step over. - - if (PUGI__IS_CHARTYPE(ch, ct_space)) - { - PUGI__SKIPWS(); // Eat any whitespace. - - ch = *s; - ++s; - } - - if (ch == '=') // '<... #=...' - { - PUGI__SKIPWS(); // Eat any whitespace. - - if (*s == '"' || *s == '\'') // '<... #="...' - { - ch = *s; // Save quote char to avoid breaking on "''" -or- '""'. - ++s; // Step over the quote. - a->value = s; // Save the offset. - - s = strconv_attribute(s, ch); - - if (!s) PUGI__THROW_ERROR(status_bad_attribute, a->value); - - // After this line the loop continues from the start; - // Whitespaces, / and > are ok, symbols and EOF are wrong, - // everything else will be detected - if (PUGI__IS_CHARTYPE(*s, ct_start_symbol)) PUGI__THROW_ERROR(status_bad_attribute, s); - } - else PUGI__THROW_ERROR(status_bad_attribute, s); - } - else PUGI__THROW_ERROR(status_bad_attribute, s); - } - else if (*s == '/') - { - ++s; - - if (*s == '>') - { - PUGI__POPNODE(); - s++; - break; - } - else if (*s == 0 && endch == '>') - { - PUGI__POPNODE(); - break; - } - else PUGI__THROW_ERROR(status_bad_start_element, s); - } - else if (*s == '>') - { - ++s; - - break; - } - else if (*s == 0 && endch == '>') - { - break; - } - else PUGI__THROW_ERROR(status_bad_start_element, s); - } - - // !!! - } - else if (ch == '/') // '<#.../' - { - if (!PUGI__ENDSWITH(*s, '>')) PUGI__THROW_ERROR(status_bad_start_element, s); - - PUGI__POPNODE(); // Pop. - - s += (*s == '>'); - } - else if (ch == 0) - { - // we stepped over null terminator, backtrack & handle closing tag - --s; - - if (endch != '>') PUGI__THROW_ERROR(status_bad_start_element, s); - } - else PUGI__THROW_ERROR(status_bad_start_element, s); - } - else if (*s == '/') - { - ++s; - - char_t* name = cursor->name; - if (!name) PUGI__THROW_ERROR(status_end_element_mismatch, s); - - while (PUGI__IS_CHARTYPE(*s, ct_symbol)) - { - if (*s++ != *name++) PUGI__THROW_ERROR(status_end_element_mismatch, s); - } - - if (*name) - { - if (*s == 0 && name[0] == endch && name[1] == 0) PUGI__THROW_ERROR(status_bad_end_element, s); - else PUGI__THROW_ERROR(status_end_element_mismatch, s); - } - - PUGI__POPNODE(); // Pop. - - PUGI__SKIPWS(); - - if (*s == 0) - { - if (endch != '>') PUGI__THROW_ERROR(status_bad_end_element, s); - } - else - { - if (*s != '>') PUGI__THROW_ERROR(status_bad_end_element, s); - ++s; - } - } - else if (*s == '?') // 'first_child) continue; - } - } - - if (!PUGI__OPTSET(parse_trim_pcdata)) - s = mark; - - if (cursor->parent || PUGI__OPTSET(parse_fragment)) - { - PUGI__PUSHNODE(node_pcdata); // Append a new node on the tree. - cursor->value = s; // Save the offset. - - s = strconv_pcdata(s); - - PUGI__POPNODE(); // Pop since this is a standalone. - - if (!*s) break; - } - else - { - PUGI__SCANFOR(*s == '<'); // '...<' - if (!*s) break; - - ++s; - } - - // We're after '<' - goto LOC_TAG; - } - } - - // check that last tag is closed - if (cursor != root) PUGI__THROW_ERROR(status_end_element_mismatch, s); - - return s; - } - - #ifdef PUGIXML_WCHAR_MODE - static char_t* parse_skip_bom(char_t* s) - { - unsigned int bom = 0xfeff; - return (s[0] == static_cast(bom)) ? s + 1 : s; - } - #else - static char_t* parse_skip_bom(char_t* s) - { - return (s[0] == '\xef' && s[1] == '\xbb' && s[2] == '\xbf') ? s + 3 : s; - } - #endif - - static bool has_element_node_siblings(xml_node_struct* node) - { - while (node) - { - if (PUGI__NODETYPE(node) == node_element) return true; - - node = node->next_sibling; - } - - return false; - } - - static xml_parse_result parse(char_t* buffer, size_t length, xml_document_struct* xmldoc, xml_node_struct* root, unsigned int optmsk) - { - // allocator object is a part of document object - xml_allocator& alloc_ = *static_cast(xmldoc); - - // early-out for empty documents - if (length == 0) - return make_parse_result(PUGI__OPTSET(parse_fragment) ? status_ok : status_no_document_element); - - // get last child of the root before parsing - xml_node_struct* last_root_child = root->first_child ? root->first_child->prev_sibling_c : 0; - - // create parser on stack - xml_parser parser(alloc_); - - // save last character and make buffer zero-terminated (speeds up parsing) - char_t endch = buffer[length - 1]; - buffer[length - 1] = 0; - - // skip BOM to make sure it does not end up as part of parse output - char_t* buffer_data = parse_skip_bom(buffer); - - // perform actual parsing - parser.parse_tree(buffer_data, root, optmsk, endch); - - // update allocator state - alloc_ = parser.alloc; - - xml_parse_result result = make_parse_result(parser.error_status, parser.error_offset ? parser.error_offset - buffer : 0); - assert(result.offset >= 0 && static_cast(result.offset) <= length); - - if (result) - { - // since we removed last character, we have to handle the only possible false positive (stray <) - if (endch == '<') - return make_parse_result(status_unrecognized_tag, length - 1); - - // check if there are any element nodes parsed - xml_node_struct* first_root_child_parsed = last_root_child ? last_root_child->next_sibling : root->first_child; - - if (!PUGI__OPTSET(parse_fragment) && !has_element_node_siblings(first_root_child_parsed)) - return make_parse_result(status_no_document_element, length - 1); - } - else - { - // roll back offset if it occurs on a null terminator in the source buffer - if (result.offset > 0 && static_cast(result.offset) == length - 1 && endch == 0) - result.offset--; - } - - return result; - } - }; - - // Output facilities - PUGI__FN xml_encoding get_write_native_encoding() - { - #ifdef PUGIXML_WCHAR_MODE - return get_wchar_encoding(); - #else - return encoding_utf8; - #endif - } - - PUGI__FN xml_encoding get_write_encoding(xml_encoding encoding) - { - // replace wchar encoding with utf implementation - if (encoding == encoding_wchar) return get_wchar_encoding(); - - // replace utf16 encoding with utf16 with specific endianness - if (encoding == encoding_utf16) return is_little_endian() ? encoding_utf16_le : encoding_utf16_be; - - // replace utf32 encoding with utf32 with specific endianness - if (encoding == encoding_utf32) return is_little_endian() ? encoding_utf32_le : encoding_utf32_be; - - // only do autodetection if no explicit encoding is requested - if (encoding != encoding_auto) return encoding; - - // assume utf8 encoding - return encoding_utf8; - } - -#ifdef PUGIXML_WCHAR_MODE - PUGI__FN size_t get_valid_length(const char_t* data, size_t length) - { - if (length < 1) return 0; - - // discard last character if it's the lead of a surrogate pair - return (sizeof(wchar_t) == 2 && static_cast(static_cast(data[length - 1]) - 0xD800) < 0x400) ? length - 1 : length; - } - - PUGI__FN size_t convert_buffer_output(char_t* r_char, uint8_t* r_u8, uint16_t* r_u16, uint32_t* r_u32, const char_t* data, size_t length, xml_encoding encoding) - { - // only endian-swapping is required - if (need_endian_swap_utf(encoding, get_wchar_encoding())) - { - convert_wchar_endian_swap(r_char, data, length); - - return length * sizeof(char_t); - } - - // convert to utf8 - if (encoding == encoding_utf8) - { - uint8_t* dest = r_u8; - uint8_t* end = utf_decoder::decode_wchar_block(data, length, dest); - - return static_cast(end - dest); - } - - // convert to utf16 - if (encoding == encoding_utf16_be || encoding == encoding_utf16_le) - { - uint16_t* dest = r_u16; - - // convert to native utf16 - uint16_t* end = utf_decoder::decode_wchar_block(data, length, dest); - - // swap if necessary - xml_encoding native_encoding = is_little_endian() ? encoding_utf16_le : encoding_utf16_be; - - if (native_encoding != encoding) convert_utf_endian_swap(dest, dest, static_cast(end - dest)); - - return static_cast(end - dest) * sizeof(uint16_t); - } - - // convert to utf32 - if (encoding == encoding_utf32_be || encoding == encoding_utf32_le) - { - uint32_t* dest = r_u32; - - // convert to native utf32 - uint32_t* end = utf_decoder::decode_wchar_block(data, length, dest); - - // swap if necessary - xml_encoding native_encoding = is_little_endian() ? encoding_utf32_le : encoding_utf32_be; - - if (native_encoding != encoding) convert_utf_endian_swap(dest, dest, static_cast(end - dest)); - - return static_cast(end - dest) * sizeof(uint32_t); - } - - // convert to latin1 - if (encoding == encoding_latin1) - { - uint8_t* dest = r_u8; - uint8_t* end = utf_decoder::decode_wchar_block(data, length, dest); - - return static_cast(end - dest); - } - - assert(!"Invalid encoding"); - return 0; - } -#else - PUGI__FN size_t get_valid_length(const char_t* data, size_t length) - { - if (length < 5) return 0; - - for (size_t i = 1; i <= 4; ++i) - { - uint8_t ch = static_cast(data[length - i]); - - // either a standalone character or a leading one - if ((ch & 0xc0) != 0x80) return length - i; - } - - // there are four non-leading characters at the end, sequence tail is broken so might as well process the whole chunk - return length; - } - - PUGI__FN size_t convert_buffer_output(char_t* /* r_char */, uint8_t* r_u8, uint16_t* r_u16, uint32_t* r_u32, const char_t* data, size_t length, xml_encoding encoding) - { - if (encoding == encoding_utf16_be || encoding == encoding_utf16_le) - { - uint16_t* dest = r_u16; - - // convert to native utf16 - uint16_t* end = utf_decoder::decode_utf8_block(reinterpret_cast(data), length, dest); - - // swap if necessary - xml_encoding native_encoding = is_little_endian() ? encoding_utf16_le : encoding_utf16_be; - - if (native_encoding != encoding) convert_utf_endian_swap(dest, dest, static_cast(end - dest)); - - return static_cast(end - dest) * sizeof(uint16_t); - } - - if (encoding == encoding_utf32_be || encoding == encoding_utf32_le) - { - uint32_t* dest = r_u32; - - // convert to native utf32 - uint32_t* end = utf_decoder::decode_utf8_block(reinterpret_cast(data), length, dest); - - // swap if necessary - xml_encoding native_encoding = is_little_endian() ? encoding_utf32_le : encoding_utf32_be; - - if (native_encoding != encoding) convert_utf_endian_swap(dest, dest, static_cast(end - dest)); - - return static_cast(end - dest) * sizeof(uint32_t); - } - - if (encoding == encoding_latin1) - { - uint8_t* dest = r_u8; - uint8_t* end = utf_decoder::decode_utf8_block(reinterpret_cast(data), length, dest); - - return static_cast(end - dest); - } - - assert(!"Invalid encoding"); - return 0; - } -#endif - - class xml_buffered_writer - { - xml_buffered_writer(const xml_buffered_writer&); - xml_buffered_writer& operator=(const xml_buffered_writer&); - - public: - xml_buffered_writer(xml_writer& writer_, xml_encoding user_encoding): writer(writer_), bufsize(0), encoding(get_write_encoding(user_encoding)) - { - PUGI__STATIC_ASSERT(bufcapacity >= 8); - } - - ~xml_buffered_writer() - { - flush(); - } - - size_t flush() - { - flush(buffer, bufsize); - bufsize = 0; - return 0; - } - - void flush(const char_t* data, size_t size) - { - if (size == 0) return; - - // fast path, just write data - if (encoding == get_write_native_encoding()) - writer.write(data, size * sizeof(char_t)); - else - { - // convert chunk - size_t result = convert_buffer_output(scratch.data_char, scratch.data_u8, scratch.data_u16, scratch.data_u32, data, size, encoding); - assert(result <= sizeof(scratch)); - - // write data - writer.write(scratch.data_u8, result); - } - } - - void write_direct(const char_t* data, size_t length) - { - // flush the remaining buffer contents - flush(); - - // handle large chunks - if (length > bufcapacity) - { - if (encoding == get_write_native_encoding()) - { - // fast path, can just write data chunk - writer.write(data, length * sizeof(char_t)); - return; - } - - // need to convert in suitable chunks - while (length > bufcapacity) - { - // get chunk size by selecting such number of characters that are guaranteed to fit into scratch buffer - // and form a complete codepoint sequence (i.e. discard start of last codepoint if necessary) - size_t chunk_size = get_valid_length(data, bufcapacity); - assert(chunk_size); - - // convert chunk and write - flush(data, chunk_size); - - // iterate - data += chunk_size; - length -= chunk_size; - } - - // small tail is copied below - bufsize = 0; - } - - memcpy(buffer + bufsize, data, length * sizeof(char_t)); - bufsize += length; - } - - void write_buffer(const char_t* data, size_t length) - { - size_t offset = bufsize; - - if (offset + length <= bufcapacity) - { - memcpy(buffer + offset, data, length * sizeof(char_t)); - bufsize = offset + length; - } - else - { - write_direct(data, length); - } - } - - void write_string(const char_t* data) - { - // write the part of the string that fits in the buffer - size_t offset = bufsize; - - while (*data && offset < bufcapacity) - buffer[offset++] = *data++; - - // write the rest - if (offset < bufcapacity) - { - bufsize = offset; - } - else - { - // backtrack a bit if we have split the codepoint - size_t length = offset - bufsize; - size_t extra = length - get_valid_length(data - length, length); - - bufsize = offset - extra; - - write_direct(data - extra, strlength(data) + extra); - } - } - - void write(char_t d0) - { - size_t offset = bufsize; - if (offset > bufcapacity - 1) offset = flush(); - - buffer[offset + 0] = d0; - bufsize = offset + 1; - } - - void write(char_t d0, char_t d1) - { - size_t offset = bufsize; - if (offset > bufcapacity - 2) offset = flush(); - - buffer[offset + 0] = d0; - buffer[offset + 1] = d1; - bufsize = offset + 2; - } - - void write(char_t d0, char_t d1, char_t d2) - { - size_t offset = bufsize; - if (offset > bufcapacity - 3) offset = flush(); - - buffer[offset + 0] = d0; - buffer[offset + 1] = d1; - buffer[offset + 2] = d2; - bufsize = offset + 3; - } - - void write(char_t d0, char_t d1, char_t d2, char_t d3) - { - size_t offset = bufsize; - if (offset > bufcapacity - 4) offset = flush(); - - buffer[offset + 0] = d0; - buffer[offset + 1] = d1; - buffer[offset + 2] = d2; - buffer[offset + 3] = d3; - bufsize = offset + 4; - } - - void write(char_t d0, char_t d1, char_t d2, char_t d3, char_t d4) - { - size_t offset = bufsize; - if (offset > bufcapacity - 5) offset = flush(); - - buffer[offset + 0] = d0; - buffer[offset + 1] = d1; - buffer[offset + 2] = d2; - buffer[offset + 3] = d3; - buffer[offset + 4] = d4; - bufsize = offset + 5; - } - - void write(char_t d0, char_t d1, char_t d2, char_t d3, char_t d4, char_t d5) - { - size_t offset = bufsize; - if (offset > bufcapacity - 6) offset = flush(); - - buffer[offset + 0] = d0; - buffer[offset + 1] = d1; - buffer[offset + 2] = d2; - buffer[offset + 3] = d3; - buffer[offset + 4] = d4; - buffer[offset + 5] = d5; - bufsize = offset + 6; - } - - // utf8 maximum expansion: x4 (-> utf32) - // utf16 maximum expansion: x2 (-> utf32) - // utf32 maximum expansion: x1 - enum - { - bufcapacitybytes = - #ifdef PUGIXML_MEMORY_OUTPUT_STACK - PUGIXML_MEMORY_OUTPUT_STACK - #else - 10240 - #endif - , - bufcapacity = bufcapacitybytes / (sizeof(char_t) + 4) - }; - - char_t buffer[bufcapacity]; - - union - { - uint8_t data_u8[4 * bufcapacity]; - uint16_t data_u16[2 * bufcapacity]; - uint32_t data_u32[bufcapacity]; - char_t data_char[bufcapacity]; - } scratch; - - xml_writer& writer; - size_t bufsize; - xml_encoding encoding; - }; - - PUGI__FN void text_output_escaped(xml_buffered_writer& writer, const char_t* s, chartypex_t type) - { - while (*s) - { - const char_t* prev = s; - - // While *s is a usual symbol - PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPEX(ss, type)); - - writer.write_buffer(prev, static_cast(s - prev)); - - switch (*s) - { - case 0: break; - case '&': - writer.write('&', 'a', 'm', 'p', ';'); - ++s; - break; - case '<': - writer.write('&', 'l', 't', ';'); - ++s; - break; - case '>': - writer.write('&', 'g', 't', ';'); - ++s; - break; - case '"': - writer.write('&', 'q', 'u', 'o', 't', ';'); - ++s; - break; - default: // s is not a usual symbol - { - unsigned int ch = static_cast(*s++); - assert(ch < 32); - - writer.write('&', '#', static_cast((ch / 10) + '0'), static_cast((ch % 10) + '0'), ';'); - } - } - } - } - - PUGI__FN void text_output(xml_buffered_writer& writer, const char_t* s, chartypex_t type, unsigned int flags) - { - if (flags & format_no_escapes) - writer.write_string(s); - else - text_output_escaped(writer, s, type); - } - - PUGI__FN void text_output_cdata(xml_buffered_writer& writer, const char_t* s) - { - do - { - writer.write('<', '!', '[', 'C', 'D'); - writer.write('A', 'T', 'A', '['); - - const char_t* prev = s; - - // look for ]]> sequence - we can't output it as is since it terminates CDATA - while (*s && !(s[0] == ']' && s[1] == ']' && s[2] == '>')) ++s; - - // skip ]] if we stopped at ]]>, > will go to the next CDATA section - if (*s) s += 2; - - writer.write_buffer(prev, static_cast(s - prev)); - - writer.write(']', ']', '>'); - } - while (*s); - } - - PUGI__FN void text_output_indent(xml_buffered_writer& writer, const char_t* indent, size_t indent_length, unsigned int depth) - { - switch (indent_length) - { - case 1: - { - for (unsigned int i = 0; i < depth; ++i) - writer.write(indent[0]); - break; - } - - case 2: - { - for (unsigned int i = 0; i < depth; ++i) - writer.write(indent[0], indent[1]); - break; - } - - case 3: - { - for (unsigned int i = 0; i < depth; ++i) - writer.write(indent[0], indent[1], indent[2]); - break; - } - - case 4: - { - for (unsigned int i = 0; i < depth; ++i) - writer.write(indent[0], indent[1], indent[2], indent[3]); - break; - } - - default: - { - for (unsigned int i = 0; i < depth; ++i) - writer.write_buffer(indent, indent_length); - } - } - } - - PUGI__FN void node_output_comment(xml_buffered_writer& writer, const char_t* s) - { - writer.write('<', '!', '-', '-'); - - while (*s) - { - const char_t* prev = s; - - // look for -\0 or -- sequence - we can't output it since -- is illegal in comment body - while (*s && !(s[0] == '-' && (s[1] == '-' || s[1] == 0))) ++s; - - writer.write_buffer(prev, static_cast(s - prev)); - - if (*s) - { - assert(*s == '-'); - - writer.write('-', ' '); - ++s; - } - } - - writer.write('-', '-', '>'); - } - - PUGI__FN void node_output_attributes(xml_buffered_writer& writer, xml_node_struct* node, unsigned int flags) - { - const char_t* default_name = PUGIXML_TEXT(":anonymous"); - - for (xml_attribute_struct* a = node->first_attribute; a; a = a->next_attribute) - { - writer.write(' '); - writer.write_string(a->name ? a->name : default_name); - writer.write('=', '"'); - - if (a->value) - text_output(writer, a->value, ctx_special_attr, flags); - - writer.write('"'); - } - } - - PUGI__FN bool node_output_start(xml_buffered_writer& writer, xml_node_struct* node, unsigned int flags) - { - const char_t* default_name = PUGIXML_TEXT(":anonymous"); - const char_t* name = node->name ? node->name : default_name; - - writer.write('<'); - writer.write_string(name); - - if (node->first_attribute) - node_output_attributes(writer, node, flags); - - if (flags & format_raw) - { - if (!node->first_child) - writer.write(' ', '/', '>'); - else - { - writer.write('>'); - - return true; - } - } - else - { - xml_node_struct* first = node->first_child; - - if (!first) - writer.write(' ', '/', '>', '\n'); - else if (!first->next_sibling && (PUGI__NODETYPE(first) == node_pcdata || PUGI__NODETYPE(first) == node_cdata)) - { - writer.write('>'); - - const char_t* value = first->value ? first->value : PUGIXML_TEXT(""); - - if (PUGI__NODETYPE(first) == node_pcdata) - text_output(writer, value, ctx_special_pcdata, flags); - else - text_output_cdata(writer, value); - - writer.write('<', '/'); - writer.write_string(name); - writer.write('>', '\n'); - } - else - { - writer.write('>', '\n'); - - return true; - } - } - - return false; - } - - PUGI__FN void node_output_end(xml_buffered_writer& writer, xml_node_struct* node, unsigned int flags) - { - const char_t* default_name = PUGIXML_TEXT(":anonymous"); - const char_t* name = node->name ? node->name : default_name; - - writer.write('<', '/'); - writer.write_string(name); - - if (flags & format_raw) - writer.write('>'); - else - writer.write('>', '\n'); - } - - PUGI__FN void node_output_simple(xml_buffered_writer& writer, xml_node_struct* node, unsigned int flags) - { - const char_t* default_name = PUGIXML_TEXT(":anonymous"); - - switch (PUGI__NODETYPE(node)) - { - case node_pcdata: - text_output(writer, node->value ? node->value : PUGIXML_TEXT(""), ctx_special_pcdata, flags); - if ((flags & format_raw) == 0) writer.write('\n'); - break; - - case node_cdata: - text_output_cdata(writer, node->value ? node->value : PUGIXML_TEXT("")); - if ((flags & format_raw) == 0) writer.write('\n'); - break; - - case node_comment: - node_output_comment(writer, node->value ? node->value : PUGIXML_TEXT("")); - if ((flags & format_raw) == 0) writer.write('\n'); - break; - - case node_pi: - writer.write('<', '?'); - writer.write_string(node->name ? node->name : default_name); - - if (node->value) - { - writer.write(' '); - writer.write_string(node->value); - } - - writer.write('?', '>'); - if ((flags & format_raw) == 0) writer.write('\n'); - break; - - case node_declaration: - writer.write('<', '?'); - writer.write_string(node->name ? node->name : default_name); - node_output_attributes(writer, node, flags); - writer.write('?', '>'); - if ((flags & format_raw) == 0) writer.write('\n'); - break; - - case node_doctype: - writer.write('<', '!', 'D', 'O', 'C'); - writer.write('T', 'Y', 'P', 'E'); - - if (node->value) - { - writer.write(' '); - writer.write_string(node->value); - } - - writer.write('>'); - if ((flags & format_raw) == 0) writer.write('\n'); - break; - - default: - assert(!"Invalid node type"); - } - } - - PUGI__FN void node_output(xml_buffered_writer& writer, xml_node_struct* root, const char_t* indent, unsigned int flags, unsigned int depth) - { - size_t indent_length = ((flags & (format_indent | format_raw)) == format_indent) ? strlength(indent) : 0; - - xml_node_struct* node = root; - - do - { - assert(node); - - // begin writing current node - if (indent_length) - text_output_indent(writer, indent, indent_length, depth); - - if (PUGI__NODETYPE(node) == node_element) - { - if (node_output_start(writer, node, flags)) - { - node = node->first_child; - depth++; - continue; - } - } - else if (PUGI__NODETYPE(node) == node_document) - { - if (node->first_child) - { - node = node->first_child; - continue; - } - } - else - { - node_output_simple(writer, node, flags); - } - - // continue to the next node - while (node != root) - { - if (node->next_sibling) - { - node = node->next_sibling; - break; - } - - node = node->parent; - - // write closing node - if (PUGI__NODETYPE(node) == node_element) - { - depth--; - - if (indent_length) - text_output_indent(writer, indent, indent_length, depth); - - node_output_end(writer, node, flags); - } - } - } - while (node != root); - } - - PUGI__FN bool has_declaration(xml_node_struct* node) - { - for (xml_node_struct* child = node->first_child; child; child = child->next_sibling) - { - xml_node_type type = PUGI__NODETYPE(child); - - if (type == node_declaration) return true; - if (type == node_element) return false; - } - - return false; - } - - PUGI__FN bool is_attribute_of(xml_attribute_struct* attr, xml_node_struct* node) - { - for (xml_attribute_struct* a = node->first_attribute; a; a = a->next_attribute) - if (a == attr) - return true; - - return false; - } - - PUGI__FN bool allow_insert_attribute(xml_node_type parent) - { - return parent == node_element || parent == node_declaration; - } - - PUGI__FN bool allow_insert_child(xml_node_type parent, xml_node_type child) - { - if (parent != node_document && parent != node_element) return false; - if (child == node_document || child == node_null) return false; - if (parent != node_document && (child == node_declaration || child == node_doctype)) return false; - - return true; - } - - PUGI__FN bool allow_move(xml_node parent, xml_node child) - { - // check that child can be a child of parent - if (!allow_insert_child(parent.type(), child.type())) - return false; - - // check that node is not moved between documents - if (parent.root() != child.root()) - return false; - - // check that new parent is not in the child subtree - xml_node cur = parent; - - while (cur) - { - if (cur == child) - return false; - - cur = cur.parent(); - } - - return true; - } - - PUGI__FN void node_copy_string(char_t*& dest, uintptr_t& header, uintptr_t header_mask, char_t* source, uintptr_t& source_header, xml_allocator* alloc) - { - assert(!dest && (header & header_mask) == 0); - - if (source) - { - if (alloc && (source_header & header_mask) == 0) - { - dest = source; - - // since strcpy_insitu can reuse document buffer memory we need to mark both source and dest as shared - header |= xml_memory_page_contents_shared_mask; - source_header |= xml_memory_page_contents_shared_mask; - } - else - strcpy_insitu(dest, header, header_mask, source); - } - } - - PUGI__FN void node_copy_contents(xml_node_struct* dn, xml_node_struct* sn, xml_allocator* shared_alloc) - { - node_copy_string(dn->name, dn->header, xml_memory_page_name_allocated_mask, sn->name, sn->header, shared_alloc); - node_copy_string(dn->value, dn->header, xml_memory_page_value_allocated_mask, sn->value, sn->header, shared_alloc); - - for (xml_attribute_struct* sa = sn->first_attribute; sa; sa = sa->next_attribute) - { - xml_attribute_struct* da = append_new_attribute(dn, get_allocator(dn)); - - if (da) - { - node_copy_string(da->name, da->header, xml_memory_page_name_allocated_mask, sa->name, sa->header, shared_alloc); - node_copy_string(da->value, da->header, xml_memory_page_value_allocated_mask, sa->value, sa->header, shared_alloc); - } - } - } - - PUGI__FN void node_copy_tree(xml_node_struct* dn, xml_node_struct* sn) - { - xml_allocator& alloc = get_allocator(dn); - xml_allocator* shared_alloc = (&alloc == &get_allocator(sn)) ? &alloc : 0; - - node_copy_contents(dn, sn, shared_alloc); - - xml_node_struct* dit = dn; - xml_node_struct* sit = sn->first_child; - - while (sit && sit != sn) - { - if (sit != dn) - { - xml_node_struct* copy = append_new_node(dit, alloc, PUGI__NODETYPE(sit)); - - if (copy) - { - node_copy_contents(copy, sit, shared_alloc); - - if (sit->first_child) - { - dit = copy; - sit = sit->first_child; - continue; - } - } - } - - // continue to the next node - do - { - if (sit->next_sibling) - { - sit = sit->next_sibling; - break; - } - - sit = sit->parent; - dit = dit->parent; - } - while (sit != sn); - } - } - - inline bool is_text_node(xml_node_struct* node) - { - xml_node_type type = PUGI__NODETYPE(node); - - return type == node_pcdata || type == node_cdata; - } - - // get value with conversion functions - PUGI__FN int get_integer_base(const char_t* value) - { - const char_t* s = value; - - while (PUGI__IS_CHARTYPE(*s, ct_space)) - s++; - - if (*s == '-') - s++; - - return (s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) ? 16 : 10; - } - - PUGI__FN int get_value_int(const char_t* value, int def) - { - if (!value) return def; - - int base = get_integer_base(value); - - #ifdef PUGIXML_WCHAR_MODE - return static_cast(wcstol(value, 0, base)); - #else - return static_cast(strtol(value, 0, base)); - #endif - } - - PUGI__FN unsigned int get_value_uint(const char_t* value, unsigned int def) - { - if (!value) return def; - - int base = get_integer_base(value); - - #ifdef PUGIXML_WCHAR_MODE - return static_cast(wcstoul(value, 0, base)); - #else - return static_cast(strtoul(value, 0, base)); - #endif - } - - PUGI__FN double get_value_double(const char_t* value, double def) - { - if (!value) return def; - - #ifdef PUGIXML_WCHAR_MODE - return wcstod(value, 0); - #else - return strtod(value, 0); - #endif - } - - PUGI__FN float get_value_float(const char_t* value, float def) - { - if (!value) return def; - - #ifdef PUGIXML_WCHAR_MODE - return static_cast(wcstod(value, 0)); - #else - return static_cast(strtod(value, 0)); - #endif - } - - PUGI__FN bool get_value_bool(const char_t* value, bool def) - { - if (!value) return def; - - // only look at first char - char_t first = *value; - - // 1*, t* (true), T* (True), y* (yes), Y* (YES) - return (first == '1' || first == 't' || first == 'T' || first == 'y' || first == 'Y'); - } - -#ifdef PUGIXML_HAS_LONG_LONG - PUGI__FN long long get_value_llong(const char_t* value, long long def) - { - if (!value) return def; - - int base = get_integer_base(value); - - #ifdef PUGIXML_WCHAR_MODE - #ifdef PUGI__MSVC_CRT_VERSION - return _wcstoi64(value, 0, base); - #else - return wcstoll(value, 0, base); - #endif - #else - #ifdef PUGI__MSVC_CRT_VERSION - return _strtoi64(value, 0, base); - #else - return strtoll(value, 0, base); - #endif - #endif - } - - PUGI__FN unsigned long long get_value_ullong(const char_t* value, unsigned long long def) - { - if (!value) return def; - - int base = get_integer_base(value); - - #ifdef PUGIXML_WCHAR_MODE - #ifdef PUGI__MSVC_CRT_VERSION - return _wcstoui64(value, 0, base); - #else - return wcstoull(value, 0, base); - #endif - #else - #ifdef PUGI__MSVC_CRT_VERSION - return _strtoui64(value, 0, base); - #else - return strtoull(value, 0, base); - #endif - #endif - } -#endif - - // set value with conversion functions - PUGI__FN bool set_value_buffer(char_t*& dest, uintptr_t& header, uintptr_t header_mask, char (&buf)[128]) - { - #ifdef PUGIXML_WCHAR_MODE - char_t wbuf[128]; - impl::widen_ascii(wbuf, buf); - - return strcpy_insitu(dest, header, header_mask, wbuf); - #else - return strcpy_insitu(dest, header, header_mask, buf); - #endif - } - - PUGI__FN bool set_value_convert(char_t*& dest, uintptr_t& header, uintptr_t header_mask, int value) - { - char buf[128]; - sprintf(buf, "%d", value); - - return set_value_buffer(dest, header, header_mask, buf); - } - - PUGI__FN bool set_value_convert(char_t*& dest, uintptr_t& header, uintptr_t header_mask, unsigned int value) - { - char buf[128]; - sprintf(buf, "%u", value); - - return set_value_buffer(dest, header, header_mask, buf); - } - - PUGI__FN bool set_value_convert(char_t*& dest, uintptr_t& header, uintptr_t header_mask, double value) - { - char buf[128]; - sprintf(buf, "%g", value); - - return set_value_buffer(dest, header, header_mask, buf); - } - - PUGI__FN bool set_value_convert(char_t*& dest, uintptr_t& header, uintptr_t header_mask, bool value) - { - return strcpy_insitu(dest, header, header_mask, value ? PUGIXML_TEXT("true") : PUGIXML_TEXT("false")); - } - -#ifdef PUGIXML_HAS_LONG_LONG - PUGI__FN bool set_value_convert(char_t*& dest, uintptr_t& header, uintptr_t header_mask, long long value) - { - char buf[128]; - sprintf(buf, "%lld", value); - - return set_value_buffer(dest, header, header_mask, buf); - } - - PUGI__FN bool set_value_convert(char_t*& dest, uintptr_t& header, uintptr_t header_mask, unsigned long long value) - { - char buf[128]; - sprintf(buf, "%llu", value); - - return set_value_buffer(dest, header, header_mask, buf); - } -#endif - - // we need to get length of entire file to load it in memory; the only (relatively) sane way to do it is via seek/tell trick - PUGI__FN xml_parse_status get_file_size(FILE* file, size_t& out_result) - { - #if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400 && !defined(_WIN32_WCE) - // there are 64-bit versions of fseek/ftell, let's use them - typedef __int64 length_type; - - _fseeki64(file, 0, SEEK_END); - length_type length = _ftelli64(file); - _fseeki64(file, 0, SEEK_SET); - #elif defined(__MINGW32__) && !defined(__NO_MINGW_LFS) && (!defined(__STRICT_ANSI__) || defined(__MINGW64_VERSION_MAJOR)) - // there are 64-bit versions of fseek/ftell, let's use them - typedef off64_t length_type; - - fseeko64(file, 0, SEEK_END); - length_type length = ftello64(file); - fseeko64(file, 0, SEEK_SET); - #else - // if this is a 32-bit OS, long is enough; if this is a unix system, long is 64-bit, which is enough; otherwise we can't do anything anyway. - typedef long length_type; - - fseek(file, 0, SEEK_END); - length_type length = ftell(file); - fseek(file, 0, SEEK_SET); - #endif - - // check for I/O errors - if (length < 0) return status_io_error; - - // check for overflow - size_t result = static_cast(length); - - if (static_cast(result) != length) return status_out_of_memory; - - // finalize - out_result = result; - - return status_ok; - } - - PUGI__FN size_t zero_terminate_buffer(void* buffer, size_t size, xml_encoding encoding) - { - // We only need to zero-terminate if encoding conversion does not do it for us - #ifdef PUGIXML_WCHAR_MODE - xml_encoding wchar_encoding = get_wchar_encoding(); - - if (encoding == wchar_encoding || need_endian_swap_utf(encoding, wchar_encoding)) - { - size_t length = size / sizeof(char_t); - - static_cast(buffer)[length] = 0; - return (length + 1) * sizeof(char_t); - } - #else - if (encoding == encoding_utf8) - { - static_cast(buffer)[size] = 0; - return size + 1; - } - #endif - - return size; - } - - PUGI__FN xml_parse_result load_file_impl(xml_document& doc, FILE* file, unsigned int options, xml_encoding encoding) - { - if (!file) return make_parse_result(status_file_not_found); - - // get file size (can result in I/O errors) - size_t size = 0; - xml_parse_status size_status = get_file_size(file, size); - - if (size_status != status_ok) - { - fclose(file); - return make_parse_result(size_status); - } - - size_t max_suffix_size = sizeof(char_t); - - // allocate buffer for the whole file - char* contents = static_cast(xml_memory::allocate(size + max_suffix_size)); - - if (!contents) - { - fclose(file); - return make_parse_result(status_out_of_memory); - } - - // read file in memory - size_t read_size = fread(contents, 1, size, file); - fclose(file); - - if (read_size != size) - { - xml_memory::deallocate(contents); - return make_parse_result(status_io_error); - } - - xml_encoding real_encoding = get_buffer_encoding(encoding, contents, size); - - return doc.load_buffer_inplace_own(contents, zero_terminate_buffer(contents, size, real_encoding), options, real_encoding); - } - -#ifndef PUGIXML_NO_STL - template struct xml_stream_chunk - { - static xml_stream_chunk* create() - { - void* memory = xml_memory::allocate(sizeof(xml_stream_chunk)); - - return new (memory) xml_stream_chunk(); - } - - static void destroy(void* ptr) - { - xml_stream_chunk* chunk = static_cast(ptr); - - // free chunk chain - while (chunk) - { - xml_stream_chunk* next_ = chunk->next; - - xml_memory::deallocate(chunk); - - chunk = next_; - } - } - - xml_stream_chunk(): next(0), size(0) - { - } - - xml_stream_chunk* next; - size_t size; - - T data[xml_memory_page_size / sizeof(T)]; - }; - - template PUGI__FN xml_parse_status load_stream_data_noseek(std::basic_istream& stream, void** out_buffer, size_t* out_size) - { - buffer_holder chunks(0, xml_stream_chunk::destroy); - - // read file to a chunk list - size_t total = 0; - xml_stream_chunk* last = 0; - - while (!stream.eof()) - { - // allocate new chunk - xml_stream_chunk* chunk = xml_stream_chunk::create(); - if (!chunk) return status_out_of_memory; - - // append chunk to list - if (last) last = last->next = chunk; - else chunks.data = last = chunk; - - // read data to chunk - stream.read(chunk->data, static_cast(sizeof(chunk->data) / sizeof(T))); - chunk->size = static_cast(stream.gcount()) * sizeof(T); - - // read may set failbit | eofbit in case gcount() is less than read length, so check for other I/O errors - if (stream.bad() || (!stream.eof() && stream.fail())) return status_io_error; - - // guard against huge files (chunk size is small enough to make this overflow check work) - if (total + chunk->size < total) return status_out_of_memory; - total += chunk->size; - } - - size_t max_suffix_size = sizeof(char_t); - - // copy chunk list to a contiguous buffer - char* buffer = static_cast(xml_memory::allocate(total + max_suffix_size)); - if (!buffer) return status_out_of_memory; - - char* write = buffer; - - for (xml_stream_chunk* chunk = static_cast*>(chunks.data); chunk; chunk = chunk->next) - { - assert(write + chunk->size <= buffer + total); - memcpy(write, chunk->data, chunk->size); - write += chunk->size; - } - - assert(write == buffer + total); - - // return buffer - *out_buffer = buffer; - *out_size = total; - - return status_ok; - } - - template PUGI__FN xml_parse_status load_stream_data_seek(std::basic_istream& stream, void** out_buffer, size_t* out_size) - { - // get length of remaining data in stream - typename std::basic_istream::pos_type pos = stream.tellg(); - stream.seekg(0, std::ios::end); - std::streamoff length = stream.tellg() - pos; - stream.seekg(pos); - - if (stream.fail() || pos < 0) return status_io_error; - - // guard against huge files - size_t read_length = static_cast(length); - - if (static_cast(read_length) != length || length < 0) return status_out_of_memory; - - size_t max_suffix_size = sizeof(char_t); - - // read stream data into memory (guard against stream exceptions with buffer holder) - buffer_holder buffer(xml_memory::allocate(read_length * sizeof(T) + max_suffix_size), xml_memory::deallocate); - if (!buffer.data) return status_out_of_memory; - - stream.read(static_cast(buffer.data), static_cast(read_length)); - - // read may set failbit | eofbit in case gcount() is less than read_length (i.e. line ending conversion), so check for other I/O errors - if (stream.bad() || (!stream.eof() && stream.fail())) return status_io_error; - - // return buffer - size_t actual_length = static_cast(stream.gcount()); - assert(actual_length <= read_length); - - *out_buffer = buffer.release(); - *out_size = actual_length * sizeof(T); - - return status_ok; - } - - template PUGI__FN xml_parse_result load_stream_impl(xml_document& doc, std::basic_istream& stream, unsigned int options, xml_encoding encoding) - { - void* buffer = 0; - size_t size = 0; - xml_parse_status status = status_ok; - - // if stream has an error bit set, bail out (otherwise tellg() can fail and we'll clear error bits) - if (stream.fail()) return make_parse_result(status_io_error); - - // load stream to memory (using seek-based implementation if possible, since it's faster and takes less memory) - if (stream.tellg() < 0) - { - stream.clear(); // clear error flags that could be set by a failing tellg - status = load_stream_data_noseek(stream, &buffer, &size); - } - else - status = load_stream_data_seek(stream, &buffer, &size); - - if (status != status_ok) return make_parse_result(status); - - xml_encoding real_encoding = get_buffer_encoding(encoding, buffer, size); - - return doc.load_buffer_inplace_own(buffer, zero_terminate_buffer(buffer, size, real_encoding), options, real_encoding); - } -#endif - -#if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__) || (defined(__MINGW32__) && (!defined(__STRICT_ANSI__) || defined(__MINGW64_VERSION_MAJOR))) - PUGI__FN FILE* open_file_wide(const wchar_t* path, const wchar_t* mode) - { - return _wfopen(path, mode); - } -#else - PUGI__FN char* convert_path_heap(const wchar_t* str) - { - assert(str); - - // first pass: get length in utf8 characters - size_t length = strlength_wide(str); - size_t size = as_utf8_begin(str, length); - - // allocate resulting string - char* result = static_cast(xml_memory::allocate(size + 1)); - if (!result) return 0; - - // second pass: convert to utf8 - as_utf8_end(result, size, str, length); - - return result; - } - - PUGI__FN FILE* open_file_wide(const wchar_t* path, const wchar_t* mode) - { - // there is no standard function to open wide paths, so our best bet is to try utf8 path - char* path_utf8 = convert_path_heap(path); - if (!path_utf8) return 0; - - // convert mode to ASCII (we mirror _wfopen interface) - char mode_ascii[4] = {0}; - for (size_t i = 0; mode[i]; ++i) mode_ascii[i] = static_cast(mode[i]); - - // try to open the utf8 path - FILE* result = fopen(path_utf8, mode_ascii); - - // free dummy buffer - xml_memory::deallocate(path_utf8); - - return result; - } -#endif - - PUGI__FN bool save_file_impl(const xml_document& doc, FILE* file, const char_t* indent, unsigned int flags, xml_encoding encoding) - { - if (!file) return false; - - xml_writer_file writer(file); - doc.save(writer, indent, flags, encoding); - - int result = ferror(file); - - fclose(file); - - return result == 0; - } - - PUGI__FN xml_parse_result load_buffer_impl(xml_document_struct* doc, xml_node_struct* root, void* contents, size_t size, unsigned int options, xml_encoding encoding, bool is_mutable, bool own, char_t** out_buffer) - { - // check input buffer - assert(contents || size == 0); - - // get actual encoding - xml_encoding buffer_encoding = impl::get_buffer_encoding(encoding, contents, size); - - // get private buffer - char_t* buffer = 0; - size_t length = 0; - - if (!impl::convert_buffer(buffer, length, buffer_encoding, contents, size, is_mutable)) return impl::make_parse_result(status_out_of_memory); - - // delete original buffer if we performed a conversion - if (own && buffer != contents && contents) impl::xml_memory::deallocate(contents); - - // store buffer for offset_debug - doc->buffer = buffer; - - // parse - xml_parse_result res = impl::xml_parser::parse(buffer, length, doc, root, options); - - // remember encoding - res.encoding = buffer_encoding; - - // grab onto buffer if it's our buffer, user is responsible for deallocating contents himself - if (own || buffer != contents) *out_buffer = buffer; - - return res; - } -PUGI__NS_END - -namespace pugi -{ - PUGI__FN xml_writer_file::xml_writer_file(void* file_): file(file_) - { - } - - PUGI__FN void xml_writer_file::write(const void* data, size_t size) - { - size_t result = fwrite(data, 1, size, static_cast(file)); - (void)!result; // unfortunately we can't do proper error handling here - } - -#ifndef PUGIXML_NO_STL - PUGI__FN xml_writer_stream::xml_writer_stream(std::basic_ostream >& stream): narrow_stream(&stream), wide_stream(0) - { - } - - PUGI__FN xml_writer_stream::xml_writer_stream(std::basic_ostream >& stream): narrow_stream(0), wide_stream(&stream) - { - } - - PUGI__FN void xml_writer_stream::write(const void* data, size_t size) - { - if (narrow_stream) - { - assert(!wide_stream); - narrow_stream->write(reinterpret_cast(data), static_cast(size)); - } - else - { - assert(wide_stream); - assert(size % sizeof(wchar_t) == 0); - - wide_stream->write(reinterpret_cast(data), static_cast(size / sizeof(wchar_t))); - } - } -#endif - - PUGI__FN xml_tree_walker::xml_tree_walker(): _depth(0) - { - } - - PUGI__FN xml_tree_walker::~xml_tree_walker() - { - } - - PUGI__FN int xml_tree_walker::depth() const - { - return _depth; - } - - PUGI__FN bool xml_tree_walker::begin(xml_node&) - { - return true; - } - - PUGI__FN bool xml_tree_walker::end(xml_node&) - { - return true; - } - - PUGI__FN xml_attribute::xml_attribute(): _attr(0) - { - } - - PUGI__FN xml_attribute::xml_attribute(xml_attribute_struct* attr): _attr(attr) - { - } - - PUGI__FN static void unspecified_bool_xml_attribute(xml_attribute***) - { - } - - PUGI__FN xml_attribute::operator xml_attribute::unspecified_bool_type() const - { - return _attr ? unspecified_bool_xml_attribute : 0; - } - - PUGI__FN bool xml_attribute::operator!() const - { - return !_attr; - } - - PUGI__FN bool xml_attribute::operator==(const xml_attribute& r) const - { - return (_attr == r._attr); - } - - PUGI__FN bool xml_attribute::operator!=(const xml_attribute& r) const - { - return (_attr != r._attr); - } - - PUGI__FN bool xml_attribute::operator<(const xml_attribute& r) const - { - return (_attr < r._attr); - } - - PUGI__FN bool xml_attribute::operator>(const xml_attribute& r) const - { - return (_attr > r._attr); - } - - PUGI__FN bool xml_attribute::operator<=(const xml_attribute& r) const - { - return (_attr <= r._attr); - } - - PUGI__FN bool xml_attribute::operator>=(const xml_attribute& r) const - { - return (_attr >= r._attr); - } - - PUGI__FN xml_attribute xml_attribute::next_attribute() const - { - return _attr ? xml_attribute(_attr->next_attribute) : xml_attribute(); - } - - PUGI__FN xml_attribute xml_attribute::previous_attribute() const - { - return _attr && _attr->prev_attribute_c->next_attribute ? xml_attribute(_attr->prev_attribute_c) : xml_attribute(); - } - - PUGI__FN const char_t* xml_attribute::as_string(const char_t* def) const - { - return (_attr && _attr->value) ? _attr->value : def; - } - - PUGI__FN int xml_attribute::as_int(int def) const - { - return impl::get_value_int(_attr ? _attr->value : 0, def); - } - - PUGI__FN unsigned int xml_attribute::as_uint(unsigned int def) const - { - return impl::get_value_uint(_attr ? _attr->value : 0, def); - } - - PUGI__FN double xml_attribute::as_double(double def) const - { - return impl::get_value_double(_attr ? _attr->value : 0, def); - } - - PUGI__FN float xml_attribute::as_float(float def) const - { - return impl::get_value_float(_attr ? _attr->value : 0, def); - } - - PUGI__FN bool xml_attribute::as_bool(bool def) const - { - return impl::get_value_bool(_attr ? _attr->value : 0, def); - } - -#ifdef PUGIXML_HAS_LONG_LONG - PUGI__FN long long xml_attribute::as_llong(long long def) const - { - return impl::get_value_llong(_attr ? _attr->value : 0, def); - } - - PUGI__FN unsigned long long xml_attribute::as_ullong(unsigned long long def) const - { - return impl::get_value_ullong(_attr ? _attr->value : 0, def); - } -#endif - - PUGI__FN bool xml_attribute::empty() const - { - return !_attr; - } - - PUGI__FN const char_t* xml_attribute::name() const - { - return (_attr && _attr->name) ? _attr->name : PUGIXML_TEXT(""); - } - - PUGI__FN const char_t* xml_attribute::value() const - { - return (_attr && _attr->value) ? _attr->value : PUGIXML_TEXT(""); - } - - PUGI__FN size_t xml_attribute::hash_value() const - { - return static_cast(reinterpret_cast(_attr) / sizeof(xml_attribute_struct)); - } - - PUGI__FN xml_attribute_struct* xml_attribute::internal_object() const - { - return _attr; - } - - PUGI__FN xml_attribute& xml_attribute::operator=(const char_t* rhs) - { - set_value(rhs); - return *this; - } - - PUGI__FN xml_attribute& xml_attribute::operator=(int rhs) - { - set_value(rhs); - return *this; - } - - PUGI__FN xml_attribute& xml_attribute::operator=(unsigned int rhs) - { - set_value(rhs); - return *this; - } - - PUGI__FN xml_attribute& xml_attribute::operator=(double rhs) - { - set_value(rhs); - return *this; - } - - PUGI__FN xml_attribute& xml_attribute::operator=(bool rhs) - { - set_value(rhs); - return *this; - } - -#ifdef PUGIXML_HAS_LONG_LONG - PUGI__FN xml_attribute& xml_attribute::operator=(long long rhs) - { - set_value(rhs); - return *this; - } - - PUGI__FN xml_attribute& xml_attribute::operator=(unsigned long long rhs) - { - set_value(rhs); - return *this; - } -#endif - - PUGI__FN bool xml_attribute::set_name(const char_t* rhs) - { - if (!_attr) return false; - - return impl::strcpy_insitu(_attr->name, _attr->header, impl::xml_memory_page_name_allocated_mask, rhs); - } - - PUGI__FN bool xml_attribute::set_value(const char_t* rhs) - { - if (!_attr) return false; - - return impl::strcpy_insitu(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs); - } - - PUGI__FN bool xml_attribute::set_value(int rhs) - { - if (!_attr) return false; - - return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs); - } - - PUGI__FN bool xml_attribute::set_value(unsigned int rhs) - { - if (!_attr) return false; - - return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs); - } - - PUGI__FN bool xml_attribute::set_value(double rhs) - { - if (!_attr) return false; - - return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs); - } - - PUGI__FN bool xml_attribute::set_value(bool rhs) - { - if (!_attr) return false; - - return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs); - } - -#ifdef PUGIXML_HAS_LONG_LONG - PUGI__FN bool xml_attribute::set_value(long long rhs) - { - if (!_attr) return false; - - return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs); - } - - PUGI__FN bool xml_attribute::set_value(unsigned long long rhs) - { - if (!_attr) return false; - - return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs); - } -#endif - -#ifdef __BORLANDC__ - PUGI__FN bool operator&&(const xml_attribute& lhs, bool rhs) - { - return (bool)lhs && rhs; - } - - PUGI__FN bool operator||(const xml_attribute& lhs, bool rhs) - { - return (bool)lhs || rhs; - } -#endif - - PUGI__FN xml_node::xml_node(): _root(0) - { - } - - PUGI__FN xml_node::xml_node(xml_node_struct* p): _root(p) - { - } - - PUGI__FN static void unspecified_bool_xml_node(xml_node***) - { - } - - PUGI__FN xml_node::operator xml_node::unspecified_bool_type() const - { - return _root ? unspecified_bool_xml_node : 0; - } - - PUGI__FN bool xml_node::operator!() const - { - return !_root; - } - - PUGI__FN xml_node::iterator xml_node::begin() const - { - return iterator(_root ? _root->first_child : 0, _root); - } - - PUGI__FN xml_node::iterator xml_node::end() const - { - return iterator(0, _root); - } - - PUGI__FN xml_node::attribute_iterator xml_node::attributes_begin() const - { - return attribute_iterator(_root ? _root->first_attribute : 0, _root); - } - - PUGI__FN xml_node::attribute_iterator xml_node::attributes_end() const - { - return attribute_iterator(0, _root); - } - - PUGI__FN xml_object_range xml_node::children() const - { - return xml_object_range(begin(), end()); - } - - PUGI__FN xml_object_range xml_node::children(const char_t* name_) const - { - return xml_object_range(xml_named_node_iterator(child(name_)._root, _root, name_), xml_named_node_iterator(0, _root, name_)); - } - - PUGI__FN xml_object_range xml_node::attributes() const - { - return xml_object_range(attributes_begin(), attributes_end()); - } - - PUGI__FN bool xml_node::operator==(const xml_node& r) const - { - return (_root == r._root); - } - - PUGI__FN bool xml_node::operator!=(const xml_node& r) const - { - return (_root != r._root); - } - - PUGI__FN bool xml_node::operator<(const xml_node& r) const - { - return (_root < r._root); - } - - PUGI__FN bool xml_node::operator>(const xml_node& r) const - { - return (_root > r._root); - } - - PUGI__FN bool xml_node::operator<=(const xml_node& r) const - { - return (_root <= r._root); - } - - PUGI__FN bool xml_node::operator>=(const xml_node& r) const - { - return (_root >= r._root); - } - - PUGI__FN bool xml_node::empty() const - { - return !_root; - } - - PUGI__FN const char_t* xml_node::name() const - { - return (_root && _root->name) ? _root->name : PUGIXML_TEXT(""); - } - - PUGI__FN xml_node_type xml_node::type() const - { - return _root ? PUGI__NODETYPE(_root) : node_null; - } - - PUGI__FN const char_t* xml_node::value() const - { - return (_root && _root->value) ? _root->value : PUGIXML_TEXT(""); - } - - PUGI__FN xml_node xml_node::child(const char_t* name_) const - { - if (!_root) return xml_node(); - - for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling) - if (i->name && impl::strequal(name_, i->name)) return xml_node(i); - - return xml_node(); - } - - PUGI__FN xml_attribute xml_node::attribute(const char_t* name_) const - { - if (!_root) return xml_attribute(); - - for (xml_attribute_struct* i = _root->first_attribute; i; i = i->next_attribute) - if (i->name && impl::strequal(name_, i->name)) - return xml_attribute(i); - - return xml_attribute(); - } - - PUGI__FN xml_node xml_node::next_sibling(const char_t* name_) const - { - if (!_root) return xml_node(); - - for (xml_node_struct* i = _root->next_sibling; i; i = i->next_sibling) - if (i->name && impl::strequal(name_, i->name)) return xml_node(i); - - return xml_node(); - } - - PUGI__FN xml_node xml_node::next_sibling() const - { - return _root ? xml_node(_root->next_sibling) : xml_node(); - } - - PUGI__FN xml_node xml_node::previous_sibling(const char_t* name_) const - { - if (!_root) return xml_node(); - - for (xml_node_struct* i = _root->prev_sibling_c; i->next_sibling; i = i->prev_sibling_c) - if (i->name && impl::strequal(name_, i->name)) return xml_node(i); - - return xml_node(); - } - - PUGI__FN xml_node xml_node::previous_sibling() const - { - if (!_root) return xml_node(); - - if (_root->prev_sibling_c->next_sibling) return xml_node(_root->prev_sibling_c); - else return xml_node(); - } - - PUGI__FN xml_node xml_node::parent() const - { - return _root ? xml_node(_root->parent) : xml_node(); - } - - PUGI__FN xml_node xml_node::root() const - { - return _root ? xml_node(&impl::get_document(_root)) : xml_node(); - } - - PUGI__FN xml_text xml_node::text() const - { - return xml_text(_root); - } - - PUGI__FN const char_t* xml_node::child_value() const - { - if (!_root) return PUGIXML_TEXT(""); - - for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling) - if (i->value && impl::is_text_node(i)) - return i->value; - - return PUGIXML_TEXT(""); - } - - PUGI__FN const char_t* xml_node::child_value(const char_t* name_) const - { - return child(name_).child_value(); - } - - PUGI__FN xml_attribute xml_node::first_attribute() const - { - return _root ? xml_attribute(_root->first_attribute) : xml_attribute(); - } - - PUGI__FN xml_attribute xml_node::last_attribute() const - { - return _root && _root->first_attribute ? xml_attribute(_root->first_attribute->prev_attribute_c) : xml_attribute(); - } - - PUGI__FN xml_node xml_node::first_child() const - { - return _root ? xml_node(_root->first_child) : xml_node(); - } - - PUGI__FN xml_node xml_node::last_child() const - { - return _root && _root->first_child ? xml_node(_root->first_child->prev_sibling_c) : xml_node(); - } - - PUGI__FN bool xml_node::set_name(const char_t* rhs) - { - switch (type()) - { - case node_pi: - case node_declaration: - case node_element: - return impl::strcpy_insitu(_root->name, _root->header, impl::xml_memory_page_name_allocated_mask, rhs); - - default: - return false; - } - } - - PUGI__FN bool xml_node::set_value(const char_t* rhs) - { - switch (type()) - { - case node_pi: - case node_cdata: - case node_pcdata: - case node_comment: - case node_doctype: - return impl::strcpy_insitu(_root->value, _root->header, impl::xml_memory_page_value_allocated_mask, rhs); - - default: - return false; - } - } - - PUGI__FN xml_attribute xml_node::append_attribute(const char_t* name_) - { - if (!impl::allow_insert_attribute(type())) return xml_attribute(); - - xml_attribute a(impl::allocate_attribute(impl::get_allocator(_root))); - if (!a) return xml_attribute(); - - impl::append_attribute(a._attr, _root); - - a.set_name(name_); - - return a; - } - - PUGI__FN xml_attribute xml_node::prepend_attribute(const char_t* name_) - { - if (!impl::allow_insert_attribute(type())) return xml_attribute(); - - xml_attribute a(impl::allocate_attribute(impl::get_allocator(_root))); - if (!a) return xml_attribute(); - - impl::prepend_attribute(a._attr, _root); - - a.set_name(name_); - - return a; - } - - PUGI__FN xml_attribute xml_node::insert_attribute_after(const char_t* name_, const xml_attribute& attr) - { - if (!impl::allow_insert_attribute(type())) return xml_attribute(); - if (!attr || !impl::is_attribute_of(attr._attr, _root)) return xml_attribute(); - - xml_attribute a(impl::allocate_attribute(impl::get_allocator(_root))); - if (!a) return xml_attribute(); - - impl::insert_attribute_after(a._attr, attr._attr, _root); - - a.set_name(name_); - - return a; - } - - PUGI__FN xml_attribute xml_node::insert_attribute_before(const char_t* name_, const xml_attribute& attr) - { - if (!impl::allow_insert_attribute(type())) return xml_attribute(); - if (!attr || !impl::is_attribute_of(attr._attr, _root)) return xml_attribute(); - - xml_attribute a(impl::allocate_attribute(impl::get_allocator(_root))); - if (!a) return xml_attribute(); - - impl::insert_attribute_before(a._attr, attr._attr, _root); - - a.set_name(name_); - - return a; - } - - PUGI__FN xml_attribute xml_node::append_copy(const xml_attribute& proto) - { - if (!proto) return xml_attribute(); - - xml_attribute result = append_attribute(proto.name()); - result.set_value(proto.value()); - - return result; - } - - PUGI__FN xml_attribute xml_node::prepend_copy(const xml_attribute& proto) - { - if (!proto) return xml_attribute(); - - xml_attribute result = prepend_attribute(proto.name()); - result.set_value(proto.value()); - - return result; - } - - PUGI__FN xml_attribute xml_node::insert_copy_after(const xml_attribute& proto, const xml_attribute& attr) - { - if (!proto) return xml_attribute(); - - xml_attribute result = insert_attribute_after(proto.name(), attr); - result.set_value(proto.value()); - - return result; - } - - PUGI__FN xml_attribute xml_node::insert_copy_before(const xml_attribute& proto, const xml_attribute& attr) - { - if (!proto) return xml_attribute(); - - xml_attribute result = insert_attribute_before(proto.name(), attr); - result.set_value(proto.value()); - - return result; - } - - PUGI__FN xml_node xml_node::append_child(xml_node_type type_) - { - if (!impl::allow_insert_child(type(), type_)) return xml_node(); - - xml_node n(impl::allocate_node(impl::get_allocator(_root), type_)); - if (!n) return xml_node(); - - impl::append_node(n._root, _root); - - if (type_ == node_declaration) n.set_name(PUGIXML_TEXT("xml")); - - return n; - } - - PUGI__FN xml_node xml_node::prepend_child(xml_node_type type_) - { - if (!impl::allow_insert_child(type(), type_)) return xml_node(); - - xml_node n(impl::allocate_node(impl::get_allocator(_root), type_)); - if (!n) return xml_node(); - - impl::prepend_node(n._root, _root); - - if (type_ == node_declaration) n.set_name(PUGIXML_TEXT("xml")); - - return n; - } - - PUGI__FN xml_node xml_node::insert_child_before(xml_node_type type_, const xml_node& node) - { - if (!impl::allow_insert_child(type(), type_)) return xml_node(); - if (!node._root || node._root->parent != _root) return xml_node(); - - xml_node n(impl::allocate_node(impl::get_allocator(_root), type_)); - if (!n) return xml_node(); - - impl::insert_node_before(n._root, node._root); - - if (type_ == node_declaration) n.set_name(PUGIXML_TEXT("xml")); - - return n; - } - - PUGI__FN xml_node xml_node::insert_child_after(xml_node_type type_, const xml_node& node) - { - if (!impl::allow_insert_child(type(), type_)) return xml_node(); - if (!node._root || node._root->parent != _root) return xml_node(); - - xml_node n(impl::allocate_node(impl::get_allocator(_root), type_)); - if (!n) return xml_node(); - - impl::insert_node_after(n._root, node._root); - - if (type_ == node_declaration) n.set_name(PUGIXML_TEXT("xml")); - - return n; - } - - PUGI__FN xml_node xml_node::append_child(const char_t* name_) - { - xml_node result = append_child(node_element); - - result.set_name(name_); - - return result; - } - - PUGI__FN xml_node xml_node::prepend_child(const char_t* name_) - { - xml_node result = prepend_child(node_element); - - result.set_name(name_); - - return result; - } - - PUGI__FN xml_node xml_node::insert_child_after(const char_t* name_, const xml_node& node) - { - xml_node result = insert_child_after(node_element, node); - - result.set_name(name_); - - return result; - } - - PUGI__FN xml_node xml_node::insert_child_before(const char_t* name_, const xml_node& node) - { - xml_node result = insert_child_before(node_element, node); - - result.set_name(name_); - - return result; - } - - PUGI__FN xml_node xml_node::append_copy(const xml_node& proto) - { - xml_node_type type_ = proto.type(); - if (!impl::allow_insert_child(type(), type_)) return xml_node(); - - xml_node n(impl::allocate_node(impl::get_allocator(_root), type_)); - if (!n) return xml_node(); - - impl::append_node(n._root, _root); - impl::node_copy_tree(n._root, proto._root); - - return n; - } - - PUGI__FN xml_node xml_node::prepend_copy(const xml_node& proto) - { - xml_node_type type_ = proto.type(); - if (!impl::allow_insert_child(type(), type_)) return xml_node(); - - xml_node n(impl::allocate_node(impl::get_allocator(_root), type_)); - if (!n) return xml_node(); - - impl::prepend_node(n._root, _root); - impl::node_copy_tree(n._root, proto._root); - - return n; - } - - PUGI__FN xml_node xml_node::insert_copy_after(const xml_node& proto, const xml_node& node) - { - xml_node_type type_ = proto.type(); - if (!impl::allow_insert_child(type(), type_)) return xml_node(); - if (!node._root || node._root->parent != _root) return xml_node(); - - xml_node n(impl::allocate_node(impl::get_allocator(_root), type_)); - if (!n) return xml_node(); - - impl::insert_node_after(n._root, node._root); - impl::node_copy_tree(n._root, proto._root); - - return n; - } - - PUGI__FN xml_node xml_node::insert_copy_before(const xml_node& proto, const xml_node& node) - { - xml_node_type type_ = proto.type(); - if (!impl::allow_insert_child(type(), type_)) return xml_node(); - if (!node._root || node._root->parent != _root) return xml_node(); - - xml_node n(impl::allocate_node(impl::get_allocator(_root), type_)); - if (!n) return xml_node(); - - impl::insert_node_before(n._root, node._root); - impl::node_copy_tree(n._root, proto._root); - - return n; - } - - PUGI__FN xml_node xml_node::append_move(const xml_node& moved) - { - if (!impl::allow_move(*this, moved)) return xml_node(); - - // disable document_buffer_order optimization since moving nodes around changes document order without changing buffer pointers - impl::get_document(_root).header |= impl::xml_memory_page_contents_shared_mask; - - impl::remove_node(moved._root); - impl::append_node(moved._root, _root); - - return moved; - } - - PUGI__FN xml_node xml_node::prepend_move(const xml_node& moved) - { - if (!impl::allow_move(*this, moved)) return xml_node(); - - // disable document_buffer_order optimization since moving nodes around changes document order without changing buffer pointers - impl::get_document(_root).header |= impl::xml_memory_page_contents_shared_mask; - - impl::remove_node(moved._root); - impl::prepend_node(moved._root, _root); - - return moved; - } - - PUGI__FN xml_node xml_node::insert_move_after(const xml_node& moved, const xml_node& node) - { - if (!impl::allow_move(*this, moved)) return xml_node(); - if (!node._root || node._root->parent != _root) return xml_node(); - if (moved._root == node._root) return xml_node(); - - // disable document_buffer_order optimization since moving nodes around changes document order without changing buffer pointers - impl::get_document(_root).header |= impl::xml_memory_page_contents_shared_mask; - - impl::remove_node(moved._root); - impl::insert_node_after(moved._root, node._root); - - return moved; - } - - PUGI__FN xml_node xml_node::insert_move_before(const xml_node& moved, const xml_node& node) - { - if (!impl::allow_move(*this, moved)) return xml_node(); - if (!node._root || node._root->parent != _root) return xml_node(); - if (moved._root == node._root) return xml_node(); - - // disable document_buffer_order optimization since moving nodes around changes document order without changing buffer pointers - impl::get_document(_root).header |= impl::xml_memory_page_contents_shared_mask; - - impl::remove_node(moved._root); - impl::insert_node_before(moved._root, node._root); - - return moved; - } - - PUGI__FN bool xml_node::remove_attribute(const char_t* name_) - { - return remove_attribute(attribute(name_)); - } - - PUGI__FN bool xml_node::remove_attribute(const xml_attribute& a) - { - if (!_root || !a._attr) return false; - if (!impl::is_attribute_of(a._attr, _root)) return false; - - impl::remove_attribute(a._attr, _root); - impl::destroy_attribute(a._attr, impl::get_allocator(_root)); - - return true; - } - - PUGI__FN bool xml_node::remove_child(const char_t* name_) - { - return remove_child(child(name_)); - } - - PUGI__FN bool xml_node::remove_child(const xml_node& n) - { - if (!_root || !n._root || n._root->parent != _root) return false; - - impl::remove_node(n._root); - impl::destroy_node(n._root, impl::get_allocator(_root)); - - return true; - } - - PUGI__FN xml_parse_result xml_node::append_buffer(const void* contents, size_t size, unsigned int options, xml_encoding encoding) - { - // append_buffer is only valid for elements/documents - if (!impl::allow_insert_child(type(), node_element)) return impl::make_parse_result(status_append_invalid_root); - - // get document node - impl::xml_document_struct* doc = &impl::get_document(_root); - - // disable document_buffer_order optimization since in a document with multiple buffers comparing buffer pointers does not make sense - doc->header |= impl::xml_memory_page_contents_shared_mask; - - // get extra buffer element (we'll store the document fragment buffer there so that we can deallocate it later) - impl::xml_memory_page* page = 0; - impl::xml_extra_buffer* extra = static_cast(doc->allocate_memory(sizeof(impl::xml_extra_buffer), page)); - (void)page; - - if (!extra) return impl::make_parse_result(status_out_of_memory); - - // save name; name of the root has to be NULL before parsing - otherwise closing node mismatches will not be detected at the top level - char_t* rootname = _root->name; - _root->name = 0; - - // parse - char_t* buffer = 0; - xml_parse_result res = impl::load_buffer_impl(doc, _root, const_cast(contents), size, options, encoding, false, false, &buffer); - - // restore name - _root->name = rootname; - - // add extra buffer to the list - extra->buffer = buffer; - extra->next = doc->extra_buffers; - doc->extra_buffers = extra; - - return res; - } - - PUGI__FN xml_node xml_node::find_child_by_attribute(const char_t* name_, const char_t* attr_name, const char_t* attr_value) const - { - if (!_root) return xml_node(); - - for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling) - if (i->name && impl::strequal(name_, i->name)) - { - for (xml_attribute_struct* a = i->first_attribute; a; a = a->next_attribute) - if (a->name && impl::strequal(attr_name, a->name) && impl::strequal(attr_value, a->value ? a->value : PUGIXML_TEXT(""))) - return xml_node(i); - } - - return xml_node(); - } - - PUGI__FN xml_node xml_node::find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const - { - if (!_root) return xml_node(); - - for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling) - for (xml_attribute_struct* a = i->first_attribute; a; a = a->next_attribute) - if (a->name && impl::strequal(attr_name, a->name) && impl::strequal(attr_value, a->value ? a->value : PUGIXML_TEXT(""))) - return xml_node(i); - - return xml_node(); - } - -#ifndef PUGIXML_NO_STL - PUGI__FN string_t xml_node::path(char_t delimiter) const - { - xml_node cursor = *this; // Make a copy. - - string_t result = cursor.name(); - - while (cursor.parent()) - { - cursor = cursor.parent(); - - string_t temp = cursor.name(); - temp += delimiter; - temp += result; - result.swap(temp); - } - - return result; - } -#endif - - PUGI__FN xml_node xml_node::first_element_by_path(const char_t* path_, char_t delimiter) const - { - xml_node found = *this; // Current search context. - - if (!_root || !path_ || !path_[0]) return found; - - if (path_[0] == delimiter) - { - // Absolute path; e.g. '/foo/bar' - found = found.root(); - ++path_; - } - - const char_t* path_segment = path_; - - while (*path_segment == delimiter) ++path_segment; - - const char_t* path_segment_end = path_segment; - - while (*path_segment_end && *path_segment_end != delimiter) ++path_segment_end; - - if (path_segment == path_segment_end) return found; - - const char_t* next_segment = path_segment_end; - - while (*next_segment == delimiter) ++next_segment; - - if (*path_segment == '.' && path_segment + 1 == path_segment_end) - return found.first_element_by_path(next_segment, delimiter); - else if (*path_segment == '.' && *(path_segment+1) == '.' && path_segment + 2 == path_segment_end) - return found.parent().first_element_by_path(next_segment, delimiter); - else - { - for (xml_node_struct* j = found._root->first_child; j; j = j->next_sibling) - { - if (j->name && impl::strequalrange(j->name, path_segment, static_cast(path_segment_end - path_segment))) - { - xml_node subsearch = xml_node(j).first_element_by_path(next_segment, delimiter); - - if (subsearch) return subsearch; - } - } - - return xml_node(); - } - } - - PUGI__FN bool xml_node::traverse(xml_tree_walker& walker) - { - walker._depth = -1; - - xml_node arg_begin = *this; - if (!walker.begin(arg_begin)) return false; - - xml_node cur = first_child(); - - if (cur) - { - ++walker._depth; - - do - { - xml_node arg_for_each = cur; - if (!walker.for_each(arg_for_each)) - return false; - - if (cur.first_child()) - { - ++walker._depth; - cur = cur.first_child(); - } - else if (cur.next_sibling()) - cur = cur.next_sibling(); - else - { - // Borland C++ workaround - while (!cur.next_sibling() && cur != *this && !cur.parent().empty()) - { - --walker._depth; - cur = cur.parent(); - } - - if (cur != *this) - cur = cur.next_sibling(); - } - } - while (cur && cur != *this); - } - - assert(walker._depth == -1); - - xml_node arg_end = *this; - return walker.end(arg_end); - } - - PUGI__FN size_t xml_node::hash_value() const - { - return static_cast(reinterpret_cast(_root) / sizeof(xml_node_struct)); - } - - PUGI__FN xml_node_struct* xml_node::internal_object() const - { - return _root; - } - - PUGI__FN void xml_node::print(xml_writer& writer, const char_t* indent, unsigned int flags, xml_encoding encoding, unsigned int depth) const - { - if (!_root) return; - - impl::xml_buffered_writer buffered_writer(writer, encoding); - - impl::node_output(buffered_writer, _root, indent, flags, depth); - } - -#ifndef PUGIXML_NO_STL - PUGI__FN void xml_node::print(std::basic_ostream >& stream, const char_t* indent, unsigned int flags, xml_encoding encoding, unsigned int depth) const - { - xml_writer_stream writer(stream); - - print(writer, indent, flags, encoding, depth); - } - - PUGI__FN void xml_node::print(std::basic_ostream >& stream, const char_t* indent, unsigned int flags, unsigned int depth) const - { - xml_writer_stream writer(stream); - - print(writer, indent, flags, encoding_wchar, depth); - } -#endif - - PUGI__FN ptrdiff_t xml_node::offset_debug() const - { - if (!_root) return -1; - - impl::xml_document_struct& doc = impl::get_document(_root); - - // we can determine the offset reliably only if there is exactly once parse buffer - if (!doc.buffer || doc.extra_buffers) return -1; - - switch (type()) - { - case node_document: - return 0; - - case node_element: - case node_declaration: - case node_pi: - return _root->name && (_root->header & impl::xml_memory_page_name_allocated_or_shared_mask) == 0 ? _root->name - doc.buffer : -1; - - case node_pcdata: - case node_cdata: - case node_comment: - case node_doctype: - return _root->value && (_root->header & impl::xml_memory_page_value_allocated_or_shared_mask) == 0 ? _root->value - doc.buffer : -1; - - default: - return -1; - } - } - -#ifdef __BORLANDC__ - PUGI__FN bool operator&&(const xml_node& lhs, bool rhs) - { - return (bool)lhs && rhs; - } - - PUGI__FN bool operator||(const xml_node& lhs, bool rhs) - { - return (bool)lhs || rhs; - } -#endif - - PUGI__FN xml_text::xml_text(xml_node_struct* root): _root(root) - { - } - - PUGI__FN xml_node_struct* xml_text::_data() const - { - if (!_root || impl::is_text_node(_root)) return _root; - - for (xml_node_struct* node = _root->first_child; node; node = node->next_sibling) - if (impl::is_text_node(node)) - return node; - - return 0; - } - - PUGI__FN xml_node_struct* xml_text::_data_new() - { - xml_node_struct* d = _data(); - if (d) return d; - - return xml_node(_root).append_child(node_pcdata).internal_object(); - } - - PUGI__FN xml_text::xml_text(): _root(0) - { - } - - PUGI__FN static void unspecified_bool_xml_text(xml_text***) - { - } - - PUGI__FN xml_text::operator xml_text::unspecified_bool_type() const - { - return _data() ? unspecified_bool_xml_text : 0; - } - - PUGI__FN bool xml_text::operator!() const - { - return !_data(); - } - - PUGI__FN bool xml_text::empty() const - { - return _data() == 0; - } - - PUGI__FN const char_t* xml_text::get() const - { - xml_node_struct* d = _data(); - - return (d && d->value) ? d->value : PUGIXML_TEXT(""); - } - - PUGI__FN const char_t* xml_text::as_string(const char_t* def) const - { - xml_node_struct* d = _data(); - - return (d && d->value) ? d->value : def; - } - - PUGI__FN int xml_text::as_int(int def) const - { - xml_node_struct* d = _data(); - - return impl::get_value_int(d ? d->value : 0, def); - } - - PUGI__FN unsigned int xml_text::as_uint(unsigned int def) const - { - xml_node_struct* d = _data(); - - return impl::get_value_uint(d ? d->value : 0, def); - } - - PUGI__FN double xml_text::as_double(double def) const - { - xml_node_struct* d = _data(); - - return impl::get_value_double(d ? d->value : 0, def); - } - - PUGI__FN float xml_text::as_float(float def) const - { - xml_node_struct* d = _data(); - - return impl::get_value_float(d ? d->value : 0, def); - } - - PUGI__FN bool xml_text::as_bool(bool def) const - { - xml_node_struct* d = _data(); - - return impl::get_value_bool(d ? d->value : 0, def); - } - -#ifdef PUGIXML_HAS_LONG_LONG - PUGI__FN long long xml_text::as_llong(long long def) const - { - xml_node_struct* d = _data(); - - return impl::get_value_llong(d ? d->value : 0, def); - } - - PUGI__FN unsigned long long xml_text::as_ullong(unsigned long long def) const - { - xml_node_struct* d = _data(); - - return impl::get_value_ullong(d ? d->value : 0, def); - } -#endif - - PUGI__FN bool xml_text::set(const char_t* rhs) - { - xml_node_struct* dn = _data_new(); - - return dn ? impl::strcpy_insitu(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs) : false; - } - - PUGI__FN bool xml_text::set(int rhs) - { - xml_node_struct* dn = _data_new(); - - return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs) : false; - } - - PUGI__FN bool xml_text::set(unsigned int rhs) - { - xml_node_struct* dn = _data_new(); - - return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs) : false; - } - - PUGI__FN bool xml_text::set(double rhs) - { - xml_node_struct* dn = _data_new(); - - return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs) : false; - } - - PUGI__FN bool xml_text::set(bool rhs) - { - xml_node_struct* dn = _data_new(); - - return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs) : false; - } - -#ifdef PUGIXML_HAS_LONG_LONG - PUGI__FN bool xml_text::set(long long rhs) - { - xml_node_struct* dn = _data_new(); - - return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs) : false; - } - - PUGI__FN bool xml_text::set(unsigned long long rhs) - { - xml_node_struct* dn = _data_new(); - - return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs) : false; - } -#endif - - PUGI__FN xml_text& xml_text::operator=(const char_t* rhs) - { - set(rhs); - return *this; - } - - PUGI__FN xml_text& xml_text::operator=(int rhs) - { - set(rhs); - return *this; - } - - PUGI__FN xml_text& xml_text::operator=(unsigned int rhs) - { - set(rhs); - return *this; - } - - PUGI__FN xml_text& xml_text::operator=(double rhs) - { - set(rhs); - return *this; - } - - PUGI__FN xml_text& xml_text::operator=(bool rhs) - { - set(rhs); - return *this; - } - -#ifdef PUGIXML_HAS_LONG_LONG - PUGI__FN xml_text& xml_text::operator=(long long rhs) - { - set(rhs); - return *this; - } - - PUGI__FN xml_text& xml_text::operator=(unsigned long long rhs) - { - set(rhs); - return *this; - } -#endif - - PUGI__FN xml_node xml_text::data() const - { - return xml_node(_data()); - } - -#ifdef __BORLANDC__ - PUGI__FN bool operator&&(const xml_text& lhs, bool rhs) - { - return (bool)lhs && rhs; - } - - PUGI__FN bool operator||(const xml_text& lhs, bool rhs) - { - return (bool)lhs || rhs; - } -#endif - - PUGI__FN xml_node_iterator::xml_node_iterator() - { - } - - PUGI__FN xml_node_iterator::xml_node_iterator(const xml_node& node): _wrap(node), _parent(node.parent()) - { - } - - PUGI__FN xml_node_iterator::xml_node_iterator(xml_node_struct* ref, xml_node_struct* parent): _wrap(ref), _parent(parent) - { - } - - PUGI__FN bool xml_node_iterator::operator==(const xml_node_iterator& rhs) const - { - return _wrap._root == rhs._wrap._root && _parent._root == rhs._parent._root; - } - - PUGI__FN bool xml_node_iterator::operator!=(const xml_node_iterator& rhs) const - { - return _wrap._root != rhs._wrap._root || _parent._root != rhs._parent._root; - } - - PUGI__FN xml_node& xml_node_iterator::operator*() const - { - assert(_wrap._root); - return _wrap; - } - - PUGI__FN xml_node* xml_node_iterator::operator->() const - { - assert(_wrap._root); - return const_cast(&_wrap); // BCC32 workaround - } - - PUGI__FN const xml_node_iterator& xml_node_iterator::operator++() - { - assert(_wrap._root); - _wrap._root = _wrap._root->next_sibling; - return *this; - } - - PUGI__FN xml_node_iterator xml_node_iterator::operator++(int) - { - xml_node_iterator temp = *this; - ++*this; - return temp; - } - - PUGI__FN const xml_node_iterator& xml_node_iterator::operator--() - { - _wrap = _wrap._root ? _wrap.previous_sibling() : _parent.last_child(); - return *this; - } - - PUGI__FN xml_node_iterator xml_node_iterator::operator--(int) - { - xml_node_iterator temp = *this; - --*this; - return temp; - } - - PUGI__FN xml_attribute_iterator::xml_attribute_iterator() - { - } - - PUGI__FN xml_attribute_iterator::xml_attribute_iterator(const xml_attribute& attr, const xml_node& parent): _wrap(attr), _parent(parent) - { - } - - PUGI__FN xml_attribute_iterator::xml_attribute_iterator(xml_attribute_struct* ref, xml_node_struct* parent): _wrap(ref), _parent(parent) - { - } - - PUGI__FN bool xml_attribute_iterator::operator==(const xml_attribute_iterator& rhs) const - { - return _wrap._attr == rhs._wrap._attr && _parent._root == rhs._parent._root; - } - - PUGI__FN bool xml_attribute_iterator::operator!=(const xml_attribute_iterator& rhs) const - { - return _wrap._attr != rhs._wrap._attr || _parent._root != rhs._parent._root; - } - - PUGI__FN xml_attribute& xml_attribute_iterator::operator*() const - { - assert(_wrap._attr); - return _wrap; - } - - PUGI__FN xml_attribute* xml_attribute_iterator::operator->() const - { - assert(_wrap._attr); - return const_cast(&_wrap); // BCC32 workaround - } - - PUGI__FN const xml_attribute_iterator& xml_attribute_iterator::operator++() - { - assert(_wrap._attr); - _wrap._attr = _wrap._attr->next_attribute; - return *this; - } - - PUGI__FN xml_attribute_iterator xml_attribute_iterator::operator++(int) - { - xml_attribute_iterator temp = *this; - ++*this; - return temp; - } - - PUGI__FN const xml_attribute_iterator& xml_attribute_iterator::operator--() - { - _wrap = _wrap._attr ? _wrap.previous_attribute() : _parent.last_attribute(); - return *this; - } - - PUGI__FN xml_attribute_iterator xml_attribute_iterator::operator--(int) - { - xml_attribute_iterator temp = *this; - --*this; - return temp; - } - - PUGI__FN xml_named_node_iterator::xml_named_node_iterator(): _name(0) - { - } - - PUGI__FN xml_named_node_iterator::xml_named_node_iterator(const xml_node& node, const char_t* name): _wrap(node), _parent(node.parent()), _name(name) - { - } - - PUGI__FN xml_named_node_iterator::xml_named_node_iterator(xml_node_struct* ref, xml_node_struct* parent, const char_t* name): _wrap(ref), _parent(parent), _name(name) - { - } - - PUGI__FN bool xml_named_node_iterator::operator==(const xml_named_node_iterator& rhs) const - { - return _wrap._root == rhs._wrap._root && _parent._root == rhs._parent._root; - } - - PUGI__FN bool xml_named_node_iterator::operator!=(const xml_named_node_iterator& rhs) const - { - return _wrap._root != rhs._wrap._root || _parent._root != rhs._parent._root; - } - - PUGI__FN xml_node& xml_named_node_iterator::operator*() const - { - assert(_wrap._root); - return _wrap; - } - - PUGI__FN xml_node* xml_named_node_iterator::operator->() const - { - assert(_wrap._root); - return const_cast(&_wrap); // BCC32 workaround - } - - PUGI__FN const xml_named_node_iterator& xml_named_node_iterator::operator++() - { - assert(_wrap._root); - _wrap = _wrap.next_sibling(_name); - return *this; - } - - PUGI__FN xml_named_node_iterator xml_named_node_iterator::operator++(int) - { - xml_named_node_iterator temp = *this; - ++*this; - return temp; - } - - PUGI__FN const xml_named_node_iterator& xml_named_node_iterator::operator--() - { - if (_wrap._root) - _wrap = _wrap.previous_sibling(_name); - else - { - _wrap = _parent.last_child(); - - if (!impl::strequal(_wrap.name(), _name)) - _wrap = _wrap.previous_sibling(_name); - } - - return *this; - } - - PUGI__FN xml_named_node_iterator xml_named_node_iterator::operator--(int) - { - xml_named_node_iterator temp = *this; - --*this; - return temp; - } - - PUGI__FN xml_parse_result::xml_parse_result(): status(status_internal_error), offset(0), encoding(encoding_auto) - { - } - - PUGI__FN xml_parse_result::operator bool() const - { - return status == status_ok; - } - - PUGI__FN const char* xml_parse_result::description() const - { - switch (status) - { - case status_ok: return "No error"; - - case status_file_not_found: return "File was not found"; - case status_io_error: return "Error reading from file/stream"; - case status_out_of_memory: return "Could not allocate memory"; - case status_internal_error: return "Internal error occurred"; - - case status_unrecognized_tag: return "Could not determine tag type"; - - case status_bad_pi: return "Error parsing document declaration/processing instruction"; - case status_bad_comment: return "Error parsing comment"; - case status_bad_cdata: return "Error parsing CDATA section"; - case status_bad_doctype: return "Error parsing document type declaration"; - case status_bad_pcdata: return "Error parsing PCDATA section"; - case status_bad_start_element: return "Error parsing start element tag"; - case status_bad_attribute: return "Error parsing element attribute"; - case status_bad_end_element: return "Error parsing end element tag"; - case status_end_element_mismatch: return "Start-end tags mismatch"; - - case status_append_invalid_root: return "Unable to append nodes: root is not an element or document"; - - case status_no_document_element: return "No document element found"; - - default: return "Unknown error"; - } - } - - PUGI__FN xml_document::xml_document(): _buffer(0) - { - create(); - } - - PUGI__FN xml_document::~xml_document() - { - destroy(); - } - - PUGI__FN void xml_document::reset() - { - destroy(); - create(); - } - - PUGI__FN void xml_document::reset(const xml_document& proto) - { - reset(); - - for (xml_node cur = proto.first_child(); cur; cur = cur.next_sibling()) - append_copy(cur); - } - - PUGI__FN void xml_document::create() - { - assert(!_root); - - // initialize sentinel page - PUGI__STATIC_ASSERT(sizeof(impl::xml_memory_page) + sizeof(impl::xml_document_struct) + impl::xml_memory_page_alignment - sizeof(void*) <= sizeof(_memory)); - - // align upwards to page boundary - void* page_memory = reinterpret_cast((reinterpret_cast(_memory) + (impl::xml_memory_page_alignment - 1)) & ~(impl::xml_memory_page_alignment - 1)); - - // prepare page structure - impl::xml_memory_page* page = impl::xml_memory_page::construct(page_memory); - assert(page); - - page->busy_size = impl::xml_memory_page_size; - - // allocate new root - _root = new (reinterpret_cast(page) + sizeof(impl::xml_memory_page)) impl::xml_document_struct(page); - _root->prev_sibling_c = _root; - - // setup sentinel page - page->allocator = static_cast(_root); - - // verify the document allocation - assert(reinterpret_cast(_root) + sizeof(impl::xml_document_struct) <= _memory + sizeof(_memory)); - } - - PUGI__FN void xml_document::destroy() - { - assert(_root); - - // destroy static storage - if (_buffer) - { - impl::xml_memory::deallocate(_buffer); - _buffer = 0; - } - - // destroy extra buffers (note: no need to destroy linked list nodes, they're allocated using document allocator) - for (impl::xml_extra_buffer* extra = static_cast(_root)->extra_buffers; extra; extra = extra->next) - { - if (extra->buffer) impl::xml_memory::deallocate(extra->buffer); - } - - // destroy dynamic storage, leave sentinel page (it's in static memory) - impl::xml_memory_page* root_page = reinterpret_cast(_root->header & impl::xml_memory_page_pointer_mask); - assert(root_page && !root_page->prev); - assert(reinterpret_cast(root_page) >= _memory && reinterpret_cast(root_page) < _memory + sizeof(_memory)); - - for (impl::xml_memory_page* page = root_page->next; page; ) - { - impl::xml_memory_page* next = page->next; - - impl::xml_allocator::deallocate_page(page); - - page = next; - } - - _root = 0; - } - -#ifndef PUGIXML_NO_STL - PUGI__FN xml_parse_result xml_document::load(std::basic_istream >& stream, unsigned int options, xml_encoding encoding) - { - reset(); - - return impl::load_stream_impl(*this, stream, options, encoding); - } - - PUGI__FN xml_parse_result xml_document::load(std::basic_istream >& stream, unsigned int options) - { - reset(); - - return impl::load_stream_impl(*this, stream, options, encoding_wchar); - } -#endif - - PUGI__FN xml_parse_result xml_document::load_string(const char_t* contents, unsigned int options) - { - // Force native encoding (skip autodetection) - #ifdef PUGIXML_WCHAR_MODE - xml_encoding encoding = encoding_wchar; - #else - xml_encoding encoding = encoding_utf8; - #endif - - return load_buffer(contents, impl::strlength(contents) * sizeof(char_t), options, encoding); - } - - PUGI__FN xml_parse_result xml_document::load(const char_t* contents, unsigned int options) - { - return load_string(contents, options); - } - - PUGI__FN xml_parse_result xml_document::load_file(const char* path_, unsigned int options, xml_encoding encoding) - { - reset(); - - FILE* file = fopen(path_, "rb"); - - return impl::load_file_impl(*this, file, options, encoding); - } - - PUGI__FN xml_parse_result xml_document::load_file(const wchar_t* path_, unsigned int options, xml_encoding encoding) - { - reset(); - - FILE* file = impl::open_file_wide(path_, L"rb"); - - return impl::load_file_impl(*this, file, options, encoding); - } - - PUGI__FN xml_parse_result xml_document::load_buffer(const void* contents, size_t size, unsigned int options, xml_encoding encoding) - { - reset(); - - return impl::load_buffer_impl(static_cast(_root), _root, const_cast(contents), size, options, encoding, false, false, &_buffer); - } - - PUGI__FN xml_parse_result xml_document::load_buffer_inplace(void* contents, size_t size, unsigned int options, xml_encoding encoding) - { - reset(); - - return impl::load_buffer_impl(static_cast(_root), _root, contents, size, options, encoding, true, false, &_buffer); - } - - PUGI__FN xml_parse_result xml_document::load_buffer_inplace_own(void* contents, size_t size, unsigned int options, xml_encoding encoding) - { - reset(); - - return impl::load_buffer_impl(static_cast(_root), _root, contents, size, options, encoding, true, true, &_buffer); - } - - PUGI__FN void xml_document::save(xml_writer& writer, const char_t* indent, unsigned int flags, xml_encoding encoding) const - { - impl::xml_buffered_writer buffered_writer(writer, encoding); - - if ((flags & format_write_bom) && encoding != encoding_latin1) - { - // BOM always represents the codepoint U+FEFF, so just write it in native encoding - #ifdef PUGIXML_WCHAR_MODE - unsigned int bom = 0xfeff; - buffered_writer.write(static_cast(bom)); - #else - buffered_writer.write('\xef', '\xbb', '\xbf'); - #endif - } - - if (!(flags & format_no_declaration) && !impl::has_declaration(_root)) - { - buffered_writer.write_string(PUGIXML_TEXT("'); - if (!(flags & format_raw)) buffered_writer.write('\n'); - } - - impl::node_output(buffered_writer, _root, indent, flags, 0); - } - -#ifndef PUGIXML_NO_STL - PUGI__FN void xml_document::save(std::basic_ostream >& stream, const char_t* indent, unsigned int flags, xml_encoding encoding) const - { - xml_writer_stream writer(stream); - - save(writer, indent, flags, encoding); - } - - PUGI__FN void xml_document::save(std::basic_ostream >& stream, const char_t* indent, unsigned int flags) const - { - xml_writer_stream writer(stream); - - save(writer, indent, flags, encoding_wchar); - } -#endif - - PUGI__FN bool xml_document::save_file(const char* path_, const char_t* indent, unsigned int flags, xml_encoding encoding) const - { - FILE* file = fopen(path_, (flags & format_save_file_text) ? "w" : "wb"); - return impl::save_file_impl(*this, file, indent, flags, encoding); - } - - PUGI__FN bool xml_document::save_file(const wchar_t* path_, const char_t* indent, unsigned int flags, xml_encoding encoding) const - { - FILE* file = impl::open_file_wide(path_, (flags & format_save_file_text) ? L"w" : L"wb"); - return impl::save_file_impl(*this, file, indent, flags, encoding); - } - - PUGI__FN xml_node xml_document::document_element() const - { - assert(_root); - - for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling) - if (PUGI__NODETYPE(i) == node_element) - return xml_node(i); - - return xml_node(); - } - -#ifndef PUGIXML_NO_STL - PUGI__FN std::string PUGIXML_FUNCTION as_utf8(const wchar_t* str) - { - assert(str); - - return impl::as_utf8_impl(str, impl::strlength_wide(str)); - } - - PUGI__FN std::string PUGIXML_FUNCTION as_utf8(const std::basic_string& str) - { - return impl::as_utf8_impl(str.c_str(), str.size()); - } - - PUGI__FN std::basic_string PUGIXML_FUNCTION as_wide(const char* str) - { - assert(str); - - return impl::as_wide_impl(str, strlen(str)); - } - - PUGI__FN std::basic_string PUGIXML_FUNCTION as_wide(const std::string& str) - { - return impl::as_wide_impl(str.c_str(), str.size()); - } -#endif - - PUGI__FN void PUGIXML_FUNCTION set_memory_management_functions(allocation_function allocate, deallocation_function deallocate) - { - impl::xml_memory::allocate = allocate; - impl::xml_memory::deallocate = deallocate; - } - - PUGI__FN allocation_function PUGIXML_FUNCTION get_memory_allocation_function() - { - return impl::xml_memory::allocate; - } - - PUGI__FN deallocation_function PUGIXML_FUNCTION get_memory_deallocation_function() - { - return impl::xml_memory::deallocate; - } -} - -#if !defined(PUGIXML_NO_STL) && (defined(_MSC_VER) || defined(__ICC)) -namespace std -{ - // Workarounds for (non-standard) iterator category detection for older versions (MSVC7/IC8 and earlier) - PUGI__FN std::bidirectional_iterator_tag _Iter_cat(const pugi::xml_node_iterator&) - { - return std::bidirectional_iterator_tag(); - } - - PUGI__FN std::bidirectional_iterator_tag _Iter_cat(const pugi::xml_attribute_iterator&) - { - return std::bidirectional_iterator_tag(); - } - - PUGI__FN std::bidirectional_iterator_tag _Iter_cat(const pugi::xml_named_node_iterator&) - { - return std::bidirectional_iterator_tag(); - } -} -#endif - -#if !defined(PUGIXML_NO_STL) && defined(__SUNPRO_CC) -namespace std -{ - // Workarounds for (non-standard) iterator category detection - PUGI__FN std::bidirectional_iterator_tag __iterator_category(const pugi::xml_node_iterator&) - { - return std::bidirectional_iterator_tag(); - } - - PUGI__FN std::bidirectional_iterator_tag __iterator_category(const pugi::xml_attribute_iterator&) - { - return std::bidirectional_iterator_tag(); - } - - PUGI__FN std::bidirectional_iterator_tag __iterator_category(const pugi::xml_named_node_iterator&) - { - return std::bidirectional_iterator_tag(); - } -} -#endif - -#ifndef PUGIXML_NO_XPATH -// STL replacements -PUGI__NS_BEGIN - struct equal_to - { - template bool operator()(const T& lhs, const T& rhs) const - { - return lhs == rhs; - } - }; - - struct not_equal_to - { - template bool operator()(const T& lhs, const T& rhs) const - { - return lhs != rhs; - } - }; - - struct less - { - template bool operator()(const T& lhs, const T& rhs) const - { - return lhs < rhs; - } - }; - - struct less_equal - { - template bool operator()(const T& lhs, const T& rhs) const - { - return lhs <= rhs; - } - }; - - template void swap(T& lhs, T& rhs) - { - T temp = lhs; - lhs = rhs; - rhs = temp; - } - - template I min_element(I begin, I end, const Pred& pred) - { - I result = begin; - - for (I it = begin + 1; it != end; ++it) - if (pred(*it, *result)) - result = it; - - return result; - } - - template void reverse(I begin, I end) - { - while (end - begin > 1) swap(*begin++, *--end); - } - - template I unique(I begin, I end) - { - // fast skip head - while (end - begin > 1 && *begin != *(begin + 1)) begin++; - - if (begin == end) return begin; - - // last written element - I write = begin++; - - // merge unique elements - while (begin != end) - { - if (*begin != *write) - *++write = *begin++; - else - begin++; - } - - // past-the-end (write points to live element) - return write + 1; - } - - template void copy_backwards(I begin, I end, I target) - { - while (begin != end) *--target = *--end; - } - - template void insertion_sort(I begin, I end, const Pred& pred, T*) - { - assert(begin != end); - - for (I it = begin + 1; it != end; ++it) - { - T val = *it; - - if (pred(val, *begin)) - { - // move to front - copy_backwards(begin, it, it + 1); - *begin = val; - } - else - { - I hole = it; - - // move hole backwards - while (pred(val, *(hole - 1))) - { - *hole = *(hole - 1); - hole--; - } - - // fill hole with element - *hole = val; - } - } - } - - // std variant for elements with == - template void partition(I begin, I middle, I end, const Pred& pred, I* out_eqbeg, I* out_eqend) - { - I eqbeg = middle, eqend = middle + 1; - - // expand equal range - while (eqbeg != begin && *(eqbeg - 1) == *eqbeg) --eqbeg; - while (eqend != end && *eqend == *eqbeg) ++eqend; - - // process outer elements - I ltend = eqbeg, gtbeg = eqend; - - for (;;) - { - // find the element from the right side that belongs to the left one - for (; gtbeg != end; ++gtbeg) - if (!pred(*eqbeg, *gtbeg)) - { - if (*gtbeg == *eqbeg) swap(*gtbeg, *eqend++); - else break; - } - - // find the element from the left side that belongs to the right one - for (; ltend != begin; --ltend) - if (!pred(*(ltend - 1), *eqbeg)) - { - if (*eqbeg == *(ltend - 1)) swap(*(ltend - 1), *--eqbeg); - else break; - } - - // scanned all elements - if (gtbeg == end && ltend == begin) - { - *out_eqbeg = eqbeg; - *out_eqend = eqend; - return; - } - - // make room for elements by moving equal area - if (gtbeg == end) - { - if (--ltend != --eqbeg) swap(*ltend, *eqbeg); - swap(*eqbeg, *--eqend); - } - else if (ltend == begin) - { - if (eqend != gtbeg) swap(*eqbeg, *eqend); - ++eqend; - swap(*gtbeg++, *eqbeg++); - } - else swap(*gtbeg++, *--ltend); - } - } - - template void median3(I first, I middle, I last, const Pred& pred) - { - if (pred(*middle, *first)) swap(*middle, *first); - if (pred(*last, *middle)) swap(*last, *middle); - if (pred(*middle, *first)) swap(*middle, *first); - } - - template void median(I first, I middle, I last, const Pred& pred) - { - if (last - first <= 40) - { - // median of three for small chunks - median3(first, middle, last, pred); - } - else - { - // median of nine - size_t step = (last - first + 1) / 8; - - median3(first, first + step, first + 2 * step, pred); - median3(middle - step, middle, middle + step, pred); - median3(last - 2 * step, last - step, last, pred); - median3(first + step, middle, last - step, pred); - } - } - - template void sort(I begin, I end, const Pred& pred) - { - // sort large chunks - while (end - begin > 32) - { - // find median element - I middle = begin + (end - begin) / 2; - median(begin, middle, end - 1, pred); - - // partition in three chunks (< = >) - I eqbeg, eqend; - partition(begin, middle, end, pred, &eqbeg, &eqend); - - // loop on larger half - if (eqbeg - begin > end - eqend) - { - sort(eqend, end, pred); - end = eqbeg; - } - else - { - sort(begin, eqbeg, pred); - begin = eqend; - } - } - - // insertion sort small chunk - if (begin != end) insertion_sort(begin, end, pred, &*begin); - } -PUGI__NS_END - -// Allocator used for AST and evaluation stacks -PUGI__NS_BEGIN - struct xpath_memory_block - { - xpath_memory_block* next; - size_t capacity; - - char data[ - #ifdef PUGIXML_MEMORY_XPATH_PAGE_SIZE - PUGIXML_MEMORY_XPATH_PAGE_SIZE - #else - 4096 - #endif - ]; - }; - - class xpath_allocator - { - xpath_memory_block* _root; - size_t _root_size; - - public: - #ifdef PUGIXML_NO_EXCEPTIONS - jmp_buf* error_handler; - #endif - - xpath_allocator(xpath_memory_block* root, size_t root_size = 0): _root(root), _root_size(root_size) - { - #ifdef PUGIXML_NO_EXCEPTIONS - error_handler = 0; - #endif - } - - void* allocate_nothrow(size_t size) - { - // align size so that we're able to store pointers in subsequent blocks - size = (size + sizeof(void*) - 1) & ~(sizeof(void*) - 1); - - if (_root_size + size <= _root->capacity) - { - void* buf = _root->data + _root_size; - _root_size += size; - return buf; - } - else - { - // make sure we have at least 1/4th of the page free after allocation to satisfy subsequent allocation requests - size_t block_capacity_base = sizeof(_root->data); - size_t block_capacity_req = size + block_capacity_base / 4; - size_t block_capacity = (block_capacity_base > block_capacity_req) ? block_capacity_base : block_capacity_req; - - size_t block_size = block_capacity + offsetof(xpath_memory_block, data); - - xpath_memory_block* block = static_cast(xml_memory::allocate(block_size)); - if (!block) return 0; - - block->next = _root; - block->capacity = block_capacity; - - _root = block; - _root_size = size; - - return block->data; - } - } - - void* allocate(size_t size) - { - void* result = allocate_nothrow(size); - - if (!result) - { - #ifdef PUGIXML_NO_EXCEPTIONS - assert(error_handler); - longjmp(*error_handler, 1); - #else - throw std::bad_alloc(); - #endif - } - - return result; - } - - void* reallocate(void* ptr, size_t old_size, size_t new_size) - { - // align size so that we're able to store pointers in subsequent blocks - old_size = (old_size + sizeof(void*) - 1) & ~(sizeof(void*) - 1); - new_size = (new_size + sizeof(void*) - 1) & ~(sizeof(void*) - 1); - - // we can only reallocate the last object - assert(ptr == 0 || static_cast(ptr) + old_size == _root->data + _root_size); - - // adjust root size so that we have not allocated the object at all - bool only_object = (_root_size == old_size); - - if (ptr) _root_size -= old_size; - - // allocate a new version (this will obviously reuse the memory if possible) - void* result = allocate(new_size); - assert(result); - - // we have a new block - if (result != ptr && ptr) - { - // copy old data - assert(new_size >= old_size); - memcpy(result, ptr, old_size); - - // free the previous page if it had no other objects - if (only_object) - { - assert(_root->data == result); - assert(_root->next); - - xpath_memory_block* next = _root->next->next; - - if (next) - { - // deallocate the whole page, unless it was the first one - xml_memory::deallocate(_root->next); - _root->next = next; - } - } - } - - return result; - } - - void revert(const xpath_allocator& state) - { - // free all new pages - xpath_memory_block* cur = _root; - - while (cur != state._root) - { - xpath_memory_block* next = cur->next; - - xml_memory::deallocate(cur); - - cur = next; - } - - // restore state - _root = state._root; - _root_size = state._root_size; - } - - void release() - { - xpath_memory_block* cur = _root; - assert(cur); - - while (cur->next) - { - xpath_memory_block* next = cur->next; - - xml_memory::deallocate(cur); - - cur = next; - } - } - }; - - struct xpath_allocator_capture - { - xpath_allocator_capture(xpath_allocator* alloc): _target(alloc), _state(*alloc) - { - } - - ~xpath_allocator_capture() - { - _target->revert(_state); - } - - xpath_allocator* _target; - xpath_allocator _state; - }; - - struct xpath_stack - { - xpath_allocator* result; - xpath_allocator* temp; - }; - - struct xpath_stack_data - { - xpath_memory_block blocks[2]; - xpath_allocator result; - xpath_allocator temp; - xpath_stack stack; - - #ifdef PUGIXML_NO_EXCEPTIONS - jmp_buf error_handler; - #endif - - xpath_stack_data(): result(blocks + 0), temp(blocks + 1) - { - blocks[0].next = blocks[1].next = 0; - blocks[0].capacity = blocks[1].capacity = sizeof(blocks[0].data); - - stack.result = &result; - stack.temp = &temp; - - #ifdef PUGIXML_NO_EXCEPTIONS - result.error_handler = temp.error_handler = &error_handler; - #endif - } - - ~xpath_stack_data() - { - result.release(); - temp.release(); - } - }; -PUGI__NS_END - -// String class -PUGI__NS_BEGIN - class xpath_string - { - const char_t* _buffer; - bool _uses_heap; - size_t _length_heap; - - static char_t* duplicate_string(const char_t* string, size_t length, xpath_allocator* alloc) - { - char_t* result = static_cast(alloc->allocate((length + 1) * sizeof(char_t))); - assert(result); - - memcpy(result, string, length * sizeof(char_t)); - result[length] = 0; - - return result; - } - - xpath_string(const char_t* buffer, bool uses_heap_, size_t length_heap): _buffer(buffer), _uses_heap(uses_heap_), _length_heap(length_heap) - { - } - - public: - static xpath_string from_const(const char_t* str) - { - return xpath_string(str, false, 0); - } - - static xpath_string from_heap_preallocated(const char_t* begin, const char_t* end) - { - assert(begin <= end && *end == 0); - - return xpath_string(begin, true, static_cast(end - begin)); - } - - static xpath_string from_heap(const char_t* begin, const char_t* end, xpath_allocator* alloc) - { - assert(begin <= end); - - size_t length = static_cast(end - begin); - - return length == 0 ? xpath_string() : xpath_string(duplicate_string(begin, length, alloc), true, length); - } - - xpath_string(): _buffer(PUGIXML_TEXT("")), _uses_heap(false), _length_heap(0) - { - } - - void append(const xpath_string& o, xpath_allocator* alloc) - { - // skip empty sources - if (!*o._buffer) return; - - // fast append for constant empty target and constant source - if (!*_buffer && !_uses_heap && !o._uses_heap) - { - _buffer = o._buffer; - } - else - { - // need to make heap copy - size_t target_length = length(); - size_t source_length = o.length(); - size_t result_length = target_length + source_length; - - // allocate new buffer - char_t* result = static_cast(alloc->reallocate(_uses_heap ? const_cast(_buffer) : 0, (target_length + 1) * sizeof(char_t), (result_length + 1) * sizeof(char_t))); - assert(result); - - // append first string to the new buffer in case there was no reallocation - if (!_uses_heap) memcpy(result, _buffer, target_length * sizeof(char_t)); - - // append second string to the new buffer - memcpy(result + target_length, o._buffer, source_length * sizeof(char_t)); - result[result_length] = 0; - - // finalize - _buffer = result; - _uses_heap = true; - _length_heap = result_length; - } - } - - const char_t* c_str() const - { - return _buffer; - } - - size_t length() const - { - return _uses_heap ? _length_heap : strlength(_buffer); - } - - char_t* data(xpath_allocator* alloc) - { - // make private heap copy - if (!_uses_heap) - { - size_t length_ = strlength(_buffer); - - _buffer = duplicate_string(_buffer, length_, alloc); - _uses_heap = true; - _length_heap = length_; - } - - return const_cast(_buffer); - } - - bool empty() const - { - return *_buffer == 0; - } - - bool operator==(const xpath_string& o) const - { - return strequal(_buffer, o._buffer); - } - - bool operator!=(const xpath_string& o) const - { - return !strequal(_buffer, o._buffer); - } - - bool uses_heap() const - { - return _uses_heap; - } - }; -PUGI__NS_END - -PUGI__NS_BEGIN - PUGI__FN bool starts_with(const char_t* string, const char_t* pattern) - { - while (*pattern && *string == *pattern) - { - string++; - pattern++; - } - - return *pattern == 0; - } - - PUGI__FN const char_t* find_char(const char_t* s, char_t c) - { - #ifdef PUGIXML_WCHAR_MODE - return wcschr(s, c); - #else - return strchr(s, c); - #endif - } - - PUGI__FN const char_t* find_substring(const char_t* s, const char_t* p) - { - #ifdef PUGIXML_WCHAR_MODE - // MSVC6 wcsstr bug workaround (if s is empty it always returns 0) - return (*p == 0) ? s : wcsstr(s, p); - #else - return strstr(s, p); - #endif - } - - // Converts symbol to lower case, if it is an ASCII one - PUGI__FN char_t tolower_ascii(char_t ch) - { - return static_cast(ch - 'A') < 26 ? static_cast(ch | ' ') : ch; - } - - PUGI__FN xpath_string string_value(const xpath_node& na, xpath_allocator* alloc) - { - if (na.attribute()) - return xpath_string::from_const(na.attribute().value()); - else - { - xml_node n = na.node(); - - switch (n.type()) - { - case node_pcdata: - case node_cdata: - case node_comment: - case node_pi: - return xpath_string::from_const(n.value()); - - case node_document: - case node_element: - { - xpath_string result; - - xml_node cur = n.first_child(); - - while (cur && cur != n) - { - if (cur.type() == node_pcdata || cur.type() == node_cdata) - result.append(xpath_string::from_const(cur.value()), alloc); - - if (cur.first_child()) - cur = cur.first_child(); - else if (cur.next_sibling()) - cur = cur.next_sibling(); - else - { - while (!cur.next_sibling() && cur != n) - cur = cur.parent(); - - if (cur != n) cur = cur.next_sibling(); - } - } - - return result; - } - - default: - return xpath_string(); - } - } - } - - PUGI__FN bool node_is_before_sibling(xml_node_struct* ln, xml_node_struct* rn) - { - assert(ln->parent == rn->parent); - - // there is no common ancestor (the shared parent is null), nodes are from different documents - if (!ln->parent) return ln < rn; - - // determine sibling order - xml_node_struct* ls = ln; - xml_node_struct* rs = rn; - - while (ls && rs) - { - if (ls == rn) return true; - if (rs == ln) return false; - - ls = ls->next_sibling; - rs = rs->next_sibling; - } - - // if rn sibling chain ended ln must be before rn - return !rs; - } - - PUGI__FN bool node_is_before(xml_node_struct* ln, xml_node_struct* rn) - { - // find common ancestor at the same depth, if any - xml_node_struct* lp = ln; - xml_node_struct* rp = rn; - - while (lp && rp && lp->parent != rp->parent) - { - lp = lp->parent; - rp = rp->parent; - } - - // parents are the same! - if (lp && rp) return node_is_before_sibling(lp, rp); - - // nodes are at different depths, need to normalize heights - bool left_higher = !lp; - - while (lp) - { - lp = lp->parent; - ln = ln->parent; - } - - while (rp) - { - rp = rp->parent; - rn = rn->parent; - } - - // one node is the ancestor of the other - if (ln == rn) return left_higher; - - // find common ancestor... again - while (ln->parent != rn->parent) - { - ln = ln->parent; - rn = rn->parent; - } - - return node_is_before_sibling(ln, rn); - } - - PUGI__FN bool node_is_ancestor(xml_node_struct* parent, xml_node_struct* node) - { - while (node && node != parent) node = node->parent; - - return parent && node == parent; - } - - PUGI__FN const void* document_buffer_order(const xpath_node& xnode) - { - xml_node_struct* node = xnode.node().internal_object(); - - if (node) - { - if ((get_document(node).header & xml_memory_page_contents_shared_mask) == 0) - { - if (node->name && (node->header & impl::xml_memory_page_name_allocated_or_shared_mask) == 0) return node->name; - if (node->value && (node->header & impl::xml_memory_page_value_allocated_or_shared_mask) == 0) return node->value; - } - - return 0; - } - - xml_attribute_struct* attr = xnode.attribute().internal_object(); - - if (attr) - { - if ((get_document(attr).header & xml_memory_page_contents_shared_mask) == 0) - { - if ((attr->header & impl::xml_memory_page_name_allocated_or_shared_mask) == 0) return attr->name; - if ((attr->header & impl::xml_memory_page_value_allocated_or_shared_mask) == 0) return attr->value; - } - - return 0; - } - - return 0; - } - - struct document_order_comparator - { - bool operator()(const xpath_node& lhs, const xpath_node& rhs) const - { - // optimized document order based check - const void* lo = document_buffer_order(lhs); - const void* ro = document_buffer_order(rhs); - - if (lo && ro) return lo < ro; - - // slow comparison - xml_node ln = lhs.node(), rn = rhs.node(); - - // compare attributes - if (lhs.attribute() && rhs.attribute()) - { - // shared parent - if (lhs.parent() == rhs.parent()) - { - // determine sibling order - for (xml_attribute a = lhs.attribute(); a; a = a.next_attribute()) - if (a == rhs.attribute()) - return true; - - return false; - } - - // compare attribute parents - ln = lhs.parent(); - rn = rhs.parent(); - } - else if (lhs.attribute()) - { - // attributes go after the parent element - if (lhs.parent() == rhs.node()) return false; - - ln = lhs.parent(); - } - else if (rhs.attribute()) - { - // attributes go after the parent element - if (rhs.parent() == lhs.node()) return true; - - rn = rhs.parent(); - } - - if (ln == rn) return false; - - if (!ln || !rn) return ln < rn; - - return node_is_before(ln.internal_object(), rn.internal_object()); - } - }; - - struct duplicate_comparator - { - bool operator()(const xpath_node& lhs, const xpath_node& rhs) const - { - if (lhs.attribute()) return rhs.attribute() ? lhs.attribute() < rhs.attribute() : true; - else return rhs.attribute() ? false : lhs.node() < rhs.node(); - } - }; - - PUGI__FN double gen_nan() - { - #if defined(__STDC_IEC_559__) || ((FLT_RADIX - 0 == 2) && (FLT_MAX_EXP - 0 == 128) && (FLT_MANT_DIG - 0 == 24)) - union { float f; uint32_t i; } u[sizeof(float) == sizeof(uint32_t) ? 1 : -1]; - u[0].i = 0x7fc00000; - return u[0].f; - #else - // fallback - const volatile double zero = 0.0; - return zero / zero; - #endif - } - - PUGI__FN bool is_nan(double value) - { - #if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__) - return !!_isnan(value); - #elif defined(fpclassify) && defined(FP_NAN) - return fpclassify(value) == FP_NAN; - #else - // fallback - const volatile double v = value; - return v != v; - #endif - } - - PUGI__FN const char_t* convert_number_to_string_special(double value) - { - #if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__) - if (_finite(value)) return (value == 0) ? PUGIXML_TEXT("0") : 0; - if (_isnan(value)) return PUGIXML_TEXT("NaN"); - return value > 0 ? PUGIXML_TEXT("Infinity") : PUGIXML_TEXT("-Infinity"); - #elif defined(fpclassify) && defined(FP_NAN) && defined(FP_INFINITE) && defined(FP_ZERO) - switch (fpclassify(value)) - { - case FP_NAN: - return PUGIXML_TEXT("NaN"); - - case FP_INFINITE: - return value > 0 ? PUGIXML_TEXT("Infinity") : PUGIXML_TEXT("-Infinity"); - - case FP_ZERO: - return PUGIXML_TEXT("0"); - - default: - return 0; - } - #else - // fallback - const volatile double v = value; - - if (v == 0) return PUGIXML_TEXT("0"); - if (v != v) return PUGIXML_TEXT("NaN"); - if (v * 2 == v) return value > 0 ? PUGIXML_TEXT("Infinity") : PUGIXML_TEXT("-Infinity"); - return 0; - #endif - } - - PUGI__FN bool convert_number_to_boolean(double value) - { - return (value != 0 && !is_nan(value)); - } - - PUGI__FN void truncate_zeros(char* begin, char* end) - { - while (begin != end && end[-1] == '0') end--; - - *end = 0; - } - - // gets mantissa digits in the form of 0.xxxxx with 0. implied and the exponent -#if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400 && !defined(_WIN32_WCE) - PUGI__FN void convert_number_to_mantissa_exponent(double value, char* buffer, size_t buffer_size, char** out_mantissa, int* out_exponent) - { - // get base values - int sign, exponent; - _ecvt_s(buffer, buffer_size, value, DBL_DIG + 1, &exponent, &sign); - - // truncate redundant zeros - truncate_zeros(buffer, buffer + strlen(buffer)); - - // fill results - *out_mantissa = buffer; - *out_exponent = exponent; - } -#else - PUGI__FN void convert_number_to_mantissa_exponent(double value, char* buffer, size_t buffer_size, char** out_mantissa, int* out_exponent) - { - // get a scientific notation value with IEEE DBL_DIG decimals - sprintf(buffer, "%.*e", DBL_DIG, value); - assert(strlen(buffer) < buffer_size); - (void)!buffer_size; - - // get the exponent (possibly negative) - char* exponent_string = strchr(buffer, 'e'); - assert(exponent_string); - - int exponent = atoi(exponent_string + 1); - - // extract mantissa string: skip sign - char* mantissa = buffer[0] == '-' ? buffer + 1 : buffer; - assert(mantissa[0] != '0' && mantissa[1] == '.'); - - // divide mantissa by 10 to eliminate integer part - mantissa[1] = mantissa[0]; - mantissa++; - exponent++; - - // remove extra mantissa digits and zero-terminate mantissa - truncate_zeros(mantissa, exponent_string); - - // fill results - *out_mantissa = mantissa; - *out_exponent = exponent; - } -#endif - - PUGI__FN xpath_string convert_number_to_string(double value, xpath_allocator* alloc) - { - // try special number conversion - const char_t* special = convert_number_to_string_special(value); - if (special) return xpath_string::from_const(special); - - // get mantissa + exponent form - char mantissa_buffer[32]; - - char* mantissa; - int exponent; - convert_number_to_mantissa_exponent(value, mantissa_buffer, sizeof(mantissa_buffer), &mantissa, &exponent); - - // allocate a buffer of suitable length for the number - size_t result_size = strlen(mantissa_buffer) + (exponent > 0 ? exponent : -exponent) + 4; - char_t* result = static_cast(alloc->allocate(sizeof(char_t) * result_size)); - assert(result); - - // make the number! - char_t* s = result; - - // sign - if (value < 0) *s++ = '-'; - - // integer part - if (exponent <= 0) - { - *s++ = '0'; - } - else - { - while (exponent > 0) - { - assert(*mantissa == 0 || static_cast(static_cast(*mantissa) - '0') <= 9); - *s++ = *mantissa ? *mantissa++ : '0'; - exponent--; - } - } - - // fractional part - if (*mantissa) - { - // decimal point - *s++ = '.'; - - // extra zeroes from negative exponent - while (exponent < 0) - { - *s++ = '0'; - exponent++; - } - - // extra mantissa digits - while (*mantissa) - { - assert(static_cast(*mantissa - '0') <= 9); - *s++ = *mantissa++; - } - } - - // zero-terminate - assert(s < result + result_size); - *s = 0; - - return xpath_string::from_heap_preallocated(result, s); - } - - PUGI__FN bool check_string_to_number_format(const char_t* string) - { - // parse leading whitespace - while (PUGI__IS_CHARTYPE(*string, ct_space)) ++string; - - // parse sign - if (*string == '-') ++string; - - if (!*string) return false; - - // if there is no integer part, there should be a decimal part with at least one digit - if (!PUGI__IS_CHARTYPEX(string[0], ctx_digit) && (string[0] != '.' || !PUGI__IS_CHARTYPEX(string[1], ctx_digit))) return false; - - // parse integer part - while (PUGI__IS_CHARTYPEX(*string, ctx_digit)) ++string; - - // parse decimal part - if (*string == '.') - { - ++string; - - while (PUGI__IS_CHARTYPEX(*string, ctx_digit)) ++string; - } - - // parse trailing whitespace - while (PUGI__IS_CHARTYPE(*string, ct_space)) ++string; - - return *string == 0; - } - - PUGI__FN double convert_string_to_number(const char_t* string) - { - // check string format - if (!check_string_to_number_format(string)) return gen_nan(); - - // parse string - #ifdef PUGIXML_WCHAR_MODE - return wcstod(string, 0); - #else - return atof(string); - #endif - } - - PUGI__FN bool convert_string_to_number_scratch(char_t (&buffer)[32], const char_t* begin, const char_t* end, double* out_result) - { - size_t length = static_cast(end - begin); - char_t* scratch = buffer; - - if (length >= sizeof(buffer) / sizeof(buffer[0])) - { - // need to make dummy on-heap copy - scratch = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); - if (!scratch) return false; - } - - // copy string to zero-terminated buffer and perform conversion - memcpy(scratch, begin, length * sizeof(char_t)); - scratch[length] = 0; - - *out_result = convert_string_to_number(scratch); - - // free dummy buffer - if (scratch != buffer) xml_memory::deallocate(scratch); - - return true; - } - - PUGI__FN double round_nearest(double value) - { - return floor(value + 0.5); - } - - PUGI__FN double round_nearest_nzero(double value) - { - // same as round_nearest, but returns -0 for [-0.5, -0] - // ceil is used to differentiate between +0 and -0 (we return -0 for [-0.5, -0] and +0 for +0) - return (value >= -0.5 && value <= 0) ? ceil(value) : floor(value + 0.5); - } - - PUGI__FN const char_t* qualified_name(const xpath_node& node) - { - return node.attribute() ? node.attribute().name() : node.node().name(); - } - - PUGI__FN const char_t* local_name(const xpath_node& node) - { - const char_t* name = qualified_name(node); - const char_t* p = find_char(name, ':'); - - return p ? p + 1 : name; - } - - struct namespace_uri_predicate - { - const char_t* prefix; - size_t prefix_length; - - namespace_uri_predicate(const char_t* name) - { - const char_t* pos = find_char(name, ':'); - - prefix = pos ? name : 0; - prefix_length = pos ? static_cast(pos - name) : 0; - } - - bool operator()(xml_attribute a) const - { - const char_t* name = a.name(); - - if (!starts_with(name, PUGIXML_TEXT("xmlns"))) return false; - - return prefix ? name[5] == ':' && strequalrange(name + 6, prefix, prefix_length) : name[5] == 0; - } - }; - - PUGI__FN const char_t* namespace_uri(xml_node node) - { - namespace_uri_predicate pred = node.name(); - - xml_node p = node; - - while (p) - { - xml_attribute a = p.find_attribute(pred); - - if (a) return a.value(); - - p = p.parent(); - } - - return PUGIXML_TEXT(""); - } - - PUGI__FN const char_t* namespace_uri(xml_attribute attr, xml_node parent) - { - namespace_uri_predicate pred = attr.name(); - - // Default namespace does not apply to attributes - if (!pred.prefix) return PUGIXML_TEXT(""); - - xml_node p = parent; - - while (p) - { - xml_attribute a = p.find_attribute(pred); - - if (a) return a.value(); - - p = p.parent(); - } - - return PUGIXML_TEXT(""); - } - - PUGI__FN const char_t* namespace_uri(const xpath_node& node) - { - return node.attribute() ? namespace_uri(node.attribute(), node.parent()) : namespace_uri(node.node()); - } - - PUGI__FN void normalize_space(char_t* buffer) - { - char_t* write = buffer; - - for (char_t* it = buffer; *it; ) - { - char_t ch = *it++; - - if (PUGI__IS_CHARTYPE(ch, ct_space)) - { - // replace whitespace sequence with single space - while (PUGI__IS_CHARTYPE(*it, ct_space)) it++; - - // avoid leading spaces - if (write != buffer) *write++ = ' '; - } - else *write++ = ch; - } - - // remove trailing space - if (write != buffer && PUGI__IS_CHARTYPE(write[-1], ct_space)) write--; - - // zero-terminate - *write = 0; - } - - PUGI__FN void translate(char_t* buffer, const char_t* from, const char_t* to, size_t to_length) - { - char_t* write = buffer; - - while (*buffer) - { - PUGI__DMC_VOLATILE char_t ch = *buffer++; - - const char_t* pos = find_char(from, ch); - - if (!pos) - *write++ = ch; // do not process - else if (static_cast(pos - from) < to_length) - *write++ = to[pos - from]; // replace - } - - // zero-terminate - *write = 0; - } - - PUGI__FN unsigned char* translate_table_generate(xpath_allocator* alloc, const char_t* from, const char_t* to) - { - unsigned char table[128] = {0}; - - while (*from) - { - unsigned int fc = static_cast(*from); - unsigned int tc = static_cast(*to); - - if (fc >= 128 || tc >= 128) - return 0; - - // code=128 means "skip character" - if (!table[fc]) - table[fc] = static_cast(tc ? tc : 128); - - from++; - if (tc) to++; - } - - for (int i = 0; i < 128; ++i) - if (!table[i]) - table[i] = static_cast(i); - - void* result = alloc->allocate_nothrow(sizeof(table)); - - if (result) - { - memcpy(result, table, sizeof(table)); - } - - return static_cast(result); - } - - PUGI__FN void translate_table(char_t* buffer, const unsigned char* table) - { - char_t* write = buffer; - - while (*buffer) - { - char_t ch = *buffer++; - unsigned int index = static_cast(ch); - - if (index < 128) - { - unsigned char code = table[index]; - - // code=128 means "skip character" (table size is 128 so 128 can be a special value) - // this code skips these characters without extra branches - *write = static_cast(code); - write += 1 - (code >> 7); - } - else - { - *write++ = ch; - } - } - - // zero-terminate - *write = 0; - } - - inline bool is_xpath_attribute(const char_t* name) - { - return !(starts_with(name, PUGIXML_TEXT("xmlns")) && (name[5] == 0 || name[5] == ':')); - } - - struct xpath_variable_boolean: xpath_variable - { - xpath_variable_boolean(): value(false) - { - } - - bool value; - char_t name[1]; - }; - - struct xpath_variable_number: xpath_variable - { - xpath_variable_number(): value(0) - { - } - - double value; - char_t name[1]; - }; - - struct xpath_variable_string: xpath_variable - { - xpath_variable_string(): value(0) - { - } - - ~xpath_variable_string() - { - if (value) xml_memory::deallocate(value); - } - - char_t* value; - char_t name[1]; - }; - - struct xpath_variable_node_set: xpath_variable - { - xpath_node_set value; - char_t name[1]; - }; - - static const xpath_node_set dummy_node_set; - - PUGI__FN unsigned int hash_string(const char_t* str) - { - // Jenkins one-at-a-time hash (http://en.wikipedia.org/wiki/Jenkins_hash_function#one-at-a-time) - unsigned int result = 0; - - while (*str) - { - result += static_cast(*str++); - result += result << 10; - result ^= result >> 6; - } - - result += result << 3; - result ^= result >> 11; - result += result << 15; - - return result; - } - - template PUGI__FN T* new_xpath_variable(const char_t* name) - { - size_t length = strlength(name); - if (length == 0) return 0; // empty variable names are invalid - - // $$ we can't use offsetof(T, name) because T is non-POD, so we just allocate additional length characters - void* memory = xml_memory::allocate(sizeof(T) + length * sizeof(char_t)); - if (!memory) return 0; - - T* result = new (memory) T(); - - memcpy(result->name, name, (length + 1) * sizeof(char_t)); - - return result; - } - - PUGI__FN xpath_variable* new_xpath_variable(xpath_value_type type, const char_t* name) - { - switch (type) - { - case xpath_type_node_set: - return new_xpath_variable(name); - - case xpath_type_number: - return new_xpath_variable(name); - - case xpath_type_string: - return new_xpath_variable(name); - - case xpath_type_boolean: - return new_xpath_variable(name); - - default: - return 0; - } - } - - template PUGI__FN void delete_xpath_variable(T* var) - { - var->~T(); - xml_memory::deallocate(var); - } - - PUGI__FN void delete_xpath_variable(xpath_value_type type, xpath_variable* var) - { - switch (type) - { - case xpath_type_node_set: - delete_xpath_variable(static_cast(var)); - break; - - case xpath_type_number: - delete_xpath_variable(static_cast(var)); - break; - - case xpath_type_string: - delete_xpath_variable(static_cast(var)); - break; - - case xpath_type_boolean: - delete_xpath_variable(static_cast(var)); - break; - - default: - assert(!"Invalid variable type"); - } - } - - PUGI__FN xpath_variable* get_variable_scratch(char_t (&buffer)[32], xpath_variable_set* set, const char_t* begin, const char_t* end) - { - size_t length = static_cast(end - begin); - char_t* scratch = buffer; - - if (length >= sizeof(buffer) / sizeof(buffer[0])) - { - // need to make dummy on-heap copy - scratch = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); - if (!scratch) return 0; - } - - // copy string to zero-terminated buffer and perform lookup - memcpy(scratch, begin, length * sizeof(char_t)); - scratch[length] = 0; - - xpath_variable* result = set->get(scratch); - - // free dummy buffer - if (scratch != buffer) xml_memory::deallocate(scratch); - - return result; - } -PUGI__NS_END - -// Internal node set class -PUGI__NS_BEGIN - PUGI__FN xpath_node_set::type_t xpath_get_order(const xpath_node* begin, const xpath_node* end) - { - if (end - begin < 2) - return xpath_node_set::type_sorted; - - document_order_comparator cmp; - - bool first = cmp(begin[0], begin[1]); - - for (const xpath_node* it = begin + 1; it + 1 < end; ++it) - if (cmp(it[0], it[1]) != first) - return xpath_node_set::type_unsorted; - - return first ? xpath_node_set::type_sorted : xpath_node_set::type_sorted_reverse; - } - - PUGI__FN xpath_node_set::type_t xpath_sort(xpath_node* begin, xpath_node* end, xpath_node_set::type_t type, bool rev) - { - xpath_node_set::type_t order = rev ? xpath_node_set::type_sorted_reverse : xpath_node_set::type_sorted; - - if (type == xpath_node_set::type_unsorted) - { - xpath_node_set::type_t sorted = xpath_get_order(begin, end); - - if (sorted == xpath_node_set::type_unsorted) - { - sort(begin, end, document_order_comparator()); - - type = xpath_node_set::type_sorted; - } - else - type = sorted; - } - - if (type != order) reverse(begin, end); - - return order; - } - - PUGI__FN xpath_node xpath_first(const xpath_node* begin, const xpath_node* end, xpath_node_set::type_t type) - { - if (begin == end) return xpath_node(); - - switch (type) - { - case xpath_node_set::type_sorted: - return *begin; - - case xpath_node_set::type_sorted_reverse: - return *(end - 1); - - case xpath_node_set::type_unsorted: - return *min_element(begin, end, document_order_comparator()); - - default: - assert(!"Invalid node set type"); - return xpath_node(); - } - } - - class xpath_node_set_raw - { - xpath_node_set::type_t _type; - - xpath_node* _begin; - xpath_node* _end; - xpath_node* _eos; - - public: - xpath_node_set_raw(): _type(xpath_node_set::type_unsorted), _begin(0), _end(0), _eos(0) - { - } - - xpath_node* begin() const - { - return _begin; - } - - xpath_node* end() const - { - return _end; - } - - bool empty() const - { - return _begin == _end; - } - - size_t size() const - { - return static_cast(_end - _begin); - } - - xpath_node first() const - { - return xpath_first(_begin, _end, _type); - } - - void push_back_grow(const xpath_node& node, xpath_allocator* alloc); - - void push_back(const xpath_node& node, xpath_allocator* alloc) - { - if (_end != _eos) - *_end++ = node; - else - push_back_grow(node, alloc); - } - - void append(const xpath_node* begin_, const xpath_node* end_, xpath_allocator* alloc) - { - if (begin_ == end_) return; - - size_t size_ = static_cast(_end - _begin); - size_t capacity = static_cast(_eos - _begin); - size_t count = static_cast(end_ - begin_); - - if (size_ + count > capacity) - { - // reallocate the old array or allocate a new one - xpath_node* data = static_cast(alloc->reallocate(_begin, capacity * sizeof(xpath_node), (size_ + count) * sizeof(xpath_node))); - assert(data); - - // finalize - _begin = data; - _end = data + size_; - _eos = data + size_ + count; - } - - memcpy(_end, begin_, count * sizeof(xpath_node)); - _end += count; - } - - void sort_do() - { - _type = xpath_sort(_begin, _end, _type, false); - } - - void truncate(xpath_node* pos) - { - assert(_begin <= pos && pos <= _end); - - _end = pos; - } - - void remove_duplicates() - { - if (_type == xpath_node_set::type_unsorted) - sort(_begin, _end, duplicate_comparator()); - - _end = unique(_begin, _end); - } - - xpath_node_set::type_t type() const - { - return _type; - } - - void set_type(xpath_node_set::type_t value) - { - _type = value; - } - }; - - PUGI__FN_NO_INLINE void xpath_node_set_raw::push_back_grow(const xpath_node& node, xpath_allocator* alloc) - { - size_t capacity = static_cast(_eos - _begin); - - // get new capacity (1.5x rule) - size_t new_capacity = capacity + capacity / 2 + 1; - - // reallocate the old array or allocate a new one - xpath_node* data = static_cast(alloc->reallocate(_begin, capacity * sizeof(xpath_node), new_capacity * sizeof(xpath_node))); - assert(data); - - // finalize - _begin = data; - _end = data + capacity; - _eos = data + new_capacity; - - // push - *_end++ = node; - } -PUGI__NS_END - -PUGI__NS_BEGIN - struct xpath_context - { - xpath_node n; - size_t position, size; - - xpath_context(const xpath_node& n_, size_t position_, size_t size_): n(n_), position(position_), size(size_) - { - } - }; - - enum lexeme_t - { - lex_none = 0, - lex_equal, - lex_not_equal, - lex_less, - lex_greater, - lex_less_or_equal, - lex_greater_or_equal, - lex_plus, - lex_minus, - lex_multiply, - lex_union, - lex_var_ref, - lex_open_brace, - lex_close_brace, - lex_quoted_string, - lex_number, - lex_slash, - lex_double_slash, - lex_open_square_brace, - lex_close_square_brace, - lex_string, - lex_comma, - lex_axis_attribute, - lex_dot, - lex_double_dot, - lex_double_colon, - lex_eof - }; - - struct xpath_lexer_string - { - const char_t* begin; - const char_t* end; - - xpath_lexer_string(): begin(0), end(0) - { - } - - bool operator==(const char_t* other) const - { - size_t length = static_cast(end - begin); - - return strequalrange(other, begin, length); - } - }; - - class xpath_lexer - { - const char_t* _cur; - const char_t* _cur_lexeme_pos; - xpath_lexer_string _cur_lexeme_contents; - - lexeme_t _cur_lexeme; - - public: - explicit xpath_lexer(const char_t* query): _cur(query) - { - next(); - } - - const char_t* state() const - { - return _cur; - } - - void next() - { - const char_t* cur = _cur; - - while (PUGI__IS_CHARTYPE(*cur, ct_space)) ++cur; - - // save lexeme position for error reporting - _cur_lexeme_pos = cur; - - switch (*cur) - { - case 0: - _cur_lexeme = lex_eof; - break; - - case '>': - if (*(cur+1) == '=') - { - cur += 2; - _cur_lexeme = lex_greater_or_equal; - } - else - { - cur += 1; - _cur_lexeme = lex_greater; - } - break; - - case '<': - if (*(cur+1) == '=') - { - cur += 2; - _cur_lexeme = lex_less_or_equal; - } - else - { - cur += 1; - _cur_lexeme = lex_less; - } - break; - - case '!': - if (*(cur+1) == '=') - { - cur += 2; - _cur_lexeme = lex_not_equal; - } - else - { - _cur_lexeme = lex_none; - } - break; - - case '=': - cur += 1; - _cur_lexeme = lex_equal; - - break; - - case '+': - cur += 1; - _cur_lexeme = lex_plus; - - break; - - case '-': - cur += 1; - _cur_lexeme = lex_minus; - - break; - - case '*': - cur += 1; - _cur_lexeme = lex_multiply; - - break; - - case '|': - cur += 1; - _cur_lexeme = lex_union; - - break; - - case '$': - cur += 1; - - if (PUGI__IS_CHARTYPEX(*cur, ctx_start_symbol)) - { - _cur_lexeme_contents.begin = cur; - - while (PUGI__IS_CHARTYPEX(*cur, ctx_symbol)) cur++; - - if (cur[0] == ':' && PUGI__IS_CHARTYPEX(cur[1], ctx_symbol)) // qname - { - cur++; // : - - while (PUGI__IS_CHARTYPEX(*cur, ctx_symbol)) cur++; - } - - _cur_lexeme_contents.end = cur; - - _cur_lexeme = lex_var_ref; - } - else - { - _cur_lexeme = lex_none; - } - - break; - - case '(': - cur += 1; - _cur_lexeme = lex_open_brace; - - break; - - case ')': - cur += 1; - _cur_lexeme = lex_close_brace; - - break; - - case '[': - cur += 1; - _cur_lexeme = lex_open_square_brace; - - break; - - case ']': - cur += 1; - _cur_lexeme = lex_close_square_brace; - - break; - - case ',': - cur += 1; - _cur_lexeme = lex_comma; - - break; - - case '/': - if (*(cur+1) == '/') - { - cur += 2; - _cur_lexeme = lex_double_slash; - } - else - { - cur += 1; - _cur_lexeme = lex_slash; - } - break; - - case '.': - if (*(cur+1) == '.') - { - cur += 2; - _cur_lexeme = lex_double_dot; - } - else if (PUGI__IS_CHARTYPEX(*(cur+1), ctx_digit)) - { - _cur_lexeme_contents.begin = cur; // . - - ++cur; - - while (PUGI__IS_CHARTYPEX(*cur, ctx_digit)) cur++; - - _cur_lexeme_contents.end = cur; - - _cur_lexeme = lex_number; - } - else - { - cur += 1; - _cur_lexeme = lex_dot; - } - break; - - case '@': - cur += 1; - _cur_lexeme = lex_axis_attribute; - - break; - - case '"': - case '\'': - { - char_t terminator = *cur; - - ++cur; - - _cur_lexeme_contents.begin = cur; - while (*cur && *cur != terminator) cur++; - _cur_lexeme_contents.end = cur; - - if (!*cur) - _cur_lexeme = lex_none; - else - { - cur += 1; - _cur_lexeme = lex_quoted_string; - } - - break; - } - - case ':': - if (*(cur+1) == ':') - { - cur += 2; - _cur_lexeme = lex_double_colon; - } - else - { - _cur_lexeme = lex_none; - } - break; - - default: - if (PUGI__IS_CHARTYPEX(*cur, ctx_digit)) - { - _cur_lexeme_contents.begin = cur; - - while (PUGI__IS_CHARTYPEX(*cur, ctx_digit)) cur++; - - if (*cur == '.') - { - cur++; - - while (PUGI__IS_CHARTYPEX(*cur, ctx_digit)) cur++; - } - - _cur_lexeme_contents.end = cur; - - _cur_lexeme = lex_number; - } - else if (PUGI__IS_CHARTYPEX(*cur, ctx_start_symbol)) - { - _cur_lexeme_contents.begin = cur; - - while (PUGI__IS_CHARTYPEX(*cur, ctx_symbol)) cur++; - - if (cur[0] == ':') - { - if (cur[1] == '*') // namespace test ncname:* - { - cur += 2; // :* - } - else if (PUGI__IS_CHARTYPEX(cur[1], ctx_symbol)) // namespace test qname - { - cur++; // : - - while (PUGI__IS_CHARTYPEX(*cur, ctx_symbol)) cur++; - } - } - - _cur_lexeme_contents.end = cur; - - _cur_lexeme = lex_string; - } - else - { - _cur_lexeme = lex_none; - } - } - - _cur = cur; - } - - lexeme_t current() const - { - return _cur_lexeme; - } - - const char_t* current_pos() const - { - return _cur_lexeme_pos; - } - - const xpath_lexer_string& contents() const - { - assert(_cur_lexeme == lex_var_ref || _cur_lexeme == lex_number || _cur_lexeme == lex_string || _cur_lexeme == lex_quoted_string); - - return _cur_lexeme_contents; - } - }; - - enum ast_type_t - { - ast_unknown, - ast_op_or, // left or right - ast_op_and, // left and right - ast_op_equal, // left = right - ast_op_not_equal, // left != right - ast_op_less, // left < right - ast_op_greater, // left > right - ast_op_less_or_equal, // left <= right - ast_op_greater_or_equal, // left >= right - ast_op_add, // left + right - ast_op_subtract, // left - right - ast_op_multiply, // left * right - ast_op_divide, // left / right - ast_op_mod, // left % right - ast_op_negate, // left - right - ast_op_union, // left | right - ast_predicate, // apply predicate to set; next points to next predicate - ast_filter, // select * from left where right - ast_string_constant, // string constant - ast_number_constant, // number constant - ast_variable, // variable - ast_func_last, // last() - ast_func_position, // position() - ast_func_count, // count(left) - ast_func_id, // id(left) - ast_func_local_name_0, // local-name() - ast_func_local_name_1, // local-name(left) - ast_func_namespace_uri_0, // namespace-uri() - ast_func_namespace_uri_1, // namespace-uri(left) - ast_func_name_0, // name() - ast_func_name_1, // name(left) - ast_func_string_0, // string() - ast_func_string_1, // string(left) - ast_func_concat, // concat(left, right, siblings) - ast_func_starts_with, // starts_with(left, right) - ast_func_contains, // contains(left, right) - ast_func_substring_before, // substring-before(left, right) - ast_func_substring_after, // substring-after(left, right) - ast_func_substring_2, // substring(left, right) - ast_func_substring_3, // substring(left, right, third) - ast_func_string_length_0, // string-length() - ast_func_string_length_1, // string-length(left) - ast_func_normalize_space_0, // normalize-space() - ast_func_normalize_space_1, // normalize-space(left) - ast_func_translate, // translate(left, right, third) - ast_func_boolean, // boolean(left) - ast_func_not, // not(left) - ast_func_true, // true() - ast_func_false, // false() - ast_func_lang, // lang(left) - ast_func_number_0, // number() - ast_func_number_1, // number(left) - ast_func_sum, // sum(left) - ast_func_floor, // floor(left) - ast_func_ceiling, // ceiling(left) - ast_func_round, // round(left) - ast_step, // process set left with step - ast_step_root, // select root node - - ast_opt_translate_table, // translate(left, right, third) where right/third are constants - ast_opt_compare_attribute // @name = 'string' - }; - - enum axis_t - { - axis_ancestor, - axis_ancestor_or_self, - axis_attribute, - axis_child, - axis_descendant, - axis_descendant_or_self, - axis_following, - axis_following_sibling, - axis_namespace, - axis_parent, - axis_preceding, - axis_preceding_sibling, - axis_self - }; - - enum nodetest_t - { - nodetest_none, - nodetest_name, - nodetest_type_node, - nodetest_type_comment, - nodetest_type_pi, - nodetest_type_text, - nodetest_pi, - nodetest_all, - nodetest_all_in_namespace - }; - - enum predicate_t - { - predicate_default, - predicate_posinv, - predicate_constant, - predicate_constant_one - }; - - enum nodeset_eval_t - { - nodeset_eval_all, - nodeset_eval_any, - nodeset_eval_first - }; - - template struct axis_to_type - { - static const axis_t axis; - }; - - template const axis_t axis_to_type::axis = N; - - class xpath_ast_node - { - private: - // node type - char _type; - char _rettype; - - // for ast_step - char _axis; - - // for ast_step/ast_predicate/ast_filter - char _test; - - // tree node structure - xpath_ast_node* _left; - xpath_ast_node* _right; - xpath_ast_node* _next; - - union - { - // value for ast_string_constant - const char_t* string; - // value for ast_number_constant - double number; - // variable for ast_variable - xpath_variable* variable; - // node test for ast_step (node name/namespace/node type/pi target) - const char_t* nodetest; - // table for ast_opt_translate_table - const unsigned char* table; - } _data; - - xpath_ast_node(const xpath_ast_node&); - xpath_ast_node& operator=(const xpath_ast_node&); - - template static bool compare_eq(xpath_ast_node* lhs, xpath_ast_node* rhs, const xpath_context& c, const xpath_stack& stack, const Comp& comp) - { - xpath_value_type lt = lhs->rettype(), rt = rhs->rettype(); - - if (lt != xpath_type_node_set && rt != xpath_type_node_set) - { - if (lt == xpath_type_boolean || rt == xpath_type_boolean) - return comp(lhs->eval_boolean(c, stack), rhs->eval_boolean(c, stack)); - else if (lt == xpath_type_number || rt == xpath_type_number) - return comp(lhs->eval_number(c, stack), rhs->eval_number(c, stack)); - else if (lt == xpath_type_string || rt == xpath_type_string) - { - xpath_allocator_capture cr(stack.result); - - xpath_string ls = lhs->eval_string(c, stack); - xpath_string rs = rhs->eval_string(c, stack); - - return comp(ls, rs); - } - } - else if (lt == xpath_type_node_set && rt == xpath_type_node_set) - { - xpath_allocator_capture cr(stack.result); - - xpath_node_set_raw ls = lhs->eval_node_set(c, stack, nodeset_eval_all); - xpath_node_set_raw rs = rhs->eval_node_set(c, stack, nodeset_eval_all); - - for (const xpath_node* li = ls.begin(); li != ls.end(); ++li) - for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri) - { - xpath_allocator_capture cri(stack.result); - - if (comp(string_value(*li, stack.result), string_value(*ri, stack.result))) - return true; - } - - return false; - } - else - { - if (lt == xpath_type_node_set) - { - swap(lhs, rhs); - swap(lt, rt); - } - - if (lt == xpath_type_boolean) - return comp(lhs->eval_boolean(c, stack), rhs->eval_boolean(c, stack)); - else if (lt == xpath_type_number) - { - xpath_allocator_capture cr(stack.result); - - double l = lhs->eval_number(c, stack); - xpath_node_set_raw rs = rhs->eval_node_set(c, stack, nodeset_eval_all); - - for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri) - { - xpath_allocator_capture cri(stack.result); - - if (comp(l, convert_string_to_number(string_value(*ri, stack.result).c_str()))) - return true; - } - - return false; - } - else if (lt == xpath_type_string) - { - xpath_allocator_capture cr(stack.result); - - xpath_string l = lhs->eval_string(c, stack); - xpath_node_set_raw rs = rhs->eval_node_set(c, stack, nodeset_eval_all); - - for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri) - { - xpath_allocator_capture cri(stack.result); - - if (comp(l, string_value(*ri, stack.result))) - return true; - } - - return false; - } - } - - assert(!"Wrong types"); - return false; - } - - static bool eval_once(xpath_node_set::type_t type, nodeset_eval_t eval) - { - return type == xpath_node_set::type_sorted ? eval != nodeset_eval_all : eval == nodeset_eval_any; - } - - template static bool compare_rel(xpath_ast_node* lhs, xpath_ast_node* rhs, const xpath_context& c, const xpath_stack& stack, const Comp& comp) - { - xpath_value_type lt = lhs->rettype(), rt = rhs->rettype(); - - if (lt != xpath_type_node_set && rt != xpath_type_node_set) - return comp(lhs->eval_number(c, stack), rhs->eval_number(c, stack)); - else if (lt == xpath_type_node_set && rt == xpath_type_node_set) - { - xpath_allocator_capture cr(stack.result); - - xpath_node_set_raw ls = lhs->eval_node_set(c, stack, nodeset_eval_all); - xpath_node_set_raw rs = rhs->eval_node_set(c, stack, nodeset_eval_all); - - for (const xpath_node* li = ls.begin(); li != ls.end(); ++li) - { - xpath_allocator_capture cri(stack.result); - - double l = convert_string_to_number(string_value(*li, stack.result).c_str()); - - for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri) - { - xpath_allocator_capture crii(stack.result); - - if (comp(l, convert_string_to_number(string_value(*ri, stack.result).c_str()))) - return true; - } - } - - return false; - } - else if (lt != xpath_type_node_set && rt == xpath_type_node_set) - { - xpath_allocator_capture cr(stack.result); - - double l = lhs->eval_number(c, stack); - xpath_node_set_raw rs = rhs->eval_node_set(c, stack, nodeset_eval_all); - - for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri) - { - xpath_allocator_capture cri(stack.result); - - if (comp(l, convert_string_to_number(string_value(*ri, stack.result).c_str()))) - return true; - } - - return false; - } - else if (lt == xpath_type_node_set && rt != xpath_type_node_set) - { - xpath_allocator_capture cr(stack.result); - - xpath_node_set_raw ls = lhs->eval_node_set(c, stack, nodeset_eval_all); - double r = rhs->eval_number(c, stack); - - for (const xpath_node* li = ls.begin(); li != ls.end(); ++li) - { - xpath_allocator_capture cri(stack.result); - - if (comp(convert_string_to_number(string_value(*li, stack.result).c_str()), r)) - return true; - } - - return false; - } - else - { - assert(!"Wrong types"); - return false; - } - } - - static void apply_predicate_boolean(xpath_node_set_raw& ns, size_t first, xpath_ast_node* expr, const xpath_stack& stack, bool once) - { - assert(ns.size() >= first); - assert(expr->rettype() != xpath_type_number); - - size_t i = 1; - size_t size = ns.size() - first; - - xpath_node* last = ns.begin() + first; - - // remove_if... or well, sort of - for (xpath_node* it = last; it != ns.end(); ++it, ++i) - { - xpath_context c(*it, i, size); - - if (expr->eval_boolean(c, stack)) - { - *last++ = *it; - - if (once) break; - } - } - - ns.truncate(last); - } - - static void apply_predicate_number(xpath_node_set_raw& ns, size_t first, xpath_ast_node* expr, const xpath_stack& stack, bool once) - { - assert(ns.size() >= first); - assert(expr->rettype() == xpath_type_number); - - size_t i = 1; - size_t size = ns.size() - first; - - xpath_node* last = ns.begin() + first; - - // remove_if... or well, sort of - for (xpath_node* it = last; it != ns.end(); ++it, ++i) - { - xpath_context c(*it, i, size); - - if (expr->eval_number(c, stack) == i) - { - *last++ = *it; - - if (once) break; - } - } - - ns.truncate(last); - } - - static void apply_predicate_number_const(xpath_node_set_raw& ns, size_t first, xpath_ast_node* expr, const xpath_stack& stack) - { - assert(ns.size() >= first); - assert(expr->rettype() == xpath_type_number); - - size_t size = ns.size() - first; - - xpath_node* last = ns.begin() + first; - - xpath_context c(xpath_node(), 1, size); - - double er = expr->eval_number(c, stack); - - if (er >= 1.0 && er <= size) - { - size_t eri = static_cast(er); - - if (er == eri) - { - xpath_node r = last[eri - 1]; - - *last++ = r; - } - } - - ns.truncate(last); - } - - void apply_predicate(xpath_node_set_raw& ns, size_t first, const xpath_stack& stack, bool once) - { - if (ns.size() == first) return; - - assert(_type == ast_filter || _type == ast_predicate); - - if (_test == predicate_constant || _test == predicate_constant_one) - apply_predicate_number_const(ns, first, _right, stack); - else if (_right->rettype() == xpath_type_number) - apply_predicate_number(ns, first, _right, stack, once); - else - apply_predicate_boolean(ns, first, _right, stack, once); - } - - void apply_predicates(xpath_node_set_raw& ns, size_t first, const xpath_stack& stack, nodeset_eval_t eval) - { - if (ns.size() == first) return; - - bool last_once = eval_once(ns.type(), eval); - - for (xpath_ast_node* pred = _right; pred; pred = pred->_next) - pred->apply_predicate(ns, first, stack, !pred->_next && last_once); - } - - bool step_push(xpath_node_set_raw& ns, xml_attribute_struct* a, xml_node_struct* parent, xpath_allocator* alloc) - { - assert(a); - - const char_t* name = a->name ? a->name : PUGIXML_TEXT(""); - - switch (_test) - { - case nodetest_name: - if (strequal(name, _data.nodetest) && is_xpath_attribute(name)) - { - ns.push_back(xpath_node(xml_attribute(a), xml_node(parent)), alloc); - return true; - } - break; - - case nodetest_type_node: - case nodetest_all: - if (is_xpath_attribute(name)) - { - ns.push_back(xpath_node(xml_attribute(a), xml_node(parent)), alloc); - return true; - } - break; - - case nodetest_all_in_namespace: - if (starts_with(name, _data.nodetest) && is_xpath_attribute(name)) - { - ns.push_back(xpath_node(xml_attribute(a), xml_node(parent)), alloc); - return true; - } - break; - - default: - ; - } - - return false; - } - - bool step_push(xpath_node_set_raw& ns, xml_node_struct* n, xpath_allocator* alloc) - { - assert(n); - - xml_node_type type = PUGI__NODETYPE(n); - - switch (_test) - { - case nodetest_name: - if (type == node_element && n->name && strequal(n->name, _data.nodetest)) - { - ns.push_back(xml_node(n), alloc); - return true; - } - break; - - case nodetest_type_node: - ns.push_back(xml_node(n), alloc); - return true; - - case nodetest_type_comment: - if (type == node_comment) - { - ns.push_back(xml_node(n), alloc); - return true; - } - break; - - case nodetest_type_text: - if (type == node_pcdata || type == node_cdata) - { - ns.push_back(xml_node(n), alloc); - return true; - } - break; - - case nodetest_type_pi: - if (type == node_pi) - { - ns.push_back(xml_node(n), alloc); - return true; - } - break; - - case nodetest_pi: - if (type == node_pi && n->name && strequal(n->name, _data.nodetest)) - { - ns.push_back(xml_node(n), alloc); - return true; - } - break; - - case nodetest_all: - if (type == node_element) - { - ns.push_back(xml_node(n), alloc); - return true; - } - break; - - case nodetest_all_in_namespace: - if (type == node_element && n->name && starts_with(n->name, _data.nodetest)) - { - ns.push_back(xml_node(n), alloc); - return true; - } - break; - - default: - assert(!"Unknown axis"); - } - - return false; - } - - template void step_fill(xpath_node_set_raw& ns, xml_node_struct* n, xpath_allocator* alloc, bool once, T) - { - const axis_t axis = T::axis; - - switch (axis) - { - case axis_attribute: - { - for (xml_attribute_struct* a = n->first_attribute; a; a = a->next_attribute) - if (step_push(ns, a, n, alloc) & once) - return; - - break; - } - - case axis_child: - { - for (xml_node_struct* c = n->first_child; c; c = c->next_sibling) - if (step_push(ns, c, alloc) & once) - return; - - break; - } - - case axis_descendant: - case axis_descendant_or_self: - { - if (axis == axis_descendant_or_self) - if (step_push(ns, n, alloc) & once) - return; - - xml_node_struct* cur = n->first_child; - - while (cur) - { - if (step_push(ns, cur, alloc) & once) - return; - - if (cur->first_child) - cur = cur->first_child; - else - { - while (!cur->next_sibling) - { - cur = cur->parent; - - if (cur == n) return; - } - - cur = cur->next_sibling; - } - } - - break; - } - - case axis_following_sibling: - { - for (xml_node_struct* c = n->next_sibling; c; c = c->next_sibling) - if (step_push(ns, c, alloc) & once) - return; - - break; - } - - case axis_preceding_sibling: - { - for (xml_node_struct* c = n->prev_sibling_c; c->next_sibling; c = c->prev_sibling_c) - if (step_push(ns, c, alloc) & once) - return; - - break; - } - - case axis_following: - { - xml_node_struct* cur = n; - - // exit from this node so that we don't include descendants - while (!cur->next_sibling) - { - cur = cur->parent; - - if (!cur) return; - } - - cur = cur->next_sibling; - - while (cur) - { - if (step_push(ns, cur, alloc) & once) - return; - - if (cur->first_child) - cur = cur->first_child; - else - { - while (!cur->next_sibling) - { - cur = cur->parent; - - if (!cur) return; - } - - cur = cur->next_sibling; - } - } - - break; - } - - case axis_preceding: - { - xml_node_struct* cur = n; - - // exit from this node so that we don't include descendants - while (!cur->prev_sibling_c->next_sibling) - { - cur = cur->parent; - - if (!cur) return; - } - - cur = cur->prev_sibling_c; - - while (cur) - { - if (cur->first_child) - cur = cur->first_child->prev_sibling_c; - else - { - // leaf node, can't be ancestor - if (step_push(ns, cur, alloc) & once) - return; - - while (!cur->prev_sibling_c->next_sibling) - { - cur = cur->parent; - - if (!cur) return; - - if (!node_is_ancestor(cur, n)) - if (step_push(ns, cur, alloc) & once) - return; - } - - cur = cur->prev_sibling_c; - } - } - - break; - } - - case axis_ancestor: - case axis_ancestor_or_self: - { - if (axis == axis_ancestor_or_self) - if (step_push(ns, n, alloc) & once) - return; - - xml_node_struct* cur = n->parent; - - while (cur) - { - if (step_push(ns, cur, alloc) & once) - return; - - cur = cur->parent; - } - - break; - } - - case axis_self: - { - step_push(ns, n, alloc); - - break; - } - - case axis_parent: - { - if (n->parent) - step_push(ns, n->parent, alloc); - - break; - } - - default: - assert(!"Unimplemented axis"); - } - } - - template void step_fill(xpath_node_set_raw& ns, xml_attribute_struct* a, xml_node_struct* p, xpath_allocator* alloc, bool once, T v) - { - const axis_t axis = T::axis; - - switch (axis) - { - case axis_ancestor: - case axis_ancestor_or_self: - { - if (axis == axis_ancestor_or_self && _test == nodetest_type_node) // reject attributes based on principal node type test - if (step_push(ns, a, p, alloc) & once) - return; - - xml_node_struct* cur = p; - - while (cur) - { - if (step_push(ns, cur, alloc) & once) - return; - - cur = cur->parent; - } - - break; - } - - case axis_descendant_or_self: - case axis_self: - { - if (_test == nodetest_type_node) // reject attributes based on principal node type test - step_push(ns, a, p, alloc); - - break; - } - - case axis_following: - { - xml_node_struct* cur = p; - - while (cur) - { - if (cur->first_child) - cur = cur->first_child; - else - { - while (!cur->next_sibling) - { - cur = cur->parent; - - if (!cur) return; - } - - cur = cur->next_sibling; - } - - if (step_push(ns, cur, alloc) & once) - return; - } - - break; - } - - case axis_parent: - { - step_push(ns, p, alloc); - - break; - } - - case axis_preceding: - { - // preceding:: axis does not include attribute nodes and attribute ancestors (they are the same as parent's ancestors), so we can reuse node preceding - step_fill(ns, p, alloc, once, v); - break; - } - - default: - assert(!"Unimplemented axis"); - } - } - - template void step_fill(xpath_node_set_raw& ns, const xpath_node& xn, xpath_allocator* alloc, bool once, T v) - { - const axis_t axis = T::axis; - const bool axis_has_attributes = (axis == axis_ancestor || axis == axis_ancestor_or_self || axis == axis_descendant_or_self || axis == axis_following || axis == axis_parent || axis == axis_preceding || axis == axis_self); - - if (xn.node()) - step_fill(ns, xn.node().internal_object(), alloc, once, v); - else if (axis_has_attributes && xn.attribute() && xn.parent()) - step_fill(ns, xn.attribute().internal_object(), xn.parent().internal_object(), alloc, once, v); - } - - template xpath_node_set_raw step_do(const xpath_context& c, const xpath_stack& stack, nodeset_eval_t eval, T v) - { - const axis_t axis = T::axis; - const bool axis_reverse = (axis == axis_ancestor || axis == axis_ancestor_or_self || axis == axis_preceding || axis == axis_preceding_sibling); - const xpath_node_set::type_t axis_type = axis_reverse ? xpath_node_set::type_sorted_reverse : xpath_node_set::type_sorted; - - bool once = - (axis == axis_attribute && _test == nodetest_name) || - (!_right && eval_once(axis_type, eval)) || - (_right && !_right->_next && _right->_test == predicate_constant_one); - - xpath_node_set_raw ns; - ns.set_type(axis_type); - - if (_left) - { - xpath_node_set_raw s = _left->eval_node_set(c, stack, nodeset_eval_all); - - // self axis preserves the original order - if (axis == axis_self) ns.set_type(s.type()); - - for (const xpath_node* it = s.begin(); it != s.end(); ++it) - { - size_t size = ns.size(); - - // in general, all axes generate elements in a particular order, but there is no order guarantee if axis is applied to two nodes - if (axis != axis_self && size != 0) ns.set_type(xpath_node_set::type_unsorted); - - step_fill(ns, *it, stack.result, once, v); - if (_right) apply_predicates(ns, size, stack, eval); - } - } - else - { - step_fill(ns, c.n, stack.result, once, v); - if (_right) apply_predicates(ns, 0, stack, eval); - } - - // child, attribute and self axes always generate unique set of nodes - // for other axis, if the set stayed sorted, it stayed unique because the traversal algorithms do not visit the same node twice - if (axis != axis_child && axis != axis_attribute && axis != axis_self && ns.type() == xpath_node_set::type_unsorted) - ns.remove_duplicates(); - - return ns; - } - - public: - xpath_ast_node(ast_type_t type, xpath_value_type rettype_, const char_t* value): - _type(static_cast(type)), _rettype(static_cast(rettype_)), _axis(0), _test(0), _left(0), _right(0), _next(0) - { - assert(type == ast_string_constant); - _data.string = value; - } - - xpath_ast_node(ast_type_t type, xpath_value_type rettype_, double value): - _type(static_cast(type)), _rettype(static_cast(rettype_)), _axis(0), _test(0), _left(0), _right(0), _next(0) - { - assert(type == ast_number_constant); - _data.number = value; - } - - xpath_ast_node(ast_type_t type, xpath_value_type rettype_, xpath_variable* value): - _type(static_cast(type)), _rettype(static_cast(rettype_)), _axis(0), _test(0), _left(0), _right(0), _next(0) - { - assert(type == ast_variable); - _data.variable = value; - } - - xpath_ast_node(ast_type_t type, xpath_value_type rettype_, xpath_ast_node* left = 0, xpath_ast_node* right = 0): - _type(static_cast(type)), _rettype(static_cast(rettype_)), _axis(0), _test(0), _left(left), _right(right), _next(0) - { - } - - xpath_ast_node(ast_type_t type, xpath_ast_node* left, axis_t axis, nodetest_t test, const char_t* contents): - _type(static_cast(type)), _rettype(xpath_type_node_set), _axis(static_cast(axis)), _test(static_cast(test)), _left(left), _right(0), _next(0) - { - assert(type == ast_step); - _data.nodetest = contents; - } - - xpath_ast_node(ast_type_t type, xpath_ast_node* left, xpath_ast_node* right, predicate_t test): - _type(static_cast(type)), _rettype(xpath_type_node_set), _axis(0), _test(static_cast(test)), _left(left), _right(right), _next(0) - { - assert(type == ast_filter || type == ast_predicate); - } - - void set_next(xpath_ast_node* value) - { - _next = value; - } - - void set_right(xpath_ast_node* value) - { - _right = value; - } - - bool eval_boolean(const xpath_context& c, const xpath_stack& stack) - { - switch (_type) - { - case ast_op_or: - return _left->eval_boolean(c, stack) || _right->eval_boolean(c, stack); - - case ast_op_and: - return _left->eval_boolean(c, stack) && _right->eval_boolean(c, stack); - - case ast_op_equal: - return compare_eq(_left, _right, c, stack, equal_to()); - - case ast_op_not_equal: - return compare_eq(_left, _right, c, stack, not_equal_to()); - - case ast_op_less: - return compare_rel(_left, _right, c, stack, less()); - - case ast_op_greater: - return compare_rel(_right, _left, c, stack, less()); - - case ast_op_less_or_equal: - return compare_rel(_left, _right, c, stack, less_equal()); - - case ast_op_greater_or_equal: - return compare_rel(_right, _left, c, stack, less_equal()); - - case ast_func_starts_with: - { - xpath_allocator_capture cr(stack.result); - - xpath_string lr = _left->eval_string(c, stack); - xpath_string rr = _right->eval_string(c, stack); - - return starts_with(lr.c_str(), rr.c_str()); - } - - case ast_func_contains: - { - xpath_allocator_capture cr(stack.result); - - xpath_string lr = _left->eval_string(c, stack); - xpath_string rr = _right->eval_string(c, stack); - - return find_substring(lr.c_str(), rr.c_str()) != 0; - } - - case ast_func_boolean: - return _left->eval_boolean(c, stack); - - case ast_func_not: - return !_left->eval_boolean(c, stack); - - case ast_func_true: - return true; - - case ast_func_false: - return false; - - case ast_func_lang: - { - if (c.n.attribute()) return false; - - xpath_allocator_capture cr(stack.result); - - xpath_string lang = _left->eval_string(c, stack); - - for (xml_node n = c.n.node(); n; n = n.parent()) - { - xml_attribute a = n.attribute(PUGIXML_TEXT("xml:lang")); - - if (a) - { - const char_t* value = a.value(); - - // strnicmp / strncasecmp is not portable - for (const char_t* lit = lang.c_str(); *lit; ++lit) - { - if (tolower_ascii(*lit) != tolower_ascii(*value)) return false; - ++value; - } - - return *value == 0 || *value == '-'; - } - } - - return false; - } - - case ast_opt_compare_attribute: - { - const char_t* value = (_right->_type == ast_string_constant) ? _right->_data.string : _right->_data.variable->get_string(); - - xml_attribute attr = c.n.node().attribute(_left->_data.nodetest); - - return attr && strequal(attr.value(), value) && is_xpath_attribute(attr.name()); - } - - case ast_variable: - { - assert(_rettype == _data.variable->type()); - - if (_rettype == xpath_type_boolean) - return _data.variable->get_boolean(); - - // fallthrough to type conversion - } - - default: - { - switch (_rettype) - { - case xpath_type_number: - return convert_number_to_boolean(eval_number(c, stack)); - - case xpath_type_string: - { - xpath_allocator_capture cr(stack.result); - - return !eval_string(c, stack).empty(); - } - - case xpath_type_node_set: - { - xpath_allocator_capture cr(stack.result); - - return !eval_node_set(c, stack, nodeset_eval_any).empty(); - } - - default: - assert(!"Wrong expression for return type boolean"); - return false; - } - } - } - } - - double eval_number(const xpath_context& c, const xpath_stack& stack) - { - switch (_type) - { - case ast_op_add: - return _left->eval_number(c, stack) + _right->eval_number(c, stack); - - case ast_op_subtract: - return _left->eval_number(c, stack) - _right->eval_number(c, stack); - - case ast_op_multiply: - return _left->eval_number(c, stack) * _right->eval_number(c, stack); - - case ast_op_divide: - return _left->eval_number(c, stack) / _right->eval_number(c, stack); - - case ast_op_mod: - return fmod(_left->eval_number(c, stack), _right->eval_number(c, stack)); - - case ast_op_negate: - return -_left->eval_number(c, stack); - - case ast_number_constant: - return _data.number; - - case ast_func_last: - return static_cast(c.size); - - case ast_func_position: - return static_cast(c.position); - - case ast_func_count: - { - xpath_allocator_capture cr(stack.result); - - return static_cast(_left->eval_node_set(c, stack, nodeset_eval_all).size()); - } - - case ast_func_string_length_0: - { - xpath_allocator_capture cr(stack.result); - - return static_cast(string_value(c.n, stack.result).length()); - } - - case ast_func_string_length_1: - { - xpath_allocator_capture cr(stack.result); - - return static_cast(_left->eval_string(c, stack).length()); - } - - case ast_func_number_0: - { - xpath_allocator_capture cr(stack.result); - - return convert_string_to_number(string_value(c.n, stack.result).c_str()); - } - - case ast_func_number_1: - return _left->eval_number(c, stack); - - case ast_func_sum: - { - xpath_allocator_capture cr(stack.result); - - double r = 0; - - xpath_node_set_raw ns = _left->eval_node_set(c, stack, nodeset_eval_all); - - for (const xpath_node* it = ns.begin(); it != ns.end(); ++it) - { - xpath_allocator_capture cri(stack.result); - - r += convert_string_to_number(string_value(*it, stack.result).c_str()); - } - - return r; - } - - case ast_func_floor: - { - double r = _left->eval_number(c, stack); - - return r == r ? floor(r) : r; - } - - case ast_func_ceiling: - { - double r = _left->eval_number(c, stack); - - return r == r ? ceil(r) : r; - } - - case ast_func_round: - return round_nearest_nzero(_left->eval_number(c, stack)); - - case ast_variable: - { - assert(_rettype == _data.variable->type()); - - if (_rettype == xpath_type_number) - return _data.variable->get_number(); - - // fallthrough to type conversion - } - - default: - { - switch (_rettype) - { - case xpath_type_boolean: - return eval_boolean(c, stack) ? 1 : 0; - - case xpath_type_string: - { - xpath_allocator_capture cr(stack.result); - - return convert_string_to_number(eval_string(c, stack).c_str()); - } - - case xpath_type_node_set: - { - xpath_allocator_capture cr(stack.result); - - return convert_string_to_number(eval_string(c, stack).c_str()); - } - - default: - assert(!"Wrong expression for return type number"); - return 0; - } - - } - } - } - - xpath_string eval_string_concat(const xpath_context& c, const xpath_stack& stack) - { - assert(_type == ast_func_concat); - - xpath_allocator_capture ct(stack.temp); - - // count the string number - size_t count = 1; - for (xpath_ast_node* nc = _right; nc; nc = nc->_next) count++; - - // gather all strings - xpath_string static_buffer[4]; - xpath_string* buffer = static_buffer; - - // allocate on-heap for large concats - if (count > sizeof(static_buffer) / sizeof(static_buffer[0])) - { - buffer = static_cast(stack.temp->allocate(count * sizeof(xpath_string))); - assert(buffer); - } - - // evaluate all strings to temporary stack - xpath_stack swapped_stack = {stack.temp, stack.result}; - - buffer[0] = _left->eval_string(c, swapped_stack); - - size_t pos = 1; - for (xpath_ast_node* n = _right; n; n = n->_next, ++pos) buffer[pos] = n->eval_string(c, swapped_stack); - assert(pos == count); - - // get total length - size_t length = 0; - for (size_t i = 0; i < count; ++i) length += buffer[i].length(); - - // create final string - char_t* result = static_cast(stack.result->allocate((length + 1) * sizeof(char_t))); - assert(result); - - char_t* ri = result; - - for (size_t j = 0; j < count; ++j) - for (const char_t* bi = buffer[j].c_str(); *bi; ++bi) - *ri++ = *bi; - - *ri = 0; - - return xpath_string::from_heap_preallocated(result, ri); - } - - xpath_string eval_string(const xpath_context& c, const xpath_stack& stack) - { - switch (_type) - { - case ast_string_constant: - return xpath_string::from_const(_data.string); - - case ast_func_local_name_0: - { - xpath_node na = c.n; - - return xpath_string::from_const(local_name(na)); - } - - case ast_func_local_name_1: - { - xpath_allocator_capture cr(stack.result); - - xpath_node_set_raw ns = _left->eval_node_set(c, stack, nodeset_eval_first); - xpath_node na = ns.first(); - - return xpath_string::from_const(local_name(na)); - } - - case ast_func_name_0: - { - xpath_node na = c.n; - - return xpath_string::from_const(qualified_name(na)); - } - - case ast_func_name_1: - { - xpath_allocator_capture cr(stack.result); - - xpath_node_set_raw ns = _left->eval_node_set(c, stack, nodeset_eval_first); - xpath_node na = ns.first(); - - return xpath_string::from_const(qualified_name(na)); - } - - case ast_func_namespace_uri_0: - { - xpath_node na = c.n; - - return xpath_string::from_const(namespace_uri(na)); - } - - case ast_func_namespace_uri_1: - { - xpath_allocator_capture cr(stack.result); - - xpath_node_set_raw ns = _left->eval_node_set(c, stack, nodeset_eval_first); - xpath_node na = ns.first(); - - return xpath_string::from_const(namespace_uri(na)); - } - - case ast_func_string_0: - return string_value(c.n, stack.result); - - case ast_func_string_1: - return _left->eval_string(c, stack); - - case ast_func_concat: - return eval_string_concat(c, stack); - - case ast_func_substring_before: - { - xpath_allocator_capture cr(stack.temp); - - xpath_stack swapped_stack = {stack.temp, stack.result}; - - xpath_string s = _left->eval_string(c, swapped_stack); - xpath_string p = _right->eval_string(c, swapped_stack); - - const char_t* pos = find_substring(s.c_str(), p.c_str()); - - return pos ? xpath_string::from_heap(s.c_str(), pos, stack.result) : xpath_string(); - } - - case ast_func_substring_after: - { - xpath_allocator_capture cr(stack.temp); - - xpath_stack swapped_stack = {stack.temp, stack.result}; - - xpath_string s = _left->eval_string(c, swapped_stack); - xpath_string p = _right->eval_string(c, swapped_stack); - - const char_t* pos = find_substring(s.c_str(), p.c_str()); - if (!pos) return xpath_string(); - - const char_t* rbegin = pos + p.length(); - const char_t* rend = s.c_str() + s.length(); - - return s.uses_heap() ? xpath_string::from_heap(rbegin, rend, stack.result) : xpath_string::from_const(rbegin); - } - - case ast_func_substring_2: - { - xpath_allocator_capture cr(stack.temp); - - xpath_stack swapped_stack = {stack.temp, stack.result}; - - xpath_string s = _left->eval_string(c, swapped_stack); - size_t s_length = s.length(); - - double first = round_nearest(_right->eval_number(c, stack)); - - if (is_nan(first)) return xpath_string(); // NaN - else if (first >= s_length + 1) return xpath_string(); - - size_t pos = first < 1 ? 1 : static_cast(first); - assert(1 <= pos && pos <= s_length + 1); - - const char_t* rbegin = s.c_str() + (pos - 1); - const char_t* rend = s.c_str() + s.length(); - - return s.uses_heap() ? xpath_string::from_heap(rbegin, rend, stack.result) : xpath_string::from_const(rbegin); - } - - case ast_func_substring_3: - { - xpath_allocator_capture cr(stack.temp); - - xpath_stack swapped_stack = {stack.temp, stack.result}; - - xpath_string s = _left->eval_string(c, swapped_stack); - size_t s_length = s.length(); - - double first = round_nearest(_right->eval_number(c, stack)); - double last = first + round_nearest(_right->_next->eval_number(c, stack)); - - if (is_nan(first) || is_nan(last)) return xpath_string(); - else if (first >= s_length + 1) return xpath_string(); - else if (first >= last) return xpath_string(); - else if (last < 1) return xpath_string(); - - size_t pos = first < 1 ? 1 : static_cast(first); - size_t end = last >= s_length + 1 ? s_length + 1 : static_cast(last); - - assert(1 <= pos && pos <= end && end <= s_length + 1); - const char_t* rbegin = s.c_str() + (pos - 1); - const char_t* rend = s.c_str() + (end - 1); - - return (end == s_length + 1 && !s.uses_heap()) ? xpath_string::from_const(rbegin) : xpath_string::from_heap(rbegin, rend, stack.result); - } - - case ast_func_normalize_space_0: - { - xpath_string s = string_value(c.n, stack.result); - - normalize_space(s.data(stack.result)); - - return s; - } - - case ast_func_normalize_space_1: - { - xpath_string s = _left->eval_string(c, stack); - - normalize_space(s.data(stack.result)); - - return s; - } - - case ast_func_translate: - { - xpath_allocator_capture cr(stack.temp); - - xpath_stack swapped_stack = {stack.temp, stack.result}; - - xpath_string s = _left->eval_string(c, stack); - xpath_string from = _right->eval_string(c, swapped_stack); - xpath_string to = _right->_next->eval_string(c, swapped_stack); - - translate(s.data(stack.result), from.c_str(), to.c_str(), to.length()); - - return s; - } - - case ast_opt_translate_table: - { - xpath_string s = _left->eval_string(c, stack); - - translate_table(s.data(stack.result), _data.table); - - return s; - } - - case ast_variable: - { - assert(_rettype == _data.variable->type()); - - if (_rettype == xpath_type_string) - return xpath_string::from_const(_data.variable->get_string()); - - // fallthrough to type conversion - } - - default: - { - switch (_rettype) - { - case xpath_type_boolean: - return xpath_string::from_const(eval_boolean(c, stack) ? PUGIXML_TEXT("true") : PUGIXML_TEXT("false")); - - case xpath_type_number: - return convert_number_to_string(eval_number(c, stack), stack.result); - - case xpath_type_node_set: - { - xpath_allocator_capture cr(stack.temp); - - xpath_stack swapped_stack = {stack.temp, stack.result}; - - xpath_node_set_raw ns = eval_node_set(c, swapped_stack, nodeset_eval_first); - return ns.empty() ? xpath_string() : string_value(ns.first(), stack.result); - } - - default: - assert(!"Wrong expression for return type string"); - return xpath_string(); - } - } - } - } - - xpath_node_set_raw eval_node_set(const xpath_context& c, const xpath_stack& stack, nodeset_eval_t eval) - { - switch (_type) - { - case ast_op_union: - { - xpath_allocator_capture cr(stack.temp); - - xpath_stack swapped_stack = {stack.temp, stack.result}; - - xpath_node_set_raw ls = _left->eval_node_set(c, swapped_stack, eval); - xpath_node_set_raw rs = _right->eval_node_set(c, stack, eval); - - // we can optimize merging two sorted sets, but this is a very rare operation, so don't bother - rs.set_type(xpath_node_set::type_unsorted); - - rs.append(ls.begin(), ls.end(), stack.result); - rs.remove_duplicates(); - - return rs; - } - - case ast_filter: - { - xpath_node_set_raw set = _left->eval_node_set(c, stack, _test == predicate_constant_one ? nodeset_eval_first : nodeset_eval_all); - - // either expression is a number or it contains position() call; sort by document order - if (_test != predicate_posinv) set.sort_do(); - - bool once = eval_once(set.type(), eval); - - apply_predicate(set, 0, stack, once); - - return set; - } - - case ast_func_id: - return xpath_node_set_raw(); - - case ast_step: - { - switch (_axis) - { - case axis_ancestor: - return step_do(c, stack, eval, axis_to_type()); - - case axis_ancestor_or_self: - return step_do(c, stack, eval, axis_to_type()); - - case axis_attribute: - return step_do(c, stack, eval, axis_to_type()); - - case axis_child: - return step_do(c, stack, eval, axis_to_type()); - - case axis_descendant: - return step_do(c, stack, eval, axis_to_type()); - - case axis_descendant_or_self: - return step_do(c, stack, eval, axis_to_type()); - - case axis_following: - return step_do(c, stack, eval, axis_to_type()); - - case axis_following_sibling: - return step_do(c, stack, eval, axis_to_type()); - - case axis_namespace: - // namespaced axis is not supported - return xpath_node_set_raw(); - - case axis_parent: - return step_do(c, stack, eval, axis_to_type()); - - case axis_preceding: - return step_do(c, stack, eval, axis_to_type()); - - case axis_preceding_sibling: - return step_do(c, stack, eval, axis_to_type()); - - case axis_self: - return step_do(c, stack, eval, axis_to_type()); - - default: - assert(!"Unknown axis"); - return xpath_node_set_raw(); - } - } - - case ast_step_root: - { - assert(!_right); // root step can't have any predicates - - xpath_node_set_raw ns; - - ns.set_type(xpath_node_set::type_sorted); - - if (c.n.node()) ns.push_back(c.n.node().root(), stack.result); - else if (c.n.attribute()) ns.push_back(c.n.parent().root(), stack.result); - - return ns; - } - - case ast_variable: - { - assert(_rettype == _data.variable->type()); - - if (_rettype == xpath_type_node_set) - { - const xpath_node_set& s = _data.variable->get_node_set(); - - xpath_node_set_raw ns; - - ns.set_type(s.type()); - ns.append(s.begin(), s.end(), stack.result); - - return ns; - } - - // fallthrough to type conversion - } - - default: - assert(!"Wrong expression for return type node set"); - return xpath_node_set_raw(); - } - } - - void optimize(xpath_allocator* alloc) - { - if (_left) _left->optimize(alloc); - if (_right) _right->optimize(alloc); - if (_next) _next->optimize(alloc); - - // Rewrite [position()=expr] with [expr] - // Note that this step has to go before classification to recognize [position()=1] - if ((_type == ast_filter || _type == ast_predicate) && - _right->_type == ast_op_equal && _right->_left->_type == ast_func_position && _right->_right->_rettype == xpath_type_number) - { - _right = _right->_right; - } - - // Classify filter/predicate ops to perform various optimizations during evaluation - if (_type == ast_filter || _type == ast_predicate) - { - assert(_test == predicate_default); - - if (_right->_type == ast_number_constant && _right->_data.number == 1.0) - _test = predicate_constant_one; - else if (_right->_rettype == xpath_type_number && (_right->_type == ast_number_constant || _right->_type == ast_variable || _right->_type == ast_func_last)) - _test = predicate_constant; - else if (_right->_rettype != xpath_type_number && _right->is_posinv_expr()) - _test = predicate_posinv; - } - - // Rewrite descendant-or-self::node()/child::foo with descendant::foo - // The former is a full form of //foo, the latter is much faster since it executes the node test immediately - // Do a similar kind of rewrite for self/descendant/descendant-or-self axes - // Note that we only rewrite positionally invariant steps (//foo[1] != /descendant::foo[1]) - if (_type == ast_step && (_axis == axis_child || _axis == axis_self || _axis == axis_descendant || _axis == axis_descendant_or_self) && _left && - _left->_type == ast_step && _left->_axis == axis_descendant_or_self && _left->_test == nodetest_type_node && !_left->_right && - is_posinv_step()) - { - if (_axis == axis_child || _axis == axis_descendant) - _axis = axis_descendant; - else - _axis = axis_descendant_or_self; - - _left = _left->_left; - } - - // Use optimized lookup table implementation for translate() with constant arguments - if (_type == ast_func_translate && _right->_type == ast_string_constant && _right->_next->_type == ast_string_constant) - { - unsigned char* table = translate_table_generate(alloc, _right->_data.string, _right->_next->_data.string); - - if (table) - { - _type = ast_opt_translate_table; - _data.table = table; - } - } - - // Use optimized path for @attr = 'value' or @attr = $value - if (_type == ast_op_equal && - _left->_type == ast_step && _left->_axis == axis_attribute && _left->_test == nodetest_name && !_left->_left && !_left->_right && - (_right->_type == ast_string_constant || (_right->_type == ast_variable && _right->_rettype == xpath_type_string))) - { - _type = ast_opt_compare_attribute; - } - } - - bool is_posinv_expr() const - { - switch (_type) - { - case ast_func_position: - case ast_func_last: - return false; - - case ast_string_constant: - case ast_number_constant: - case ast_variable: - return true; - - case ast_step: - case ast_step_root: - return true; - - case ast_predicate: - case ast_filter: - return true; - - default: - if (_left && !_left->is_posinv_expr()) return false; - - for (xpath_ast_node* n = _right; n; n = n->_next) - if (!n->is_posinv_expr()) return false; - - return true; - } - } - - bool is_posinv_step() const - { - assert(_type == ast_step); - - for (xpath_ast_node* n = _right; n; n = n->_next) - { - assert(n->_type == ast_predicate); - - if (n->_test != predicate_posinv) - return false; - } - - return true; - } - - xpath_value_type rettype() const - { - return static_cast(_rettype); - } - }; - - struct xpath_parser - { - xpath_allocator* _alloc; - xpath_lexer _lexer; - - const char_t* _query; - xpath_variable_set* _variables; - - xpath_parse_result* _result; - - char_t _scratch[32]; - - #ifdef PUGIXML_NO_EXCEPTIONS - jmp_buf _error_handler; - #endif - - void throw_error(const char* message) - { - _result->error = message; - _result->offset = _lexer.current_pos() - _query; - - #ifdef PUGIXML_NO_EXCEPTIONS - longjmp(_error_handler, 1); - #else - throw xpath_exception(*_result); - #endif - } - - void throw_error_oom() - { - #ifdef PUGIXML_NO_EXCEPTIONS - throw_error("Out of memory"); - #else - throw std::bad_alloc(); - #endif - } - - void* alloc_node() - { - void* result = _alloc->allocate_nothrow(sizeof(xpath_ast_node)); - - if (!result) throw_error_oom(); - - return result; - } - - const char_t* alloc_string(const xpath_lexer_string& value) - { - if (value.begin) - { - size_t length = static_cast(value.end - value.begin); - - char_t* c = static_cast(_alloc->allocate_nothrow((length + 1) * sizeof(char_t))); - if (!c) throw_error_oom(); - assert(c); // workaround for clang static analysis - - memcpy(c, value.begin, length * sizeof(char_t)); - c[length] = 0; - - return c; - } - else return 0; - } - - xpath_ast_node* parse_function_helper(ast_type_t type0, ast_type_t type1, size_t argc, xpath_ast_node* args[2]) - { - assert(argc <= 1); - - if (argc == 1 && args[0]->rettype() != xpath_type_node_set) throw_error("Function has to be applied to node set"); - - return new (alloc_node()) xpath_ast_node(argc == 0 ? type0 : type1, xpath_type_string, args[0]); - } - - xpath_ast_node* parse_function(const xpath_lexer_string& name, size_t argc, xpath_ast_node* args[2]) - { - switch (name.begin[0]) - { - case 'b': - if (name == PUGIXML_TEXT("boolean") && argc == 1) - return new (alloc_node()) xpath_ast_node(ast_func_boolean, xpath_type_boolean, args[0]); - - break; - - case 'c': - if (name == PUGIXML_TEXT("count") && argc == 1) - { - if (args[0]->rettype() != xpath_type_node_set) throw_error("Function has to be applied to node set"); - return new (alloc_node()) xpath_ast_node(ast_func_count, xpath_type_number, args[0]); - } - else if (name == PUGIXML_TEXT("contains") && argc == 2) - return new (alloc_node()) xpath_ast_node(ast_func_contains, xpath_type_boolean, args[0], args[1]); - else if (name == PUGIXML_TEXT("concat") && argc >= 2) - return new (alloc_node()) xpath_ast_node(ast_func_concat, xpath_type_string, args[0], args[1]); - else if (name == PUGIXML_TEXT("ceiling") && argc == 1) - return new (alloc_node()) xpath_ast_node(ast_func_ceiling, xpath_type_number, args[0]); - - break; - - case 'f': - if (name == PUGIXML_TEXT("false") && argc == 0) - return new (alloc_node()) xpath_ast_node(ast_func_false, xpath_type_boolean); - else if (name == PUGIXML_TEXT("floor") && argc == 1) - return new (alloc_node()) xpath_ast_node(ast_func_floor, xpath_type_number, args[0]); - - break; - - case 'i': - if (name == PUGIXML_TEXT("id") && argc == 1) - return new (alloc_node()) xpath_ast_node(ast_func_id, xpath_type_node_set, args[0]); - - break; - - case 'l': - if (name == PUGIXML_TEXT("last") && argc == 0) - return new (alloc_node()) xpath_ast_node(ast_func_last, xpath_type_number); - else if (name == PUGIXML_TEXT("lang") && argc == 1) - return new (alloc_node()) xpath_ast_node(ast_func_lang, xpath_type_boolean, args[0]); - else if (name == PUGIXML_TEXT("local-name") && argc <= 1) - return parse_function_helper(ast_func_local_name_0, ast_func_local_name_1, argc, args); - - break; - - case 'n': - if (name == PUGIXML_TEXT("name") && argc <= 1) - return parse_function_helper(ast_func_name_0, ast_func_name_1, argc, args); - else if (name == PUGIXML_TEXT("namespace-uri") && argc <= 1) - return parse_function_helper(ast_func_namespace_uri_0, ast_func_namespace_uri_1, argc, args); - else if (name == PUGIXML_TEXT("normalize-space") && argc <= 1) - return new (alloc_node()) xpath_ast_node(argc == 0 ? ast_func_normalize_space_0 : ast_func_normalize_space_1, xpath_type_string, args[0], args[1]); - else if (name == PUGIXML_TEXT("not") && argc == 1) - return new (alloc_node()) xpath_ast_node(ast_func_not, xpath_type_boolean, args[0]); - else if (name == PUGIXML_TEXT("number") && argc <= 1) - return new (alloc_node()) xpath_ast_node(argc == 0 ? ast_func_number_0 : ast_func_number_1, xpath_type_number, args[0]); - - break; - - case 'p': - if (name == PUGIXML_TEXT("position") && argc == 0) - return new (alloc_node()) xpath_ast_node(ast_func_position, xpath_type_number); - - break; - - case 'r': - if (name == PUGIXML_TEXT("round") && argc == 1) - return new (alloc_node()) xpath_ast_node(ast_func_round, xpath_type_number, args[0]); - - break; - - case 's': - if (name == PUGIXML_TEXT("string") && argc <= 1) - return new (alloc_node()) xpath_ast_node(argc == 0 ? ast_func_string_0 : ast_func_string_1, xpath_type_string, args[0]); - else if (name == PUGIXML_TEXT("string-length") && argc <= 1) - return new (alloc_node()) xpath_ast_node(argc == 0 ? ast_func_string_length_0 : ast_func_string_length_1, xpath_type_number, args[0]); - else if (name == PUGIXML_TEXT("starts-with") && argc == 2) - return new (alloc_node()) xpath_ast_node(ast_func_starts_with, xpath_type_boolean, args[0], args[1]); - else if (name == PUGIXML_TEXT("substring-before") && argc == 2) - return new (alloc_node()) xpath_ast_node(ast_func_substring_before, xpath_type_string, args[0], args[1]); - else if (name == PUGIXML_TEXT("substring-after") && argc == 2) - return new (alloc_node()) xpath_ast_node(ast_func_substring_after, xpath_type_string, args[0], args[1]); - else if (name == PUGIXML_TEXT("substring") && (argc == 2 || argc == 3)) - return new (alloc_node()) xpath_ast_node(argc == 2 ? ast_func_substring_2 : ast_func_substring_3, xpath_type_string, args[0], args[1]); - else if (name == PUGIXML_TEXT("sum") && argc == 1) - { - if (args[0]->rettype() != xpath_type_node_set) throw_error("Function has to be applied to node set"); - return new (alloc_node()) xpath_ast_node(ast_func_sum, xpath_type_number, args[0]); - } - - break; - - case 't': - if (name == PUGIXML_TEXT("translate") && argc == 3) - return new (alloc_node()) xpath_ast_node(ast_func_translate, xpath_type_string, args[0], args[1]); - else if (name == PUGIXML_TEXT("true") && argc == 0) - return new (alloc_node()) xpath_ast_node(ast_func_true, xpath_type_boolean); - - break; - - default: - break; - } - - throw_error("Unrecognized function or wrong parameter count"); - - return 0; - } - - axis_t parse_axis_name(const xpath_lexer_string& name, bool& specified) - { - specified = true; - - switch (name.begin[0]) - { - case 'a': - if (name == PUGIXML_TEXT("ancestor")) - return axis_ancestor; - else if (name == PUGIXML_TEXT("ancestor-or-self")) - return axis_ancestor_or_self; - else if (name == PUGIXML_TEXT("attribute")) - return axis_attribute; - - break; - - case 'c': - if (name == PUGIXML_TEXT("child")) - return axis_child; - - break; - - case 'd': - if (name == PUGIXML_TEXT("descendant")) - return axis_descendant; - else if (name == PUGIXML_TEXT("descendant-or-self")) - return axis_descendant_or_self; - - break; - - case 'f': - if (name == PUGIXML_TEXT("following")) - return axis_following; - else if (name == PUGIXML_TEXT("following-sibling")) - return axis_following_sibling; - - break; - - case 'n': - if (name == PUGIXML_TEXT("namespace")) - return axis_namespace; - - break; - - case 'p': - if (name == PUGIXML_TEXT("parent")) - return axis_parent; - else if (name == PUGIXML_TEXT("preceding")) - return axis_preceding; - else if (name == PUGIXML_TEXT("preceding-sibling")) - return axis_preceding_sibling; - - break; - - case 's': - if (name == PUGIXML_TEXT("self")) - return axis_self; - - break; - - default: - break; - } - - specified = false; - return axis_child; - } - - nodetest_t parse_node_test_type(const xpath_lexer_string& name) - { - switch (name.begin[0]) - { - case 'c': - if (name == PUGIXML_TEXT("comment")) - return nodetest_type_comment; - - break; - - case 'n': - if (name == PUGIXML_TEXT("node")) - return nodetest_type_node; - - break; - - case 'p': - if (name == PUGIXML_TEXT("processing-instruction")) - return nodetest_type_pi; - - break; - - case 't': - if (name == PUGIXML_TEXT("text")) - return nodetest_type_text; - - break; - - default: - break; - } - - return nodetest_none; - } - - // PrimaryExpr ::= VariableReference | '(' Expr ')' | Literal | Number | FunctionCall - xpath_ast_node* parse_primary_expression() - { - switch (_lexer.current()) - { - case lex_var_ref: - { - xpath_lexer_string name = _lexer.contents(); - - if (!_variables) - throw_error("Unknown variable: variable set is not provided"); - - xpath_variable* var = get_variable_scratch(_scratch, _variables, name.begin, name.end); - - if (!var) - throw_error("Unknown variable: variable set does not contain the given name"); - - _lexer.next(); - - return new (alloc_node()) xpath_ast_node(ast_variable, var->type(), var); - } - - case lex_open_brace: - { - _lexer.next(); - - xpath_ast_node* n = parse_expression(); - - if (_lexer.current() != lex_close_brace) - throw_error("Unmatched braces"); - - _lexer.next(); - - return n; - } - - case lex_quoted_string: - { - const char_t* value = alloc_string(_lexer.contents()); - - xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_string_constant, xpath_type_string, value); - _lexer.next(); - - return n; - } - - case lex_number: - { - double value = 0; - - if (!convert_string_to_number_scratch(_scratch, _lexer.contents().begin, _lexer.contents().end, &value)) - throw_error_oom(); - - xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_number_constant, xpath_type_number, value); - _lexer.next(); - - return n; - } - - case lex_string: - { - xpath_ast_node* args[2] = {0}; - size_t argc = 0; - - xpath_lexer_string function = _lexer.contents(); - _lexer.next(); - - xpath_ast_node* last_arg = 0; - - if (_lexer.current() != lex_open_brace) - throw_error("Unrecognized function call"); - _lexer.next(); - - if (_lexer.current() != lex_close_brace) - args[argc++] = parse_expression(); - - while (_lexer.current() != lex_close_brace) - { - if (_lexer.current() != lex_comma) - throw_error("No comma between function arguments"); - _lexer.next(); - - xpath_ast_node* n = parse_expression(); - - if (argc < 2) args[argc] = n; - else last_arg->set_next(n); - - argc++; - last_arg = n; - } - - _lexer.next(); - - return parse_function(function, argc, args); - } - - default: - throw_error("Unrecognizable primary expression"); - - return 0; - } - } - - // FilterExpr ::= PrimaryExpr | FilterExpr Predicate - // Predicate ::= '[' PredicateExpr ']' - // PredicateExpr ::= Expr - xpath_ast_node* parse_filter_expression() - { - xpath_ast_node* n = parse_primary_expression(); - - while (_lexer.current() == lex_open_square_brace) - { - _lexer.next(); - - xpath_ast_node* expr = parse_expression(); - - if (n->rettype() != xpath_type_node_set) throw_error("Predicate has to be applied to node set"); - - n = new (alloc_node()) xpath_ast_node(ast_filter, n, expr, predicate_default); - - if (_lexer.current() != lex_close_square_brace) - throw_error("Unmatched square brace"); - - _lexer.next(); - } - - return n; - } - - // Step ::= AxisSpecifier NodeTest Predicate* | AbbreviatedStep - // AxisSpecifier ::= AxisName '::' | '@'? - // NodeTest ::= NameTest | NodeType '(' ')' | 'processing-instruction' '(' Literal ')' - // NameTest ::= '*' | NCName ':' '*' | QName - // AbbreviatedStep ::= '.' | '..' - xpath_ast_node* parse_step(xpath_ast_node* set) - { - if (set && set->rettype() != xpath_type_node_set) - throw_error("Step has to be applied to node set"); - - bool axis_specified = false; - axis_t axis = axis_child; // implied child axis - - if (_lexer.current() == lex_axis_attribute) - { - axis = axis_attribute; - axis_specified = true; - - _lexer.next(); - } - else if (_lexer.current() == lex_dot) - { - _lexer.next(); - - return new (alloc_node()) xpath_ast_node(ast_step, set, axis_self, nodetest_type_node, 0); - } - else if (_lexer.current() == lex_double_dot) - { - _lexer.next(); - - return new (alloc_node()) xpath_ast_node(ast_step, set, axis_parent, nodetest_type_node, 0); - } - - nodetest_t nt_type = nodetest_none; - xpath_lexer_string nt_name; - - if (_lexer.current() == lex_string) - { - // node name test - nt_name = _lexer.contents(); - _lexer.next(); - - // was it an axis name? - if (_lexer.current() == lex_double_colon) - { - // parse axis name - if (axis_specified) throw_error("Two axis specifiers in one step"); - - axis = parse_axis_name(nt_name, axis_specified); - - if (!axis_specified) throw_error("Unknown axis"); - - // read actual node test - _lexer.next(); - - if (_lexer.current() == lex_multiply) - { - nt_type = nodetest_all; - nt_name = xpath_lexer_string(); - _lexer.next(); - } - else if (_lexer.current() == lex_string) - { - nt_name = _lexer.contents(); - _lexer.next(); - } - else throw_error("Unrecognized node test"); - } - - if (nt_type == nodetest_none) - { - // node type test or processing-instruction - if (_lexer.current() == lex_open_brace) - { - _lexer.next(); - - if (_lexer.current() == lex_close_brace) - { - _lexer.next(); - - nt_type = parse_node_test_type(nt_name); - - if (nt_type == nodetest_none) throw_error("Unrecognized node type"); - - nt_name = xpath_lexer_string(); - } - else if (nt_name == PUGIXML_TEXT("processing-instruction")) - { - if (_lexer.current() != lex_quoted_string) - throw_error("Only literals are allowed as arguments to processing-instruction()"); - - nt_type = nodetest_pi; - nt_name = _lexer.contents(); - _lexer.next(); - - if (_lexer.current() != lex_close_brace) - throw_error("Unmatched brace near processing-instruction()"); - _lexer.next(); - } - else - throw_error("Unmatched brace near node type test"); - - } - // QName or NCName:* - else - { - if (nt_name.end - nt_name.begin > 2 && nt_name.end[-2] == ':' && nt_name.end[-1] == '*') // NCName:* - { - nt_name.end--; // erase * - - nt_type = nodetest_all_in_namespace; - } - else nt_type = nodetest_name; - } - } - } - else if (_lexer.current() == lex_multiply) - { - nt_type = nodetest_all; - _lexer.next(); - } - else throw_error("Unrecognized node test"); - - xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_step, set, axis, nt_type, alloc_string(nt_name)); - - xpath_ast_node* last = 0; - - while (_lexer.current() == lex_open_square_brace) - { - _lexer.next(); - - xpath_ast_node* expr = parse_expression(); - - xpath_ast_node* pred = new (alloc_node()) xpath_ast_node(ast_predicate, 0, expr, predicate_default); - - if (_lexer.current() != lex_close_square_brace) - throw_error("Unmatched square brace"); - _lexer.next(); - - if (last) last->set_next(pred); - else n->set_right(pred); - - last = pred; - } - - return n; - } - - // RelativeLocationPath ::= Step | RelativeLocationPath '/' Step | RelativeLocationPath '//' Step - xpath_ast_node* parse_relative_location_path(xpath_ast_node* set) - { - xpath_ast_node* n = parse_step(set); - - while (_lexer.current() == lex_slash || _lexer.current() == lex_double_slash) - { - lexeme_t l = _lexer.current(); - _lexer.next(); - - if (l == lex_double_slash) - n = new (alloc_node()) xpath_ast_node(ast_step, n, axis_descendant_or_self, nodetest_type_node, 0); - - n = parse_step(n); - } - - return n; - } - - // LocationPath ::= RelativeLocationPath | AbsoluteLocationPath - // AbsoluteLocationPath ::= '/' RelativeLocationPath? | '//' RelativeLocationPath - xpath_ast_node* parse_location_path() - { - if (_lexer.current() == lex_slash) - { - _lexer.next(); - - xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_step_root, xpath_type_node_set); - - // relative location path can start from axis_attribute, dot, double_dot, multiply and string lexemes; any other lexeme means standalone root path - lexeme_t l = _lexer.current(); - - if (l == lex_string || l == lex_axis_attribute || l == lex_dot || l == lex_double_dot || l == lex_multiply) - return parse_relative_location_path(n); - else - return n; - } - else if (_lexer.current() == lex_double_slash) - { - _lexer.next(); - - xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_step_root, xpath_type_node_set); - n = new (alloc_node()) xpath_ast_node(ast_step, n, axis_descendant_or_self, nodetest_type_node, 0); - - return parse_relative_location_path(n); - } - - // else clause moved outside of if because of bogus warning 'control may reach end of non-void function being inlined' in gcc 4.0.1 - return parse_relative_location_path(0); - } - - // PathExpr ::= LocationPath - // | FilterExpr - // | FilterExpr '/' RelativeLocationPath - // | FilterExpr '//' RelativeLocationPath - // UnionExpr ::= PathExpr | UnionExpr '|' PathExpr - // UnaryExpr ::= UnionExpr | '-' UnaryExpr - xpath_ast_node* parse_path_or_unary_expression() - { - // Clarification. - // PathExpr begins with either LocationPath or FilterExpr. - // FilterExpr begins with PrimaryExpr - // PrimaryExpr begins with '$' in case of it being a variable reference, - // '(' in case of it being an expression, string literal, number constant or - // function call. - - if (_lexer.current() == lex_var_ref || _lexer.current() == lex_open_brace || - _lexer.current() == lex_quoted_string || _lexer.current() == lex_number || - _lexer.current() == lex_string) - { - if (_lexer.current() == lex_string) - { - // This is either a function call, or not - if not, we shall proceed with location path - const char_t* state = _lexer.state(); - - while (PUGI__IS_CHARTYPE(*state, ct_space)) ++state; - - if (*state != '(') return parse_location_path(); - - // This looks like a function call; however this still can be a node-test. Check it. - if (parse_node_test_type(_lexer.contents()) != nodetest_none) return parse_location_path(); - } - - xpath_ast_node* n = parse_filter_expression(); - - if (_lexer.current() == lex_slash || _lexer.current() == lex_double_slash) - { - lexeme_t l = _lexer.current(); - _lexer.next(); - - if (l == lex_double_slash) - { - if (n->rettype() != xpath_type_node_set) throw_error("Step has to be applied to node set"); - - n = new (alloc_node()) xpath_ast_node(ast_step, n, axis_descendant_or_self, nodetest_type_node, 0); - } - - // select from location path - return parse_relative_location_path(n); - } - - return n; - } - else if (_lexer.current() == lex_minus) - { - _lexer.next(); - - // precedence 7+ - only parses union expressions - xpath_ast_node* expr = parse_expression_rec(parse_path_or_unary_expression(), 7); - - return new (alloc_node()) xpath_ast_node(ast_op_negate, xpath_type_number, expr); - } - else - return parse_location_path(); - } - - struct binary_op_t - { - ast_type_t asttype; - xpath_value_type rettype; - int precedence; - - binary_op_t(): asttype(ast_unknown), rettype(xpath_type_none), precedence(0) - { - } - - binary_op_t(ast_type_t asttype_, xpath_value_type rettype_, int precedence_): asttype(asttype_), rettype(rettype_), precedence(precedence_) - { - } - - static binary_op_t parse(xpath_lexer& lexer) - { - switch (lexer.current()) - { - case lex_string: - if (lexer.contents() == PUGIXML_TEXT("or")) - return binary_op_t(ast_op_or, xpath_type_boolean, 1); - else if (lexer.contents() == PUGIXML_TEXT("and")) - return binary_op_t(ast_op_and, xpath_type_boolean, 2); - else if (lexer.contents() == PUGIXML_TEXT("div")) - return binary_op_t(ast_op_divide, xpath_type_number, 6); - else if (lexer.contents() == PUGIXML_TEXT("mod")) - return binary_op_t(ast_op_mod, xpath_type_number, 6); - else - return binary_op_t(); - - case lex_equal: - return binary_op_t(ast_op_equal, xpath_type_boolean, 3); - - case lex_not_equal: - return binary_op_t(ast_op_not_equal, xpath_type_boolean, 3); - - case lex_less: - return binary_op_t(ast_op_less, xpath_type_boolean, 4); - - case lex_greater: - return binary_op_t(ast_op_greater, xpath_type_boolean, 4); - - case lex_less_or_equal: - return binary_op_t(ast_op_less_or_equal, xpath_type_boolean, 4); - - case lex_greater_or_equal: - return binary_op_t(ast_op_greater_or_equal, xpath_type_boolean, 4); - - case lex_plus: - return binary_op_t(ast_op_add, xpath_type_number, 5); - - case lex_minus: - return binary_op_t(ast_op_subtract, xpath_type_number, 5); - - case lex_multiply: - return binary_op_t(ast_op_multiply, xpath_type_number, 6); - - case lex_union: - return binary_op_t(ast_op_union, xpath_type_node_set, 7); - - default: - return binary_op_t(); - } - } - }; - - xpath_ast_node* parse_expression_rec(xpath_ast_node* lhs, int limit) - { - binary_op_t op = binary_op_t::parse(_lexer); - - while (op.asttype != ast_unknown && op.precedence >= limit) - { - _lexer.next(); - - xpath_ast_node* rhs = parse_path_or_unary_expression(); - - binary_op_t nextop = binary_op_t::parse(_lexer); - - while (nextop.asttype != ast_unknown && nextop.precedence > op.precedence) - { - rhs = parse_expression_rec(rhs, nextop.precedence); - - nextop = binary_op_t::parse(_lexer); - } - - if (op.asttype == ast_op_union && (lhs->rettype() != xpath_type_node_set || rhs->rettype() != xpath_type_node_set)) - throw_error("Union operator has to be applied to node sets"); - - lhs = new (alloc_node()) xpath_ast_node(op.asttype, op.rettype, lhs, rhs); - - op = binary_op_t::parse(_lexer); - } - - return lhs; - } - - // Expr ::= OrExpr - // OrExpr ::= AndExpr | OrExpr 'or' AndExpr - // AndExpr ::= EqualityExpr | AndExpr 'and' EqualityExpr - // EqualityExpr ::= RelationalExpr - // | EqualityExpr '=' RelationalExpr - // | EqualityExpr '!=' RelationalExpr - // RelationalExpr ::= AdditiveExpr - // | RelationalExpr '<' AdditiveExpr - // | RelationalExpr '>' AdditiveExpr - // | RelationalExpr '<=' AdditiveExpr - // | RelationalExpr '>=' AdditiveExpr - // AdditiveExpr ::= MultiplicativeExpr - // | AdditiveExpr '+' MultiplicativeExpr - // | AdditiveExpr '-' MultiplicativeExpr - // MultiplicativeExpr ::= UnaryExpr - // | MultiplicativeExpr '*' UnaryExpr - // | MultiplicativeExpr 'div' UnaryExpr - // | MultiplicativeExpr 'mod' UnaryExpr - xpath_ast_node* parse_expression() - { - return parse_expression_rec(parse_path_or_unary_expression(), 0); - } - - xpath_parser(const char_t* query, xpath_variable_set* variables, xpath_allocator* alloc, xpath_parse_result* result): _alloc(alloc), _lexer(query), _query(query), _variables(variables), _result(result) - { - } - - xpath_ast_node* parse() - { - xpath_ast_node* result = parse_expression(); - - if (_lexer.current() != lex_eof) - { - // there are still unparsed tokens left, error - throw_error("Incorrect query"); - } - - return result; - } - - static xpath_ast_node* parse(const char_t* query, xpath_variable_set* variables, xpath_allocator* alloc, xpath_parse_result* result) - { - xpath_parser parser(query, variables, alloc, result); - - #ifdef PUGIXML_NO_EXCEPTIONS - int error = setjmp(parser._error_handler); - - return (error == 0) ? parser.parse() : 0; - #else - return parser.parse(); - #endif - } - }; - - struct xpath_query_impl - { - static xpath_query_impl* create() - { - void* memory = xml_memory::allocate(sizeof(xpath_query_impl)); - - return new (memory) xpath_query_impl(); - } - - static void destroy(void* ptr) - { - if (!ptr) return; - - // free all allocated pages - static_cast(ptr)->alloc.release(); - - // free allocator memory (with the first page) - xml_memory::deallocate(ptr); - } - - xpath_query_impl(): root(0), alloc(&block) - { - block.next = 0; - block.capacity = sizeof(block.data); - } - - xpath_ast_node* root; - xpath_allocator alloc; - xpath_memory_block block; - }; - - PUGI__FN xpath_string evaluate_string_impl(xpath_query_impl* impl, const xpath_node& n, xpath_stack_data& sd) - { - if (!impl) return xpath_string(); - - #ifdef PUGIXML_NO_EXCEPTIONS - if (setjmp(sd.error_handler)) return xpath_string(); - #endif - - xpath_context c(n, 1, 1); - - return impl->root->eval_string(c, sd.stack); - } - - PUGI__FN impl::xpath_ast_node* evaluate_node_set_prepare(xpath_query_impl* impl) - { - if (!impl) return 0; - - if (impl->root->rettype() != xpath_type_node_set) - { - #ifdef PUGIXML_NO_EXCEPTIONS - return 0; - #else - xpath_parse_result res; - res.error = "Expression does not evaluate to node set"; - - throw xpath_exception(res); - #endif - } - - return impl->root; - } -PUGI__NS_END - -namespace pugi -{ -#ifndef PUGIXML_NO_EXCEPTIONS - PUGI__FN xpath_exception::xpath_exception(const xpath_parse_result& result_): _result(result_) - { - assert(_result.error); - } - - PUGI__FN const char* xpath_exception::what() const throw() - { - return _result.error; - } - - PUGI__FN const xpath_parse_result& xpath_exception::result() const - { - return _result; - } -#endif - - PUGI__FN xpath_node::xpath_node() - { - } - - PUGI__FN xpath_node::xpath_node(const xml_node& node_): _node(node_) - { - } - - PUGI__FN xpath_node::xpath_node(const xml_attribute& attribute_, const xml_node& parent_): _node(attribute_ ? parent_ : xml_node()), _attribute(attribute_) - { - } - - PUGI__FN xml_node xpath_node::node() const - { - return _attribute ? xml_node() : _node; - } - - PUGI__FN xml_attribute xpath_node::attribute() const - { - return _attribute; - } - - PUGI__FN xml_node xpath_node::parent() const - { - return _attribute ? _node : _node.parent(); - } - - PUGI__FN static void unspecified_bool_xpath_node(xpath_node***) - { - } - - PUGI__FN xpath_node::operator xpath_node::unspecified_bool_type() const - { - return (_node || _attribute) ? unspecified_bool_xpath_node : 0; - } - - PUGI__FN bool xpath_node::operator!() const - { - return !(_node || _attribute); - } - - PUGI__FN bool xpath_node::operator==(const xpath_node& n) const - { - return _node == n._node && _attribute == n._attribute; - } - - PUGI__FN bool xpath_node::operator!=(const xpath_node& n) const - { - return _node != n._node || _attribute != n._attribute; - } - -#ifdef __BORLANDC__ - PUGI__FN bool operator&&(const xpath_node& lhs, bool rhs) - { - return (bool)lhs && rhs; - } - - PUGI__FN bool operator||(const xpath_node& lhs, bool rhs) - { - return (bool)lhs || rhs; - } -#endif - - PUGI__FN void xpath_node_set::_assign(const_iterator begin_, const_iterator end_) - { - assert(begin_ <= end_); - - size_t size_ = static_cast(end_ - begin_); - - if (size_ <= 1) - { - // deallocate old buffer - if (_begin != &_storage) impl::xml_memory::deallocate(_begin); - - // use internal buffer - if (begin_ != end_) _storage = *begin_; - - _begin = &_storage; - _end = &_storage + size_; - } - else - { - // make heap copy - xpath_node* storage = static_cast(impl::xml_memory::allocate(size_ * sizeof(xpath_node))); - - if (!storage) - { - #ifdef PUGIXML_NO_EXCEPTIONS - return; - #else - throw std::bad_alloc(); - #endif - } - - memcpy(storage, begin_, size_ * sizeof(xpath_node)); - - // deallocate old buffer - if (_begin != &_storage) impl::xml_memory::deallocate(_begin); - - // finalize - _begin = storage; - _end = storage + size_; - } - } - - PUGI__FN xpath_node_set::xpath_node_set(): _type(type_unsorted), _begin(&_storage), _end(&_storage) - { - } - - PUGI__FN xpath_node_set::xpath_node_set(const_iterator begin_, const_iterator end_, type_t type_): _type(type_), _begin(&_storage), _end(&_storage) - { - _assign(begin_, end_); - } - - PUGI__FN xpath_node_set::~xpath_node_set() - { - if (_begin != &_storage) impl::xml_memory::deallocate(_begin); - } - - PUGI__FN xpath_node_set::xpath_node_set(const xpath_node_set& ns): _type(ns._type), _begin(&_storage), _end(&_storage) - { - _assign(ns._begin, ns._end); - } - - PUGI__FN xpath_node_set& xpath_node_set::operator=(const xpath_node_set& ns) - { - if (this == &ns) return *this; - - _type = ns._type; - _assign(ns._begin, ns._end); - - return *this; - } - - PUGI__FN xpath_node_set::type_t xpath_node_set::type() const - { - return _type; - } - - PUGI__FN size_t xpath_node_set::size() const - { - return _end - _begin; - } - - PUGI__FN bool xpath_node_set::empty() const - { - return _begin == _end; - } - - PUGI__FN const xpath_node& xpath_node_set::operator[](size_t index) const - { - assert(index < size()); - return _begin[index]; - } - - PUGI__FN xpath_node_set::const_iterator xpath_node_set::begin() const - { - return _begin; - } - - PUGI__FN xpath_node_set::const_iterator xpath_node_set::end() const - { - return _end; - } - - PUGI__FN void xpath_node_set::sort(bool reverse) - { - _type = impl::xpath_sort(_begin, _end, _type, reverse); - } - - PUGI__FN xpath_node xpath_node_set::first() const - { - return impl::xpath_first(_begin, _end, _type); - } - - PUGI__FN xpath_parse_result::xpath_parse_result(): error("Internal error"), offset(0) - { - } - - PUGI__FN xpath_parse_result::operator bool() const - { - return error == 0; - } - - PUGI__FN const char* xpath_parse_result::description() const - { - return error ? error : "No error"; - } - - PUGI__FN xpath_variable::xpath_variable(): _type(xpath_type_none), _next(0) - { - } - - PUGI__FN const char_t* xpath_variable::name() const - { - switch (_type) - { - case xpath_type_node_set: - return static_cast(this)->name; - - case xpath_type_number: - return static_cast(this)->name; - - case xpath_type_string: - return static_cast(this)->name; - - case xpath_type_boolean: - return static_cast(this)->name; - - default: - assert(!"Invalid variable type"); - return 0; - } - } - - PUGI__FN xpath_value_type xpath_variable::type() const - { - return _type; - } - - PUGI__FN bool xpath_variable::get_boolean() const - { - return (_type == xpath_type_boolean) ? static_cast(this)->value : false; - } - - PUGI__FN double xpath_variable::get_number() const - { - return (_type == xpath_type_number) ? static_cast(this)->value : impl::gen_nan(); - } - - PUGI__FN const char_t* xpath_variable::get_string() const - { - const char_t* value = (_type == xpath_type_string) ? static_cast(this)->value : 0; - return value ? value : PUGIXML_TEXT(""); - } - - PUGI__FN const xpath_node_set& xpath_variable::get_node_set() const - { - return (_type == xpath_type_node_set) ? static_cast(this)->value : impl::dummy_node_set; - } - - PUGI__FN bool xpath_variable::set(bool value) - { - if (_type != xpath_type_boolean) return false; - - static_cast(this)->value = value; - return true; - } - - PUGI__FN bool xpath_variable::set(double value) - { - if (_type != xpath_type_number) return false; - - static_cast(this)->value = value; - return true; - } - - PUGI__FN bool xpath_variable::set(const char_t* value) - { - if (_type != xpath_type_string) return false; - - impl::xpath_variable_string* var = static_cast(this); - - // duplicate string - size_t size = (impl::strlength(value) + 1) * sizeof(char_t); - - char_t* copy = static_cast(impl::xml_memory::allocate(size)); - if (!copy) return false; - - memcpy(copy, value, size); - - // replace old string - if (var->value) impl::xml_memory::deallocate(var->value); - var->value = copy; - - return true; - } - - PUGI__FN bool xpath_variable::set(const xpath_node_set& value) - { - if (_type != xpath_type_node_set) return false; - - static_cast(this)->value = value; - return true; - } - - PUGI__FN xpath_variable_set::xpath_variable_set() - { - for (size_t i = 0; i < sizeof(_data) / sizeof(_data[0]); ++i) _data[i] = 0; - } - - PUGI__FN xpath_variable_set::~xpath_variable_set() - { - for (size_t i = 0; i < sizeof(_data) / sizeof(_data[0]); ++i) - { - xpath_variable* var = _data[i]; - - while (var) - { - xpath_variable* next = var->_next; - - impl::delete_xpath_variable(var->_type, var); - - var = next; - } - } - } - - PUGI__FN xpath_variable* xpath_variable_set::find(const char_t* name) const - { - const size_t hash_size = sizeof(_data) / sizeof(_data[0]); - size_t hash = impl::hash_string(name) % hash_size; - - // look for existing variable - for (xpath_variable* var = _data[hash]; var; var = var->_next) - if (impl::strequal(var->name(), name)) - return var; - - return 0; - } - - PUGI__FN xpath_variable* xpath_variable_set::add(const char_t* name, xpath_value_type type) - { - const size_t hash_size = sizeof(_data) / sizeof(_data[0]); - size_t hash = impl::hash_string(name) % hash_size; - - // look for existing variable - for (xpath_variable* var = _data[hash]; var; var = var->_next) - if (impl::strequal(var->name(), name)) - return var->type() == type ? var : 0; - - // add new variable - xpath_variable* result = impl::new_xpath_variable(type, name); - - if (result) - { - result->_type = type; - result->_next = _data[hash]; - - _data[hash] = result; - } - - return result; - } - - PUGI__FN bool xpath_variable_set::set(const char_t* name, bool value) - { - xpath_variable* var = add(name, xpath_type_boolean); - return var ? var->set(value) : false; - } - - PUGI__FN bool xpath_variable_set::set(const char_t* name, double value) - { - xpath_variable* var = add(name, xpath_type_number); - return var ? var->set(value) : false; - } - - PUGI__FN bool xpath_variable_set::set(const char_t* name, const char_t* value) - { - xpath_variable* var = add(name, xpath_type_string); - return var ? var->set(value) : false; - } - - PUGI__FN bool xpath_variable_set::set(const char_t* name, const xpath_node_set& value) - { - xpath_variable* var = add(name, xpath_type_node_set); - return var ? var->set(value) : false; - } - - PUGI__FN xpath_variable* xpath_variable_set::get(const char_t* name) - { - return find(name); - } - - PUGI__FN const xpath_variable* xpath_variable_set::get(const char_t* name) const - { - return find(name); - } - - PUGI__FN xpath_query::xpath_query(const char_t* query, xpath_variable_set* variables): _impl(0) - { - impl::xpath_query_impl* qimpl = impl::xpath_query_impl::create(); - - if (!qimpl) - { - #ifdef PUGIXML_NO_EXCEPTIONS - _result.error = "Out of memory"; - #else - throw std::bad_alloc(); - #endif - } - else - { - impl::buffer_holder impl_holder(qimpl, impl::xpath_query_impl::destroy); - - qimpl->root = impl::xpath_parser::parse(query, variables, &qimpl->alloc, &_result); - - if (qimpl->root) - { - qimpl->root->optimize(&qimpl->alloc); - - _impl = static_cast(impl_holder.release()); - _result.error = 0; - } - } - } - - PUGI__FN xpath_query::~xpath_query() - { - impl::xpath_query_impl::destroy(_impl); - } - - PUGI__FN xpath_value_type xpath_query::return_type() const - { - if (!_impl) return xpath_type_none; - - return static_cast(_impl)->root->rettype(); - } - - PUGI__FN bool xpath_query::evaluate_boolean(const xpath_node& n) const - { - if (!_impl) return false; - - impl::xpath_context c(n, 1, 1); - impl::xpath_stack_data sd; - - #ifdef PUGIXML_NO_EXCEPTIONS - if (setjmp(sd.error_handler)) return false; - #endif - - return static_cast(_impl)->root->eval_boolean(c, sd.stack); - } - - PUGI__FN double xpath_query::evaluate_number(const xpath_node& n) const - { - if (!_impl) return impl::gen_nan(); - - impl::xpath_context c(n, 1, 1); - impl::xpath_stack_data sd; - - #ifdef PUGIXML_NO_EXCEPTIONS - if (setjmp(sd.error_handler)) return impl::gen_nan(); - #endif - - return static_cast(_impl)->root->eval_number(c, sd.stack); - } - -#ifndef PUGIXML_NO_STL - PUGI__FN string_t xpath_query::evaluate_string(const xpath_node& n) const - { - impl::xpath_stack_data sd; - - impl::xpath_string r = impl::evaluate_string_impl(static_cast(_impl), n, sd); - - return string_t(r.c_str(), r.length()); - } -#endif - - PUGI__FN size_t xpath_query::evaluate_string(char_t* buffer, size_t capacity, const xpath_node& n) const - { - impl::xpath_stack_data sd; - - impl::xpath_string r = impl::evaluate_string_impl(static_cast(_impl), n, sd); - - size_t full_size = r.length() + 1; - - if (capacity > 0) - { - size_t size = (full_size < capacity) ? full_size : capacity; - assert(size > 0); - - memcpy(buffer, r.c_str(), (size - 1) * sizeof(char_t)); - buffer[size - 1] = 0; - } - - return full_size; - } - - PUGI__FN xpath_node_set xpath_query::evaluate_node_set(const xpath_node& n) const - { - impl::xpath_ast_node* root = impl::evaluate_node_set_prepare(static_cast(_impl)); - if (!root) return xpath_node_set(); - - impl::xpath_context c(n, 1, 1); - impl::xpath_stack_data sd; - - #ifdef PUGIXML_NO_EXCEPTIONS - if (setjmp(sd.error_handler)) return xpath_node_set(); - #endif - - impl::xpath_node_set_raw r = root->eval_node_set(c, sd.stack, impl::nodeset_eval_all); - - return xpath_node_set(r.begin(), r.end(), r.type()); - } - - PUGI__FN xpath_node xpath_query::evaluate_node(const xpath_node& n) const - { - impl::xpath_ast_node* root = impl::evaluate_node_set_prepare(static_cast(_impl)); - if (!root) return xpath_node(); - - impl::xpath_context c(n, 1, 1); - impl::xpath_stack_data sd; - - #ifdef PUGIXML_NO_EXCEPTIONS - if (setjmp(sd.error_handler)) return xpath_node(); - #endif - - impl::xpath_node_set_raw r = root->eval_node_set(c, sd.stack, impl::nodeset_eval_first); - - return r.first(); - } - - PUGI__FN const xpath_parse_result& xpath_query::result() const - { - return _result; - } - - PUGI__FN static void unspecified_bool_xpath_query(xpath_query***) - { - } - - PUGI__FN xpath_query::operator xpath_query::unspecified_bool_type() const - { - return _impl ? unspecified_bool_xpath_query : 0; - } - - PUGI__FN bool xpath_query::operator!() const - { - return !_impl; - } - - PUGI__FN xpath_node xml_node::select_node(const char_t* query, xpath_variable_set* variables) const - { - xpath_query q(query, variables); - return select_node(q); - } - - PUGI__FN xpath_node xml_node::select_node(const xpath_query& query) const - { - return query.evaluate_node(*this); - } - - PUGI__FN xpath_node_set xml_node::select_nodes(const char_t* query, xpath_variable_set* variables) const - { - xpath_query q(query, variables); - return select_nodes(q); - } - - PUGI__FN xpath_node_set xml_node::select_nodes(const xpath_query& query) const - { - return query.evaluate_node_set(*this); - } - - PUGI__FN xpath_node xml_node::select_single_node(const char_t* query, xpath_variable_set* variables) const - { - xpath_query q(query, variables); - return select_single_node(q); - } - - PUGI__FN xpath_node xml_node::select_single_node(const xpath_query& query) const - { - return query.evaluate_node(*this); - } -} - -#endif - -#ifdef __BORLANDC__ -# pragma option pop -#endif - -// Intel C++ does not properly keep warning state for function templates, -// so popping warning state at the end of translation unit leads to warnings in the middle. -#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) -# pragma warning(pop) -#endif - -// Undefine all local macros (makes sure we're not leaking macros in header-only mode) -#undef PUGI__NO_INLINE -#undef PUGI__UNLIKELY -#undef PUGI__STATIC_ASSERT -#undef PUGI__DMC_VOLATILE -#undef PUGI__MSVC_CRT_VERSION -#undef PUGI__NS_BEGIN -#undef PUGI__NS_END -#undef PUGI__FN -#undef PUGI__FN_NO_INLINE -#undef PUGI__NODETYPE -#undef PUGI__IS_CHARTYPE_IMPL -#undef PUGI__IS_CHARTYPE -#undef PUGI__IS_CHARTYPEX -#undef PUGI__ENDSWITH -#undef PUGI__SKIPWS -#undef PUGI__OPTSET -#undef PUGI__PUSHNODE -#undef PUGI__POPNODE -#undef PUGI__SCANFOR -#undef PUGI__SCANWHILE -#undef PUGI__SCANWHILE_UNROLL -#undef PUGI__ENDSEG -#undef PUGI__THROW_ERROR -#undef PUGI__CHECK_ERROR - -#endif - -/** - * Copyright (c) 2006-2014 Arseny Kapoulkine - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ +/** + * pugixml parser - version 1.7 + * -------------------------------------------------------- + * Copyright (C) 2006-2015, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) + * Report bugs and download new versions at http://pugixml.org/ + * + * This library is distributed under the MIT License. See notice at the end + * of this file. + * + * This work is based on the pugxml parser, which is: + * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) + */ + +#ifndef SOURCE_PUGIXML_CPP +#define SOURCE_PUGIXML_CPP + +#include "pugixml.hpp" + +#include +#include +#include +#include +#include + +#ifdef PUGIXML_WCHAR_MODE +# include +#endif + +#ifndef PUGIXML_NO_XPATH +# include +# include +# ifdef PUGIXML_NO_EXCEPTIONS +# include +# endif +#endif + +#ifndef PUGIXML_NO_STL +# include +# include +# include +#endif + +// For placement new +#include + +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4127) // conditional expression is constant +# pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +# pragma warning(disable: 4611) // interaction between '_setjmp' and C++ object destruction is non-portable +# pragma warning(disable: 4702) // unreachable code +# pragma warning(disable: 4996) // this function or variable may be unsafe +# pragma warning(disable: 4793) // function compiled as native: presence of '_setjmp' makes a function unmanaged +#endif + +#ifdef __INTEL_COMPILER +# pragma warning(disable: 177) // function was declared but never referenced +# pragma warning(disable: 279) // controlling expression is constant +# pragma warning(disable: 1478 1786) // function was declared "deprecated" +# pragma warning(disable: 1684) // conversion from pointer to same-sized integral type +#endif + +#if defined(__BORLANDC__) && defined(PUGIXML_HEADER_ONLY) +# pragma warn -8080 // symbol is declared but never used; disabling this inside push/pop bracket does not make the warning go away +#endif + +#ifdef __BORLANDC__ +# pragma option push +# pragma warn -8008 // condition is always false +# pragma warn -8066 // unreachable code +#endif + +#ifdef __SNC__ +// Using diag_push/diag_pop does not disable the warnings inside templates due to a compiler bug +# pragma diag_suppress=178 // function was declared but never referenced +# pragma diag_suppress=237 // controlling expression is constant +#endif + +// Inlining controls +#if defined(_MSC_VER) && _MSC_VER >= 1300 +# define PUGI__NO_INLINE __declspec(noinline) +#elif defined(__GNUC__) +# define PUGI__NO_INLINE __attribute__((noinline)) +#else +# define PUGI__NO_INLINE +#endif + +// Branch weight controls +#if defined(__GNUC__) +# define PUGI__UNLIKELY(cond) __builtin_expect(cond, 0) +#else +# define PUGI__UNLIKELY(cond) (cond) +#endif + +// Simple static assertion +#define PUGI__STATIC_ASSERT(cond) { static const char condition_failed[(cond) ? 1 : -1] = {0}; (void)condition_failed[0]; } + +// Digital Mars C++ bug workaround for passing char loaded from memory via stack +#ifdef __DMC__ +# define PUGI__DMC_VOLATILE volatile +#else +# define PUGI__DMC_VOLATILE +#endif + +// Borland C++ bug workaround for not defining ::memcpy depending on header include order (can't always use std::memcpy because some compilers don't have it at all) +#if defined(__BORLANDC__) && !defined(__MEM_H_USING_LIST) +using std::memcpy; +using std::memmove; +using std::memset; +#endif + +// In some environments MSVC is a compiler but the CRT lacks certain MSVC-specific features +#if defined(_MSC_VER) && !defined(__S3E__) +# define PUGI__MSVC_CRT_VERSION _MSC_VER +#endif + +#ifdef PUGIXML_HEADER_ONLY +# define PUGI__NS_BEGIN namespace pugi { namespace impl { +# define PUGI__NS_END } } +# define PUGI__FN inline +# define PUGI__FN_NO_INLINE inline +#else +# if defined(_MSC_VER) && _MSC_VER < 1300 // MSVC6 seems to have an amusing bug with anonymous namespaces inside namespaces +# define PUGI__NS_BEGIN namespace pugi { namespace impl { +# define PUGI__NS_END } } +# else +# define PUGI__NS_BEGIN namespace pugi { namespace impl { namespace { +# define PUGI__NS_END } } } +# endif +# define PUGI__FN +# define PUGI__FN_NO_INLINE PUGI__NO_INLINE +#endif + +// uintptr_t +#if !defined(_MSC_VER) || _MSC_VER >= 1600 +# include +#else +namespace pugi +{ +# ifndef _UINTPTR_T_DEFINED + typedef size_t uintptr_t; +# endif + + typedef unsigned __int8 uint8_t; + typedef unsigned __int16 uint16_t; + typedef unsigned __int32 uint32_t; +} +#endif + +// Memory allocation +PUGI__NS_BEGIN + PUGI__FN void* default_allocate(size_t size) + { + return malloc(size); + } + + PUGI__FN void default_deallocate(void* ptr) + { + free(ptr); + } + + template + struct xml_memory_management_function_storage + { + static allocation_function allocate; + static deallocation_function deallocate; + }; + + // Global allocation functions are stored in class statics so that in header mode linker deduplicates them + // Without a template<> we'll get multiple definitions of the same static + template allocation_function xml_memory_management_function_storage::allocate = default_allocate; + template deallocation_function xml_memory_management_function_storage::deallocate = default_deallocate; + + typedef xml_memory_management_function_storage xml_memory; +PUGI__NS_END + +// String utilities +PUGI__NS_BEGIN + // Get string length + PUGI__FN size_t strlength(const char_t* s) + { + assert(s); + + #ifdef PUGIXML_WCHAR_MODE + return wcslen(s); + #else + return strlen(s); + #endif + } + + // Compare two strings + PUGI__FN bool strequal(const char_t* src, const char_t* dst) + { + assert(src && dst); + + #ifdef PUGIXML_WCHAR_MODE + return wcscmp(src, dst) == 0; + #else + return strcmp(src, dst) == 0; + #endif + } + + // Compare lhs with [rhs_begin, rhs_end) + PUGI__FN bool strequalrange(const char_t* lhs, const char_t* rhs, size_t count) + { + for (size_t i = 0; i < count; ++i) + if (lhs[i] != rhs[i]) + return false; + + return lhs[count] == 0; + } + + // Get length of wide string, even if CRT lacks wide character support + PUGI__FN size_t strlength_wide(const wchar_t* s) + { + assert(s); + + #ifdef PUGIXML_WCHAR_MODE + return wcslen(s); + #else + const wchar_t* end = s; + while (*end) end++; + return static_cast(end - s); + #endif + } +PUGI__NS_END + +// auto_ptr-like object for exception recovery +PUGI__NS_BEGIN + template struct auto_deleter + { + T* data; + D deleter; + + auto_deleter(T* data_, D deleter_): data(data_), deleter(deleter_) + { + } + + ~auto_deleter() + { + if (data) deleter(data); + } + + T* release() + { + T* result = data; + data = 0; + return result; + } + }; +PUGI__NS_END + +#ifdef PUGIXML_COMPACT +PUGI__NS_BEGIN + class compact_hash_table + { + public: + compact_hash_table(): _items(0), _capacity(0), _count(0) + { + } + + void clear() + { + if (_items) + { + xml_memory::deallocate(_items); + _items = 0; + _capacity = 0; + _count = 0; + } + } + + void** find(const void* key) + { + assert(key); + + if (_capacity == 0) return 0; + + size_t hashmod = _capacity - 1; + size_t bucket = hash(key) & hashmod; + + for (size_t probe = 0; probe <= hashmod; ++probe) + { + item_t& probe_item = _items[bucket]; + + if (probe_item.key == key) + return &probe_item.value; + + if (probe_item.key == 0) + return 0; + + // hash collision, quadratic probing + bucket = (bucket + probe + 1) & hashmod; + } + + assert(!"Hash table is full"); + return 0; + } + + void** insert(const void* key) + { + assert(key); + assert(_capacity != 0 && _count < _capacity - _capacity / 4); + + size_t hashmod = _capacity - 1; + size_t bucket = hash(key) & hashmod; + + for (size_t probe = 0; probe <= hashmod; ++probe) + { + item_t& probe_item = _items[bucket]; + + if (probe_item.key == 0) + { + probe_item.key = key; + _count++; + return &probe_item.value; + } + + if (probe_item.key == key) + return &probe_item.value; + + // hash collision, quadratic probing + bucket = (bucket + probe + 1) & hashmod; + } + + assert(!"Hash table is full"); + return 0; + } + + bool reserve() + { + if (_count + 16 >= _capacity - _capacity / 4) + return rehash(); + + return true; + } + + private: + struct item_t + { + const void* key; + void* value; + }; + + item_t* _items; + size_t _capacity; + + size_t _count; + + bool rehash(); + + static unsigned int hash(const void* key) + { + unsigned int h = static_cast(reinterpret_cast(key)); + + // MurmurHash3 32-bit finalizer + h ^= h >> 16; + h *= 0x85ebca6bu; + h ^= h >> 13; + h *= 0xc2b2ae35u; + h ^= h >> 16; + + return h; + } + }; + + PUGI__FN_NO_INLINE bool compact_hash_table::rehash() + { + compact_hash_table rt; + rt._capacity = (_capacity == 0) ? 32 : _capacity * 2; + rt._items = static_cast(xml_memory::allocate(sizeof(item_t) * rt._capacity)); + + if (!rt._items) + return false; + + memset(rt._items, 0, sizeof(item_t) * rt._capacity); + + for (size_t i = 0; i < _capacity; ++i) + if (_items[i].key) + *rt.insert(_items[i].key) = _items[i].value; + + if (_items) + xml_memory::deallocate(_items); + + _capacity = rt._capacity; + _items = rt._items; + + assert(_count == rt._count); + + return true; + } + +PUGI__NS_END +#endif + +PUGI__NS_BEGIN + static const size_t xml_memory_page_size = + #ifdef PUGIXML_MEMORY_PAGE_SIZE + PUGIXML_MEMORY_PAGE_SIZE + #else + 32768 + #endif + ; + +#ifdef PUGIXML_COMPACT + static const uintptr_t xml_memory_block_alignment = 4; + + static const uintptr_t xml_memory_page_alignment = sizeof(void*); +#else + static const uintptr_t xml_memory_block_alignment = sizeof(void*); + + static const uintptr_t xml_memory_page_alignment = 64; + static const uintptr_t xml_memory_page_pointer_mask = ~(xml_memory_page_alignment - 1); +#endif + + // extra metadata bits + static const uintptr_t xml_memory_page_contents_shared_mask = 32; + static const uintptr_t xml_memory_page_name_allocated_mask = 16; + static const uintptr_t xml_memory_page_value_allocated_mask = 8; + static const uintptr_t xml_memory_page_type_mask = 7; + + // combined masks for string uniqueness + static const uintptr_t xml_memory_page_name_allocated_or_shared_mask = xml_memory_page_name_allocated_mask | xml_memory_page_contents_shared_mask; + static const uintptr_t xml_memory_page_value_allocated_or_shared_mask = xml_memory_page_value_allocated_mask | xml_memory_page_contents_shared_mask; + +#ifdef PUGIXML_COMPACT + #define PUGI__GETPAGE_IMPL(header) (header).get_page() +#else + #define PUGI__GETPAGE_IMPL(header) reinterpret_cast((header) & impl::xml_memory_page_pointer_mask) +#endif + + #define PUGI__GETPAGE(n) PUGI__GETPAGE_IMPL((n)->header) + #define PUGI__NODETYPE(n) static_cast(((n)->header & impl::xml_memory_page_type_mask) + 1) + + struct xml_allocator; + + struct xml_memory_page + { + static xml_memory_page* construct(void* memory) + { + xml_memory_page* result = static_cast(memory); + + result->allocator = 0; + result->prev = 0; + result->next = 0; + result->busy_size = 0; + result->freed_size = 0; + + #ifdef PUGIXML_COMPACT + result->compact_string_base = 0; + result->compact_shared_parent = 0; + result->compact_page_marker = 0; + #endif + + return result; + } + + xml_allocator* allocator; + + xml_memory_page* prev; + xml_memory_page* next; + + size_t busy_size; + size_t freed_size; + + #ifdef PUGIXML_COMPACT + char_t* compact_string_base; + void* compact_shared_parent; + uint32_t* compact_page_marker; + #endif + }; + + struct xml_memory_string_header + { + uint16_t page_offset; // offset from page->data + uint16_t full_size; // 0 if string occupies whole page + }; + + struct xml_allocator + { + xml_allocator(xml_memory_page* root): _root(root), _busy_size(root->busy_size) + { + #ifdef PUGIXML_COMPACT + _hash = 0; + #endif + } + + xml_memory_page* allocate_page(size_t data_size) + { + size_t size = sizeof(xml_memory_page) + data_size; + + // allocate block with some alignment, leaving memory for worst-case padding + void* memory = xml_memory::allocate(size + xml_memory_page_alignment); + if (!memory) return 0; + + // align to next page boundary (note: this guarantees at least 1 usable byte before the page) + char* page_memory = reinterpret_cast((reinterpret_cast(memory) + xml_memory_page_alignment) & ~(xml_memory_page_alignment - 1)); + + // prepare page structure + xml_memory_page* page = xml_memory_page::construct(page_memory); + assert(page); + + page->allocator = _root->allocator; + + // record the offset for freeing the memory block + assert(page_memory > memory && page_memory - static_cast(memory) <= 127); + page_memory[-1] = static_cast(page_memory - static_cast(memory)); + + return page; + } + + static void deallocate_page(xml_memory_page* page) + { + char* page_memory = reinterpret_cast(page); + + xml_memory::deallocate(page_memory - page_memory[-1]); + } + + void* allocate_memory_oob(size_t size, xml_memory_page*& out_page); + + void* allocate_memory(size_t size, xml_memory_page*& out_page) + { + if (PUGI__UNLIKELY(_busy_size + size > xml_memory_page_size)) + return allocate_memory_oob(size, out_page); + + void* buf = reinterpret_cast(_root) + sizeof(xml_memory_page) + _busy_size; + + _busy_size += size; + + out_page = _root; + + return buf; + } + + #ifdef PUGIXML_COMPACT + void* allocate_object(size_t size, xml_memory_page*& out_page) + { + void* result = allocate_memory(size + sizeof(uint32_t), out_page); + if (!result) return 0; + + // adjust for marker + ptrdiff_t offset = static_cast(result) - reinterpret_cast(out_page->compact_page_marker); + + if (PUGI__UNLIKELY(static_cast(offset) >= 256 * xml_memory_block_alignment)) + { + // insert new marker + uint32_t* marker = static_cast(result); + + *marker = static_cast(reinterpret_cast(marker) - reinterpret_cast(out_page)); + out_page->compact_page_marker = marker; + + // since we don't reuse the page space until we reallocate it, we can just pretend that we freed the marker block + // this will make sure deallocate_memory correctly tracks the size + out_page->freed_size += sizeof(uint32_t); + + return marker + 1; + } + else + { + // roll back uint32_t part + _busy_size -= sizeof(uint32_t); + + return result; + } + } + #else + void* allocate_object(size_t size, xml_memory_page*& out_page) + { + return allocate_memory(size, out_page); + } + #endif + + void deallocate_memory(void* ptr, size_t size, xml_memory_page* page) + { + if (page == _root) page->busy_size = _busy_size; + + assert(ptr >= reinterpret_cast(page) + sizeof(xml_memory_page) && ptr < reinterpret_cast(page) + sizeof(xml_memory_page) + page->busy_size); + (void)!ptr; + + page->freed_size += size; + assert(page->freed_size <= page->busy_size); + + if (page->freed_size == page->busy_size) + { + if (page->next == 0) + { + assert(_root == page); + + // top page freed, just reset sizes + page->busy_size = 0; + page->freed_size = 0; + + #ifdef PUGIXML_COMPACT + // reset compact state to maximize efficiency + page->compact_string_base = 0; + page->compact_shared_parent = 0; + page->compact_page_marker = 0; + #endif + + _busy_size = 0; + } + else + { + assert(_root != page); + assert(page->prev); + + // remove from the list + page->prev->next = page->next; + page->next->prev = page->prev; + + // deallocate + deallocate_page(page); + } + } + } + + char_t* allocate_string(size_t length) + { + static const size_t max_encoded_offset = (1 << 16) * xml_memory_block_alignment; + + PUGI__STATIC_ASSERT(xml_memory_page_size <= max_encoded_offset); + + // allocate memory for string and header block + size_t size = sizeof(xml_memory_string_header) + length * sizeof(char_t); + + // round size up to block alignment boundary + size_t full_size = (size + (xml_memory_block_alignment - 1)) & ~(xml_memory_block_alignment - 1); + + xml_memory_page* page; + xml_memory_string_header* header = static_cast(allocate_memory(full_size, page)); + + if (!header) return 0; + + // setup header + ptrdiff_t page_offset = reinterpret_cast(header) - reinterpret_cast(page) - sizeof(xml_memory_page); + + assert(page_offset % xml_memory_block_alignment == 0); + assert(page_offset >= 0 && static_cast(page_offset) < max_encoded_offset); + header->page_offset = static_cast(static_cast(page_offset) / xml_memory_block_alignment); + + // full_size == 0 for large strings that occupy the whole page + assert(full_size % xml_memory_block_alignment == 0); + assert(full_size < max_encoded_offset || (page->busy_size == full_size && page_offset == 0)); + header->full_size = static_cast(full_size < max_encoded_offset ? full_size / xml_memory_block_alignment : 0); + + // round-trip through void* to avoid 'cast increases required alignment of target type' warning + // header is guaranteed a pointer-sized alignment, which should be enough for char_t + return static_cast(static_cast(header + 1)); + } + + void deallocate_string(char_t* string) + { + // this function casts pointers through void* to avoid 'cast increases required alignment of target type' warnings + // we're guaranteed the proper (pointer-sized) alignment on the input string if it was allocated via allocate_string + + // get header + xml_memory_string_header* header = static_cast(static_cast(string)) - 1; + assert(header); + + // deallocate + size_t page_offset = sizeof(xml_memory_page) + header->page_offset * xml_memory_block_alignment; + xml_memory_page* page = reinterpret_cast(static_cast(reinterpret_cast(header) - page_offset)); + + // if full_size == 0 then this string occupies the whole page + size_t full_size = header->full_size == 0 ? page->busy_size : header->full_size * xml_memory_block_alignment; + + deallocate_memory(header, full_size, page); + } + + bool reserve() + { + #ifdef PUGIXML_COMPACT + return _hash->reserve(); + #else + return true; + #endif + } + + xml_memory_page* _root; + size_t _busy_size; + + #ifdef PUGIXML_COMPACT + compact_hash_table* _hash; + #endif + }; + + PUGI__FN_NO_INLINE void* xml_allocator::allocate_memory_oob(size_t size, xml_memory_page*& out_page) + { + const size_t large_allocation_threshold = xml_memory_page_size / 4; + + xml_memory_page* page = allocate_page(size <= large_allocation_threshold ? xml_memory_page_size : size); + out_page = page; + + if (!page) return 0; + + if (size <= large_allocation_threshold) + { + _root->busy_size = _busy_size; + + // insert page at the end of linked list + page->prev = _root; + _root->next = page; + _root = page; + + _busy_size = size; + } + else + { + // insert page before the end of linked list, so that it is deleted as soon as possible + // the last page is not deleted even if it's empty (see deallocate_memory) + assert(_root->prev); + + page->prev = _root->prev; + page->next = _root; + + _root->prev->next = page; + _root->prev = page; + + page->busy_size = size; + } + + return reinterpret_cast(page) + sizeof(xml_memory_page); + } +PUGI__NS_END + +#ifdef PUGIXML_COMPACT +PUGI__NS_BEGIN + static const uintptr_t compact_alignment_log2 = 2; + static const uintptr_t compact_alignment = 1 << compact_alignment_log2; + + class compact_header + { + public: + compact_header(xml_memory_page* page, unsigned int flags) + { + PUGI__STATIC_ASSERT(xml_memory_block_alignment == compact_alignment); + + ptrdiff_t offset = (reinterpret_cast(this) - reinterpret_cast(page->compact_page_marker)); + assert(offset % compact_alignment == 0 && static_cast(offset) < 256 * compact_alignment); + + _page = static_cast(offset >> compact_alignment_log2); + _flags = static_cast(flags); + } + + void operator&=(uintptr_t mod) + { + _flags &= static_cast(mod); + } + + void operator|=(uintptr_t mod) + { + _flags |= static_cast(mod); + } + + uintptr_t operator&(uintptr_t mod) const + { + return _flags & mod; + } + + xml_memory_page* get_page() const + { + // round-trip through void* to silence 'cast increases required alignment of target type' warnings + const char* page_marker = reinterpret_cast(this) - (_page << compact_alignment_log2); + const char* page = page_marker - *reinterpret_cast(static_cast(page_marker)); + + return const_cast(reinterpret_cast(static_cast(page))); + } + + private: + unsigned char _page; + unsigned char _flags; + }; + + PUGI__FN xml_memory_page* compact_get_page(const void* object, int header_offset) + { + const compact_header* header = reinterpret_cast(static_cast(object) - header_offset); + + return header->get_page(); + } + + template PUGI__FN_NO_INLINE T* compact_get_value(const void* object) + { + return static_cast(*compact_get_page(object, header_offset)->allocator->_hash->find(object)); + } + + template PUGI__FN_NO_INLINE void compact_set_value(const void* object, T* value) + { + *compact_get_page(object, header_offset)->allocator->_hash->insert(object) = value; + } + + template class compact_pointer + { + public: + compact_pointer(): _data(0) + { + } + + void operator=(const compact_pointer& rhs) + { + *this = rhs + 0; + } + + void operator=(T* value) + { + if (value) + { + // value is guaranteed to be compact-aligned; 'this' is not + // our decoding is based on 'this' aligned to compact alignment downwards (see operator T*) + // so for negative offsets (e.g. -3) we need to adjust the diff by compact_alignment - 1 to + // compensate for arithmetic shift rounding for negative values + ptrdiff_t diff = reinterpret_cast(value) - reinterpret_cast(this); + ptrdiff_t offset = ((diff + int(compact_alignment - 1)) >> compact_alignment_log2) - start; + + if (static_cast(offset) <= 253) + _data = static_cast(offset + 1); + else + { + compact_set_value(this, value); + + _data = 255; + } + } + else + _data = 0; + } + + operator T*() const + { + if (_data) + { + if (_data < 255) + { + uintptr_t base = reinterpret_cast(this) & ~(compact_alignment - 1); + + return reinterpret_cast(base + ((_data - 1 + start) << compact_alignment_log2)); + } + else + return compact_get_value(this); + } + else + return 0; + } + + T* operator->() const + { + return *this; + } + + private: + unsigned char _data; + }; + + template class compact_pointer_parent + { + public: + compact_pointer_parent(): _data(0) + { + } + + void operator=(const compact_pointer_parent& rhs) + { + *this = rhs + 0; + } + + void operator=(T* value) + { + if (value) + { + // value is guaranteed to be compact-aligned; 'this' is not + // our decoding is based on 'this' aligned to compact alignment downwards (see operator T*) + // so for negative offsets (e.g. -3) we need to adjust the diff by compact_alignment - 1 to + // compensate for arithmetic shift behavior for negative values + ptrdiff_t diff = reinterpret_cast(value) - reinterpret_cast(this); + ptrdiff_t offset = ((diff + int(compact_alignment - 1)) >> compact_alignment_log2) + 65533; + + if (static_cast(offset) <= 65533) + { + _data = static_cast(offset + 1); + } + else + { + xml_memory_page* page = compact_get_page(this, header_offset); + + if (PUGI__UNLIKELY(page->compact_shared_parent == 0)) + page->compact_shared_parent = value; + + if (page->compact_shared_parent == value) + { + _data = 65534; + } + else + { + compact_set_value(this, value); + + _data = 65535; + } + } + } + else + { + _data = 0; + } + } + + operator T*() const + { + if (_data) + { + if (_data < 65534) + { + uintptr_t base = reinterpret_cast(this) & ~(compact_alignment - 1); + + return reinterpret_cast(base + ((_data - 1 - 65533) << compact_alignment_log2)); + } + else if (_data == 65534) + return static_cast(compact_get_page(this, header_offset)->compact_shared_parent); + else + return compact_get_value(this); + } + else + return 0; + } + + T* operator->() const + { + return *this; + } + + private: + uint16_t _data; + }; + + template class compact_string + { + public: + compact_string(): _data(0) + { + } + + void operator=(const compact_string& rhs) + { + *this = rhs + 0; + } + + void operator=(char_t* value) + { + if (value) + { + xml_memory_page* page = compact_get_page(this, header_offset); + + if (PUGI__UNLIKELY(page->compact_string_base == 0)) + page->compact_string_base = value; + + ptrdiff_t offset = value - page->compact_string_base; + + if (static_cast(offset) < (65535 << 7)) + { + // round-trip through void* to silence 'cast increases required alignment of target type' warnings + uint16_t* base = reinterpret_cast(static_cast(reinterpret_cast(this) - base_offset)); + + if (*base == 0) + { + *base = static_cast((offset >> 7) + 1); + _data = static_cast((offset & 127) + 1); + } + else + { + ptrdiff_t remainder = offset - ((*base - 1) << 7); + + if (static_cast(remainder) <= 253) + { + _data = static_cast(remainder + 1); + } + else + { + compact_set_value(this, value); + + _data = 255; + } + } + } + else + { + compact_set_value(this, value); + + _data = 255; + } + } + else + { + _data = 0; + } + } + + operator char_t*() const + { + if (_data) + { + if (_data < 255) + { + xml_memory_page* page = compact_get_page(this, header_offset); + + // round-trip through void* to silence 'cast increases required alignment of target type' warnings + const uint16_t* base = reinterpret_cast(static_cast(reinterpret_cast(this) - base_offset)); + assert(*base); + + ptrdiff_t offset = ((*base - 1) << 7) + (_data - 1); + + return page->compact_string_base + offset; + } + else + { + return compact_get_value(this); + } + } + else + return 0; + } + + private: + unsigned char _data; + }; +PUGI__NS_END +#endif + +#ifdef PUGIXML_COMPACT +namespace pugi +{ + struct xml_attribute_struct + { + xml_attribute_struct(impl::xml_memory_page* page): header(page, 0), namevalue_base(0) + { + PUGI__STATIC_ASSERT(sizeof(xml_attribute_struct) == 8); + } + + impl::compact_header header; + + uint16_t namevalue_base; + + impl::compact_string<4, 2> name; + impl::compact_string<5, 3> value; + + impl::compact_pointer prev_attribute_c; + impl::compact_pointer next_attribute; + }; + + struct xml_node_struct + { + xml_node_struct(impl::xml_memory_page* page, xml_node_type type): header(page, type - 1), namevalue_base(0) + { + PUGI__STATIC_ASSERT(sizeof(xml_node_struct) == 12); + } + + impl::compact_header header; + + uint16_t namevalue_base; + + impl::compact_string<4, 2> name; + impl::compact_string<5, 3> value; + + impl::compact_pointer_parent parent; + + impl::compact_pointer first_child; + + impl::compact_pointer prev_sibling_c; + impl::compact_pointer next_sibling; + + impl::compact_pointer first_attribute; + }; +} +#else +namespace pugi +{ + struct xml_attribute_struct + { + xml_attribute_struct(impl::xml_memory_page* page): header(reinterpret_cast(page)), name(0), value(0), prev_attribute_c(0), next_attribute(0) + { + } + + uintptr_t header; + + char_t* name; + char_t* value; + + xml_attribute_struct* prev_attribute_c; + xml_attribute_struct* next_attribute; + }; + + struct xml_node_struct + { + xml_node_struct(impl::xml_memory_page* page, xml_node_type type): header(reinterpret_cast(page) | (type - 1)), name(0), value(0), parent(0), first_child(0), prev_sibling_c(0), next_sibling(0), first_attribute(0) + { + } + + uintptr_t header; + + char_t* name; + char_t* value; + + xml_node_struct* parent; + + xml_node_struct* first_child; + + xml_node_struct* prev_sibling_c; + xml_node_struct* next_sibling; + + xml_attribute_struct* first_attribute; + }; +} +#endif + +PUGI__NS_BEGIN + struct xml_extra_buffer + { + char_t* buffer; + xml_extra_buffer* next; + }; + + struct xml_document_struct: public xml_node_struct, public xml_allocator + { + xml_document_struct(xml_memory_page* page): xml_node_struct(page, node_document), xml_allocator(page), buffer(0), extra_buffers(0) + { + #ifdef PUGIXML_COMPACT + _hash = &hash; + #endif + } + + const char_t* buffer; + + xml_extra_buffer* extra_buffers; + + #ifdef PUGIXML_COMPACT + compact_hash_table hash; + #endif + }; + + template inline xml_allocator& get_allocator(const Object* object) + { + assert(object); + + return *PUGI__GETPAGE(object)->allocator; + } + + template inline xml_document_struct& get_document(const Object* object) + { + assert(object); + + return *static_cast(PUGI__GETPAGE(object)->allocator); + } +PUGI__NS_END + +// Low-level DOM operations +PUGI__NS_BEGIN + inline xml_attribute_struct* allocate_attribute(xml_allocator& alloc) + { + xml_memory_page* page; + void* memory = alloc.allocate_object(sizeof(xml_attribute_struct), page); + if (!memory) return 0; + + return new (memory) xml_attribute_struct(page); + } + + inline xml_node_struct* allocate_node(xml_allocator& alloc, xml_node_type type) + { + xml_memory_page* page; + void* memory = alloc.allocate_object(sizeof(xml_node_struct), page); + if (!memory) return 0; + + return new (memory) xml_node_struct(page, type); + } + + inline void destroy_attribute(xml_attribute_struct* a, xml_allocator& alloc) + { + if (a->header & impl::xml_memory_page_name_allocated_mask) + alloc.deallocate_string(a->name); + + if (a->header & impl::xml_memory_page_value_allocated_mask) + alloc.deallocate_string(a->value); + + alloc.deallocate_memory(a, sizeof(xml_attribute_struct), PUGI__GETPAGE(a)); + } + + inline void destroy_node(xml_node_struct* n, xml_allocator& alloc) + { + if (n->header & impl::xml_memory_page_name_allocated_mask) + alloc.deallocate_string(n->name); + + if (n->header & impl::xml_memory_page_value_allocated_mask) + alloc.deallocate_string(n->value); + + for (xml_attribute_struct* attr = n->first_attribute; attr; ) + { + xml_attribute_struct* next = attr->next_attribute; + + destroy_attribute(attr, alloc); + + attr = next; + } + + for (xml_node_struct* child = n->first_child; child; ) + { + xml_node_struct* next = child->next_sibling; + + destroy_node(child, alloc); + + child = next; + } + + alloc.deallocate_memory(n, sizeof(xml_node_struct), PUGI__GETPAGE(n)); + } + + inline void append_node(xml_node_struct* child, xml_node_struct* node) + { + child->parent = node; + + xml_node_struct* head = node->first_child; + + if (head) + { + xml_node_struct* tail = head->prev_sibling_c; + + tail->next_sibling = child; + child->prev_sibling_c = tail; + head->prev_sibling_c = child; + } + else + { + node->first_child = child; + child->prev_sibling_c = child; + } + } + + inline void prepend_node(xml_node_struct* child, xml_node_struct* node) + { + child->parent = node; + + xml_node_struct* head = node->first_child; + + if (head) + { + child->prev_sibling_c = head->prev_sibling_c; + head->prev_sibling_c = child; + } + else + child->prev_sibling_c = child; + + child->next_sibling = head; + node->first_child = child; + } + + inline void insert_node_after(xml_node_struct* child, xml_node_struct* node) + { + xml_node_struct* parent = node->parent; + + child->parent = parent; + + if (node->next_sibling) + node->next_sibling->prev_sibling_c = child; + else + parent->first_child->prev_sibling_c = child; + + child->next_sibling = node->next_sibling; + child->prev_sibling_c = node; + + node->next_sibling = child; + } + + inline void insert_node_before(xml_node_struct* child, xml_node_struct* node) + { + xml_node_struct* parent = node->parent; + + child->parent = parent; + + if (node->prev_sibling_c->next_sibling) + node->prev_sibling_c->next_sibling = child; + else + parent->first_child = child; + + child->prev_sibling_c = node->prev_sibling_c; + child->next_sibling = node; + + node->prev_sibling_c = child; + } + + inline void remove_node(xml_node_struct* node) + { + xml_node_struct* parent = node->parent; + + if (node->next_sibling) + node->next_sibling->prev_sibling_c = node->prev_sibling_c; + else + parent->first_child->prev_sibling_c = node->prev_sibling_c; + + if (node->prev_sibling_c->next_sibling) + node->prev_sibling_c->next_sibling = node->next_sibling; + else + parent->first_child = node->next_sibling; + + node->parent = 0; + node->prev_sibling_c = 0; + node->next_sibling = 0; + } + + inline void append_attribute(xml_attribute_struct* attr, xml_node_struct* node) + { + xml_attribute_struct* head = node->first_attribute; + + if (head) + { + xml_attribute_struct* tail = head->prev_attribute_c; + + tail->next_attribute = attr; + attr->prev_attribute_c = tail; + head->prev_attribute_c = attr; + } + else + { + node->first_attribute = attr; + attr->prev_attribute_c = attr; + } + } + + inline void prepend_attribute(xml_attribute_struct* attr, xml_node_struct* node) + { + xml_attribute_struct* head = node->first_attribute; + + if (head) + { + attr->prev_attribute_c = head->prev_attribute_c; + head->prev_attribute_c = attr; + } + else + attr->prev_attribute_c = attr; + + attr->next_attribute = head; + node->first_attribute = attr; + } + + inline void insert_attribute_after(xml_attribute_struct* attr, xml_attribute_struct* place, xml_node_struct* node) + { + if (place->next_attribute) + place->next_attribute->prev_attribute_c = attr; + else + node->first_attribute->prev_attribute_c = attr; + + attr->next_attribute = place->next_attribute; + attr->prev_attribute_c = place; + place->next_attribute = attr; + } + + inline void insert_attribute_before(xml_attribute_struct* attr, xml_attribute_struct* place, xml_node_struct* node) + { + if (place->prev_attribute_c->next_attribute) + place->prev_attribute_c->next_attribute = attr; + else + node->first_attribute = attr; + + attr->prev_attribute_c = place->prev_attribute_c; + attr->next_attribute = place; + place->prev_attribute_c = attr; + } + + inline void remove_attribute(xml_attribute_struct* attr, xml_node_struct* node) + { + if (attr->next_attribute) + attr->next_attribute->prev_attribute_c = attr->prev_attribute_c; + else + node->first_attribute->prev_attribute_c = attr->prev_attribute_c; + + if (attr->prev_attribute_c->next_attribute) + attr->prev_attribute_c->next_attribute = attr->next_attribute; + else + node->first_attribute = attr->next_attribute; + + attr->prev_attribute_c = 0; + attr->next_attribute = 0; + } + + PUGI__FN_NO_INLINE xml_node_struct* append_new_node(xml_node_struct* node, xml_allocator& alloc, xml_node_type type = node_element) + { + if (!alloc.reserve()) return 0; + + xml_node_struct* child = allocate_node(alloc, type); + if (!child) return 0; + + append_node(child, node); + + return child; + } + + PUGI__FN_NO_INLINE xml_attribute_struct* append_new_attribute(xml_node_struct* node, xml_allocator& alloc) + { + if (!alloc.reserve()) return 0; + + xml_attribute_struct* attr = allocate_attribute(alloc); + if (!attr) return 0; + + append_attribute(attr, node); + + return attr; + } +PUGI__NS_END + +// Helper classes for code generation +PUGI__NS_BEGIN + struct opt_false + { + enum { value = 0 }; + }; + + struct opt_true + { + enum { value = 1 }; + }; +PUGI__NS_END + +// Unicode utilities +PUGI__NS_BEGIN + inline uint16_t endian_swap(uint16_t value) + { + return static_cast(((value & 0xff) << 8) | (value >> 8)); + } + + inline uint32_t endian_swap(uint32_t value) + { + return ((value & 0xff) << 24) | ((value & 0xff00) << 8) | ((value & 0xff0000) >> 8) | (value >> 24); + } + + struct utf8_counter + { + typedef size_t value_type; + + static value_type low(value_type result, uint32_t ch) + { + // U+0000..U+007F + if (ch < 0x80) return result + 1; + // U+0080..U+07FF + else if (ch < 0x800) return result + 2; + // U+0800..U+FFFF + else return result + 3; + } + + static value_type high(value_type result, uint32_t) + { + // U+10000..U+10FFFF + return result + 4; + } + }; + + struct utf8_writer + { + typedef uint8_t* value_type; + + static value_type low(value_type result, uint32_t ch) + { + // U+0000..U+007F + if (ch < 0x80) + { + *result = static_cast(ch); + return result + 1; + } + // U+0080..U+07FF + else if (ch < 0x800) + { + result[0] = static_cast(0xC0 | (ch >> 6)); + result[1] = static_cast(0x80 | (ch & 0x3F)); + return result + 2; + } + // U+0800..U+FFFF + else + { + result[0] = static_cast(0xE0 | (ch >> 12)); + result[1] = static_cast(0x80 | ((ch >> 6) & 0x3F)); + result[2] = static_cast(0x80 | (ch & 0x3F)); + return result + 3; + } + } + + static value_type high(value_type result, uint32_t ch) + { + // U+10000..U+10FFFF + result[0] = static_cast(0xF0 | (ch >> 18)); + result[1] = static_cast(0x80 | ((ch >> 12) & 0x3F)); + result[2] = static_cast(0x80 | ((ch >> 6) & 0x3F)); + result[3] = static_cast(0x80 | (ch & 0x3F)); + return result + 4; + } + + static value_type any(value_type result, uint32_t ch) + { + return (ch < 0x10000) ? low(result, ch) : high(result, ch); + } + }; + + struct utf16_counter + { + typedef size_t value_type; + + static value_type low(value_type result, uint32_t) + { + return result + 1; + } + + static value_type high(value_type result, uint32_t) + { + return result + 2; + } + }; + + struct utf16_writer + { + typedef uint16_t* value_type; + + static value_type low(value_type result, uint32_t ch) + { + *result = static_cast(ch); + + return result + 1; + } + + static value_type high(value_type result, uint32_t ch) + { + uint32_t msh = static_cast(ch - 0x10000) >> 10; + uint32_t lsh = static_cast(ch - 0x10000) & 0x3ff; + + result[0] = static_cast(0xD800 + msh); + result[1] = static_cast(0xDC00 + lsh); + + return result + 2; + } + + static value_type any(value_type result, uint32_t ch) + { + return (ch < 0x10000) ? low(result, ch) : high(result, ch); + } + }; + + struct utf32_counter + { + typedef size_t value_type; + + static value_type low(value_type result, uint32_t) + { + return result + 1; + } + + static value_type high(value_type result, uint32_t) + { + return result + 1; + } + }; + + struct utf32_writer + { + typedef uint32_t* value_type; + + static value_type low(value_type result, uint32_t ch) + { + *result = ch; + + return result + 1; + } + + static value_type high(value_type result, uint32_t ch) + { + *result = ch; + + return result + 1; + } + + static value_type any(value_type result, uint32_t ch) + { + *result = ch; + + return result + 1; + } + }; + + struct latin1_writer + { + typedef uint8_t* value_type; + + static value_type low(value_type result, uint32_t ch) + { + *result = static_cast(ch > 255 ? '?' : ch); + + return result + 1; + } + + static value_type high(value_type result, uint32_t ch) + { + (void)ch; + + *result = '?'; + + return result + 1; + } + }; + + struct utf8_decoder + { + typedef uint8_t type; + + template static inline typename Traits::value_type process(const uint8_t* data, size_t size, typename Traits::value_type result, Traits) + { + const uint8_t utf8_byte_mask = 0x3f; + + while (size) + { + uint8_t lead = *data; + + // 0xxxxxxx -> U+0000..U+007F + if (lead < 0x80) + { + result = Traits::low(result, lead); + data += 1; + size -= 1; + + // process aligned single-byte (ascii) blocks + if ((reinterpret_cast(data) & 3) == 0) + { + // round-trip through void* to silence 'cast increases required alignment of target type' warnings + while (size >= 4 && (*static_cast(static_cast(data)) & 0x80808080) == 0) + { + result = Traits::low(result, data[0]); + result = Traits::low(result, data[1]); + result = Traits::low(result, data[2]); + result = Traits::low(result, data[3]); + data += 4; + size -= 4; + } + } + } + // 110xxxxx -> U+0080..U+07FF + else if (static_cast(lead - 0xC0) < 0x20 && size >= 2 && (data[1] & 0xc0) == 0x80) + { + result = Traits::low(result, ((lead & ~0xC0) << 6) | (data[1] & utf8_byte_mask)); + data += 2; + size -= 2; + } + // 1110xxxx -> U+0800-U+FFFF + else if (static_cast(lead - 0xE0) < 0x10 && size >= 3 && (data[1] & 0xc0) == 0x80 && (data[2] & 0xc0) == 0x80) + { + result = Traits::low(result, ((lead & ~0xE0) << 12) | ((data[1] & utf8_byte_mask) << 6) | (data[2] & utf8_byte_mask)); + data += 3; + size -= 3; + } + // 11110xxx -> U+10000..U+10FFFF + else if (static_cast(lead - 0xF0) < 0x08 && size >= 4 && (data[1] & 0xc0) == 0x80 && (data[2] & 0xc0) == 0x80 && (data[3] & 0xc0) == 0x80) + { + result = Traits::high(result, ((lead & ~0xF0) << 18) | ((data[1] & utf8_byte_mask) << 12) | ((data[2] & utf8_byte_mask) << 6) | (data[3] & utf8_byte_mask)); + data += 4; + size -= 4; + } + // 10xxxxxx or 11111xxx -> invalid + else + { + data += 1; + size -= 1; + } + } + + return result; + } + }; + + template struct utf16_decoder + { + typedef uint16_t type; + + template static inline typename Traits::value_type process(const uint16_t* data, size_t size, typename Traits::value_type result, Traits) + { + while (size) + { + uint16_t lead = opt_swap::value ? endian_swap(*data) : *data; + + // U+0000..U+D7FF + if (lead < 0xD800) + { + result = Traits::low(result, lead); + data += 1; + size -= 1; + } + // U+E000..U+FFFF + else if (static_cast(lead - 0xE000) < 0x2000) + { + result = Traits::low(result, lead); + data += 1; + size -= 1; + } + // surrogate pair lead + else if (static_cast(lead - 0xD800) < 0x400 && size >= 2) + { + uint16_t next = opt_swap::value ? endian_swap(data[1]) : data[1]; + + if (static_cast(next - 0xDC00) < 0x400) + { + result = Traits::high(result, 0x10000 + ((lead & 0x3ff) << 10) + (next & 0x3ff)); + data += 2; + size -= 2; + } + else + { + data += 1; + size -= 1; + } + } + else + { + data += 1; + size -= 1; + } + } + + return result; + } + }; + + template struct utf32_decoder + { + typedef uint32_t type; + + template static inline typename Traits::value_type process(const uint32_t* data, size_t size, typename Traits::value_type result, Traits) + { + while (size) + { + uint32_t lead = opt_swap::value ? endian_swap(*data) : *data; + + // U+0000..U+FFFF + if (lead < 0x10000) + { + result = Traits::low(result, lead); + data += 1; + size -= 1; + } + // U+10000..U+10FFFF + else + { + result = Traits::high(result, lead); + data += 1; + size -= 1; + } + } + + return result; + } + }; + + struct latin1_decoder + { + typedef uint8_t type; + + template static inline typename Traits::value_type process(const uint8_t* data, size_t size, typename Traits::value_type result, Traits) + { + while (size) + { + result = Traits::low(result, *data); + data += 1; + size -= 1; + } + + return result; + } + }; + + template struct wchar_selector; + + template <> struct wchar_selector<2> + { + typedef uint16_t type; + typedef utf16_counter counter; + typedef utf16_writer writer; + typedef utf16_decoder decoder; + }; + + template <> struct wchar_selector<4> + { + typedef uint32_t type; + typedef utf32_counter counter; + typedef utf32_writer writer; + typedef utf32_decoder decoder; + }; + + typedef wchar_selector::counter wchar_counter; + typedef wchar_selector::writer wchar_writer; + + struct wchar_decoder + { + typedef wchar_t type; + + template static inline typename Traits::value_type process(const wchar_t* data, size_t size, typename Traits::value_type result, Traits traits) + { + typedef wchar_selector::decoder decoder; + + return decoder::process(reinterpret_cast(data), size, result, traits); + } + }; + +#ifdef PUGIXML_WCHAR_MODE + PUGI__FN void convert_wchar_endian_swap(wchar_t* result, const wchar_t* data, size_t length) + { + for (size_t i = 0; i < length; ++i) + result[i] = static_cast(endian_swap(static_cast::type>(data[i]))); + } +#endif +PUGI__NS_END + +PUGI__NS_BEGIN + enum chartype_t + { + ct_parse_pcdata = 1, // \0, &, \r, < + ct_parse_attr = 2, // \0, &, \r, ', " + ct_parse_attr_ws = 4, // \0, &, \r, ', ", \n, tab + ct_space = 8, // \r, \n, space, tab + ct_parse_cdata = 16, // \0, ], >, \r + ct_parse_comment = 32, // \0, -, >, \r + ct_symbol = 64, // Any symbol > 127, a-z, A-Z, 0-9, _, :, -, . + ct_start_symbol = 128 // Any symbol > 127, a-z, A-Z, _, : + }; + + static const unsigned char chartype_table[256] = + { + 55, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 0, 0, 63, 0, 0, // 0-15 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16-31 + 8, 0, 6, 0, 0, 0, 7, 6, 0, 0, 0, 0, 0, 96, 64, 0, // 32-47 + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 192, 0, 1, 0, 48, 0, // 48-63 + 0, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, // 64-79 + 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 0, 0, 16, 0, 192, // 80-95 + 0, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, // 96-111 + 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 0, 0, 0, 0, 0, // 112-127 + + 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, // 128+ + 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, + 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, + 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, + 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, + 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, + 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, + 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192 + }; + + enum chartypex_t + { + ctx_special_pcdata = 1, // Any symbol >= 0 and < 32 (except \t, \r, \n), &, <, > + ctx_special_attr = 2, // Any symbol >= 0 and < 32 (except \t), &, <, >, " + ctx_start_symbol = 4, // Any symbol > 127, a-z, A-Z, _ + ctx_digit = 8, // 0-9 + ctx_symbol = 16 // Any symbol > 127, a-z, A-Z, 0-9, _, -, . + }; + + static const unsigned char chartypex_table[256] = + { + 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 2, 3, 3, 2, 3, 3, // 0-15 + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 16-31 + 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 16, 16, 0, // 32-47 + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 3, 0, 3, 0, // 48-63 + + 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, // 64-79 + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 20, // 80-95 + 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, // 96-111 + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, // 112-127 + + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, // 128+ + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20 + }; + +#ifdef PUGIXML_WCHAR_MODE + #define PUGI__IS_CHARTYPE_IMPL(c, ct, table) ((static_cast(c) < 128 ? table[static_cast(c)] : table[128]) & (ct)) +#else + #define PUGI__IS_CHARTYPE_IMPL(c, ct, table) (table[static_cast(c)] & (ct)) +#endif + + #define PUGI__IS_CHARTYPE(c, ct) PUGI__IS_CHARTYPE_IMPL(c, ct, chartype_table) + #define PUGI__IS_CHARTYPEX(c, ct) PUGI__IS_CHARTYPE_IMPL(c, ct, chartypex_table) + + PUGI__FN bool is_little_endian() + { + unsigned int ui = 1; + + return *reinterpret_cast(&ui) == 1; + } + + PUGI__FN xml_encoding get_wchar_encoding() + { + PUGI__STATIC_ASSERT(sizeof(wchar_t) == 2 || sizeof(wchar_t) == 4); + + if (sizeof(wchar_t) == 2) + return is_little_endian() ? encoding_utf16_le : encoding_utf16_be; + else + return is_little_endian() ? encoding_utf32_le : encoding_utf32_be; + } + + PUGI__FN xml_encoding guess_buffer_encoding(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3) + { + // look for BOM in first few bytes + if (d0 == 0 && d1 == 0 && d2 == 0xfe && d3 == 0xff) return encoding_utf32_be; + if (d0 == 0xff && d1 == 0xfe && d2 == 0 && d3 == 0) return encoding_utf32_le; + if (d0 == 0xfe && d1 == 0xff) return encoding_utf16_be; + if (d0 == 0xff && d1 == 0xfe) return encoding_utf16_le; + if (d0 == 0xef && d1 == 0xbb && d2 == 0xbf) return encoding_utf8; + + // look for <, (contents); + + PUGI__DMC_VOLATILE uint8_t d0 = data[0], d1 = data[1], d2 = data[2], d3 = data[3]; + + return guess_buffer_encoding(d0, d1, d2, d3); + } + + PUGI__FN bool get_mutable_buffer(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, bool is_mutable) + { + size_t length = size / sizeof(char_t); + + if (is_mutable) + { + out_buffer = static_cast(const_cast(contents)); + out_length = length; + } + else + { + char_t* buffer = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); + if (!buffer) return false; + + if (contents) + memcpy(buffer, contents, length * sizeof(char_t)); + else + assert(length == 0); + + buffer[length] = 0; + + out_buffer = buffer; + out_length = length + 1; + } + + return true; + } + +#ifdef PUGIXML_WCHAR_MODE + PUGI__FN bool need_endian_swap_utf(xml_encoding le, xml_encoding re) + { + return (le == encoding_utf16_be && re == encoding_utf16_le) || (le == encoding_utf16_le && re == encoding_utf16_be) || + (le == encoding_utf32_be && re == encoding_utf32_le) || (le == encoding_utf32_le && re == encoding_utf32_be); + } + + PUGI__FN bool convert_buffer_endian_swap(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, bool is_mutable) + { + const char_t* data = static_cast(contents); + size_t length = size / sizeof(char_t); + + if (is_mutable) + { + char_t* buffer = const_cast(data); + + convert_wchar_endian_swap(buffer, data, length); + + out_buffer = buffer; + out_length = length; + } + else + { + char_t* buffer = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); + if (!buffer) return false; + + convert_wchar_endian_swap(buffer, data, length); + buffer[length] = 0; + + out_buffer = buffer; + out_length = length + 1; + } + + return true; + } + + template PUGI__FN bool convert_buffer_generic(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, D) + { + const typename D::type* data = static_cast(contents); + size_t data_length = size / sizeof(typename D::type); + + // first pass: get length in wchar_t units + size_t length = D::process(data, data_length, 0, wchar_counter()); + + // allocate buffer of suitable length + char_t* buffer = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); + if (!buffer) return false; + + // second pass: convert utf16 input to wchar_t + wchar_writer::value_type obegin = reinterpret_cast(buffer); + wchar_writer::value_type oend = D::process(data, data_length, obegin, wchar_writer()); + + assert(oend == obegin + length); + *oend = 0; + + out_buffer = buffer; + out_length = length + 1; + + return true; + } + + PUGI__FN bool convert_buffer(char_t*& out_buffer, size_t& out_length, xml_encoding encoding, const void* contents, size_t size, bool is_mutable) + { + // get native encoding + xml_encoding wchar_encoding = get_wchar_encoding(); + + // fast path: no conversion required + if (encoding == wchar_encoding) + return get_mutable_buffer(out_buffer, out_length, contents, size, is_mutable); + + // only endian-swapping is required + if (need_endian_swap_utf(encoding, wchar_encoding)) + return convert_buffer_endian_swap(out_buffer, out_length, contents, size, is_mutable); + + // source encoding is utf8 + if (encoding == encoding_utf8) + return convert_buffer_generic(out_buffer, out_length, contents, size, utf8_decoder()); + + // source encoding is utf16 + if (encoding == encoding_utf16_be || encoding == encoding_utf16_le) + { + xml_encoding native_encoding = is_little_endian() ? encoding_utf16_le : encoding_utf16_be; + + return (native_encoding == encoding) ? + convert_buffer_generic(out_buffer, out_length, contents, size, utf16_decoder()) : + convert_buffer_generic(out_buffer, out_length, contents, size, utf16_decoder()); + } + + // source encoding is utf32 + if (encoding == encoding_utf32_be || encoding == encoding_utf32_le) + { + xml_encoding native_encoding = is_little_endian() ? encoding_utf32_le : encoding_utf32_be; + + return (native_encoding == encoding) ? + convert_buffer_generic(out_buffer, out_length, contents, size, utf32_decoder()) : + convert_buffer_generic(out_buffer, out_length, contents, size, utf32_decoder()); + } + + // source encoding is latin1 + if (encoding == encoding_latin1) + return convert_buffer_generic(out_buffer, out_length, contents, size, latin1_decoder()); + + assert(!"Invalid encoding"); + return false; + } +#else + template PUGI__FN bool convert_buffer_generic(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, D) + { + const typename D::type* data = static_cast(contents); + size_t data_length = size / sizeof(typename D::type); + + // first pass: get length in utf8 units + size_t length = D::process(data, data_length, 0, utf8_counter()); + + // allocate buffer of suitable length + char_t* buffer = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); + if (!buffer) return false; + + // second pass: convert utf16 input to utf8 + uint8_t* obegin = reinterpret_cast(buffer); + uint8_t* oend = D::process(data, data_length, obegin, utf8_writer()); + + assert(oend == obegin + length); + *oend = 0; + + out_buffer = buffer; + out_length = length + 1; + + return true; + } + + PUGI__FN size_t get_latin1_7bit_prefix_length(const uint8_t* data, size_t size) + { + for (size_t i = 0; i < size; ++i) + if (data[i] > 127) + return i; + + return size; + } + + PUGI__FN bool convert_buffer_latin1(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, bool is_mutable) + { + const uint8_t* data = static_cast(contents); + size_t data_length = size; + + // get size of prefix that does not need utf8 conversion + size_t prefix_length = get_latin1_7bit_prefix_length(data, data_length); + assert(prefix_length <= data_length); + + const uint8_t* postfix = data + prefix_length; + size_t postfix_length = data_length - prefix_length; + + // if no conversion is needed, just return the original buffer + if (postfix_length == 0) return get_mutable_buffer(out_buffer, out_length, contents, size, is_mutable); + + // first pass: get length in utf8 units + size_t length = prefix_length + latin1_decoder::process(postfix, postfix_length, 0, utf8_counter()); + + // allocate buffer of suitable length + char_t* buffer = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); + if (!buffer) return false; + + // second pass: convert latin1 input to utf8 + memcpy(buffer, data, prefix_length); + + uint8_t* obegin = reinterpret_cast(buffer); + uint8_t* oend = latin1_decoder::process(postfix, postfix_length, obegin + prefix_length, utf8_writer()); + + assert(oend == obegin + length); + *oend = 0; + + out_buffer = buffer; + out_length = length + 1; + + return true; + } + + PUGI__FN bool convert_buffer(char_t*& out_buffer, size_t& out_length, xml_encoding encoding, const void* contents, size_t size, bool is_mutable) + { + // fast path: no conversion required + if (encoding == encoding_utf8) + return get_mutable_buffer(out_buffer, out_length, contents, size, is_mutable); + + // source encoding is utf16 + if (encoding == encoding_utf16_be || encoding == encoding_utf16_le) + { + xml_encoding native_encoding = is_little_endian() ? encoding_utf16_le : encoding_utf16_be; + + return (native_encoding == encoding) ? + convert_buffer_generic(out_buffer, out_length, contents, size, utf16_decoder()) : + convert_buffer_generic(out_buffer, out_length, contents, size, utf16_decoder()); + } + + // source encoding is utf32 + if (encoding == encoding_utf32_be || encoding == encoding_utf32_le) + { + xml_encoding native_encoding = is_little_endian() ? encoding_utf32_le : encoding_utf32_be; + + return (native_encoding == encoding) ? + convert_buffer_generic(out_buffer, out_length, contents, size, utf32_decoder()) : + convert_buffer_generic(out_buffer, out_length, contents, size, utf32_decoder()); + } + + // source encoding is latin1 + if (encoding == encoding_latin1) + return convert_buffer_latin1(out_buffer, out_length, contents, size, is_mutable); + + assert(!"Invalid encoding"); + return false; + } +#endif + + PUGI__FN size_t as_utf8_begin(const wchar_t* str, size_t length) + { + // get length in utf8 characters + return wchar_decoder::process(str, length, 0, utf8_counter()); + } + + PUGI__FN void as_utf8_end(char* buffer, size_t size, const wchar_t* str, size_t length) + { + // convert to utf8 + uint8_t* begin = reinterpret_cast(buffer); + uint8_t* end = wchar_decoder::process(str, length, begin, utf8_writer()); + + assert(begin + size == end); + (void)!end; + (void)!size; + } + +#ifndef PUGIXML_NO_STL + PUGI__FN std::string as_utf8_impl(const wchar_t* str, size_t length) + { + // first pass: get length in utf8 characters + size_t size = as_utf8_begin(str, length); + + // allocate resulting string + std::string result; + result.resize(size); + + // second pass: convert to utf8 + if (size > 0) as_utf8_end(&result[0], size, str, length); + + return result; + } + + PUGI__FN std::basic_string as_wide_impl(const char* str, size_t size) + { + const uint8_t* data = reinterpret_cast(str); + + // first pass: get length in wchar_t units + size_t length = utf8_decoder::process(data, size, 0, wchar_counter()); + + // allocate resulting string + std::basic_string result; + result.resize(length); + + // second pass: convert to wchar_t + if (length > 0) + { + wchar_writer::value_type begin = reinterpret_cast(&result[0]); + wchar_writer::value_type end = utf8_decoder::process(data, size, begin, wchar_writer()); + + assert(begin + length == end); + (void)!end; + } + + return result; + } +#endif + + template + inline bool strcpy_insitu_allow(size_t length, const Header& header, uintptr_t header_mask, char_t* target) + { + // never reuse shared memory + if (header & xml_memory_page_contents_shared_mask) return false; + + size_t target_length = strlength(target); + + // always reuse document buffer memory if possible + if ((header & header_mask) == 0) return target_length >= length; + + // reuse heap memory if waste is not too great + const size_t reuse_threshold = 32; + + return target_length >= length && (target_length < reuse_threshold || target_length - length < target_length / 2); + } + + template + PUGI__FN bool strcpy_insitu(String& dest, Header& header, uintptr_t header_mask, const char_t* source, size_t source_length) + { + if (source_length == 0) + { + // empty string and null pointer are equivalent, so just deallocate old memory + xml_allocator* alloc = PUGI__GETPAGE_IMPL(header)->allocator; + + if (header & header_mask) alloc->deallocate_string(dest); + + // mark the string as not allocated + dest = 0; + header &= ~header_mask; + + return true; + } + else if (dest && strcpy_insitu_allow(source_length, header, header_mask, dest)) + { + // we can reuse old buffer, so just copy the new data (including zero terminator) + memcpy(dest, source, source_length * sizeof(char_t)); + dest[source_length] = 0; + + return true; + } + else + { + xml_allocator* alloc = PUGI__GETPAGE_IMPL(header)->allocator; + + if (!alloc->reserve()) return false; + + // allocate new buffer + char_t* buf = alloc->allocate_string(source_length + 1); + if (!buf) return false; + + // copy the string (including zero terminator) + memcpy(buf, source, source_length * sizeof(char_t)); + buf[source_length] = 0; + + // deallocate old buffer (*after* the above to protect against overlapping memory and/or allocation failures) + if (header & header_mask) alloc->deallocate_string(dest); + + // the string is now allocated, so set the flag + dest = buf; + header |= header_mask; + + return true; + } + } + + struct gap + { + char_t* end; + size_t size; + + gap(): end(0), size(0) + { + } + + // Push new gap, move s count bytes further (skipping the gap). + // Collapse previous gap. + void push(char_t*& s, size_t count) + { + if (end) // there was a gap already; collapse it + { + // Move [old_gap_end, new_gap_start) to [old_gap_start, ...) + assert(s >= end); + memmove(end - size, end, reinterpret_cast(s) - reinterpret_cast(end)); + } + + s += count; // end of current gap + + // "merge" two gaps + end = s; + size += count; + } + + // Collapse all gaps, return past-the-end pointer + char_t* flush(char_t* s) + { + if (end) + { + // Move [old_gap_end, current_pos) to [old_gap_start, ...) + assert(s >= end); + memmove(end - size, end, reinterpret_cast(s) - reinterpret_cast(end)); + + return s - size; + } + else return s; + } + }; + + PUGI__FN char_t* strconv_escape(char_t* s, gap& g) + { + char_t* stre = s + 1; + + switch (*stre) + { + case '#': // &#... + { + unsigned int ucsc = 0; + + if (stre[1] == 'x') // &#x... (hex code) + { + stre += 2; + + char_t ch = *stre; + + if (ch == ';') return stre; + + for (;;) + { + if (static_cast(ch - '0') <= 9) + ucsc = 16 * ucsc + (ch - '0'); + else if (static_cast((ch | ' ') - 'a') <= 5) + ucsc = 16 * ucsc + ((ch | ' ') - 'a' + 10); + else if (ch == ';') + break; + else // cancel + return stre; + + ch = *++stre; + } + + ++stre; + } + else // &#... (dec code) + { + char_t ch = *++stre; + + if (ch == ';') return stre; + + for (;;) + { + if (static_cast(static_cast(ch) - '0') <= 9) + ucsc = 10 * ucsc + (ch - '0'); + else if (ch == ';') + break; + else // cancel + return stre; + + ch = *++stre; + } + + ++stre; + } + + #ifdef PUGIXML_WCHAR_MODE + s = reinterpret_cast(wchar_writer::any(reinterpret_cast(s), ucsc)); + #else + s = reinterpret_cast(utf8_writer::any(reinterpret_cast(s), ucsc)); + #endif + + g.push(s, stre - s); + return stre; + } + + case 'a': // &a + { + ++stre; + + if (*stre == 'm') // &am + { + if (*++stre == 'p' && *++stre == ';') // & + { + *s++ = '&'; + ++stre; + + g.push(s, stre - s); + return stre; + } + } + else if (*stre == 'p') // &ap + { + if (*++stre == 'o' && *++stre == 's' && *++stre == ';') // ' + { + *s++ = '\''; + ++stre; + + g.push(s, stre - s); + return stre; + } + } + break; + } + + case 'g': // &g + { + if (*++stre == 't' && *++stre == ';') // > + { + *s++ = '>'; + ++stre; + + g.push(s, stre - s); + return stre; + } + break; + } + + case 'l': // &l + { + if (*++stre == 't' && *++stre == ';') // < + { + *s++ = '<'; + ++stre; + + g.push(s, stre - s); + return stre; + } + break; + } + + case 'q': // &q + { + if (*++stre == 'u' && *++stre == 'o' && *++stre == 't' && *++stre == ';') // " + { + *s++ = '"'; + ++stre; + + g.push(s, stre - s); + return stre; + } + break; + } + + default: + break; + } + + return stre; + } + + // Parser utilities + #define PUGI__ENDSWITH(c, e) ((c) == (e) || ((c) == 0 && endch == (e))) + #define PUGI__SKIPWS() { while (PUGI__IS_CHARTYPE(*s, ct_space)) ++s; } + #define PUGI__OPTSET(OPT) ( optmsk & (OPT) ) + #define PUGI__PUSHNODE(TYPE) { cursor = append_new_node(cursor, alloc, TYPE); if (!cursor) PUGI__THROW_ERROR(status_out_of_memory, s); } + #define PUGI__POPNODE() { cursor = cursor->parent; } + #define PUGI__SCANFOR(X) { while (*s != 0 && !(X)) ++s; } + #define PUGI__SCANWHILE(X) { while (X) ++s; } + #define PUGI__SCANWHILE_UNROLL(X) { for (;;) { char_t ss = s[0]; if (PUGI__UNLIKELY(!(X))) { break; } ss = s[1]; if (PUGI__UNLIKELY(!(X))) { s += 1; break; } ss = s[2]; if (PUGI__UNLIKELY(!(X))) { s += 2; break; } ss = s[3]; if (PUGI__UNLIKELY(!(X))) { s += 3; break; } s += 4; } } + #define PUGI__ENDSEG() { ch = *s; *s = 0; ++s; } + #define PUGI__THROW_ERROR(err, m) return error_offset = m, error_status = err, static_cast(0) + #define PUGI__CHECK_ERROR(err, m) { if (*s == 0) PUGI__THROW_ERROR(err, m); } + + PUGI__FN char_t* strconv_comment(char_t* s, char_t endch) + { + gap g; + + while (true) + { + PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(ss, ct_parse_comment)); + + if (*s == '\r') // Either a single 0x0d or 0x0d 0x0a pair + { + *s++ = '\n'; // replace first one with 0x0a + + if (*s == '\n') g.push(s, 1); + } + else if (s[0] == '-' && s[1] == '-' && PUGI__ENDSWITH(s[2], '>')) // comment ends here + { + *g.flush(s) = 0; + + return s + (s[2] == '>' ? 3 : 2); + } + else if (*s == 0) + { + return 0; + } + else ++s; + } + } + + PUGI__FN char_t* strconv_cdata(char_t* s, char_t endch) + { + gap g; + + while (true) + { + PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(ss, ct_parse_cdata)); + + if (*s == '\r') // Either a single 0x0d or 0x0d 0x0a pair + { + *s++ = '\n'; // replace first one with 0x0a + + if (*s == '\n') g.push(s, 1); + } + else if (s[0] == ']' && s[1] == ']' && PUGI__ENDSWITH(s[2], '>')) // CDATA ends here + { + *g.flush(s) = 0; + + return s + 1; + } + else if (*s == 0) + { + return 0; + } + else ++s; + } + } + + typedef char_t* (*strconv_pcdata_t)(char_t*); + + template struct strconv_pcdata_impl + { + static char_t* parse(char_t* s) + { + gap g; + + char_t* begin = s; + + while (true) + { + PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(ss, ct_parse_pcdata)); + + if (*s == '<') // PCDATA ends here + { + char_t* end = g.flush(s); + + if (opt_trim::value) + while (end > begin && PUGI__IS_CHARTYPE(end[-1], ct_space)) + --end; + + *end = 0; + + return s + 1; + } + else if (opt_eol::value && *s == '\r') // Either a single 0x0d or 0x0d 0x0a pair + { + *s++ = '\n'; // replace first one with 0x0a + + if (*s == '\n') g.push(s, 1); + } + else if (opt_escape::value && *s == '&') + { + s = strconv_escape(s, g); + } + else if (*s == 0) + { + char_t* end = g.flush(s); + + if (opt_trim::value) + while (end > begin && PUGI__IS_CHARTYPE(end[-1], ct_space)) + --end; + + *end = 0; + + return s; + } + else ++s; + } + } + }; + + PUGI__FN strconv_pcdata_t get_strconv_pcdata(unsigned int optmask) + { + PUGI__STATIC_ASSERT(parse_escapes == 0x10 && parse_eol == 0x20 && parse_trim_pcdata == 0x0800); + + switch (((optmask >> 4) & 3) | ((optmask >> 9) & 4)) // get bitmask for flags (eol escapes trim) + { + case 0: return strconv_pcdata_impl::parse; + case 1: return strconv_pcdata_impl::parse; + case 2: return strconv_pcdata_impl::parse; + case 3: return strconv_pcdata_impl::parse; + case 4: return strconv_pcdata_impl::parse; + case 5: return strconv_pcdata_impl::parse; + case 6: return strconv_pcdata_impl::parse; + case 7: return strconv_pcdata_impl::parse; + default: assert(false); return 0; // should not get here + } + } + + typedef char_t* (*strconv_attribute_t)(char_t*, char_t); + + template struct strconv_attribute_impl + { + static char_t* parse_wnorm(char_t* s, char_t end_quote) + { + gap g; + + // trim leading whitespaces + if (PUGI__IS_CHARTYPE(*s, ct_space)) + { + char_t* str = s; + + do ++str; + while (PUGI__IS_CHARTYPE(*str, ct_space)); + + g.push(s, str - s); + } + + while (true) + { + PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(ss, ct_parse_attr_ws | ct_space)); + + if (*s == end_quote) + { + char_t* str = g.flush(s); + + do *str-- = 0; + while (PUGI__IS_CHARTYPE(*str, ct_space)); + + return s + 1; + } + else if (PUGI__IS_CHARTYPE(*s, ct_space)) + { + *s++ = ' '; + + if (PUGI__IS_CHARTYPE(*s, ct_space)) + { + char_t* str = s + 1; + while (PUGI__IS_CHARTYPE(*str, ct_space)) ++str; + + g.push(s, str - s); + } + } + else if (opt_escape::value && *s == '&') + { + s = strconv_escape(s, g); + } + else if (!*s) + { + return 0; + } + else ++s; + } + } + + static char_t* parse_wconv(char_t* s, char_t end_quote) + { + gap g; + + while (true) + { + PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(ss, ct_parse_attr_ws)); + + if (*s == end_quote) + { + *g.flush(s) = 0; + + return s + 1; + } + else if (PUGI__IS_CHARTYPE(*s, ct_space)) + { + if (*s == '\r') + { + *s++ = ' '; + + if (*s == '\n') g.push(s, 1); + } + else *s++ = ' '; + } + else if (opt_escape::value && *s == '&') + { + s = strconv_escape(s, g); + } + else if (!*s) + { + return 0; + } + else ++s; + } + } + + static char_t* parse_eol(char_t* s, char_t end_quote) + { + gap g; + + while (true) + { + PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(ss, ct_parse_attr)); + + if (*s == end_quote) + { + *g.flush(s) = 0; + + return s + 1; + } + else if (*s == '\r') + { + *s++ = '\n'; + + if (*s == '\n') g.push(s, 1); + } + else if (opt_escape::value && *s == '&') + { + s = strconv_escape(s, g); + } + else if (!*s) + { + return 0; + } + else ++s; + } + } + + static char_t* parse_simple(char_t* s, char_t end_quote) + { + gap g; + + while (true) + { + PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(ss, ct_parse_attr)); + + if (*s == end_quote) + { + *g.flush(s) = 0; + + return s + 1; + } + else if (opt_escape::value && *s == '&') + { + s = strconv_escape(s, g); + } + else if (!*s) + { + return 0; + } + else ++s; + } + } + }; + + PUGI__FN strconv_attribute_t get_strconv_attribute(unsigned int optmask) + { + PUGI__STATIC_ASSERT(parse_escapes == 0x10 && parse_eol == 0x20 && parse_wconv_attribute == 0x40 && parse_wnorm_attribute == 0x80); + + switch ((optmask >> 4) & 15) // get bitmask for flags (wconv wnorm eol escapes) + { + case 0: return strconv_attribute_impl::parse_simple; + case 1: return strconv_attribute_impl::parse_simple; + case 2: return strconv_attribute_impl::parse_eol; + case 3: return strconv_attribute_impl::parse_eol; + case 4: return strconv_attribute_impl::parse_wconv; + case 5: return strconv_attribute_impl::parse_wconv; + case 6: return strconv_attribute_impl::parse_wconv; + case 7: return strconv_attribute_impl::parse_wconv; + case 8: return strconv_attribute_impl::parse_wnorm; + case 9: return strconv_attribute_impl::parse_wnorm; + case 10: return strconv_attribute_impl::parse_wnorm; + case 11: return strconv_attribute_impl::parse_wnorm; + case 12: return strconv_attribute_impl::parse_wnorm; + case 13: return strconv_attribute_impl::parse_wnorm; + case 14: return strconv_attribute_impl::parse_wnorm; + case 15: return strconv_attribute_impl::parse_wnorm; + default: assert(false); return 0; // should not get here + } + } + + inline xml_parse_result make_parse_result(xml_parse_status status, ptrdiff_t offset = 0) + { + xml_parse_result result; + result.status = status; + result.offset = offset; + + return result; + } + + struct xml_parser + { + xml_allocator alloc; + xml_allocator* alloc_state; + char_t* error_offset; + xml_parse_status error_status; + + xml_parser(xml_allocator* alloc_): alloc(*alloc_), alloc_state(alloc_), error_offset(0), error_status(status_ok) + { + } + + ~xml_parser() + { + *alloc_state = alloc; + } + + // DOCTYPE consists of nested sections of the following possible types: + // , , "...", '...' + // + // + // First group can not contain nested groups + // Second group can contain nested groups of the same type + // Third group can contain all other groups + char_t* parse_doctype_primitive(char_t* s) + { + if (*s == '"' || *s == '\'') + { + // quoted string + char_t ch = *s++; + PUGI__SCANFOR(*s == ch); + if (!*s) PUGI__THROW_ERROR(status_bad_doctype, s); + + s++; + } + else if (s[0] == '<' && s[1] == '?') + { + // + s += 2; + PUGI__SCANFOR(s[0] == '?' && s[1] == '>'); // no need for ENDSWITH because ?> can't terminate proper doctype + if (!*s) PUGI__THROW_ERROR(status_bad_doctype, s); + + s += 2; + } + else if (s[0] == '<' && s[1] == '!' && s[2] == '-' && s[3] == '-') + { + s += 4; + PUGI__SCANFOR(s[0] == '-' && s[1] == '-' && s[2] == '>'); // no need for ENDSWITH because --> can't terminate proper doctype + if (!*s) PUGI__THROW_ERROR(status_bad_doctype, s); + + s += 3; + } + else PUGI__THROW_ERROR(status_bad_doctype, s); + + return s; + } + + char_t* parse_doctype_ignore(char_t* s) + { + size_t depth = 0; + + assert(s[0] == '<' && s[1] == '!' && s[2] == '['); + s += 3; + + while (*s) + { + if (s[0] == '<' && s[1] == '!' && s[2] == '[') + { + // nested ignore section + s += 3; + depth++; + } + else if (s[0] == ']' && s[1] == ']' && s[2] == '>') + { + // ignore section end + s += 3; + + if (depth == 0) + return s; + + depth--; + } + else s++; + } + + PUGI__THROW_ERROR(status_bad_doctype, s); + } + + char_t* parse_doctype_group(char_t* s, char_t endch) + { + size_t depth = 0; + + assert((s[0] == '<' || s[0] == 0) && s[1] == '!'); + s += 2; + + while (*s) + { + if (s[0] == '<' && s[1] == '!' && s[2] != '-') + { + if (s[2] == '[') + { + // ignore + s = parse_doctype_ignore(s); + if (!s) return s; + } + else + { + // some control group + s += 2; + depth++; + } + } + else if (s[0] == '<' || s[0] == '"' || s[0] == '\'') + { + // unknown tag (forbidden), or some primitive group + s = parse_doctype_primitive(s); + if (!s) return s; + } + else if (*s == '>') + { + if (depth == 0) + return s; + + depth--; + s++; + } + else s++; + } + + if (depth != 0 || endch != '>') PUGI__THROW_ERROR(status_bad_doctype, s); + + return s; + } + + char_t* parse_exclamation(char_t* s, xml_node_struct* cursor, unsigned int optmsk, char_t endch) + { + // parse node contents, starting with exclamation mark + ++s; + + if (*s == '-') // 'value = s; // Save the offset. + } + + if (PUGI__OPTSET(parse_eol) && PUGI__OPTSET(parse_comments)) + { + s = strconv_comment(s, endch); + + if (!s) PUGI__THROW_ERROR(status_bad_comment, cursor->value); + } + else + { + // Scan for terminating '-->'. + PUGI__SCANFOR(s[0] == '-' && s[1] == '-' && PUGI__ENDSWITH(s[2], '>')); + PUGI__CHECK_ERROR(status_bad_comment, s); + + if (PUGI__OPTSET(parse_comments)) + *s = 0; // Zero-terminate this segment at the first terminating '-'. + + s += (s[2] == '>' ? 3 : 2); // Step over the '\0->'. + } + } + else PUGI__THROW_ERROR(status_bad_comment, s); + } + else if (*s == '[') + { + // 'value = s; // Save the offset. + + if (PUGI__OPTSET(parse_eol)) + { + s = strconv_cdata(s, endch); + + if (!s) PUGI__THROW_ERROR(status_bad_cdata, cursor->value); + } + else + { + // Scan for terminating ']]>'. + PUGI__SCANFOR(s[0] == ']' && s[1] == ']' && PUGI__ENDSWITH(s[2], '>')); + PUGI__CHECK_ERROR(status_bad_cdata, s); + + *s++ = 0; // Zero-terminate this segment. + } + } + else // Flagged for discard, but we still have to scan for the terminator. + { + // Scan for terminating ']]>'. + PUGI__SCANFOR(s[0] == ']' && s[1] == ']' && PUGI__ENDSWITH(s[2], '>')); + PUGI__CHECK_ERROR(status_bad_cdata, s); + + ++s; + } + + s += (s[1] == '>' ? 2 : 1); // Step over the last ']>'. + } + else PUGI__THROW_ERROR(status_bad_cdata, s); + } + else if (s[0] == 'D' && s[1] == 'O' && s[2] == 'C' && s[3] == 'T' && s[4] == 'Y' && s[5] == 'P' && PUGI__ENDSWITH(s[6], 'E')) + { + s -= 2; + + if (cursor->parent) PUGI__THROW_ERROR(status_bad_doctype, s); + + char_t* mark = s + 9; + + s = parse_doctype_group(s, endch); + if (!s) return s; + + assert((*s == 0 && endch == '>') || *s == '>'); + if (*s) *s++ = 0; + + if (PUGI__OPTSET(parse_doctype)) + { + while (PUGI__IS_CHARTYPE(*mark, ct_space)) ++mark; + + PUGI__PUSHNODE(node_doctype); + + cursor->value = mark; + } + } + else if (*s == 0 && endch == '-') PUGI__THROW_ERROR(status_bad_comment, s); + else if (*s == 0 && endch == '[') PUGI__THROW_ERROR(status_bad_cdata, s); + else PUGI__THROW_ERROR(status_unrecognized_tag, s); + + return s; + } + + char_t* parse_question(char_t* s, xml_node_struct*& ref_cursor, unsigned int optmsk, char_t endch) + { + // load into registers + xml_node_struct* cursor = ref_cursor; + char_t ch = 0; + + // parse node contents, starting with question mark + ++s; + + // read PI target + char_t* target = s; + + if (!PUGI__IS_CHARTYPE(*s, ct_start_symbol)) PUGI__THROW_ERROR(status_bad_pi, s); + + PUGI__SCANWHILE(PUGI__IS_CHARTYPE(*s, ct_symbol)); + PUGI__CHECK_ERROR(status_bad_pi, s); + + // determine node type; stricmp / strcasecmp is not portable + bool declaration = (target[0] | ' ') == 'x' && (target[1] | ' ') == 'm' && (target[2] | ' ') == 'l' && target + 3 == s; + + if (declaration ? PUGI__OPTSET(parse_declaration) : PUGI__OPTSET(parse_pi)) + { + if (declaration) + { + // disallow non top-level declarations + if (cursor->parent) PUGI__THROW_ERROR(status_bad_pi, s); + + PUGI__PUSHNODE(node_declaration); + } + else + { + PUGI__PUSHNODE(node_pi); + } + + cursor->name = target; + + PUGI__ENDSEG(); + + // parse value/attributes + if (ch == '?') + { + // empty node + if (!PUGI__ENDSWITH(*s, '>')) PUGI__THROW_ERROR(status_bad_pi, s); + s += (*s == '>'); + + PUGI__POPNODE(); + } + else if (PUGI__IS_CHARTYPE(ch, ct_space)) + { + PUGI__SKIPWS(); + + // scan for tag end + char_t* value = s; + + PUGI__SCANFOR(s[0] == '?' && PUGI__ENDSWITH(s[1], '>')); + PUGI__CHECK_ERROR(status_bad_pi, s); + + if (declaration) + { + // replace ending ? with / so that 'element' terminates properly + *s = '/'; + + // we exit from this function with cursor at node_declaration, which is a signal to parse() to go to LOC_ATTRIBUTES + s = value; + } + else + { + // store value and step over > + cursor->value = value; + + PUGI__POPNODE(); + + PUGI__ENDSEG(); + + s += (*s == '>'); + } + } + else PUGI__THROW_ERROR(status_bad_pi, s); + } + else + { + // scan for tag end + PUGI__SCANFOR(s[0] == '?' && PUGI__ENDSWITH(s[1], '>')); + PUGI__CHECK_ERROR(status_bad_pi, s); + + s += (s[1] == '>' ? 2 : 1); + } + + // store from registers + ref_cursor = cursor; + + return s; + } + + char_t* parse_tree(char_t* s, xml_node_struct* root, unsigned int optmsk, char_t endch) + { + strconv_attribute_t strconv_attribute = get_strconv_attribute(optmsk); + strconv_pcdata_t strconv_pcdata = get_strconv_pcdata(optmsk); + + char_t ch = 0; + xml_node_struct* cursor = root; + char_t* mark = s; + + while (*s != 0) + { + if (*s == '<') + { + ++s; + + LOC_TAG: + if (PUGI__IS_CHARTYPE(*s, ct_start_symbol)) // '<#...' + { + PUGI__PUSHNODE(node_element); // Append a new node to the tree. + + cursor->name = s; + + PUGI__SCANWHILE_UNROLL(PUGI__IS_CHARTYPE(ss, ct_symbol)); // Scan for a terminator. + PUGI__ENDSEG(); // Save char in 'ch', terminate & step over. + + if (ch == '>') + { + // end of tag + } + else if (PUGI__IS_CHARTYPE(ch, ct_space)) + { + LOC_ATTRIBUTES: + while (true) + { + PUGI__SKIPWS(); // Eat any whitespace. + + if (PUGI__IS_CHARTYPE(*s, ct_start_symbol)) // <... #... + { + xml_attribute_struct* a = append_new_attribute(cursor, alloc); // Make space for this attribute. + if (!a) PUGI__THROW_ERROR(status_out_of_memory, s); + + a->name = s; // Save the offset. + + PUGI__SCANWHILE_UNROLL(PUGI__IS_CHARTYPE(ss, ct_symbol)); // Scan for a terminator. + PUGI__ENDSEG(); // Save char in 'ch', terminate & step over. + + if (PUGI__IS_CHARTYPE(ch, ct_space)) + { + PUGI__SKIPWS(); // Eat any whitespace. + + ch = *s; + ++s; + } + + if (ch == '=') // '<... #=...' + { + PUGI__SKIPWS(); // Eat any whitespace. + + if (*s == '"' || *s == '\'') // '<... #="...' + { + ch = *s; // Save quote char to avoid breaking on "''" -or- '""'. + ++s; // Step over the quote. + a->value = s; // Save the offset. + + s = strconv_attribute(s, ch); + + if (!s) PUGI__THROW_ERROR(status_bad_attribute, a->value); + + // After this line the loop continues from the start; + // Whitespaces, / and > are ok, symbols and EOF are wrong, + // everything else will be detected + if (PUGI__IS_CHARTYPE(*s, ct_start_symbol)) PUGI__THROW_ERROR(status_bad_attribute, s); + } + else PUGI__THROW_ERROR(status_bad_attribute, s); + } + else PUGI__THROW_ERROR(status_bad_attribute, s); + } + else if (*s == '/') + { + ++s; + + if (*s == '>') + { + PUGI__POPNODE(); + s++; + break; + } + else if (*s == 0 && endch == '>') + { + PUGI__POPNODE(); + break; + } + else PUGI__THROW_ERROR(status_bad_start_element, s); + } + else if (*s == '>') + { + ++s; + + break; + } + else if (*s == 0 && endch == '>') + { + break; + } + else PUGI__THROW_ERROR(status_bad_start_element, s); + } + + // !!! + } + else if (ch == '/') // '<#.../' + { + if (!PUGI__ENDSWITH(*s, '>')) PUGI__THROW_ERROR(status_bad_start_element, s); + + PUGI__POPNODE(); // Pop. + + s += (*s == '>'); + } + else if (ch == 0) + { + // we stepped over null terminator, backtrack & handle closing tag + --s; + + if (endch != '>') PUGI__THROW_ERROR(status_bad_start_element, s); + } + else PUGI__THROW_ERROR(status_bad_start_element, s); + } + else if (*s == '/') + { + ++s; + + char_t* name = cursor->name; + if (!name) PUGI__THROW_ERROR(status_end_element_mismatch, s); + + while (PUGI__IS_CHARTYPE(*s, ct_symbol)) + { + if (*s++ != *name++) PUGI__THROW_ERROR(status_end_element_mismatch, s); + } + + if (*name) + { + if (*s == 0 && name[0] == endch && name[1] == 0) PUGI__THROW_ERROR(status_bad_end_element, s); + else PUGI__THROW_ERROR(status_end_element_mismatch, s); + } + + PUGI__POPNODE(); // Pop. + + PUGI__SKIPWS(); + + if (*s == 0) + { + if (endch != '>') PUGI__THROW_ERROR(status_bad_end_element, s); + } + else + { + if (*s != '>') PUGI__THROW_ERROR(status_bad_end_element, s); + ++s; + } + } + else if (*s == '?') // 'first_child) continue; + } + } + + if (!PUGI__OPTSET(parse_trim_pcdata)) + s = mark; + + if (cursor->parent || PUGI__OPTSET(parse_fragment)) + { + PUGI__PUSHNODE(node_pcdata); // Append a new node on the tree. + cursor->value = s; // Save the offset. + + s = strconv_pcdata(s); + + PUGI__POPNODE(); // Pop since this is a standalone. + + if (!*s) break; + } + else + { + PUGI__SCANFOR(*s == '<'); // '...<' + if (!*s) break; + + ++s; + } + + // We're after '<' + goto LOC_TAG; + } + } + + // check that last tag is closed + if (cursor != root) PUGI__THROW_ERROR(status_end_element_mismatch, s); + + return s; + } + + #ifdef PUGIXML_WCHAR_MODE + static char_t* parse_skip_bom(char_t* s) + { + unsigned int bom = 0xfeff; + return (s[0] == static_cast(bom)) ? s + 1 : s; + } + #else + static char_t* parse_skip_bom(char_t* s) + { + return (s[0] == '\xef' && s[1] == '\xbb' && s[2] == '\xbf') ? s + 3 : s; + } + #endif + + static bool has_element_node_siblings(xml_node_struct* node) + { + while (node) + { + if (PUGI__NODETYPE(node) == node_element) return true; + + node = node->next_sibling; + } + + return false; + } + + static xml_parse_result parse(char_t* buffer, size_t length, xml_document_struct* xmldoc, xml_node_struct* root, unsigned int optmsk) + { + // early-out for empty documents + if (length == 0) + return make_parse_result(PUGI__OPTSET(parse_fragment) ? status_ok : status_no_document_element); + + // get last child of the root before parsing + xml_node_struct* last_root_child = root->first_child ? root->first_child->prev_sibling_c + 0 : 0; + + // create parser on stack + xml_parser parser(static_cast(xmldoc)); + + // save last character and make buffer zero-terminated (speeds up parsing) + char_t endch = buffer[length - 1]; + buffer[length - 1] = 0; + + // skip BOM to make sure it does not end up as part of parse output + char_t* buffer_data = parse_skip_bom(buffer); + + // perform actual parsing + parser.parse_tree(buffer_data, root, optmsk, endch); + + xml_parse_result result = make_parse_result(parser.error_status, parser.error_offset ? parser.error_offset - buffer : 0); + assert(result.offset >= 0 && static_cast(result.offset) <= length); + + if (result) + { + // since we removed last character, we have to handle the only possible false positive (stray <) + if (endch == '<') + return make_parse_result(status_unrecognized_tag, length - 1); + + // check if there are any element nodes parsed + xml_node_struct* first_root_child_parsed = last_root_child ? last_root_child->next_sibling + 0 : root->first_child+ 0; + + if (!PUGI__OPTSET(parse_fragment) && !has_element_node_siblings(first_root_child_parsed)) + return make_parse_result(status_no_document_element, length - 1); + } + else + { + // roll back offset if it occurs on a null terminator in the source buffer + if (result.offset > 0 && static_cast(result.offset) == length - 1 && endch == 0) + result.offset--; + } + + return result; + } + }; + + // Output facilities + PUGI__FN xml_encoding get_write_native_encoding() + { + #ifdef PUGIXML_WCHAR_MODE + return get_wchar_encoding(); + #else + return encoding_utf8; + #endif + } + + PUGI__FN xml_encoding get_write_encoding(xml_encoding encoding) + { + // replace wchar encoding with utf implementation + if (encoding == encoding_wchar) return get_wchar_encoding(); + + // replace utf16 encoding with utf16 with specific endianness + if (encoding == encoding_utf16) return is_little_endian() ? encoding_utf16_le : encoding_utf16_be; + + // replace utf32 encoding with utf32 with specific endianness + if (encoding == encoding_utf32) return is_little_endian() ? encoding_utf32_le : encoding_utf32_be; + + // only do autodetection if no explicit encoding is requested + if (encoding != encoding_auto) return encoding; + + // assume utf8 encoding + return encoding_utf8; + } + + template PUGI__FN size_t convert_buffer_output_generic(typename T::value_type dest, const char_t* data, size_t length, D, T) + { + PUGI__STATIC_ASSERT(sizeof(char_t) == sizeof(typename D::type)); + + typename T::value_type end = D::process(reinterpret_cast(data), length, dest, T()); + + return static_cast(end - dest) * sizeof(*dest); + } + + template PUGI__FN size_t convert_buffer_output_generic(typename T::value_type dest, const char_t* data, size_t length, D, T, bool opt_swap) + { + PUGI__STATIC_ASSERT(sizeof(char_t) == sizeof(typename D::type)); + + typename T::value_type end = D::process(reinterpret_cast(data), length, dest, T()); + + if (opt_swap) + { + for (typename T::value_type i = dest; i != end; ++i) + *i = endian_swap(*i); + } + + return static_cast(end - dest) * sizeof(*dest); + } + +#ifdef PUGIXML_WCHAR_MODE + PUGI__FN size_t get_valid_length(const char_t* data, size_t length) + { + if (length < 1) return 0; + + // discard last character if it's the lead of a surrogate pair + return (sizeof(wchar_t) == 2 && static_cast(static_cast(data[length - 1]) - 0xD800) < 0x400) ? length - 1 : length; + } + + PUGI__FN size_t convert_buffer_output(char_t* r_char, uint8_t* r_u8, uint16_t* r_u16, uint32_t* r_u32, const char_t* data, size_t length, xml_encoding encoding) + { + // only endian-swapping is required + if (need_endian_swap_utf(encoding, get_wchar_encoding())) + { + convert_wchar_endian_swap(r_char, data, length); + + return length * sizeof(char_t); + } + + // convert to utf8 + if (encoding == encoding_utf8) + return convert_buffer_output_generic(r_u8, data, length, wchar_decoder(), utf8_writer()); + + // convert to utf16 + if (encoding == encoding_utf16_be || encoding == encoding_utf16_le) + { + xml_encoding native_encoding = is_little_endian() ? encoding_utf16_le : encoding_utf16_be; + + return convert_buffer_output_generic(r_u16, data, length, wchar_decoder(), utf16_writer(), native_encoding != encoding); + } + + // convert to utf32 + if (encoding == encoding_utf32_be || encoding == encoding_utf32_le) + { + xml_encoding native_encoding = is_little_endian() ? encoding_utf32_le : encoding_utf32_be; + + return convert_buffer_output_generic(r_u32, data, length, wchar_decoder(), utf32_writer(), native_encoding != encoding); + } + + // convert to latin1 + if (encoding == encoding_latin1) + return convert_buffer_output_generic(r_u8, data, length, wchar_decoder(), latin1_writer()); + + assert(!"Invalid encoding"); + return 0; + } +#else + PUGI__FN size_t get_valid_length(const char_t* data, size_t length) + { + if (length < 5) return 0; + + for (size_t i = 1; i <= 4; ++i) + { + uint8_t ch = static_cast(data[length - i]); + + // either a standalone character or a leading one + if ((ch & 0xc0) != 0x80) return length - i; + } + + // there are four non-leading characters at the end, sequence tail is broken so might as well process the whole chunk + return length; + } + + PUGI__FN size_t convert_buffer_output(char_t* /* r_char */, uint8_t* r_u8, uint16_t* r_u16, uint32_t* r_u32, const char_t* data, size_t length, xml_encoding encoding) + { + if (encoding == encoding_utf16_be || encoding == encoding_utf16_le) + { + xml_encoding native_encoding = is_little_endian() ? encoding_utf16_le : encoding_utf16_be; + + return convert_buffer_output_generic(r_u16, data, length, utf8_decoder(), utf16_writer(), native_encoding != encoding); + } + + if (encoding == encoding_utf32_be || encoding == encoding_utf32_le) + { + xml_encoding native_encoding = is_little_endian() ? encoding_utf32_le : encoding_utf32_be; + + return convert_buffer_output_generic(r_u32, data, length, utf8_decoder(), utf32_writer(), native_encoding != encoding); + } + + if (encoding == encoding_latin1) + return convert_buffer_output_generic(r_u8, data, length, utf8_decoder(), latin1_writer()); + + assert(!"Invalid encoding"); + return 0; + } +#endif + + class xml_buffered_writer + { + xml_buffered_writer(const xml_buffered_writer&); + xml_buffered_writer& operator=(const xml_buffered_writer&); + + public: + xml_buffered_writer(xml_writer& writer_, xml_encoding user_encoding): writer(writer_), bufsize(0), encoding(get_write_encoding(user_encoding)) + { + PUGI__STATIC_ASSERT(bufcapacity >= 8); + } + + size_t flush() + { + flush(buffer, bufsize); + bufsize = 0; + return 0; + } + + void flush(const char_t* data, size_t size) + { + if (size == 0) return; + + // fast path, just write data + if (encoding == get_write_native_encoding()) + writer.write(data, size * sizeof(char_t)); + else + { + // convert chunk + size_t result = convert_buffer_output(scratch.data_char, scratch.data_u8, scratch.data_u16, scratch.data_u32, data, size, encoding); + assert(result <= sizeof(scratch)); + + // write data + writer.write(scratch.data_u8, result); + } + } + + void write_direct(const char_t* data, size_t length) + { + // flush the remaining buffer contents + flush(); + + // handle large chunks + if (length > bufcapacity) + { + if (encoding == get_write_native_encoding()) + { + // fast path, can just write data chunk + writer.write(data, length * sizeof(char_t)); + return; + } + + // need to convert in suitable chunks + while (length > bufcapacity) + { + // get chunk size by selecting such number of characters that are guaranteed to fit into scratch buffer + // and form a complete codepoint sequence (i.e. discard start of last codepoint if necessary) + size_t chunk_size = get_valid_length(data, bufcapacity); + assert(chunk_size); + + // convert chunk and write + flush(data, chunk_size); + + // iterate + data += chunk_size; + length -= chunk_size; + } + + // small tail is copied below + bufsize = 0; + } + + memcpy(buffer + bufsize, data, length * sizeof(char_t)); + bufsize += length; + } + + void write_buffer(const char_t* data, size_t length) + { + size_t offset = bufsize; + + if (offset + length <= bufcapacity) + { + memcpy(buffer + offset, data, length * sizeof(char_t)); + bufsize = offset + length; + } + else + { + write_direct(data, length); + } + } + + void write_string(const char_t* data) + { + // write the part of the string that fits in the buffer + size_t offset = bufsize; + + while (*data && offset < bufcapacity) + buffer[offset++] = *data++; + + // write the rest + if (offset < bufcapacity) + { + bufsize = offset; + } + else + { + // backtrack a bit if we have split the codepoint + size_t length = offset - bufsize; + size_t extra = length - get_valid_length(data - length, length); + + bufsize = offset - extra; + + write_direct(data - extra, strlength(data) + extra); + } + } + + void write(char_t d0) + { + size_t offset = bufsize; + if (offset > bufcapacity - 1) offset = flush(); + + buffer[offset + 0] = d0; + bufsize = offset + 1; + } + + void write(char_t d0, char_t d1) + { + size_t offset = bufsize; + if (offset > bufcapacity - 2) offset = flush(); + + buffer[offset + 0] = d0; + buffer[offset + 1] = d1; + bufsize = offset + 2; + } + + void write(char_t d0, char_t d1, char_t d2) + { + size_t offset = bufsize; + if (offset > bufcapacity - 3) offset = flush(); + + buffer[offset + 0] = d0; + buffer[offset + 1] = d1; + buffer[offset + 2] = d2; + bufsize = offset + 3; + } + + void write(char_t d0, char_t d1, char_t d2, char_t d3) + { + size_t offset = bufsize; + if (offset > bufcapacity - 4) offset = flush(); + + buffer[offset + 0] = d0; + buffer[offset + 1] = d1; + buffer[offset + 2] = d2; + buffer[offset + 3] = d3; + bufsize = offset + 4; + } + + void write(char_t d0, char_t d1, char_t d2, char_t d3, char_t d4) + { + size_t offset = bufsize; + if (offset > bufcapacity - 5) offset = flush(); + + buffer[offset + 0] = d0; + buffer[offset + 1] = d1; + buffer[offset + 2] = d2; + buffer[offset + 3] = d3; + buffer[offset + 4] = d4; + bufsize = offset + 5; + } + + void write(char_t d0, char_t d1, char_t d2, char_t d3, char_t d4, char_t d5) + { + size_t offset = bufsize; + if (offset > bufcapacity - 6) offset = flush(); + + buffer[offset + 0] = d0; + buffer[offset + 1] = d1; + buffer[offset + 2] = d2; + buffer[offset + 3] = d3; + buffer[offset + 4] = d4; + buffer[offset + 5] = d5; + bufsize = offset + 6; + } + + // utf8 maximum expansion: x4 (-> utf32) + // utf16 maximum expansion: x2 (-> utf32) + // utf32 maximum expansion: x1 + enum + { + bufcapacitybytes = + #ifdef PUGIXML_MEMORY_OUTPUT_STACK + PUGIXML_MEMORY_OUTPUT_STACK + #else + 10240 + #endif + , + bufcapacity = bufcapacitybytes / (sizeof(char_t) + 4) + }; + + char_t buffer[bufcapacity]; + + union + { + uint8_t data_u8[4 * bufcapacity]; + uint16_t data_u16[2 * bufcapacity]; + uint32_t data_u32[bufcapacity]; + char_t data_char[bufcapacity]; + } scratch; + + xml_writer& writer; + size_t bufsize; + xml_encoding encoding; + }; + + PUGI__FN void text_output_escaped(xml_buffered_writer& writer, const char_t* s, chartypex_t type) + { + while (*s) + { + const char_t* prev = s; + + // While *s is a usual symbol + PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPEX(ss, type)); + + writer.write_buffer(prev, static_cast(s - prev)); + + switch (*s) + { + case 0: break; + case '&': + writer.write('&', 'a', 'm', 'p', ';'); + ++s; + break; + case '<': + writer.write('&', 'l', 't', ';'); + ++s; + break; + case '>': + writer.write('&', 'g', 't', ';'); + ++s; + break; + case '"': + writer.write('&', 'q', 'u', 'o', 't', ';'); + ++s; + break; + default: // s is not a usual symbol + { + unsigned int ch = static_cast(*s++); + assert(ch < 32); + + writer.write('&', '#', static_cast((ch / 10) + '0'), static_cast((ch % 10) + '0'), ';'); + } + } + } + } + + PUGI__FN void text_output(xml_buffered_writer& writer, const char_t* s, chartypex_t type, unsigned int flags) + { + if (flags & format_no_escapes) + writer.write_string(s); + else + text_output_escaped(writer, s, type); + } + + PUGI__FN void text_output_cdata(xml_buffered_writer& writer, const char_t* s) + { + do + { + writer.write('<', '!', '[', 'C', 'D'); + writer.write('A', 'T', 'A', '['); + + const char_t* prev = s; + + // look for ]]> sequence - we can't output it as is since it terminates CDATA + while (*s && !(s[0] == ']' && s[1] == ']' && s[2] == '>')) ++s; + + // skip ]] if we stopped at ]]>, > will go to the next CDATA section + if (*s) s += 2; + + writer.write_buffer(prev, static_cast(s - prev)); + + writer.write(']', ']', '>'); + } + while (*s); + } + + PUGI__FN void text_output_indent(xml_buffered_writer& writer, const char_t* indent, size_t indent_length, unsigned int depth) + { + switch (indent_length) + { + case 1: + { + for (unsigned int i = 0; i < depth; ++i) + writer.write(indent[0]); + break; + } + + case 2: + { + for (unsigned int i = 0; i < depth; ++i) + writer.write(indent[0], indent[1]); + break; + } + + case 3: + { + for (unsigned int i = 0; i < depth; ++i) + writer.write(indent[0], indent[1], indent[2]); + break; + } + + case 4: + { + for (unsigned int i = 0; i < depth; ++i) + writer.write(indent[0], indent[1], indent[2], indent[3]); + break; + } + + default: + { + for (unsigned int i = 0; i < depth; ++i) + writer.write_buffer(indent, indent_length); + } + } + } + + PUGI__FN void node_output_comment(xml_buffered_writer& writer, const char_t* s) + { + writer.write('<', '!', '-', '-'); + + while (*s) + { + const char_t* prev = s; + + // look for -\0 or -- sequence - we can't output it since -- is illegal in comment body + while (*s && !(s[0] == '-' && (s[1] == '-' || s[1] == 0))) ++s; + + writer.write_buffer(prev, static_cast(s - prev)); + + if (*s) + { + assert(*s == '-'); + + writer.write('-', ' '); + ++s; + } + } + + writer.write('-', '-', '>'); + } + + PUGI__FN void node_output_pi_value(xml_buffered_writer& writer, const char_t* s) + { + while (*s) + { + const char_t* prev = s; + + // look for ?> sequence - we can't output it since ?> terminates PI + while (*s && !(s[0] == '?' && s[1] == '>')) ++s; + + writer.write_buffer(prev, static_cast(s - prev)); + + if (*s) + { + assert(s[0] == '?' && s[1] == '>'); + + writer.write('?', ' ', '>'); + s += 2; + } + } + } + + PUGI__FN void node_output_attributes(xml_buffered_writer& writer, xml_node_struct* node, const char_t* indent, size_t indent_length, unsigned int flags, unsigned int depth) + { + const char_t* default_name = PUGIXML_TEXT(":anonymous"); + + for (xml_attribute_struct* a = node->first_attribute; a; a = a->next_attribute) + { + if ((flags & (format_indent_attributes | format_raw)) == format_indent_attributes) + { + writer.write('\n'); + + text_output_indent(writer, indent, indent_length, depth + 1); + } + else + { + writer.write(' '); + } + + writer.write_string(a->name ? a->name + 0 : default_name); + writer.write('=', '"'); + + if (a->value) + text_output(writer, a->value, ctx_special_attr, flags); + + writer.write('"'); + } + } + + PUGI__FN bool node_output_start(xml_buffered_writer& writer, xml_node_struct* node, const char_t* indent, size_t indent_length, unsigned int flags, unsigned int depth) + { + const char_t* default_name = PUGIXML_TEXT(":anonymous"); + const char_t* name = node->name ? node->name + 0 : default_name; + + writer.write('<'); + writer.write_string(name); + + if (node->first_attribute) + node_output_attributes(writer, node, indent, indent_length, flags, depth); + + if (!node->first_child) + { + writer.write(' ', '/', '>'); + + return false; + } + else + { + writer.write('>'); + + return true; + } + } + + PUGI__FN void node_output_end(xml_buffered_writer& writer, xml_node_struct* node) + { + const char_t* default_name = PUGIXML_TEXT(":anonymous"); + const char_t* name = node->name ? node->name + 0 : default_name; + + writer.write('<', '/'); + writer.write_string(name); + writer.write('>'); + } + + PUGI__FN void node_output_simple(xml_buffered_writer& writer, xml_node_struct* node, unsigned int flags) + { + const char_t* default_name = PUGIXML_TEXT(":anonymous"); + + switch (PUGI__NODETYPE(node)) + { + case node_pcdata: + text_output(writer, node->value ? node->value + 0 : PUGIXML_TEXT(""), ctx_special_pcdata, flags); + break; + + case node_cdata: + text_output_cdata(writer, node->value ? node->value + 0 : PUGIXML_TEXT("")); + break; + + case node_comment: + node_output_comment(writer, node->value ? node->value + 0 : PUGIXML_TEXT("")); + break; + + case node_pi: + writer.write('<', '?'); + writer.write_string(node->name ? node->name + 0 : default_name); + + if (node->value) + { + writer.write(' '); + node_output_pi_value(writer, node->value); + } + + writer.write('?', '>'); + break; + + case node_declaration: + writer.write('<', '?'); + writer.write_string(node->name ? node->name + 0 : default_name); + node_output_attributes(writer, node, PUGIXML_TEXT(""), 0, flags | format_raw, 0); + writer.write('?', '>'); + break; + + case node_doctype: + writer.write('<', '!', 'D', 'O', 'C'); + writer.write('T', 'Y', 'P', 'E'); + + if (node->value) + { + writer.write(' '); + writer.write_string(node->value); + } + + writer.write('>'); + break; + + default: + assert(!"Invalid node type"); + } + } + + enum indent_flags_t + { + indent_newline = 1, + indent_indent = 2 + }; + + PUGI__FN void node_output(xml_buffered_writer& writer, xml_node_struct* root, const char_t* indent, unsigned int flags, unsigned int depth) + { + size_t indent_length = ((flags & (format_indent | format_indent_attributes)) && (flags & format_raw) == 0) ? strlength(indent) : 0; + unsigned int indent_flags = indent_indent; + + xml_node_struct* node = root; + + do + { + assert(node); + + // begin writing current node + if (PUGI__NODETYPE(node) == node_pcdata || PUGI__NODETYPE(node) == node_cdata) + { + node_output_simple(writer, node, flags); + + indent_flags = 0; + } + else + { + if ((indent_flags & indent_newline) && (flags & format_raw) == 0) + writer.write('\n'); + + if ((indent_flags & indent_indent) && indent_length) + text_output_indent(writer, indent, indent_length, depth); + + if (PUGI__NODETYPE(node) == node_element) + { + indent_flags = indent_newline | indent_indent; + + if (node_output_start(writer, node, indent, indent_length, flags, depth)) + { + node = node->first_child; + depth++; + continue; + } + } + else if (PUGI__NODETYPE(node) == node_document) + { + indent_flags = indent_indent; + + if (node->first_child) + { + node = node->first_child; + continue; + } + } + else + { + node_output_simple(writer, node, flags); + + indent_flags = indent_newline | indent_indent; + } + } + + // continue to the next node + while (node != root) + { + if (node->next_sibling) + { + node = node->next_sibling; + break; + } + + node = node->parent; + + // write closing node + if (PUGI__NODETYPE(node) == node_element) + { + depth--; + + if ((indent_flags & indent_newline) && (flags & format_raw) == 0) + writer.write('\n'); + + if ((indent_flags & indent_indent) && indent_length) + text_output_indent(writer, indent, indent_length, depth); + + node_output_end(writer, node); + + indent_flags = indent_newline | indent_indent; + } + } + } + while (node != root); + + if ((indent_flags & indent_newline) && (flags & format_raw) == 0) + writer.write('\n'); + } + + PUGI__FN bool has_declaration(xml_node_struct* node) + { + for (xml_node_struct* child = node->first_child; child; child = child->next_sibling) + { + xml_node_type type = PUGI__NODETYPE(child); + + if (type == node_declaration) return true; + if (type == node_element) return false; + } + + return false; + } + + PUGI__FN bool is_attribute_of(xml_attribute_struct* attr, xml_node_struct* node) + { + for (xml_attribute_struct* a = node->first_attribute; a; a = a->next_attribute) + if (a == attr) + return true; + + return false; + } + + PUGI__FN bool allow_insert_attribute(xml_node_type parent) + { + return parent == node_element || parent == node_declaration; + } + + PUGI__FN bool allow_insert_child(xml_node_type parent, xml_node_type child) + { + if (parent != node_document && parent != node_element) return false; + if (child == node_document || child == node_null) return false; + if (parent != node_document && (child == node_declaration || child == node_doctype)) return false; + + return true; + } + + PUGI__FN bool allow_move(xml_node parent, xml_node child) + { + // check that child can be a child of parent + if (!allow_insert_child(parent.type(), child.type())) + return false; + + // check that node is not moved between documents + if (parent.root() != child.root()) + return false; + + // check that new parent is not in the child subtree + xml_node cur = parent; + + while (cur) + { + if (cur == child) + return false; + + cur = cur.parent(); + } + + return true; + } + + template + PUGI__FN void node_copy_string(String& dest, Header& header, uintptr_t header_mask, char_t* source, Header& source_header, xml_allocator* alloc) + { + assert(!dest && (header & header_mask) == 0); + + if (source) + { + if (alloc && (source_header & header_mask) == 0) + { + dest = source; + + // since strcpy_insitu can reuse document buffer memory we need to mark both source and dest as shared + header |= xml_memory_page_contents_shared_mask; + source_header |= xml_memory_page_contents_shared_mask; + } + else + strcpy_insitu(dest, header, header_mask, source, strlength(source)); + } + } + + PUGI__FN void node_copy_contents(xml_node_struct* dn, xml_node_struct* sn, xml_allocator* shared_alloc) + { + node_copy_string(dn->name, dn->header, xml_memory_page_name_allocated_mask, sn->name, sn->header, shared_alloc); + node_copy_string(dn->value, dn->header, xml_memory_page_value_allocated_mask, sn->value, sn->header, shared_alloc); + + for (xml_attribute_struct* sa = sn->first_attribute; sa; sa = sa->next_attribute) + { + xml_attribute_struct* da = append_new_attribute(dn, get_allocator(dn)); + + if (da) + { + node_copy_string(da->name, da->header, xml_memory_page_name_allocated_mask, sa->name, sa->header, shared_alloc); + node_copy_string(da->value, da->header, xml_memory_page_value_allocated_mask, sa->value, sa->header, shared_alloc); + } + } + } + + PUGI__FN void node_copy_tree(xml_node_struct* dn, xml_node_struct* sn) + { + xml_allocator& alloc = get_allocator(dn); + xml_allocator* shared_alloc = (&alloc == &get_allocator(sn)) ? &alloc : 0; + + node_copy_contents(dn, sn, shared_alloc); + + xml_node_struct* dit = dn; + xml_node_struct* sit = sn->first_child; + + while (sit && sit != sn) + { + if (sit != dn) + { + xml_node_struct* copy = append_new_node(dit, alloc, PUGI__NODETYPE(sit)); + + if (copy) + { + node_copy_contents(copy, sit, shared_alloc); + + if (sit->first_child) + { + dit = copy; + sit = sit->first_child; + continue; + } + } + } + + // continue to the next node + do + { + if (sit->next_sibling) + { + sit = sit->next_sibling; + break; + } + + sit = sit->parent; + dit = dit->parent; + } + while (sit != sn); + } + } + + PUGI__FN void node_copy_attribute(xml_attribute_struct* da, xml_attribute_struct* sa) + { + xml_allocator& alloc = get_allocator(da); + xml_allocator* shared_alloc = (&alloc == &get_allocator(sa)) ? &alloc : 0; + + node_copy_string(da->name, da->header, xml_memory_page_name_allocated_mask, sa->name, sa->header, shared_alloc); + node_copy_string(da->value, da->header, xml_memory_page_value_allocated_mask, sa->value, sa->header, shared_alloc); + } + + inline bool is_text_node(xml_node_struct* node) + { + xml_node_type type = PUGI__NODETYPE(node); + + return type == node_pcdata || type == node_cdata; + } + + // get value with conversion functions + template U string_to_integer(const char_t* value, U minneg, U maxpos) + { + U result = 0; + const char_t* s = value; + + while (PUGI__IS_CHARTYPE(*s, ct_space)) + s++; + + bool negative = (*s == '-'); + + s += (*s == '+' || *s == '-'); + + bool overflow = false; + + if (s[0] == '0' && (s[1] | ' ') == 'x') + { + s += 2; + + // since overflow detection relies on length of the sequence skip leading zeros + while (*s == '0') + s++; + + const char_t* start = s; + + for (;;) + { + if (static_cast(*s - '0') < 10) + result = result * 16 + (*s - '0'); + else if (static_cast((*s | ' ') - 'a') < 6) + result = result * 16 + ((*s | ' ') - 'a' + 10); + else + break; + + s++; + } + + size_t digits = static_cast(s - start); + + overflow = digits > sizeof(U) * 2; + } + else + { + // since overflow detection relies on length of the sequence skip leading zeros + while (*s == '0') + s++; + + const char_t* start = s; + + for (;;) + { + if (static_cast(*s - '0') < 10) + result = result * 10 + (*s - '0'); + else + break; + + s++; + } + + size_t digits = static_cast(s - start); + + PUGI__STATIC_ASSERT(sizeof(U) == 8 || sizeof(U) == 4 || sizeof(U) == 2); + + const size_t max_digits10 = sizeof(U) == 8 ? 20 : sizeof(U) == 4 ? 10 : 5; + const char_t max_lead = sizeof(U) == 8 ? '1' : sizeof(U) == 4 ? '4' : '6'; + const size_t high_bit = sizeof(U) * 8 - 1; + + overflow = digits >= max_digits10 && !(digits == max_digits10 && (*start < max_lead || (*start == max_lead && result >> high_bit))); + } + + if (negative) + return (overflow || result > minneg) ? 0 - minneg : 0 - result; + else + return (overflow || result > maxpos) ? maxpos : result; + } + + PUGI__FN int get_value_int(const char_t* value) + { + return string_to_integer(value, 0 - static_cast(INT_MIN), INT_MAX); + } + + PUGI__FN unsigned int get_value_uint(const char_t* value) + { + return string_to_integer(value, 0, UINT_MAX); + } + + PUGI__FN double get_value_double(const char_t* value) + { + #ifdef PUGIXML_WCHAR_MODE + return wcstod(value, 0); + #else + return strtod(value, 0); + #endif + } + + PUGI__FN float get_value_float(const char_t* value) + { + #ifdef PUGIXML_WCHAR_MODE + return static_cast(wcstod(value, 0)); + #else + return static_cast(strtod(value, 0)); + #endif + } + + PUGI__FN bool get_value_bool(const char_t* value) + { + // only look at first char + char_t first = *value; + + // 1*, t* (true), T* (True), y* (yes), Y* (YES) + return (first == '1' || first == 't' || first == 'T' || first == 'y' || first == 'Y'); + } + +#ifdef PUGIXML_HAS_LONG_LONG + PUGI__FN long long get_value_llong(const char_t* value) + { + return string_to_integer(value, 0 - static_cast(LLONG_MIN), LLONG_MAX); + } + + PUGI__FN unsigned long long get_value_ullong(const char_t* value) + { + return string_to_integer(value, 0, ULLONG_MAX); + } +#endif + + template + PUGI__FN char_t* integer_to_string(char_t* begin, char_t* end, U value, bool negative) + { + char_t* result = end - 1; + U rest = negative ? 0 - value : value; + + do + { + *result-- = static_cast('0' + (rest % 10)); + rest /= 10; + } + while (rest); + + assert(result >= begin); + (void)begin; + + *result = '-'; + + return result + !negative; + } + + // set value with conversion functions + template + PUGI__FN bool set_value_ascii(String& dest, Header& header, uintptr_t header_mask, char* buf) + { + #ifdef PUGIXML_WCHAR_MODE + char_t wbuf[128]; + assert(strlen(buf) < sizeof(wbuf) / sizeof(wbuf[0])); + + size_t offset = 0; + for (; buf[offset]; ++offset) wbuf[offset] = buf[offset]; + + return strcpy_insitu(dest, header, header_mask, wbuf, offset); + #else + return strcpy_insitu(dest, header, header_mask, buf, strlen(buf)); + #endif + } + + template + PUGI__FN bool set_value_convert(String& dest, Header& header, uintptr_t header_mask, int value) + { + char_t buf[64]; + char_t* end = buf + sizeof(buf) / sizeof(buf[0]); + char_t* begin = integer_to_string(buf, end, value, value < 0); + + return strcpy_insitu(dest, header, header_mask, begin, end - begin); + } + + template + PUGI__FN bool set_value_convert(String& dest, Header& header, uintptr_t header_mask, unsigned int value) + { + char_t buf[64]; + char_t* end = buf + sizeof(buf) / sizeof(buf[0]); + char_t* begin = integer_to_string(buf, end, value, false); + + return strcpy_insitu(dest, header, header_mask, begin, end - begin); + } + + template + PUGI__FN bool set_value_convert(String& dest, Header& header, uintptr_t header_mask, float value) + { + char buf[128]; + sprintf(buf, "%.9g", value); + + return set_value_ascii(dest, header, header_mask, buf); + } + + template + PUGI__FN bool set_value_convert(String& dest, Header& header, uintptr_t header_mask, double value) + { + char buf[128]; + sprintf(buf, "%.17g", value); + + return set_value_ascii(dest, header, header_mask, buf); + } + + template + PUGI__FN bool set_value_convert(String& dest, Header& header, uintptr_t header_mask, bool value) + { + return strcpy_insitu(dest, header, header_mask, value ? PUGIXML_TEXT("true") : PUGIXML_TEXT("false"), value ? 4 : 5); + } + +#ifdef PUGIXML_HAS_LONG_LONG + template + PUGI__FN bool set_value_convert(String& dest, Header& header, uintptr_t header_mask, long long value) + { + char_t buf[64]; + char_t* end = buf + sizeof(buf) / sizeof(buf[0]); + char_t* begin = integer_to_string(buf, end, value, value < 0); + + return strcpy_insitu(dest, header, header_mask, begin, end - begin); + } + + template + PUGI__FN bool set_value_convert(String& dest, Header& header, uintptr_t header_mask, unsigned long long value) + { + char_t buf[64]; + char_t* end = buf + sizeof(buf) / sizeof(buf[0]); + char_t* begin = integer_to_string(buf, end, value, false); + + return strcpy_insitu(dest, header, header_mask, begin, end - begin); + } +#endif + + PUGI__FN xml_parse_result load_buffer_impl(xml_document_struct* doc, xml_node_struct* root, void* contents, size_t size, unsigned int options, xml_encoding encoding, bool is_mutable, bool own, char_t** out_buffer) + { + // check input buffer + if (!contents && size) return make_parse_result(status_io_error); + + // get actual encoding + xml_encoding buffer_encoding = impl::get_buffer_encoding(encoding, contents, size); + + // get private buffer + char_t* buffer = 0; + size_t length = 0; + + if (!impl::convert_buffer(buffer, length, buffer_encoding, contents, size, is_mutable)) return impl::make_parse_result(status_out_of_memory); + + // delete original buffer if we performed a conversion + if (own && buffer != contents && contents) impl::xml_memory::deallocate(contents); + + // grab onto buffer if it's our buffer, user is responsible for deallocating contents himself + if (own || buffer != contents) *out_buffer = buffer; + + // store buffer for offset_debug + doc->buffer = buffer; + + // parse + xml_parse_result res = impl::xml_parser::parse(buffer, length, doc, root, options); + + // remember encoding + res.encoding = buffer_encoding; + + return res; + } + + // we need to get length of entire file to load it in memory; the only (relatively) sane way to do it is via seek/tell trick + PUGI__FN xml_parse_status get_file_size(FILE* file, size_t& out_result) + { + #if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400 && !defined(_WIN32_WCE) + // there are 64-bit versions of fseek/ftell, let's use them + typedef __int64 length_type; + + _fseeki64(file, 0, SEEK_END); + length_type length = _ftelli64(file); + _fseeki64(file, 0, SEEK_SET); + #elif defined(__MINGW32__) && !defined(__NO_MINGW_LFS) && (!defined(__STRICT_ANSI__) || defined(__MINGW64_VERSION_MAJOR)) + // there are 64-bit versions of fseek/ftell, let's use them + typedef off64_t length_type; + + fseeko64(file, 0, SEEK_END); + length_type length = ftello64(file); + fseeko64(file, 0, SEEK_SET); + #else + // if this is a 32-bit OS, long is enough; if this is a unix system, long is 64-bit, which is enough; otherwise we can't do anything anyway. + typedef long length_type; + + fseek(file, 0, SEEK_END); + length_type length = ftell(file); + fseek(file, 0, SEEK_SET); + #endif + + // check for I/O errors + if (length < 0) return status_io_error; + + // check for overflow + size_t result = static_cast(length); + + if (static_cast(result) != length) return status_out_of_memory; + + // finalize + out_result = result; + + return status_ok; + } + + // This function assumes that buffer has extra sizeof(char_t) writable bytes after size + PUGI__FN size_t zero_terminate_buffer(void* buffer, size_t size, xml_encoding encoding) + { + // We only need to zero-terminate if encoding conversion does not do it for us + #ifdef PUGIXML_WCHAR_MODE + xml_encoding wchar_encoding = get_wchar_encoding(); + + if (encoding == wchar_encoding || need_endian_swap_utf(encoding, wchar_encoding)) + { + size_t length = size / sizeof(char_t); + + static_cast(buffer)[length] = 0; + return (length + 1) * sizeof(char_t); + } + #else + if (encoding == encoding_utf8) + { + static_cast(buffer)[size] = 0; + return size + 1; + } + #endif + + return size; + } + + PUGI__FN xml_parse_result load_file_impl(xml_document_struct* doc, FILE* file, unsigned int options, xml_encoding encoding, char_t** out_buffer) + { + if (!file) return make_parse_result(status_file_not_found); + + // get file size (can result in I/O errors) + size_t size = 0; + xml_parse_status size_status = get_file_size(file, size); + if (size_status != status_ok) return make_parse_result(size_status); + + size_t max_suffix_size = sizeof(char_t); + + // allocate buffer for the whole file + char* contents = static_cast(xml_memory::allocate(size + max_suffix_size)); + if (!contents) return make_parse_result(status_out_of_memory); + + // read file in memory + size_t read_size = fread(contents, 1, size, file); + + if (read_size != size) + { + xml_memory::deallocate(contents); + return make_parse_result(status_io_error); + } + + xml_encoding real_encoding = get_buffer_encoding(encoding, contents, size); + + return load_buffer_impl(doc, doc, contents, zero_terminate_buffer(contents, size, real_encoding), options, real_encoding, true, true, out_buffer); + } + +#ifndef PUGIXML_NO_STL + template struct xml_stream_chunk + { + static xml_stream_chunk* create() + { + void* memory = xml_memory::allocate(sizeof(xml_stream_chunk)); + if (!memory) return 0; + + return new (memory) xml_stream_chunk(); + } + + static void destroy(xml_stream_chunk* chunk) + { + // free chunk chain + while (chunk) + { + xml_stream_chunk* next_ = chunk->next; + + xml_memory::deallocate(chunk); + + chunk = next_; + } + } + + xml_stream_chunk(): next(0), size(0) + { + } + + xml_stream_chunk* next; + size_t size; + + T data[xml_memory_page_size / sizeof(T)]; + }; + + template PUGI__FN xml_parse_status load_stream_data_noseek(std::basic_istream& stream, void** out_buffer, size_t* out_size) + { + auto_deleter > chunks(0, xml_stream_chunk::destroy); + + // read file to a chunk list + size_t total = 0; + xml_stream_chunk* last = 0; + + while (!stream.eof()) + { + // allocate new chunk + xml_stream_chunk* chunk = xml_stream_chunk::create(); + if (!chunk) return status_out_of_memory; + + // append chunk to list + if (last) last = last->next = chunk; + else chunks.data = last = chunk; + + // read data to chunk + stream.read(chunk->data, static_cast(sizeof(chunk->data) / sizeof(T))); + chunk->size = static_cast(stream.gcount()) * sizeof(T); + + // read may set failbit | eofbit in case gcount() is less than read length, so check for other I/O errors + if (stream.bad() || (!stream.eof() && stream.fail())) return status_io_error; + + // guard against huge files (chunk size is small enough to make this overflow check work) + if (total + chunk->size < total) return status_out_of_memory; + total += chunk->size; + } + + size_t max_suffix_size = sizeof(char_t); + + // copy chunk list to a contiguous buffer + char* buffer = static_cast(xml_memory::allocate(total + max_suffix_size)); + if (!buffer) return status_out_of_memory; + + char* write = buffer; + + for (xml_stream_chunk* chunk = chunks.data; chunk; chunk = chunk->next) + { + assert(write + chunk->size <= buffer + total); + memcpy(write, chunk->data, chunk->size); + write += chunk->size; + } + + assert(write == buffer + total); + + // return buffer + *out_buffer = buffer; + *out_size = total; + + return status_ok; + } + + template PUGI__FN xml_parse_status load_stream_data_seek(std::basic_istream& stream, void** out_buffer, size_t* out_size) + { + // get length of remaining data in stream + typename std::basic_istream::pos_type pos = stream.tellg(); + stream.seekg(0, std::ios::end); + std::streamoff length = stream.tellg() - pos; + stream.seekg(pos); + + if (stream.fail() || pos < 0) return status_io_error; + + // guard against huge files + size_t read_length = static_cast(length); + + if (static_cast(read_length) != length || length < 0) return status_out_of_memory; + + size_t max_suffix_size = sizeof(char_t); + + // read stream data into memory (guard against stream exceptions with buffer holder) + auto_deleter buffer(xml_memory::allocate(read_length * sizeof(T) + max_suffix_size), xml_memory::deallocate); + if (!buffer.data) return status_out_of_memory; + + stream.read(static_cast(buffer.data), static_cast(read_length)); + + // read may set failbit | eofbit in case gcount() is less than read_length (i.e. line ending conversion), so check for other I/O errors + if (stream.bad() || (!stream.eof() && stream.fail())) return status_io_error; + + // return buffer + size_t actual_length = static_cast(stream.gcount()); + assert(actual_length <= read_length); + + *out_buffer = buffer.release(); + *out_size = actual_length * sizeof(T); + + return status_ok; + } + + template PUGI__FN xml_parse_result load_stream_impl(xml_document_struct* doc, std::basic_istream& stream, unsigned int options, xml_encoding encoding, char_t** out_buffer) + { + void* buffer = 0; + size_t size = 0; + xml_parse_status status = status_ok; + + // if stream has an error bit set, bail out (otherwise tellg() can fail and we'll clear error bits) + if (stream.fail()) return make_parse_result(status_io_error); + + // load stream to memory (using seek-based implementation if possible, since it's faster and takes less memory) + if (stream.tellg() < 0) + { + stream.clear(); // clear error flags that could be set by a failing tellg + status = load_stream_data_noseek(stream, &buffer, &size); + } + else + status = load_stream_data_seek(stream, &buffer, &size); + + if (status != status_ok) return make_parse_result(status); + + xml_encoding real_encoding = get_buffer_encoding(encoding, buffer, size); + + return load_buffer_impl(doc, doc, buffer, zero_terminate_buffer(buffer, size, real_encoding), options, real_encoding, true, true, out_buffer); + } +#endif + +#if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__) || (defined(__MINGW32__) && (!defined(__STRICT_ANSI__) || defined(__MINGW64_VERSION_MAJOR))) + PUGI__FN FILE* open_file_wide(const wchar_t* path, const wchar_t* mode) + { + return _wfopen(path, mode); + } +#else + PUGI__FN char* convert_path_heap(const wchar_t* str) + { + assert(str); + + // first pass: get length in utf8 characters + size_t length = strlength_wide(str); + size_t size = as_utf8_begin(str, length); + + // allocate resulting string + char* result = static_cast(xml_memory::allocate(size + 1)); + if (!result) return 0; + + // second pass: convert to utf8 + as_utf8_end(result, size, str, length); + + // zero-terminate + result[size] = 0; + + return result; + } + + PUGI__FN FILE* open_file_wide(const wchar_t* path, const wchar_t* mode) + { + // there is no standard function to open wide paths, so our best bet is to try utf8 path + char* path_utf8 = convert_path_heap(path); + if (!path_utf8) return 0; + + // convert mode to ASCII (we mirror _wfopen interface) + char mode_ascii[4] = {0}; + for (size_t i = 0; mode[i]; ++i) mode_ascii[i] = static_cast(mode[i]); + + // try to open the utf8 path + FILE* result = fopen(path_utf8, mode_ascii); + + // free dummy buffer + xml_memory::deallocate(path_utf8); + + return result; + } +#endif + + PUGI__FN bool save_file_impl(const xml_document& doc, FILE* file, const char_t* indent, unsigned int flags, xml_encoding encoding) + { + if (!file) return false; + + xml_writer_file writer(file); + doc.save(writer, indent, flags, encoding); + + return ferror(file) == 0; + } + + struct name_null_sentry + { + xml_node_struct* node; + char_t* name; + + name_null_sentry(xml_node_struct* node_): node(node_), name(node_->name) + { + node->name = 0; + } + + ~name_null_sentry() + { + node->name = name; + } + }; +PUGI__NS_END + +namespace pugi +{ + PUGI__FN xml_writer_file::xml_writer_file(void* file_): file(file_) + { + } + + PUGI__FN void xml_writer_file::write(const void* data, size_t size) + { + size_t result = fwrite(data, 1, size, static_cast(file)); + (void)!result; // unfortunately we can't do proper error handling here + } + +#ifndef PUGIXML_NO_STL + PUGI__FN xml_writer_stream::xml_writer_stream(std::basic_ostream >& stream): narrow_stream(&stream), wide_stream(0) + { + } + + PUGI__FN xml_writer_stream::xml_writer_stream(std::basic_ostream >& stream): narrow_stream(0), wide_stream(&stream) + { + } + + PUGI__FN void xml_writer_stream::write(const void* data, size_t size) + { + if (narrow_stream) + { + assert(!wide_stream); + narrow_stream->write(reinterpret_cast(data), static_cast(size)); + } + else + { + assert(wide_stream); + assert(size % sizeof(wchar_t) == 0); + + wide_stream->write(reinterpret_cast(data), static_cast(size / sizeof(wchar_t))); + } + } +#endif + + PUGI__FN xml_tree_walker::xml_tree_walker(): _depth(0) + { + } + + PUGI__FN xml_tree_walker::~xml_tree_walker() + { + } + + PUGI__FN int xml_tree_walker::depth() const + { + return _depth; + } + + PUGI__FN bool xml_tree_walker::begin(xml_node&) + { + return true; + } + + PUGI__FN bool xml_tree_walker::end(xml_node&) + { + return true; + } + + PUGI__FN xml_attribute::xml_attribute(): _attr(0) + { + } + + PUGI__FN xml_attribute::xml_attribute(xml_attribute_struct* attr): _attr(attr) + { + } + + PUGI__FN static void unspecified_bool_xml_attribute(xml_attribute***) + { + } + + PUGI__FN xml_attribute::operator xml_attribute::unspecified_bool_type() const + { + return _attr ? unspecified_bool_xml_attribute : 0; + } + + PUGI__FN bool xml_attribute::operator!() const + { + return !_attr; + } + + PUGI__FN bool xml_attribute::operator==(const xml_attribute& r) const + { + return (_attr == r._attr); + } + + PUGI__FN bool xml_attribute::operator!=(const xml_attribute& r) const + { + return (_attr != r._attr); + } + + PUGI__FN bool xml_attribute::operator<(const xml_attribute& r) const + { + return (_attr < r._attr); + } + + PUGI__FN bool xml_attribute::operator>(const xml_attribute& r) const + { + return (_attr > r._attr); + } + + PUGI__FN bool xml_attribute::operator<=(const xml_attribute& r) const + { + return (_attr <= r._attr); + } + + PUGI__FN bool xml_attribute::operator>=(const xml_attribute& r) const + { + return (_attr >= r._attr); + } + + PUGI__FN xml_attribute xml_attribute::next_attribute() const + { + return _attr ? xml_attribute(_attr->next_attribute) : xml_attribute(); + } + + PUGI__FN xml_attribute xml_attribute::previous_attribute() const + { + return _attr && _attr->prev_attribute_c->next_attribute ? xml_attribute(_attr->prev_attribute_c) : xml_attribute(); + } + + PUGI__FN const char_t* xml_attribute::as_string(const char_t* def) const + { + return (_attr && _attr->value) ? _attr->value + 0 : def; + } + + PUGI__FN int xml_attribute::as_int(int def) const + { + return (_attr && _attr->value) ? impl::get_value_int(_attr->value) : def; + } + + PUGI__FN unsigned int xml_attribute::as_uint(unsigned int def) const + { + return (_attr && _attr->value) ? impl::get_value_uint(_attr->value) : def; + } + + PUGI__FN double xml_attribute::as_double(double def) const + { + return (_attr && _attr->value) ? impl::get_value_double(_attr->value) : def; + } + + PUGI__FN float xml_attribute::as_float(float def) const + { + return (_attr && _attr->value) ? impl::get_value_float(_attr->value) : def; + } + + PUGI__FN bool xml_attribute::as_bool(bool def) const + { + return (_attr && _attr->value) ? impl::get_value_bool(_attr->value) : def; + } + +#ifdef PUGIXML_HAS_LONG_LONG + PUGI__FN long long xml_attribute::as_llong(long long def) const + { + return (_attr && _attr->value) ? impl::get_value_llong(_attr->value) : def; + } + + PUGI__FN unsigned long long xml_attribute::as_ullong(unsigned long long def) const + { + return (_attr && _attr->value) ? impl::get_value_ullong(_attr->value) : def; + } +#endif + + PUGI__FN bool xml_attribute::empty() const + { + return !_attr; + } + + PUGI__FN const char_t* xml_attribute::name() const + { + return (_attr && _attr->name) ? _attr->name + 0 : PUGIXML_TEXT(""); + } + + PUGI__FN const char_t* xml_attribute::value() const + { + return (_attr && _attr->value) ? _attr->value + 0 : PUGIXML_TEXT(""); + } + + PUGI__FN size_t xml_attribute::hash_value() const + { + return static_cast(reinterpret_cast(_attr) / sizeof(xml_attribute_struct)); + } + + PUGI__FN xml_attribute_struct* xml_attribute::internal_object() const + { + return _attr; + } + + PUGI__FN xml_attribute& xml_attribute::operator=(const char_t* rhs) + { + set_value(rhs); + return *this; + } + + PUGI__FN xml_attribute& xml_attribute::operator=(int rhs) + { + set_value(rhs); + return *this; + } + + PUGI__FN xml_attribute& xml_attribute::operator=(unsigned int rhs) + { + set_value(rhs); + return *this; + } + + PUGI__FN xml_attribute& xml_attribute::operator=(double rhs) + { + set_value(rhs); + return *this; + } + + PUGI__FN xml_attribute& xml_attribute::operator=(float rhs) + { + set_value(rhs); + return *this; + } + + PUGI__FN xml_attribute& xml_attribute::operator=(bool rhs) + { + set_value(rhs); + return *this; + } + +#ifdef PUGIXML_HAS_LONG_LONG + PUGI__FN xml_attribute& xml_attribute::operator=(long long rhs) + { + set_value(rhs); + return *this; + } + + PUGI__FN xml_attribute& xml_attribute::operator=(unsigned long long rhs) + { + set_value(rhs); + return *this; + } +#endif + + PUGI__FN bool xml_attribute::set_name(const char_t* rhs) + { + if (!_attr) return false; + + return impl::strcpy_insitu(_attr->name, _attr->header, impl::xml_memory_page_name_allocated_mask, rhs, impl::strlength(rhs)); + } + + PUGI__FN bool xml_attribute::set_value(const char_t* rhs) + { + if (!_attr) return false; + + return impl::strcpy_insitu(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs, impl::strlength(rhs)); + } + + PUGI__FN bool xml_attribute::set_value(int rhs) + { + if (!_attr) return false; + + return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs); + } + + PUGI__FN bool xml_attribute::set_value(unsigned int rhs) + { + if (!_attr) return false; + + return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs); + } + + PUGI__FN bool xml_attribute::set_value(double rhs) + { + if (!_attr) return false; + + return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs); + } + + PUGI__FN bool xml_attribute::set_value(float rhs) + { + if (!_attr) return false; + + return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs); + } + + PUGI__FN bool xml_attribute::set_value(bool rhs) + { + if (!_attr) return false; + + return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs); + } + +#ifdef PUGIXML_HAS_LONG_LONG + PUGI__FN bool xml_attribute::set_value(long long rhs) + { + if (!_attr) return false; + + return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs); + } + + PUGI__FN bool xml_attribute::set_value(unsigned long long rhs) + { + if (!_attr) return false; + + return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs); + } +#endif + +#ifdef __BORLANDC__ + PUGI__FN bool operator&&(const xml_attribute& lhs, bool rhs) + { + return (bool)lhs && rhs; + } + + PUGI__FN bool operator||(const xml_attribute& lhs, bool rhs) + { + return (bool)lhs || rhs; + } +#endif + + PUGI__FN xml_node::xml_node(): _root(0) + { + } + + PUGI__FN xml_node::xml_node(xml_node_struct* p): _root(p) + { + } + + PUGI__FN static void unspecified_bool_xml_node(xml_node***) + { + } + + PUGI__FN xml_node::operator xml_node::unspecified_bool_type() const + { + return _root ? unspecified_bool_xml_node : 0; + } + + PUGI__FN bool xml_node::operator!() const + { + return !_root; + } + + PUGI__FN xml_node::iterator xml_node::begin() const + { + return iterator(_root ? _root->first_child + 0 : 0, _root); + } + + PUGI__FN xml_node::iterator xml_node::end() const + { + return iterator(0, _root); + } + + PUGI__FN xml_node::attribute_iterator xml_node::attributes_begin() const + { + return attribute_iterator(_root ? _root->first_attribute + 0 : 0, _root); + } + + PUGI__FN xml_node::attribute_iterator xml_node::attributes_end() const + { + return attribute_iterator(0, _root); + } + + PUGI__FN xml_object_range xml_node::children() const + { + return xml_object_range(begin(), end()); + } + + PUGI__FN xml_object_range xml_node::children(const char_t* name_) const + { + return xml_object_range(xml_named_node_iterator(child(name_)._root, _root, name_), xml_named_node_iterator(0, _root, name_)); + } + + PUGI__FN xml_object_range xml_node::attributes() const + { + return xml_object_range(attributes_begin(), attributes_end()); + } + + PUGI__FN bool xml_node::operator==(const xml_node& r) const + { + return (_root == r._root); + } + + PUGI__FN bool xml_node::operator!=(const xml_node& r) const + { + return (_root != r._root); + } + + PUGI__FN bool xml_node::operator<(const xml_node& r) const + { + return (_root < r._root); + } + + PUGI__FN bool xml_node::operator>(const xml_node& r) const + { + return (_root > r._root); + } + + PUGI__FN bool xml_node::operator<=(const xml_node& r) const + { + return (_root <= r._root); + } + + PUGI__FN bool xml_node::operator>=(const xml_node& r) const + { + return (_root >= r._root); + } + + PUGI__FN bool xml_node::empty() const + { + return !_root; + } + + PUGI__FN const char_t* xml_node::name() const + { + return (_root && _root->name) ? _root->name + 0 : PUGIXML_TEXT(""); + } + + PUGI__FN xml_node_type xml_node::type() const + { + return _root ? PUGI__NODETYPE(_root) : node_null; + } + + PUGI__FN const char_t* xml_node::value() const + { + return (_root && _root->value) ? _root->value + 0 : PUGIXML_TEXT(""); + } + + PUGI__FN xml_node xml_node::child(const char_t* name_) const + { + if (!_root) return xml_node(); + + for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling) + if (i->name && impl::strequal(name_, i->name)) return xml_node(i); + + return xml_node(); + } + + PUGI__FN xml_attribute xml_node::attribute(const char_t* name_) const + { + if (!_root) return xml_attribute(); + + for (xml_attribute_struct* i = _root->first_attribute; i; i = i->next_attribute) + if (i->name && impl::strequal(name_, i->name)) + return xml_attribute(i); + + return xml_attribute(); + } + + PUGI__FN xml_node xml_node::next_sibling(const char_t* name_) const + { + if (!_root) return xml_node(); + + for (xml_node_struct* i = _root->next_sibling; i; i = i->next_sibling) + if (i->name && impl::strequal(name_, i->name)) return xml_node(i); + + return xml_node(); + } + + PUGI__FN xml_node xml_node::next_sibling() const + { + return _root ? xml_node(_root->next_sibling) : xml_node(); + } + + PUGI__FN xml_node xml_node::previous_sibling(const char_t* name_) const + { + if (!_root) return xml_node(); + + for (xml_node_struct* i = _root->prev_sibling_c; i->next_sibling; i = i->prev_sibling_c) + if (i->name && impl::strequal(name_, i->name)) return xml_node(i); + + return xml_node(); + } + + PUGI__FN xml_attribute xml_node::attribute(const char_t* name_, xml_attribute& hint_) const + { + xml_attribute_struct* hint = hint_._attr; + + // if hint is not an attribute of node, behavior is not defined + assert(!hint || (_root && impl::is_attribute_of(hint, _root))); + + if (!_root) return xml_attribute(); + + // optimistically search from hint up until the end + for (xml_attribute_struct* i = hint; i; i = i->next_attribute) + if (i->name && impl::strequal(name_, i->name)) + { + // update hint to maximize efficiency of searching for consecutive attributes + hint_._attr = i->next_attribute; + + return xml_attribute(i); + } + + // wrap around and search from the first attribute until the hint + // 'j' null pointer check is technically redundant, but it prevents a crash in case the assertion above fails + for (xml_attribute_struct* j = _root->first_attribute; j && j != hint; j = j->next_attribute) + if (j->name && impl::strequal(name_, j->name)) + { + // update hint to maximize efficiency of searching for consecutive attributes + hint_._attr = j->next_attribute; + + return xml_attribute(j); + } + + return xml_attribute(); + } + + PUGI__FN xml_node xml_node::previous_sibling() const + { + if (!_root) return xml_node(); + + if (_root->prev_sibling_c->next_sibling) return xml_node(_root->prev_sibling_c); + else return xml_node(); + } + + PUGI__FN xml_node xml_node::parent() const + { + return _root ? xml_node(_root->parent) : xml_node(); + } + + PUGI__FN xml_node xml_node::root() const + { + return _root ? xml_node(&impl::get_document(_root)) : xml_node(); + } + + PUGI__FN xml_text xml_node::text() const + { + return xml_text(_root); + } + + PUGI__FN const char_t* xml_node::child_value() const + { + if (!_root) return PUGIXML_TEXT(""); + + for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling) + if (impl::is_text_node(i) && i->value) + return i->value; + + return PUGIXML_TEXT(""); + } + + PUGI__FN const char_t* xml_node::child_value(const char_t* name_) const + { + return child(name_).child_value(); + } + + PUGI__FN xml_attribute xml_node::first_attribute() const + { + return _root ? xml_attribute(_root->first_attribute) : xml_attribute(); + } + + PUGI__FN xml_attribute xml_node::last_attribute() const + { + return _root && _root->first_attribute ? xml_attribute(_root->first_attribute->prev_attribute_c) : xml_attribute(); + } + + PUGI__FN xml_node xml_node::first_child() const + { + return _root ? xml_node(_root->first_child) : xml_node(); + } + + PUGI__FN xml_node xml_node::last_child() const + { + return _root && _root->first_child ? xml_node(_root->first_child->prev_sibling_c) : xml_node(); + } + + PUGI__FN bool xml_node::set_name(const char_t* rhs) + { + xml_node_type type_ = _root ? PUGI__NODETYPE(_root) : node_null; + + if (type_ != node_element && type_ != node_pi && type_ != node_declaration) + return false; + + return impl::strcpy_insitu(_root->name, _root->header, impl::xml_memory_page_name_allocated_mask, rhs, impl::strlength(rhs)); + } + + PUGI__FN bool xml_node::set_value(const char_t* rhs) + { + xml_node_type type_ = _root ? PUGI__NODETYPE(_root) : node_null; + + if (type_ != node_pcdata && type_ != node_cdata && type_ != node_comment && type_ != node_pi && type_ != node_doctype) + return false; + + return impl::strcpy_insitu(_root->value, _root->header, impl::xml_memory_page_value_allocated_mask, rhs, impl::strlength(rhs)); + } + + PUGI__FN xml_attribute xml_node::append_attribute(const char_t* name_) + { + if (!impl::allow_insert_attribute(type())) return xml_attribute(); + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return xml_attribute(); + + xml_attribute a(impl::allocate_attribute(alloc)); + if (!a) return xml_attribute(); + + impl::append_attribute(a._attr, _root); + + a.set_name(name_); + + return a; + } + + PUGI__FN xml_attribute xml_node::prepend_attribute(const char_t* name_) + { + if (!impl::allow_insert_attribute(type())) return xml_attribute(); + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return xml_attribute(); + + xml_attribute a(impl::allocate_attribute(alloc)); + if (!a) return xml_attribute(); + + impl::prepend_attribute(a._attr, _root); + + a.set_name(name_); + + return a; + } + + PUGI__FN xml_attribute xml_node::insert_attribute_after(const char_t* name_, const xml_attribute& attr) + { + if (!impl::allow_insert_attribute(type())) return xml_attribute(); + if (!attr || !impl::is_attribute_of(attr._attr, _root)) return xml_attribute(); + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return xml_attribute(); + + xml_attribute a(impl::allocate_attribute(alloc)); + if (!a) return xml_attribute(); + + impl::insert_attribute_after(a._attr, attr._attr, _root); + + a.set_name(name_); + + return a; + } + + PUGI__FN xml_attribute xml_node::insert_attribute_before(const char_t* name_, const xml_attribute& attr) + { + if (!impl::allow_insert_attribute(type())) return xml_attribute(); + if (!attr || !impl::is_attribute_of(attr._attr, _root)) return xml_attribute(); + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return xml_attribute(); + + xml_attribute a(impl::allocate_attribute(alloc)); + if (!a) return xml_attribute(); + + impl::insert_attribute_before(a._attr, attr._attr, _root); + + a.set_name(name_); + + return a; + } + + PUGI__FN xml_attribute xml_node::append_copy(const xml_attribute& proto) + { + if (!proto) return xml_attribute(); + if (!impl::allow_insert_attribute(type())) return xml_attribute(); + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return xml_attribute(); + + xml_attribute a(impl::allocate_attribute(alloc)); + if (!a) return xml_attribute(); + + impl::append_attribute(a._attr, _root); + impl::node_copy_attribute(a._attr, proto._attr); + + return a; + } + + PUGI__FN xml_attribute xml_node::prepend_copy(const xml_attribute& proto) + { + if (!proto) return xml_attribute(); + if (!impl::allow_insert_attribute(type())) return xml_attribute(); + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return xml_attribute(); + + xml_attribute a(impl::allocate_attribute(alloc)); + if (!a) return xml_attribute(); + + impl::prepend_attribute(a._attr, _root); + impl::node_copy_attribute(a._attr, proto._attr); + + return a; + } + + PUGI__FN xml_attribute xml_node::insert_copy_after(const xml_attribute& proto, const xml_attribute& attr) + { + if (!proto) return xml_attribute(); + if (!impl::allow_insert_attribute(type())) return xml_attribute(); + if (!attr || !impl::is_attribute_of(attr._attr, _root)) return xml_attribute(); + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return xml_attribute(); + + xml_attribute a(impl::allocate_attribute(alloc)); + if (!a) return xml_attribute(); + + impl::insert_attribute_after(a._attr, attr._attr, _root); + impl::node_copy_attribute(a._attr, proto._attr); + + return a; + } + + PUGI__FN xml_attribute xml_node::insert_copy_before(const xml_attribute& proto, const xml_attribute& attr) + { + if (!proto) return xml_attribute(); + if (!impl::allow_insert_attribute(type())) return xml_attribute(); + if (!attr || !impl::is_attribute_of(attr._attr, _root)) return xml_attribute(); + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return xml_attribute(); + + xml_attribute a(impl::allocate_attribute(alloc)); + if (!a) return xml_attribute(); + + impl::insert_attribute_before(a._attr, attr._attr, _root); + impl::node_copy_attribute(a._attr, proto._attr); + + return a; + } + + PUGI__FN xml_node xml_node::append_child(xml_node_type type_) + { + if (!impl::allow_insert_child(type(), type_)) return xml_node(); + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return xml_node(); + + xml_node n(impl::allocate_node(alloc, type_)); + if (!n) return xml_node(); + + impl::append_node(n._root, _root); + + if (type_ == node_declaration) n.set_name(PUGIXML_TEXT("xml")); + + return n; + } + + PUGI__FN xml_node xml_node::prepend_child(xml_node_type type_) + { + if (!impl::allow_insert_child(type(), type_)) return xml_node(); + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return xml_node(); + + xml_node n(impl::allocate_node(alloc, type_)); + if (!n) return xml_node(); + + impl::prepend_node(n._root, _root); + + if (type_ == node_declaration) n.set_name(PUGIXML_TEXT("xml")); + + return n; + } + + PUGI__FN xml_node xml_node::insert_child_before(xml_node_type type_, const xml_node& node) + { + if (!impl::allow_insert_child(type(), type_)) return xml_node(); + if (!node._root || node._root->parent != _root) return xml_node(); + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return xml_node(); + + xml_node n(impl::allocate_node(alloc, type_)); + if (!n) return xml_node(); + + impl::insert_node_before(n._root, node._root); + + if (type_ == node_declaration) n.set_name(PUGIXML_TEXT("xml")); + + return n; + } + + PUGI__FN xml_node xml_node::insert_child_after(xml_node_type type_, const xml_node& node) + { + if (!impl::allow_insert_child(type(), type_)) return xml_node(); + if (!node._root || node._root->parent != _root) return xml_node(); + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return xml_node(); + + xml_node n(impl::allocate_node(alloc, type_)); + if (!n) return xml_node(); + + impl::insert_node_after(n._root, node._root); + + if (type_ == node_declaration) n.set_name(PUGIXML_TEXT("xml")); + + return n; + } + + PUGI__FN xml_node xml_node::append_child(const char_t* name_) + { + xml_node result = append_child(node_element); + + result.set_name(name_); + + return result; + } + + PUGI__FN xml_node xml_node::prepend_child(const char_t* name_) + { + xml_node result = prepend_child(node_element); + + result.set_name(name_); + + return result; + } + + PUGI__FN xml_node xml_node::insert_child_after(const char_t* name_, const xml_node& node) + { + xml_node result = insert_child_after(node_element, node); + + result.set_name(name_); + + return result; + } + + PUGI__FN xml_node xml_node::insert_child_before(const char_t* name_, const xml_node& node) + { + xml_node result = insert_child_before(node_element, node); + + result.set_name(name_); + + return result; + } + + PUGI__FN xml_node xml_node::append_copy(const xml_node& proto) + { + xml_node_type type_ = proto.type(); + if (!impl::allow_insert_child(type(), type_)) return xml_node(); + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return xml_node(); + + xml_node n(impl::allocate_node(alloc, type_)); + if (!n) return xml_node(); + + impl::append_node(n._root, _root); + impl::node_copy_tree(n._root, proto._root); + + return n; + } + + PUGI__FN xml_node xml_node::prepend_copy(const xml_node& proto) + { + xml_node_type type_ = proto.type(); + if (!impl::allow_insert_child(type(), type_)) return xml_node(); + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return xml_node(); + + xml_node n(impl::allocate_node(alloc, type_)); + if (!n) return xml_node(); + + impl::prepend_node(n._root, _root); + impl::node_copy_tree(n._root, proto._root); + + return n; + } + + PUGI__FN xml_node xml_node::insert_copy_after(const xml_node& proto, const xml_node& node) + { + xml_node_type type_ = proto.type(); + if (!impl::allow_insert_child(type(), type_)) return xml_node(); + if (!node._root || node._root->parent != _root) return xml_node(); + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return xml_node(); + + xml_node n(impl::allocate_node(alloc, type_)); + if (!n) return xml_node(); + + impl::insert_node_after(n._root, node._root); + impl::node_copy_tree(n._root, proto._root); + + return n; + } + + PUGI__FN xml_node xml_node::insert_copy_before(const xml_node& proto, const xml_node& node) + { + xml_node_type type_ = proto.type(); + if (!impl::allow_insert_child(type(), type_)) return xml_node(); + if (!node._root || node._root->parent != _root) return xml_node(); + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return xml_node(); + + xml_node n(impl::allocate_node(alloc, type_)); + if (!n) return xml_node(); + + impl::insert_node_before(n._root, node._root); + impl::node_copy_tree(n._root, proto._root); + + return n; + } + + PUGI__FN xml_node xml_node::append_move(const xml_node& moved) + { + if (!impl::allow_move(*this, moved)) return xml_node(); + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return xml_node(); + + // disable document_buffer_order optimization since moving nodes around changes document order without changing buffer pointers + impl::get_document(_root).header |= impl::xml_memory_page_contents_shared_mask; + + impl::remove_node(moved._root); + impl::append_node(moved._root, _root); + + return moved; + } + + PUGI__FN xml_node xml_node::prepend_move(const xml_node& moved) + { + if (!impl::allow_move(*this, moved)) return xml_node(); + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return xml_node(); + + // disable document_buffer_order optimization since moving nodes around changes document order without changing buffer pointers + impl::get_document(_root).header |= impl::xml_memory_page_contents_shared_mask; + + impl::remove_node(moved._root); + impl::prepend_node(moved._root, _root); + + return moved; + } + + PUGI__FN xml_node xml_node::insert_move_after(const xml_node& moved, const xml_node& node) + { + if (!impl::allow_move(*this, moved)) return xml_node(); + if (!node._root || node._root->parent != _root) return xml_node(); + if (moved._root == node._root) return xml_node(); + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return xml_node(); + + // disable document_buffer_order optimization since moving nodes around changes document order without changing buffer pointers + impl::get_document(_root).header |= impl::xml_memory_page_contents_shared_mask; + + impl::remove_node(moved._root); + impl::insert_node_after(moved._root, node._root); + + return moved; + } + + PUGI__FN xml_node xml_node::insert_move_before(const xml_node& moved, const xml_node& node) + { + if (!impl::allow_move(*this, moved)) return xml_node(); + if (!node._root || node._root->parent != _root) return xml_node(); + if (moved._root == node._root) return xml_node(); + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return xml_node(); + + // disable document_buffer_order optimization since moving nodes around changes document order without changing buffer pointers + impl::get_document(_root).header |= impl::xml_memory_page_contents_shared_mask; + + impl::remove_node(moved._root); + impl::insert_node_before(moved._root, node._root); + + return moved; + } + + PUGI__FN bool xml_node::remove_attribute(const char_t* name_) + { + return remove_attribute(attribute(name_)); + } + + PUGI__FN bool xml_node::remove_attribute(const xml_attribute& a) + { + if (!_root || !a._attr) return false; + if (!impl::is_attribute_of(a._attr, _root)) return false; + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return false; + + impl::remove_attribute(a._attr, _root); + impl::destroy_attribute(a._attr, alloc); + + return true; + } + + PUGI__FN bool xml_node::remove_child(const char_t* name_) + { + return remove_child(child(name_)); + } + + PUGI__FN bool xml_node::remove_child(const xml_node& n) + { + if (!_root || !n._root || n._root->parent != _root) return false; + + impl::xml_allocator& alloc = impl::get_allocator(_root); + if (!alloc.reserve()) return false; + + impl::remove_node(n._root); + impl::destroy_node(n._root, alloc); + + return true; + } + + PUGI__FN xml_parse_result xml_node::append_buffer(const void* contents, size_t size, unsigned int options, xml_encoding encoding) + { + // append_buffer is only valid for elements/documents + if (!impl::allow_insert_child(type(), node_element)) return impl::make_parse_result(status_append_invalid_root); + + // get document node + impl::xml_document_struct* doc = &impl::get_document(_root); + + // disable document_buffer_order optimization since in a document with multiple buffers comparing buffer pointers does not make sense + doc->header |= impl::xml_memory_page_contents_shared_mask; + + // get extra buffer element (we'll store the document fragment buffer there so that we can deallocate it later) + impl::xml_memory_page* page = 0; + impl::xml_extra_buffer* extra = static_cast(doc->allocate_memory(sizeof(impl::xml_extra_buffer), page)); + (void)page; + + if (!extra) return impl::make_parse_result(status_out_of_memory); + + // add extra buffer to the list + extra->buffer = 0; + extra->next = doc->extra_buffers; + doc->extra_buffers = extra; + + // name of the root has to be NULL before parsing - otherwise closing node mismatches will not be detected at the top level + impl::name_null_sentry sentry(_root); + + return impl::load_buffer_impl(doc, _root, const_cast(contents), size, options, encoding, false, false, &extra->buffer); + } + + PUGI__FN xml_node xml_node::find_child_by_attribute(const char_t* name_, const char_t* attr_name, const char_t* attr_value) const + { + if (!_root) return xml_node(); + + for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling) + if (i->name && impl::strequal(name_, i->name)) + { + for (xml_attribute_struct* a = i->first_attribute; a; a = a->next_attribute) + if (a->name && impl::strequal(attr_name, a->name) && impl::strequal(attr_value, a->value ? a->value + 0 : PUGIXML_TEXT(""))) + return xml_node(i); + } + + return xml_node(); + } + + PUGI__FN xml_node xml_node::find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const + { + if (!_root) return xml_node(); + + for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling) + for (xml_attribute_struct* a = i->first_attribute; a; a = a->next_attribute) + if (a->name && impl::strequal(attr_name, a->name) && impl::strequal(attr_value, a->value ? a->value + 0 : PUGIXML_TEXT(""))) + return xml_node(i); + + return xml_node(); + } + +#ifndef PUGIXML_NO_STL + PUGI__FN string_t xml_node::path(char_t delimiter) const + { + if (!_root) return string_t(); + + size_t offset = 0; + + for (xml_node_struct* i = _root; i; i = i->parent) + { + offset += (i != _root); + offset += i->name ? impl::strlength(i->name) : 0; + } + + string_t result; + result.resize(offset); + + for (xml_node_struct* j = _root; j; j = j->parent) + { + if (j != _root) + result[--offset] = delimiter; + + if (j->name && *j->name) + { + size_t length = impl::strlength(j->name); + + offset -= length; + memcpy(&result[offset], j->name, length * sizeof(char_t)); + } + } + + assert(offset == 0); + + return result; + } +#endif + + PUGI__FN xml_node xml_node::first_element_by_path(const char_t* path_, char_t delimiter) const + { + xml_node found = *this; // Current search context. + + if (!_root || !path_ || !path_[0]) return found; + + if (path_[0] == delimiter) + { + // Absolute path; e.g. '/foo/bar' + found = found.root(); + ++path_; + } + + const char_t* path_segment = path_; + + while (*path_segment == delimiter) ++path_segment; + + const char_t* path_segment_end = path_segment; + + while (*path_segment_end && *path_segment_end != delimiter) ++path_segment_end; + + if (path_segment == path_segment_end) return found; + + const char_t* next_segment = path_segment_end; + + while (*next_segment == delimiter) ++next_segment; + + if (*path_segment == '.' && path_segment + 1 == path_segment_end) + return found.first_element_by_path(next_segment, delimiter); + else if (*path_segment == '.' && *(path_segment+1) == '.' && path_segment + 2 == path_segment_end) + return found.parent().first_element_by_path(next_segment, delimiter); + else + { + for (xml_node_struct* j = found._root->first_child; j; j = j->next_sibling) + { + if (j->name && impl::strequalrange(j->name, path_segment, static_cast(path_segment_end - path_segment))) + { + xml_node subsearch = xml_node(j).first_element_by_path(next_segment, delimiter); + + if (subsearch) return subsearch; + } + } + + return xml_node(); + } + } + + PUGI__FN bool xml_node::traverse(xml_tree_walker& walker) + { + walker._depth = -1; + + xml_node arg_begin = *this; + if (!walker.begin(arg_begin)) return false; + + xml_node cur = first_child(); + + if (cur) + { + ++walker._depth; + + do + { + xml_node arg_for_each = cur; + if (!walker.for_each(arg_for_each)) + return false; + + if (cur.first_child()) + { + ++walker._depth; + cur = cur.first_child(); + } + else if (cur.next_sibling()) + cur = cur.next_sibling(); + else + { + // Borland C++ workaround + while (!cur.next_sibling() && cur != *this && !cur.parent().empty()) + { + --walker._depth; + cur = cur.parent(); + } + + if (cur != *this) + cur = cur.next_sibling(); + } + } + while (cur && cur != *this); + } + + assert(walker._depth == -1); + + xml_node arg_end = *this; + return walker.end(arg_end); + } + + PUGI__FN size_t xml_node::hash_value() const + { + return static_cast(reinterpret_cast(_root) / sizeof(xml_node_struct)); + } + + PUGI__FN xml_node_struct* xml_node::internal_object() const + { + return _root; + } + + PUGI__FN void xml_node::print(xml_writer& writer, const char_t* indent, unsigned int flags, xml_encoding encoding, unsigned int depth) const + { + if (!_root) return; + + impl::xml_buffered_writer buffered_writer(writer, encoding); + + impl::node_output(buffered_writer, _root, indent, flags, depth); + + buffered_writer.flush(); + } + +#ifndef PUGIXML_NO_STL + PUGI__FN void xml_node::print(std::basic_ostream >& stream, const char_t* indent, unsigned int flags, xml_encoding encoding, unsigned int depth) const + { + xml_writer_stream writer(stream); + + print(writer, indent, flags, encoding, depth); + } + + PUGI__FN void xml_node::print(std::basic_ostream >& stream, const char_t* indent, unsigned int flags, unsigned int depth) const + { + xml_writer_stream writer(stream); + + print(writer, indent, flags, encoding_wchar, depth); + } +#endif + + PUGI__FN ptrdiff_t xml_node::offset_debug() const + { + if (!_root) return -1; + + impl::xml_document_struct& doc = impl::get_document(_root); + + // we can determine the offset reliably only if there is exactly once parse buffer + if (!doc.buffer || doc.extra_buffers) return -1; + + switch (type()) + { + case node_document: + return 0; + + case node_element: + case node_declaration: + case node_pi: + return _root->name && (_root->header & impl::xml_memory_page_name_allocated_or_shared_mask) == 0 ? _root->name - doc.buffer : -1; + + case node_pcdata: + case node_cdata: + case node_comment: + case node_doctype: + return _root->value && (_root->header & impl::xml_memory_page_value_allocated_or_shared_mask) == 0 ? _root->value - doc.buffer : -1; + + default: + return -1; + } + } + +#ifdef __BORLANDC__ + PUGI__FN bool operator&&(const xml_node& lhs, bool rhs) + { + return (bool)lhs && rhs; + } + + PUGI__FN bool operator||(const xml_node& lhs, bool rhs) + { + return (bool)lhs || rhs; + } +#endif + + PUGI__FN xml_text::xml_text(xml_node_struct* root): _root(root) + { + } + + PUGI__FN xml_node_struct* xml_text::_data() const + { + if (!_root || impl::is_text_node(_root)) return _root; + + for (xml_node_struct* node = _root->first_child; node; node = node->next_sibling) + if (impl::is_text_node(node)) + return node; + + return 0; + } + + PUGI__FN xml_node_struct* xml_text::_data_new() + { + xml_node_struct* d = _data(); + if (d) return d; + + return xml_node(_root).append_child(node_pcdata).internal_object(); + } + + PUGI__FN xml_text::xml_text(): _root(0) + { + } + + PUGI__FN static void unspecified_bool_xml_text(xml_text***) + { + } + + PUGI__FN xml_text::operator xml_text::unspecified_bool_type() const + { + return _data() ? unspecified_bool_xml_text : 0; + } + + PUGI__FN bool xml_text::operator!() const + { + return !_data(); + } + + PUGI__FN bool xml_text::empty() const + { + return _data() == 0; + } + + PUGI__FN const char_t* xml_text::get() const + { + xml_node_struct* d = _data(); + + return (d && d->value) ? d->value + 0 : PUGIXML_TEXT(""); + } + + PUGI__FN const char_t* xml_text::as_string(const char_t* def) const + { + xml_node_struct* d = _data(); + + return (d && d->value) ? d->value + 0 : def; + } + + PUGI__FN int xml_text::as_int(int def) const + { + xml_node_struct* d = _data(); + + return (d && d->value) ? impl::get_value_int(d->value) : def; + } + + PUGI__FN unsigned int xml_text::as_uint(unsigned int def) const + { + xml_node_struct* d = _data(); + + return (d && d->value) ? impl::get_value_uint(d->value) : def; + } + + PUGI__FN double xml_text::as_double(double def) const + { + xml_node_struct* d = _data(); + + return (d && d->value) ? impl::get_value_double(d->value) : def; + } + + PUGI__FN float xml_text::as_float(float def) const + { + xml_node_struct* d = _data(); + + return (d && d->value) ? impl::get_value_float(d->value) : def; + } + + PUGI__FN bool xml_text::as_bool(bool def) const + { + xml_node_struct* d = _data(); + + return (d && d->value) ? impl::get_value_bool(d->value) : def; + } + +#ifdef PUGIXML_HAS_LONG_LONG + PUGI__FN long long xml_text::as_llong(long long def) const + { + xml_node_struct* d = _data(); + + return (d && d->value) ? impl::get_value_llong(d->value) : def; + } + + PUGI__FN unsigned long long xml_text::as_ullong(unsigned long long def) const + { + xml_node_struct* d = _data(); + + return (d && d->value) ? impl::get_value_ullong(d->value) : def; + } +#endif + + PUGI__FN bool xml_text::set(const char_t* rhs) + { + xml_node_struct* dn = _data_new(); + + return dn ? impl::strcpy_insitu(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs, impl::strlength(rhs)) : false; + } + + PUGI__FN bool xml_text::set(int rhs) + { + xml_node_struct* dn = _data_new(); + + return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs) : false; + } + + PUGI__FN bool xml_text::set(unsigned int rhs) + { + xml_node_struct* dn = _data_new(); + + return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs) : false; + } + + PUGI__FN bool xml_text::set(float rhs) + { + xml_node_struct* dn = _data_new(); + + return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs) : false; + } + + PUGI__FN bool xml_text::set(double rhs) + { + xml_node_struct* dn = _data_new(); + + return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs) : false; + } + + PUGI__FN bool xml_text::set(bool rhs) + { + xml_node_struct* dn = _data_new(); + + return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs) : false; + } + +#ifdef PUGIXML_HAS_LONG_LONG + PUGI__FN bool xml_text::set(long long rhs) + { + xml_node_struct* dn = _data_new(); + + return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs) : false; + } + + PUGI__FN bool xml_text::set(unsigned long long rhs) + { + xml_node_struct* dn = _data_new(); + + return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs) : false; + } +#endif + + PUGI__FN xml_text& xml_text::operator=(const char_t* rhs) + { + set(rhs); + return *this; + } + + PUGI__FN xml_text& xml_text::operator=(int rhs) + { + set(rhs); + return *this; + } + + PUGI__FN xml_text& xml_text::operator=(unsigned int rhs) + { + set(rhs); + return *this; + } + + PUGI__FN xml_text& xml_text::operator=(double rhs) + { + set(rhs); + return *this; + } + + PUGI__FN xml_text& xml_text::operator=(float rhs) + { + set(rhs); + return *this; + } + + PUGI__FN xml_text& xml_text::operator=(bool rhs) + { + set(rhs); + return *this; + } + +#ifdef PUGIXML_HAS_LONG_LONG + PUGI__FN xml_text& xml_text::operator=(long long rhs) + { + set(rhs); + return *this; + } + + PUGI__FN xml_text& xml_text::operator=(unsigned long long rhs) + { + set(rhs); + return *this; + } +#endif + + PUGI__FN xml_node xml_text::data() const + { + return xml_node(_data()); + } + +#ifdef __BORLANDC__ + PUGI__FN bool operator&&(const xml_text& lhs, bool rhs) + { + return (bool)lhs && rhs; + } + + PUGI__FN bool operator||(const xml_text& lhs, bool rhs) + { + return (bool)lhs || rhs; + } +#endif + + PUGI__FN xml_node_iterator::xml_node_iterator() + { + } + + PUGI__FN xml_node_iterator::xml_node_iterator(const xml_node& node): _wrap(node), _parent(node.parent()) + { + } + + PUGI__FN xml_node_iterator::xml_node_iterator(xml_node_struct* ref, xml_node_struct* parent): _wrap(ref), _parent(parent) + { + } + + PUGI__FN bool xml_node_iterator::operator==(const xml_node_iterator& rhs) const + { + return _wrap._root == rhs._wrap._root && _parent._root == rhs._parent._root; + } + + PUGI__FN bool xml_node_iterator::operator!=(const xml_node_iterator& rhs) const + { + return _wrap._root != rhs._wrap._root || _parent._root != rhs._parent._root; + } + + PUGI__FN xml_node& xml_node_iterator::operator*() const + { + assert(_wrap._root); + return _wrap; + } + + PUGI__FN xml_node* xml_node_iterator::operator->() const + { + assert(_wrap._root); + return const_cast(&_wrap); // BCC32 workaround + } + + PUGI__FN const xml_node_iterator& xml_node_iterator::operator++() + { + assert(_wrap._root); + _wrap._root = _wrap._root->next_sibling; + return *this; + } + + PUGI__FN xml_node_iterator xml_node_iterator::operator++(int) + { + xml_node_iterator temp = *this; + ++*this; + return temp; + } + + PUGI__FN const xml_node_iterator& xml_node_iterator::operator--() + { + _wrap = _wrap._root ? _wrap.previous_sibling() : _parent.last_child(); + return *this; + } + + PUGI__FN xml_node_iterator xml_node_iterator::operator--(int) + { + xml_node_iterator temp = *this; + --*this; + return temp; + } + + PUGI__FN xml_attribute_iterator::xml_attribute_iterator() + { + } + + PUGI__FN xml_attribute_iterator::xml_attribute_iterator(const xml_attribute& attr, const xml_node& parent): _wrap(attr), _parent(parent) + { + } + + PUGI__FN xml_attribute_iterator::xml_attribute_iterator(xml_attribute_struct* ref, xml_node_struct* parent): _wrap(ref), _parent(parent) + { + } + + PUGI__FN bool xml_attribute_iterator::operator==(const xml_attribute_iterator& rhs) const + { + return _wrap._attr == rhs._wrap._attr && _parent._root == rhs._parent._root; + } + + PUGI__FN bool xml_attribute_iterator::operator!=(const xml_attribute_iterator& rhs) const + { + return _wrap._attr != rhs._wrap._attr || _parent._root != rhs._parent._root; + } + + PUGI__FN xml_attribute& xml_attribute_iterator::operator*() const + { + assert(_wrap._attr); + return _wrap; + } + + PUGI__FN xml_attribute* xml_attribute_iterator::operator->() const + { + assert(_wrap._attr); + return const_cast(&_wrap); // BCC32 workaround + } + + PUGI__FN const xml_attribute_iterator& xml_attribute_iterator::operator++() + { + assert(_wrap._attr); + _wrap._attr = _wrap._attr->next_attribute; + return *this; + } + + PUGI__FN xml_attribute_iterator xml_attribute_iterator::operator++(int) + { + xml_attribute_iterator temp = *this; + ++*this; + return temp; + } + + PUGI__FN const xml_attribute_iterator& xml_attribute_iterator::operator--() + { + _wrap = _wrap._attr ? _wrap.previous_attribute() : _parent.last_attribute(); + return *this; + } + + PUGI__FN xml_attribute_iterator xml_attribute_iterator::operator--(int) + { + xml_attribute_iterator temp = *this; + --*this; + return temp; + } + + PUGI__FN xml_named_node_iterator::xml_named_node_iterator(): _name(0) + { + } + + PUGI__FN xml_named_node_iterator::xml_named_node_iterator(const xml_node& node, const char_t* name): _wrap(node), _parent(node.parent()), _name(name) + { + } + + PUGI__FN xml_named_node_iterator::xml_named_node_iterator(xml_node_struct* ref, xml_node_struct* parent, const char_t* name): _wrap(ref), _parent(parent), _name(name) + { + } + + PUGI__FN bool xml_named_node_iterator::operator==(const xml_named_node_iterator& rhs) const + { + return _wrap._root == rhs._wrap._root && _parent._root == rhs._parent._root; + } + + PUGI__FN bool xml_named_node_iterator::operator!=(const xml_named_node_iterator& rhs) const + { + return _wrap._root != rhs._wrap._root || _parent._root != rhs._parent._root; + } + + PUGI__FN xml_node& xml_named_node_iterator::operator*() const + { + assert(_wrap._root); + return _wrap; + } + + PUGI__FN xml_node* xml_named_node_iterator::operator->() const + { + assert(_wrap._root); + return const_cast(&_wrap); // BCC32 workaround + } + + PUGI__FN const xml_named_node_iterator& xml_named_node_iterator::operator++() + { + assert(_wrap._root); + _wrap = _wrap.next_sibling(_name); + return *this; + } + + PUGI__FN xml_named_node_iterator xml_named_node_iterator::operator++(int) + { + xml_named_node_iterator temp = *this; + ++*this; + return temp; + } + + PUGI__FN const xml_named_node_iterator& xml_named_node_iterator::operator--() + { + if (_wrap._root) + _wrap = _wrap.previous_sibling(_name); + else + { + _wrap = _parent.last_child(); + + if (!impl::strequal(_wrap.name(), _name)) + _wrap = _wrap.previous_sibling(_name); + } + + return *this; + } + + PUGI__FN xml_named_node_iterator xml_named_node_iterator::operator--(int) + { + xml_named_node_iterator temp = *this; + --*this; + return temp; + } + + PUGI__FN xml_parse_result::xml_parse_result(): status(status_internal_error), offset(0), encoding(encoding_auto) + { + } + + PUGI__FN xml_parse_result::operator bool() const + { + return status == status_ok; + } + + PUGI__FN const char* xml_parse_result::description() const + { + switch (status) + { + case status_ok: return "No error"; + + case status_file_not_found: return "File was not found"; + case status_io_error: return "Error reading from file/stream"; + case status_out_of_memory: return "Could not allocate memory"; + case status_internal_error: return "Internal error occurred"; + + case status_unrecognized_tag: return "Could not determine tag type"; + + case status_bad_pi: return "Error parsing document declaration/processing instruction"; + case status_bad_comment: return "Error parsing comment"; + case status_bad_cdata: return "Error parsing CDATA section"; + case status_bad_doctype: return "Error parsing document type declaration"; + case status_bad_pcdata: return "Error parsing PCDATA section"; + case status_bad_start_element: return "Error parsing start element tag"; + case status_bad_attribute: return "Error parsing element attribute"; + case status_bad_end_element: return "Error parsing end element tag"; + case status_end_element_mismatch: return "Start-end tags mismatch"; + + case status_append_invalid_root: return "Unable to append nodes: root is not an element or document"; + + case status_no_document_element: return "No document element found"; + + default: return "Unknown error"; + } + } + + PUGI__FN xml_document::xml_document(): _buffer(0) + { + create(); + } + + PUGI__FN xml_document::~xml_document() + { + destroy(); + } + + PUGI__FN void xml_document::reset() + { + destroy(); + create(); + } + + PUGI__FN void xml_document::reset(const xml_document& proto) + { + reset(); + + for (xml_node cur = proto.first_child(); cur; cur = cur.next_sibling()) + append_copy(cur); + } + + PUGI__FN void xml_document::create() + { + assert(!_root); + + #ifdef PUGIXML_COMPACT + const size_t page_offset = sizeof(uint32_t); + #else + const size_t page_offset = 0; + #endif + + // initialize sentinel page + PUGI__STATIC_ASSERT(sizeof(impl::xml_memory_page) + sizeof(impl::xml_document_struct) + impl::xml_memory_page_alignment - sizeof(void*) + page_offset <= sizeof(_memory)); + + // align upwards to page boundary + void* page_memory = reinterpret_cast((reinterpret_cast(_memory) + (impl::xml_memory_page_alignment - 1)) & ~(impl::xml_memory_page_alignment - 1)); + + // prepare page structure + impl::xml_memory_page* page = impl::xml_memory_page::construct(page_memory); + assert(page); + + page->busy_size = impl::xml_memory_page_size; + + // setup first page marker + #ifdef PUGIXML_COMPACT + // round-trip through void* to avoid 'cast increases required alignment of target type' warning + page->compact_page_marker = reinterpret_cast(static_cast(reinterpret_cast(page) + sizeof(impl::xml_memory_page))); + *page->compact_page_marker = sizeof(impl::xml_memory_page); + #endif + + // allocate new root + _root = new (reinterpret_cast(page) + sizeof(impl::xml_memory_page) + page_offset) impl::xml_document_struct(page); + _root->prev_sibling_c = _root; + + // setup sentinel page + page->allocator = static_cast(_root); + + // verify the document allocation + assert(reinterpret_cast(_root) + sizeof(impl::xml_document_struct) <= _memory + sizeof(_memory)); + } + + PUGI__FN void xml_document::destroy() + { + assert(_root); + + // destroy static storage + if (_buffer) + { + impl::xml_memory::deallocate(_buffer); + _buffer = 0; + } + + // destroy extra buffers (note: no need to destroy linked list nodes, they're allocated using document allocator) + for (impl::xml_extra_buffer* extra = static_cast(_root)->extra_buffers; extra; extra = extra->next) + { + if (extra->buffer) impl::xml_memory::deallocate(extra->buffer); + } + + // destroy dynamic storage, leave sentinel page (it's in static memory) + impl::xml_memory_page* root_page = PUGI__GETPAGE(_root); + assert(root_page && !root_page->prev); + assert(reinterpret_cast(root_page) >= _memory && reinterpret_cast(root_page) < _memory + sizeof(_memory)); + + for (impl::xml_memory_page* page = root_page->next; page; ) + { + impl::xml_memory_page* next = page->next; + + impl::xml_allocator::deallocate_page(page); + + page = next; + } + + #ifdef PUGIXML_COMPACT + // destroy hash table + static_cast(_root)->hash.clear(); + #endif + + _root = 0; + } + +#ifndef PUGIXML_NO_STL + PUGI__FN xml_parse_result xml_document::load(std::basic_istream >& stream, unsigned int options, xml_encoding encoding) + { + reset(); + + return impl::load_stream_impl(static_cast(_root), stream, options, encoding, &_buffer); + } + + PUGI__FN xml_parse_result xml_document::load(std::basic_istream >& stream, unsigned int options) + { + reset(); + + return impl::load_stream_impl(static_cast(_root), stream, options, encoding_wchar, &_buffer); + } +#endif + + PUGI__FN xml_parse_result xml_document::load_string(const char_t* contents, unsigned int options) + { + // Force native encoding (skip autodetection) + #ifdef PUGIXML_WCHAR_MODE + xml_encoding encoding = encoding_wchar; + #else + xml_encoding encoding = encoding_utf8; + #endif + + return load_buffer(contents, impl::strlength(contents) * sizeof(char_t), options, encoding); + } + + PUGI__FN xml_parse_result xml_document::load(const char_t* contents, unsigned int options) + { + return load_string(contents, options); + } + + PUGI__FN xml_parse_result xml_document::load_file(const char* path_, unsigned int options, xml_encoding encoding) + { + reset(); + + using impl::auto_deleter; // MSVC7 workaround + auto_deleter file(fopen(path_, "rb"), fclose); + + return impl::load_file_impl(static_cast(_root), file.data, options, encoding, &_buffer); + } + + PUGI__FN xml_parse_result xml_document::load_file(const wchar_t* path_, unsigned int options, xml_encoding encoding) + { + reset(); + + using impl::auto_deleter; // MSVC7 workaround + auto_deleter file(impl::open_file_wide(path_, L"rb"), fclose); + + return impl::load_file_impl(static_cast(_root), file.data, options, encoding, &_buffer); + } + + PUGI__FN xml_parse_result xml_document::load_buffer(const void* contents, size_t size, unsigned int options, xml_encoding encoding) + { + reset(); + + return impl::load_buffer_impl(static_cast(_root), _root, const_cast(contents), size, options, encoding, false, false, &_buffer); + } + + PUGI__FN xml_parse_result xml_document::load_buffer_inplace(void* contents, size_t size, unsigned int options, xml_encoding encoding) + { + reset(); + + return impl::load_buffer_impl(static_cast(_root), _root, contents, size, options, encoding, true, false, &_buffer); + } + + PUGI__FN xml_parse_result xml_document::load_buffer_inplace_own(void* contents, size_t size, unsigned int options, xml_encoding encoding) + { + reset(); + + return impl::load_buffer_impl(static_cast(_root), _root, contents, size, options, encoding, true, true, &_buffer); + } + + PUGI__FN void xml_document::save(xml_writer& writer, const char_t* indent, unsigned int flags, xml_encoding encoding) const + { + impl::xml_buffered_writer buffered_writer(writer, encoding); + + if ((flags & format_write_bom) && encoding != encoding_latin1) + { + // BOM always represents the codepoint U+FEFF, so just write it in native encoding + #ifdef PUGIXML_WCHAR_MODE + unsigned int bom = 0xfeff; + buffered_writer.write(static_cast(bom)); + #else + buffered_writer.write('\xef', '\xbb', '\xbf'); + #endif + } + + if (!(flags & format_no_declaration) && !impl::has_declaration(_root)) + { + buffered_writer.write_string(PUGIXML_TEXT("'); + if (!(flags & format_raw)) buffered_writer.write('\n'); + } + + impl::node_output(buffered_writer, _root, indent, flags, 0); + + buffered_writer.flush(); + } + +#ifndef PUGIXML_NO_STL + PUGI__FN void xml_document::save(std::basic_ostream >& stream, const char_t* indent, unsigned int flags, xml_encoding encoding) const + { + xml_writer_stream writer(stream); + + save(writer, indent, flags, encoding); + } + + PUGI__FN void xml_document::save(std::basic_ostream >& stream, const char_t* indent, unsigned int flags) const + { + xml_writer_stream writer(stream); + + save(writer, indent, flags, encoding_wchar); + } +#endif + + PUGI__FN bool xml_document::save_file(const char* path_, const char_t* indent, unsigned int flags, xml_encoding encoding) const + { + using impl::auto_deleter; // MSVC7 workaround + auto_deleter file(fopen(path_, (flags & format_save_file_text) ? "w" : "wb"), fclose); + + return impl::save_file_impl(*this, file.data, indent, flags, encoding); + } + + PUGI__FN bool xml_document::save_file(const wchar_t* path_, const char_t* indent, unsigned int flags, xml_encoding encoding) const + { + using impl::auto_deleter; // MSVC7 workaround + auto_deleter file(impl::open_file_wide(path_, (flags & format_save_file_text) ? L"w" : L"wb"), fclose); + + return impl::save_file_impl(*this, file.data, indent, flags, encoding); + } + + PUGI__FN xml_node xml_document::document_element() const + { + assert(_root); + + for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling) + if (PUGI__NODETYPE(i) == node_element) + return xml_node(i); + + return xml_node(); + } + +#ifndef PUGIXML_NO_STL + PUGI__FN std::string PUGIXML_FUNCTION as_utf8(const wchar_t* str) + { + assert(str); + + return impl::as_utf8_impl(str, impl::strlength_wide(str)); + } + + PUGI__FN std::string PUGIXML_FUNCTION as_utf8(const std::basic_string& str) + { + return impl::as_utf8_impl(str.c_str(), str.size()); + } + + PUGI__FN std::basic_string PUGIXML_FUNCTION as_wide(const char* str) + { + assert(str); + + return impl::as_wide_impl(str, strlen(str)); + } + + PUGI__FN std::basic_string PUGIXML_FUNCTION as_wide(const std::string& str) + { + return impl::as_wide_impl(str.c_str(), str.size()); + } +#endif + + PUGI__FN void PUGIXML_FUNCTION set_memory_management_functions(allocation_function allocate, deallocation_function deallocate) + { + impl::xml_memory::allocate = allocate; + impl::xml_memory::deallocate = deallocate; + } + + PUGI__FN allocation_function PUGIXML_FUNCTION get_memory_allocation_function() + { + return impl::xml_memory::allocate; + } + + PUGI__FN deallocation_function PUGIXML_FUNCTION get_memory_deallocation_function() + { + return impl::xml_memory::deallocate; + } +} + +#if !defined(PUGIXML_NO_STL) && (defined(_MSC_VER) || defined(__ICC)) +namespace std +{ + // Workarounds for (non-standard) iterator category detection for older versions (MSVC7/IC8 and earlier) + PUGI__FN std::bidirectional_iterator_tag _Iter_cat(const pugi::xml_node_iterator&) + { + return std::bidirectional_iterator_tag(); + } + + PUGI__FN std::bidirectional_iterator_tag _Iter_cat(const pugi::xml_attribute_iterator&) + { + return std::bidirectional_iterator_tag(); + } + + PUGI__FN std::bidirectional_iterator_tag _Iter_cat(const pugi::xml_named_node_iterator&) + { + return std::bidirectional_iterator_tag(); + } +} +#endif + +#if !defined(PUGIXML_NO_STL) && defined(__SUNPRO_CC) +namespace std +{ + // Workarounds for (non-standard) iterator category detection + PUGI__FN std::bidirectional_iterator_tag __iterator_category(const pugi::xml_node_iterator&) + { + return std::bidirectional_iterator_tag(); + } + + PUGI__FN std::bidirectional_iterator_tag __iterator_category(const pugi::xml_attribute_iterator&) + { + return std::bidirectional_iterator_tag(); + } + + PUGI__FN std::bidirectional_iterator_tag __iterator_category(const pugi::xml_named_node_iterator&) + { + return std::bidirectional_iterator_tag(); + } +} +#endif + +#ifndef PUGIXML_NO_XPATH +// STL replacements +PUGI__NS_BEGIN + struct equal_to + { + template bool operator()(const T& lhs, const T& rhs) const + { + return lhs == rhs; + } + }; + + struct not_equal_to + { + template bool operator()(const T& lhs, const T& rhs) const + { + return lhs != rhs; + } + }; + + struct less + { + template bool operator()(const T& lhs, const T& rhs) const + { + return lhs < rhs; + } + }; + + struct less_equal + { + template bool operator()(const T& lhs, const T& rhs) const + { + return lhs <= rhs; + } + }; + + template void swap(T& lhs, T& rhs) + { + T temp = lhs; + lhs = rhs; + rhs = temp; + } + + template I min_element(I begin, I end, const Pred& pred) + { + I result = begin; + + for (I it = begin + 1; it != end; ++it) + if (pred(*it, *result)) + result = it; + + return result; + } + + template void reverse(I begin, I end) + { + while (end - begin > 1) swap(*begin++, *--end); + } + + template I unique(I begin, I end) + { + // fast skip head + while (end - begin > 1 && *begin != *(begin + 1)) begin++; + + if (begin == end) return begin; + + // last written element + I write = begin++; + + // merge unique elements + while (begin != end) + { + if (*begin != *write) + *++write = *begin++; + else + begin++; + } + + // past-the-end (write points to live element) + return write + 1; + } + + template void copy_backwards(I begin, I end, I target) + { + while (begin != end) *--target = *--end; + } + + template void insertion_sort(I begin, I end, const Pred& pred, T*) + { + assert(begin != end); + + for (I it = begin + 1; it != end; ++it) + { + T val = *it; + + if (pred(val, *begin)) + { + // move to front + copy_backwards(begin, it, it + 1); + *begin = val; + } + else + { + I hole = it; + + // move hole backwards + while (pred(val, *(hole - 1))) + { + *hole = *(hole - 1); + hole--; + } + + // fill hole with element + *hole = val; + } + } + } + + // std variant for elements with == + template void partition(I begin, I middle, I end, const Pred& pred, I* out_eqbeg, I* out_eqend) + { + I eqbeg = middle, eqend = middle + 1; + + // expand equal range + while (eqbeg != begin && *(eqbeg - 1) == *eqbeg) --eqbeg; + while (eqend != end && *eqend == *eqbeg) ++eqend; + + // process outer elements + I ltend = eqbeg, gtbeg = eqend; + + for (;;) + { + // find the element from the right side that belongs to the left one + for (; gtbeg != end; ++gtbeg) + if (!pred(*eqbeg, *gtbeg)) + { + if (*gtbeg == *eqbeg) swap(*gtbeg, *eqend++); + else break; + } + + // find the element from the left side that belongs to the right one + for (; ltend != begin; --ltend) + if (!pred(*(ltend - 1), *eqbeg)) + { + if (*eqbeg == *(ltend - 1)) swap(*(ltend - 1), *--eqbeg); + else break; + } + + // scanned all elements + if (gtbeg == end && ltend == begin) + { + *out_eqbeg = eqbeg; + *out_eqend = eqend; + return; + } + + // make room for elements by moving equal area + if (gtbeg == end) + { + if (--ltend != --eqbeg) swap(*ltend, *eqbeg); + swap(*eqbeg, *--eqend); + } + else if (ltend == begin) + { + if (eqend != gtbeg) swap(*eqbeg, *eqend); + ++eqend; + swap(*gtbeg++, *eqbeg++); + } + else swap(*gtbeg++, *--ltend); + } + } + + template void median3(I first, I middle, I last, const Pred& pred) + { + if (pred(*middle, *first)) swap(*middle, *first); + if (pred(*last, *middle)) swap(*last, *middle); + if (pred(*middle, *first)) swap(*middle, *first); + } + + template void median(I first, I middle, I last, const Pred& pred) + { + if (last - first <= 40) + { + // median of three for small chunks + median3(first, middle, last, pred); + } + else + { + // median of nine + size_t step = (last - first + 1) / 8; + + median3(first, first + step, first + 2 * step, pred); + median3(middle - step, middle, middle + step, pred); + median3(last - 2 * step, last - step, last, pred); + median3(first + step, middle, last - step, pred); + } + } + + template void sort(I begin, I end, const Pred& pred) + { + // sort large chunks + while (end - begin > 32) + { + // find median element + I middle = begin + (end - begin) / 2; + median(begin, middle, end - 1, pred); + + // partition in three chunks (< = >) + I eqbeg, eqend; + partition(begin, middle, end, pred, &eqbeg, &eqend); + + // loop on larger half + if (eqbeg - begin > end - eqend) + { + sort(eqend, end, pred); + end = eqbeg; + } + else + { + sort(begin, eqbeg, pred); + begin = eqend; + } + } + + // insertion sort small chunk + if (begin != end) insertion_sort(begin, end, pred, &*begin); + } +PUGI__NS_END + +// Allocator used for AST and evaluation stacks +PUGI__NS_BEGIN + static const size_t xpath_memory_page_size = + #ifdef PUGIXML_MEMORY_XPATH_PAGE_SIZE + PUGIXML_MEMORY_XPATH_PAGE_SIZE + #else + 4096 + #endif + ; + + static const uintptr_t xpath_memory_block_alignment = sizeof(double) > sizeof(void*) ? sizeof(double) : sizeof(void*); + + struct xpath_memory_block + { + xpath_memory_block* next; + size_t capacity; + + union + { + char data[xpath_memory_page_size]; + double alignment; + }; + }; + + class xpath_allocator + { + xpath_memory_block* _root; + size_t _root_size; + + public: + #ifdef PUGIXML_NO_EXCEPTIONS + jmp_buf* error_handler; + #endif + + xpath_allocator(xpath_memory_block* root, size_t root_size = 0): _root(root), _root_size(root_size) + { + #ifdef PUGIXML_NO_EXCEPTIONS + error_handler = 0; + #endif + } + + void* allocate_nothrow(size_t size) + { + // round size up to block alignment boundary + size = (size + xpath_memory_block_alignment - 1) & ~(xpath_memory_block_alignment - 1); + + if (_root_size + size <= _root->capacity) + { + void* buf = &_root->data[0] + _root_size; + _root_size += size; + return buf; + } + else + { + // make sure we have at least 1/4th of the page free after allocation to satisfy subsequent allocation requests + size_t block_capacity_base = sizeof(_root->data); + size_t block_capacity_req = size + block_capacity_base / 4; + size_t block_capacity = (block_capacity_base > block_capacity_req) ? block_capacity_base : block_capacity_req; + + size_t block_size = block_capacity + offsetof(xpath_memory_block, data); + + xpath_memory_block* block = static_cast(xml_memory::allocate(block_size)); + if (!block) return 0; + + block->next = _root; + block->capacity = block_capacity; + + _root = block; + _root_size = size; + + return block->data; + } + } + + void* allocate(size_t size) + { + void* result = allocate_nothrow(size); + + if (!result) + { + #ifdef PUGIXML_NO_EXCEPTIONS + assert(error_handler); + longjmp(*error_handler, 1); + #else + throw std::bad_alloc(); + #endif + } + + return result; + } + + void* reallocate(void* ptr, size_t old_size, size_t new_size) + { + // round size up to block alignment boundary + old_size = (old_size + xpath_memory_block_alignment - 1) & ~(xpath_memory_block_alignment - 1); + new_size = (new_size + xpath_memory_block_alignment - 1) & ~(xpath_memory_block_alignment - 1); + + // we can only reallocate the last object + assert(ptr == 0 || static_cast(ptr) + old_size == &_root->data[0] + _root_size); + + // adjust root size so that we have not allocated the object at all + bool only_object = (_root_size == old_size); + + if (ptr) _root_size -= old_size; + + // allocate a new version (this will obviously reuse the memory if possible) + void* result = allocate(new_size); + assert(result); + + // we have a new block + if (result != ptr && ptr) + { + // copy old data + assert(new_size >= old_size); + memcpy(result, ptr, old_size); + + // free the previous page if it had no other objects + if (only_object) + { + assert(_root->data == result); + assert(_root->next); + + xpath_memory_block* next = _root->next->next; + + if (next) + { + // deallocate the whole page, unless it was the first one + xml_memory::deallocate(_root->next); + _root->next = next; + } + } + } + + return result; + } + + void revert(const xpath_allocator& state) + { + // free all new pages + xpath_memory_block* cur = _root; + + while (cur != state._root) + { + xpath_memory_block* next = cur->next; + + xml_memory::deallocate(cur); + + cur = next; + } + + // restore state + _root = state._root; + _root_size = state._root_size; + } + + void release() + { + xpath_memory_block* cur = _root; + assert(cur); + + while (cur->next) + { + xpath_memory_block* next = cur->next; + + xml_memory::deallocate(cur); + + cur = next; + } + } + }; + + struct xpath_allocator_capture + { + xpath_allocator_capture(xpath_allocator* alloc): _target(alloc), _state(*alloc) + { + } + + ~xpath_allocator_capture() + { + _target->revert(_state); + } + + xpath_allocator* _target; + xpath_allocator _state; + }; + + struct xpath_stack + { + xpath_allocator* result; + xpath_allocator* temp; + }; + + struct xpath_stack_data + { + xpath_memory_block blocks[2]; + xpath_allocator result; + xpath_allocator temp; + xpath_stack stack; + + #ifdef PUGIXML_NO_EXCEPTIONS + jmp_buf error_handler; + #endif + + xpath_stack_data(): result(blocks + 0), temp(blocks + 1) + { + blocks[0].next = blocks[1].next = 0; + blocks[0].capacity = blocks[1].capacity = sizeof(blocks[0].data); + + stack.result = &result; + stack.temp = &temp; + + #ifdef PUGIXML_NO_EXCEPTIONS + result.error_handler = temp.error_handler = &error_handler; + #endif + } + + ~xpath_stack_data() + { + result.release(); + temp.release(); + } + }; +PUGI__NS_END + +// String class +PUGI__NS_BEGIN + class xpath_string + { + const char_t* _buffer; + bool _uses_heap; + size_t _length_heap; + + static char_t* duplicate_string(const char_t* string, size_t length, xpath_allocator* alloc) + { + char_t* result = static_cast(alloc->allocate((length + 1) * sizeof(char_t))); + assert(result); + + memcpy(result, string, length * sizeof(char_t)); + result[length] = 0; + + return result; + } + + xpath_string(const char_t* buffer, bool uses_heap_, size_t length_heap): _buffer(buffer), _uses_heap(uses_heap_), _length_heap(length_heap) + { + } + + public: + static xpath_string from_const(const char_t* str) + { + return xpath_string(str, false, 0); + } + + static xpath_string from_heap_preallocated(const char_t* begin, const char_t* end) + { + assert(begin <= end && *end == 0); + + return xpath_string(begin, true, static_cast(end - begin)); + } + + static xpath_string from_heap(const char_t* begin, const char_t* end, xpath_allocator* alloc) + { + assert(begin <= end); + + size_t length = static_cast(end - begin); + + return length == 0 ? xpath_string() : xpath_string(duplicate_string(begin, length, alloc), true, length); + } + + xpath_string(): _buffer(PUGIXML_TEXT("")), _uses_heap(false), _length_heap(0) + { + } + + void append(const xpath_string& o, xpath_allocator* alloc) + { + // skip empty sources + if (!*o._buffer) return; + + // fast append for constant empty target and constant source + if (!*_buffer && !_uses_heap && !o._uses_heap) + { + _buffer = o._buffer; + } + else + { + // need to make heap copy + size_t target_length = length(); + size_t source_length = o.length(); + size_t result_length = target_length + source_length; + + // allocate new buffer + char_t* result = static_cast(alloc->reallocate(_uses_heap ? const_cast(_buffer) : 0, (target_length + 1) * sizeof(char_t), (result_length + 1) * sizeof(char_t))); + assert(result); + + // append first string to the new buffer in case there was no reallocation + if (!_uses_heap) memcpy(result, _buffer, target_length * sizeof(char_t)); + + // append second string to the new buffer + memcpy(result + target_length, o._buffer, source_length * sizeof(char_t)); + result[result_length] = 0; + + // finalize + _buffer = result; + _uses_heap = true; + _length_heap = result_length; + } + } + + const char_t* c_str() const + { + return _buffer; + } + + size_t length() const + { + return _uses_heap ? _length_heap : strlength(_buffer); + } + + char_t* data(xpath_allocator* alloc) + { + // make private heap copy + if (!_uses_heap) + { + size_t length_ = strlength(_buffer); + + _buffer = duplicate_string(_buffer, length_, alloc); + _uses_heap = true; + _length_heap = length_; + } + + return const_cast(_buffer); + } + + bool empty() const + { + return *_buffer == 0; + } + + bool operator==(const xpath_string& o) const + { + return strequal(_buffer, o._buffer); + } + + bool operator!=(const xpath_string& o) const + { + return !strequal(_buffer, o._buffer); + } + + bool uses_heap() const + { + return _uses_heap; + } + }; +PUGI__NS_END + +PUGI__NS_BEGIN + PUGI__FN bool starts_with(const char_t* string, const char_t* pattern) + { + while (*pattern && *string == *pattern) + { + string++; + pattern++; + } + + return *pattern == 0; + } + + PUGI__FN const char_t* find_char(const char_t* s, char_t c) + { + #ifdef PUGIXML_WCHAR_MODE + return wcschr(s, c); + #else + return strchr(s, c); + #endif + } + + PUGI__FN const char_t* find_substring(const char_t* s, const char_t* p) + { + #ifdef PUGIXML_WCHAR_MODE + // MSVC6 wcsstr bug workaround (if s is empty it always returns 0) + return (*p == 0) ? s : wcsstr(s, p); + #else + return strstr(s, p); + #endif + } + + // Converts symbol to lower case, if it is an ASCII one + PUGI__FN char_t tolower_ascii(char_t ch) + { + return static_cast(ch - 'A') < 26 ? static_cast(ch | ' ') : ch; + } + + PUGI__FN xpath_string string_value(const xpath_node& na, xpath_allocator* alloc) + { + if (na.attribute()) + return xpath_string::from_const(na.attribute().value()); + else + { + xml_node n = na.node(); + + switch (n.type()) + { + case node_pcdata: + case node_cdata: + case node_comment: + case node_pi: + return xpath_string::from_const(n.value()); + + case node_document: + case node_element: + { + xpath_string result; + + xml_node cur = n.first_child(); + + while (cur && cur != n) + { + if (cur.type() == node_pcdata || cur.type() == node_cdata) + result.append(xpath_string::from_const(cur.value()), alloc); + + if (cur.first_child()) + cur = cur.first_child(); + else if (cur.next_sibling()) + cur = cur.next_sibling(); + else + { + while (!cur.next_sibling() && cur != n) + cur = cur.parent(); + + if (cur != n) cur = cur.next_sibling(); + } + } + + return result; + } + + default: + return xpath_string(); + } + } + } + + PUGI__FN bool node_is_before_sibling(xml_node_struct* ln, xml_node_struct* rn) + { + assert(ln->parent == rn->parent); + + // there is no common ancestor (the shared parent is null), nodes are from different documents + if (!ln->parent) return ln < rn; + + // determine sibling order + xml_node_struct* ls = ln; + xml_node_struct* rs = rn; + + while (ls && rs) + { + if (ls == rn) return true; + if (rs == ln) return false; + + ls = ls->next_sibling; + rs = rs->next_sibling; + } + + // if rn sibling chain ended ln must be before rn + return !rs; + } + + PUGI__FN bool node_is_before(xml_node_struct* ln, xml_node_struct* rn) + { + // find common ancestor at the same depth, if any + xml_node_struct* lp = ln; + xml_node_struct* rp = rn; + + while (lp && rp && lp->parent != rp->parent) + { + lp = lp->parent; + rp = rp->parent; + } + + // parents are the same! + if (lp && rp) return node_is_before_sibling(lp, rp); + + // nodes are at different depths, need to normalize heights + bool left_higher = !lp; + + while (lp) + { + lp = lp->parent; + ln = ln->parent; + } + + while (rp) + { + rp = rp->parent; + rn = rn->parent; + } + + // one node is the ancestor of the other + if (ln == rn) return left_higher; + + // find common ancestor... again + while (ln->parent != rn->parent) + { + ln = ln->parent; + rn = rn->parent; + } + + return node_is_before_sibling(ln, rn); + } + + PUGI__FN bool node_is_ancestor(xml_node_struct* parent, xml_node_struct* node) + { + while (node && node != parent) node = node->parent; + + return parent && node == parent; + } + + PUGI__FN const void* document_buffer_order(const xpath_node& xnode) + { + xml_node_struct* node = xnode.node().internal_object(); + + if (node) + { + if ((get_document(node).header & xml_memory_page_contents_shared_mask) == 0) + { + if (node->name && (node->header & impl::xml_memory_page_name_allocated_or_shared_mask) == 0) return node->name; + if (node->value && (node->header & impl::xml_memory_page_value_allocated_or_shared_mask) == 0) return node->value; + } + + return 0; + } + + xml_attribute_struct* attr = xnode.attribute().internal_object(); + + if (attr) + { + if ((get_document(attr).header & xml_memory_page_contents_shared_mask) == 0) + { + if ((attr->header & impl::xml_memory_page_name_allocated_or_shared_mask) == 0) return attr->name; + if ((attr->header & impl::xml_memory_page_value_allocated_or_shared_mask) == 0) return attr->value; + } + + return 0; + } + + return 0; + } + + struct document_order_comparator + { + bool operator()(const xpath_node& lhs, const xpath_node& rhs) const + { + // optimized document order based check + const void* lo = document_buffer_order(lhs); + const void* ro = document_buffer_order(rhs); + + if (lo && ro) return lo < ro; + + // slow comparison + xml_node ln = lhs.node(), rn = rhs.node(); + + // compare attributes + if (lhs.attribute() && rhs.attribute()) + { + // shared parent + if (lhs.parent() == rhs.parent()) + { + // determine sibling order + for (xml_attribute a = lhs.attribute(); a; a = a.next_attribute()) + if (a == rhs.attribute()) + return true; + + return false; + } + + // compare attribute parents + ln = lhs.parent(); + rn = rhs.parent(); + } + else if (lhs.attribute()) + { + // attributes go after the parent element + if (lhs.parent() == rhs.node()) return false; + + ln = lhs.parent(); + } + else if (rhs.attribute()) + { + // attributes go after the parent element + if (rhs.parent() == lhs.node()) return true; + + rn = rhs.parent(); + } + + if (ln == rn) return false; + + if (!ln || !rn) return ln < rn; + + return node_is_before(ln.internal_object(), rn.internal_object()); + } + }; + + struct duplicate_comparator + { + bool operator()(const xpath_node& lhs, const xpath_node& rhs) const + { + if (lhs.attribute()) return rhs.attribute() ? lhs.attribute() < rhs.attribute() : true; + else return rhs.attribute() ? false : lhs.node() < rhs.node(); + } + }; + + PUGI__FN double gen_nan() + { + #if defined(__STDC_IEC_559__) || ((FLT_RADIX - 0 == 2) && (FLT_MAX_EXP - 0 == 128) && (FLT_MANT_DIG - 0 == 24)) + union { float f; uint32_t i; } u[sizeof(float) == sizeof(uint32_t) ? 1 : -1]; + u[0].i = 0x7fc00000; + return u[0].f; + #else + // fallback + const volatile double zero = 0.0; + return zero / zero; + #endif + } + + PUGI__FN bool is_nan(double value) + { + #if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__) + return !!_isnan(value); + #elif defined(fpclassify) && defined(FP_NAN) + return fpclassify(value) == FP_NAN; + #else + // fallback + const volatile double v = value; + return v != v; + #endif + } + + PUGI__FN const char_t* convert_number_to_string_special(double value) + { + #if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__) + if (_finite(value)) return (value == 0) ? PUGIXML_TEXT("0") : 0; + if (_isnan(value)) return PUGIXML_TEXT("NaN"); + return value > 0 ? PUGIXML_TEXT("Infinity") : PUGIXML_TEXT("-Infinity"); + #elif defined(fpclassify) && defined(FP_NAN) && defined(FP_INFINITE) && defined(FP_ZERO) + switch (fpclassify(value)) + { + case FP_NAN: + return PUGIXML_TEXT("NaN"); + + case FP_INFINITE: + return value > 0 ? PUGIXML_TEXT("Infinity") : PUGIXML_TEXT("-Infinity"); + + case FP_ZERO: + return PUGIXML_TEXT("0"); + + default: + return 0; + } + #else + // fallback + const volatile double v = value; + + if (v == 0) return PUGIXML_TEXT("0"); + if (v != v) return PUGIXML_TEXT("NaN"); + if (v * 2 == v) return value > 0 ? PUGIXML_TEXT("Infinity") : PUGIXML_TEXT("-Infinity"); + return 0; + #endif + } + + PUGI__FN bool convert_number_to_boolean(double value) + { + return (value != 0 && !is_nan(value)); + } + + PUGI__FN void truncate_zeros(char* begin, char* end) + { + while (begin != end && end[-1] == '0') end--; + + *end = 0; + } + + // gets mantissa digits in the form of 0.xxxxx with 0. implied and the exponent +#if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400 && !defined(_WIN32_WCE) + PUGI__FN void convert_number_to_mantissa_exponent(double value, char* buffer, size_t buffer_size, char** out_mantissa, int* out_exponent) + { + // get base values + int sign, exponent; + _ecvt_s(buffer, buffer_size, value, DBL_DIG + 1, &exponent, &sign); + + // truncate redundant zeros + truncate_zeros(buffer, buffer + strlen(buffer)); + + // fill results + *out_mantissa = buffer; + *out_exponent = exponent; + } +#else + PUGI__FN void convert_number_to_mantissa_exponent(double value, char* buffer, size_t buffer_size, char** out_mantissa, int* out_exponent) + { + // get a scientific notation value with IEEE DBL_DIG decimals + sprintf(buffer, "%.*e", DBL_DIG, value); + assert(strlen(buffer) < buffer_size); + (void)!buffer_size; + + // get the exponent (possibly negative) + char* exponent_string = strchr(buffer, 'e'); + assert(exponent_string); + + int exponent = atoi(exponent_string + 1); + + // extract mantissa string: skip sign + char* mantissa = buffer[0] == '-' ? buffer + 1 : buffer; + assert(mantissa[0] != '0' && mantissa[1] == '.'); + + // divide mantissa by 10 to eliminate integer part + mantissa[1] = mantissa[0]; + mantissa++; + exponent++; + + // remove extra mantissa digits and zero-terminate mantissa + truncate_zeros(mantissa, exponent_string); + + // fill results + *out_mantissa = mantissa; + *out_exponent = exponent; + } +#endif + + PUGI__FN xpath_string convert_number_to_string(double value, xpath_allocator* alloc) + { + // try special number conversion + const char_t* special = convert_number_to_string_special(value); + if (special) return xpath_string::from_const(special); + + // get mantissa + exponent form + char mantissa_buffer[32]; + + char* mantissa; + int exponent; + convert_number_to_mantissa_exponent(value, mantissa_buffer, sizeof(mantissa_buffer), &mantissa, &exponent); + + // allocate a buffer of suitable length for the number + size_t result_size = strlen(mantissa_buffer) + (exponent > 0 ? exponent : -exponent) + 4; + char_t* result = static_cast(alloc->allocate(sizeof(char_t) * result_size)); + assert(result); + + // make the number! + char_t* s = result; + + // sign + if (value < 0) *s++ = '-'; + + // integer part + if (exponent <= 0) + { + *s++ = '0'; + } + else + { + while (exponent > 0) + { + assert(*mantissa == 0 || static_cast(static_cast(*mantissa) - '0') <= 9); + *s++ = *mantissa ? *mantissa++ : '0'; + exponent--; + } + } + + // fractional part + if (*mantissa) + { + // decimal point + *s++ = '.'; + + // extra zeroes from negative exponent + while (exponent < 0) + { + *s++ = '0'; + exponent++; + } + + // extra mantissa digits + while (*mantissa) + { + assert(static_cast(*mantissa - '0') <= 9); + *s++ = *mantissa++; + } + } + + // zero-terminate + assert(s < result + result_size); + *s = 0; + + return xpath_string::from_heap_preallocated(result, s); + } + + PUGI__FN bool check_string_to_number_format(const char_t* string) + { + // parse leading whitespace + while (PUGI__IS_CHARTYPE(*string, ct_space)) ++string; + + // parse sign + if (*string == '-') ++string; + + if (!*string) return false; + + // if there is no integer part, there should be a decimal part with at least one digit + if (!PUGI__IS_CHARTYPEX(string[0], ctx_digit) && (string[0] != '.' || !PUGI__IS_CHARTYPEX(string[1], ctx_digit))) return false; + + // parse integer part + while (PUGI__IS_CHARTYPEX(*string, ctx_digit)) ++string; + + // parse decimal part + if (*string == '.') + { + ++string; + + while (PUGI__IS_CHARTYPEX(*string, ctx_digit)) ++string; + } + + // parse trailing whitespace + while (PUGI__IS_CHARTYPE(*string, ct_space)) ++string; + + return *string == 0; + } + + PUGI__FN double convert_string_to_number(const char_t* string) + { + // check string format + if (!check_string_to_number_format(string)) return gen_nan(); + + // parse string + #ifdef PUGIXML_WCHAR_MODE + return wcstod(string, 0); + #else + return strtod(string, 0); + #endif + } + + PUGI__FN bool convert_string_to_number_scratch(char_t (&buffer)[32], const char_t* begin, const char_t* end, double* out_result) + { + size_t length = static_cast(end - begin); + char_t* scratch = buffer; + + if (length >= sizeof(buffer) / sizeof(buffer[0])) + { + // need to make dummy on-heap copy + scratch = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); + if (!scratch) return false; + } + + // copy string to zero-terminated buffer and perform conversion + memcpy(scratch, begin, length * sizeof(char_t)); + scratch[length] = 0; + + *out_result = convert_string_to_number(scratch); + + // free dummy buffer + if (scratch != buffer) xml_memory::deallocate(scratch); + + return true; + } + + PUGI__FN double round_nearest(double value) + { + return floor(value + 0.5); + } + + PUGI__FN double round_nearest_nzero(double value) + { + // same as round_nearest, but returns -0 for [-0.5, -0] + // ceil is used to differentiate between +0 and -0 (we return -0 for [-0.5, -0] and +0 for +0) + return (value >= -0.5 && value <= 0) ? ceil(value) : floor(value + 0.5); + } + + PUGI__FN const char_t* qualified_name(const xpath_node& node) + { + return node.attribute() ? node.attribute().name() : node.node().name(); + } + + PUGI__FN const char_t* local_name(const xpath_node& node) + { + const char_t* name = qualified_name(node); + const char_t* p = find_char(name, ':'); + + return p ? p + 1 : name; + } + + struct namespace_uri_predicate + { + const char_t* prefix; + size_t prefix_length; + + namespace_uri_predicate(const char_t* name) + { + const char_t* pos = find_char(name, ':'); + + prefix = pos ? name : 0; + prefix_length = pos ? static_cast(pos - name) : 0; + } + + bool operator()(xml_attribute a) const + { + const char_t* name = a.name(); + + if (!starts_with(name, PUGIXML_TEXT("xmlns"))) return false; + + return prefix ? name[5] == ':' && strequalrange(name + 6, prefix, prefix_length) : name[5] == 0; + } + }; + + PUGI__FN const char_t* namespace_uri(xml_node node) + { + namespace_uri_predicate pred = node.name(); + + xml_node p = node; + + while (p) + { + xml_attribute a = p.find_attribute(pred); + + if (a) return a.value(); + + p = p.parent(); + } + + return PUGIXML_TEXT(""); + } + + PUGI__FN const char_t* namespace_uri(xml_attribute attr, xml_node parent) + { + namespace_uri_predicate pred = attr.name(); + + // Default namespace does not apply to attributes + if (!pred.prefix) return PUGIXML_TEXT(""); + + xml_node p = parent; + + while (p) + { + xml_attribute a = p.find_attribute(pred); + + if (a) return a.value(); + + p = p.parent(); + } + + return PUGIXML_TEXT(""); + } + + PUGI__FN const char_t* namespace_uri(const xpath_node& node) + { + return node.attribute() ? namespace_uri(node.attribute(), node.parent()) : namespace_uri(node.node()); + } + + PUGI__FN char_t* normalize_space(char_t* buffer) + { + char_t* write = buffer; + + for (char_t* it = buffer; *it; ) + { + char_t ch = *it++; + + if (PUGI__IS_CHARTYPE(ch, ct_space)) + { + // replace whitespace sequence with single space + while (PUGI__IS_CHARTYPE(*it, ct_space)) it++; + + // avoid leading spaces + if (write != buffer) *write++ = ' '; + } + else *write++ = ch; + } + + // remove trailing space + if (write != buffer && PUGI__IS_CHARTYPE(write[-1], ct_space)) write--; + + // zero-terminate + *write = 0; + + return write; + } + + PUGI__FN char_t* translate(char_t* buffer, const char_t* from, const char_t* to, size_t to_length) + { + char_t* write = buffer; + + while (*buffer) + { + PUGI__DMC_VOLATILE char_t ch = *buffer++; + + const char_t* pos = find_char(from, ch); + + if (!pos) + *write++ = ch; // do not process + else if (static_cast(pos - from) < to_length) + *write++ = to[pos - from]; // replace + } + + // zero-terminate + *write = 0; + + return write; + } + + PUGI__FN unsigned char* translate_table_generate(xpath_allocator* alloc, const char_t* from, const char_t* to) + { + unsigned char table[128] = {0}; + + while (*from) + { + unsigned int fc = static_cast(*from); + unsigned int tc = static_cast(*to); + + if (fc >= 128 || tc >= 128) + return 0; + + // code=128 means "skip character" + if (!table[fc]) + table[fc] = static_cast(tc ? tc : 128); + + from++; + if (tc) to++; + } + + for (int i = 0; i < 128; ++i) + if (!table[i]) + table[i] = static_cast(i); + + void* result = alloc->allocate_nothrow(sizeof(table)); + + if (result) + { + memcpy(result, table, sizeof(table)); + } + + return static_cast(result); + } + + PUGI__FN char_t* translate_table(char_t* buffer, const unsigned char* table) + { + char_t* write = buffer; + + while (*buffer) + { + char_t ch = *buffer++; + unsigned int index = static_cast(ch); + + if (index < 128) + { + unsigned char code = table[index]; + + // code=128 means "skip character" (table size is 128 so 128 can be a special value) + // this code skips these characters without extra branches + *write = static_cast(code); + write += 1 - (code >> 7); + } + else + { + *write++ = ch; + } + } + + // zero-terminate + *write = 0; + + return write; + } + + inline bool is_xpath_attribute(const char_t* name) + { + return !(starts_with(name, PUGIXML_TEXT("xmlns")) && (name[5] == 0 || name[5] == ':')); + } + + struct xpath_variable_boolean: xpath_variable + { + xpath_variable_boolean(): xpath_variable(xpath_type_boolean), value(false) + { + } + + bool value; + char_t name[1]; + }; + + struct xpath_variable_number: xpath_variable + { + xpath_variable_number(): xpath_variable(xpath_type_number), value(0) + { + } + + double value; + char_t name[1]; + }; + + struct xpath_variable_string: xpath_variable + { + xpath_variable_string(): xpath_variable(xpath_type_string), value(0) + { + } + + ~xpath_variable_string() + { + if (value) xml_memory::deallocate(value); + } + + char_t* value; + char_t name[1]; + }; + + struct xpath_variable_node_set: xpath_variable + { + xpath_variable_node_set(): xpath_variable(xpath_type_node_set) + { + } + + xpath_node_set value; + char_t name[1]; + }; + + static const xpath_node_set dummy_node_set; + + PUGI__FN unsigned int hash_string(const char_t* str) + { + // Jenkins one-at-a-time hash (http://en.wikipedia.org/wiki/Jenkins_hash_function#one-at-a-time) + unsigned int result = 0; + + while (*str) + { + result += static_cast(*str++); + result += result << 10; + result ^= result >> 6; + } + + result += result << 3; + result ^= result >> 11; + result += result << 15; + + return result; + } + + template PUGI__FN T* new_xpath_variable(const char_t* name) + { + size_t length = strlength(name); + if (length == 0) return 0; // empty variable names are invalid + + // $$ we can't use offsetof(T, name) because T is non-POD, so we just allocate additional length characters + void* memory = xml_memory::allocate(sizeof(T) + length * sizeof(char_t)); + if (!memory) return 0; + + T* result = new (memory) T(); + + memcpy(result->name, name, (length + 1) * sizeof(char_t)); + + return result; + } + + PUGI__FN xpath_variable* new_xpath_variable(xpath_value_type type, const char_t* name) + { + switch (type) + { + case xpath_type_node_set: + return new_xpath_variable(name); + + case xpath_type_number: + return new_xpath_variable(name); + + case xpath_type_string: + return new_xpath_variable(name); + + case xpath_type_boolean: + return new_xpath_variable(name); + + default: + return 0; + } + } + + template PUGI__FN void delete_xpath_variable(T* var) + { + var->~T(); + xml_memory::deallocate(var); + } + + PUGI__FN void delete_xpath_variable(xpath_value_type type, xpath_variable* var) + { + switch (type) + { + case xpath_type_node_set: + delete_xpath_variable(static_cast(var)); + break; + + case xpath_type_number: + delete_xpath_variable(static_cast(var)); + break; + + case xpath_type_string: + delete_xpath_variable(static_cast(var)); + break; + + case xpath_type_boolean: + delete_xpath_variable(static_cast(var)); + break; + + default: + assert(!"Invalid variable type"); + } + } + + PUGI__FN bool copy_xpath_variable(xpath_variable* lhs, const xpath_variable* rhs) + { + switch (rhs->type()) + { + case xpath_type_node_set: + return lhs->set(static_cast(rhs)->value); + + case xpath_type_number: + return lhs->set(static_cast(rhs)->value); + + case xpath_type_string: + return lhs->set(static_cast(rhs)->value); + + case xpath_type_boolean: + return lhs->set(static_cast(rhs)->value); + + default: + assert(!"Invalid variable type"); + return false; + } + } + + PUGI__FN bool get_variable_scratch(char_t (&buffer)[32], xpath_variable_set* set, const char_t* begin, const char_t* end, xpath_variable** out_result) + { + size_t length = static_cast(end - begin); + char_t* scratch = buffer; + + if (length >= sizeof(buffer) / sizeof(buffer[0])) + { + // need to make dummy on-heap copy + scratch = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); + if (!scratch) return false; + } + + // copy string to zero-terminated buffer and perform lookup + memcpy(scratch, begin, length * sizeof(char_t)); + scratch[length] = 0; + + *out_result = set->get(scratch); + + // free dummy buffer + if (scratch != buffer) xml_memory::deallocate(scratch); + + return true; + } +PUGI__NS_END + +// Internal node set class +PUGI__NS_BEGIN + PUGI__FN xpath_node_set::type_t xpath_get_order(const xpath_node* begin, const xpath_node* end) + { + if (end - begin < 2) + return xpath_node_set::type_sorted; + + document_order_comparator cmp; + + bool first = cmp(begin[0], begin[1]); + + for (const xpath_node* it = begin + 1; it + 1 < end; ++it) + if (cmp(it[0], it[1]) != first) + return xpath_node_set::type_unsorted; + + return first ? xpath_node_set::type_sorted : xpath_node_set::type_sorted_reverse; + } + + PUGI__FN xpath_node_set::type_t xpath_sort(xpath_node* begin, xpath_node* end, xpath_node_set::type_t type, bool rev) + { + xpath_node_set::type_t order = rev ? xpath_node_set::type_sorted_reverse : xpath_node_set::type_sorted; + + if (type == xpath_node_set::type_unsorted) + { + xpath_node_set::type_t sorted = xpath_get_order(begin, end); + + if (sorted == xpath_node_set::type_unsorted) + { + sort(begin, end, document_order_comparator()); + + type = xpath_node_set::type_sorted; + } + else + type = sorted; + } + + if (type != order) reverse(begin, end); + + return order; + } + + PUGI__FN xpath_node xpath_first(const xpath_node* begin, const xpath_node* end, xpath_node_set::type_t type) + { + if (begin == end) return xpath_node(); + + switch (type) + { + case xpath_node_set::type_sorted: + return *begin; + + case xpath_node_set::type_sorted_reverse: + return *(end - 1); + + case xpath_node_set::type_unsorted: + return *min_element(begin, end, document_order_comparator()); + + default: + assert(!"Invalid node set type"); + return xpath_node(); + } + } + + class xpath_node_set_raw + { + xpath_node_set::type_t _type; + + xpath_node* _begin; + xpath_node* _end; + xpath_node* _eos; + + public: + xpath_node_set_raw(): _type(xpath_node_set::type_unsorted), _begin(0), _end(0), _eos(0) + { + } + + xpath_node* begin() const + { + return _begin; + } + + xpath_node* end() const + { + return _end; + } + + bool empty() const + { + return _begin == _end; + } + + size_t size() const + { + return static_cast(_end - _begin); + } + + xpath_node first() const + { + return xpath_first(_begin, _end, _type); + } + + void push_back_grow(const xpath_node& node, xpath_allocator* alloc); + + void push_back(const xpath_node& node, xpath_allocator* alloc) + { + if (_end != _eos) + *_end++ = node; + else + push_back_grow(node, alloc); + } + + void append(const xpath_node* begin_, const xpath_node* end_, xpath_allocator* alloc) + { + if (begin_ == end_) return; + + size_t size_ = static_cast(_end - _begin); + size_t capacity = static_cast(_eos - _begin); + size_t count = static_cast(end_ - begin_); + + if (size_ + count > capacity) + { + // reallocate the old array or allocate a new one + xpath_node* data = static_cast(alloc->reallocate(_begin, capacity * sizeof(xpath_node), (size_ + count) * sizeof(xpath_node))); + assert(data); + + // finalize + _begin = data; + _end = data + size_; + _eos = data + size_ + count; + } + + memcpy(_end, begin_, count * sizeof(xpath_node)); + _end += count; + } + + void sort_do() + { + _type = xpath_sort(_begin, _end, _type, false); + } + + void truncate(xpath_node* pos) + { + assert(_begin <= pos && pos <= _end); + + _end = pos; + } + + void remove_duplicates() + { + if (_type == xpath_node_set::type_unsorted) + sort(_begin, _end, duplicate_comparator()); + + _end = unique(_begin, _end); + } + + xpath_node_set::type_t type() const + { + return _type; + } + + void set_type(xpath_node_set::type_t value) + { + _type = value; + } + }; + + PUGI__FN_NO_INLINE void xpath_node_set_raw::push_back_grow(const xpath_node& node, xpath_allocator* alloc) + { + size_t capacity = static_cast(_eos - _begin); + + // get new capacity (1.5x rule) + size_t new_capacity = capacity + capacity / 2 + 1; + + // reallocate the old array or allocate a new one + xpath_node* data = static_cast(alloc->reallocate(_begin, capacity * sizeof(xpath_node), new_capacity * sizeof(xpath_node))); + assert(data); + + // finalize + _begin = data; + _end = data + capacity; + _eos = data + new_capacity; + + // push + *_end++ = node; + } +PUGI__NS_END + +PUGI__NS_BEGIN + struct xpath_context + { + xpath_node n; + size_t position, size; + + xpath_context(const xpath_node& n_, size_t position_, size_t size_): n(n_), position(position_), size(size_) + { + } + }; + + enum lexeme_t + { + lex_none = 0, + lex_equal, + lex_not_equal, + lex_less, + lex_greater, + lex_less_or_equal, + lex_greater_or_equal, + lex_plus, + lex_minus, + lex_multiply, + lex_union, + lex_var_ref, + lex_open_brace, + lex_close_brace, + lex_quoted_string, + lex_number, + lex_slash, + lex_double_slash, + lex_open_square_brace, + lex_close_square_brace, + lex_string, + lex_comma, + lex_axis_attribute, + lex_dot, + lex_double_dot, + lex_double_colon, + lex_eof + }; + + struct xpath_lexer_string + { + const char_t* begin; + const char_t* end; + + xpath_lexer_string(): begin(0), end(0) + { + } + + bool operator==(const char_t* other) const + { + size_t length = static_cast(end - begin); + + return strequalrange(other, begin, length); + } + }; + + class xpath_lexer + { + const char_t* _cur; + const char_t* _cur_lexeme_pos; + xpath_lexer_string _cur_lexeme_contents; + + lexeme_t _cur_lexeme; + + public: + explicit xpath_lexer(const char_t* query): _cur(query) + { + next(); + } + + const char_t* state() const + { + return _cur; + } + + void next() + { + const char_t* cur = _cur; + + while (PUGI__IS_CHARTYPE(*cur, ct_space)) ++cur; + + // save lexeme position for error reporting + _cur_lexeme_pos = cur; + + switch (*cur) + { + case 0: + _cur_lexeme = lex_eof; + break; + + case '>': + if (*(cur+1) == '=') + { + cur += 2; + _cur_lexeme = lex_greater_or_equal; + } + else + { + cur += 1; + _cur_lexeme = lex_greater; + } + break; + + case '<': + if (*(cur+1) == '=') + { + cur += 2; + _cur_lexeme = lex_less_or_equal; + } + else + { + cur += 1; + _cur_lexeme = lex_less; + } + break; + + case '!': + if (*(cur+1) == '=') + { + cur += 2; + _cur_lexeme = lex_not_equal; + } + else + { + _cur_lexeme = lex_none; + } + break; + + case '=': + cur += 1; + _cur_lexeme = lex_equal; + + break; + + case '+': + cur += 1; + _cur_lexeme = lex_plus; + + break; + + case '-': + cur += 1; + _cur_lexeme = lex_minus; + + break; + + case '*': + cur += 1; + _cur_lexeme = lex_multiply; + + break; + + case '|': + cur += 1; + _cur_lexeme = lex_union; + + break; + + case '$': + cur += 1; + + if (PUGI__IS_CHARTYPEX(*cur, ctx_start_symbol)) + { + _cur_lexeme_contents.begin = cur; + + while (PUGI__IS_CHARTYPEX(*cur, ctx_symbol)) cur++; + + if (cur[0] == ':' && PUGI__IS_CHARTYPEX(cur[1], ctx_symbol)) // qname + { + cur++; // : + + while (PUGI__IS_CHARTYPEX(*cur, ctx_symbol)) cur++; + } + + _cur_lexeme_contents.end = cur; + + _cur_lexeme = lex_var_ref; + } + else + { + _cur_lexeme = lex_none; + } + + break; + + case '(': + cur += 1; + _cur_lexeme = lex_open_brace; + + break; + + case ')': + cur += 1; + _cur_lexeme = lex_close_brace; + + break; + + case '[': + cur += 1; + _cur_lexeme = lex_open_square_brace; + + break; + + case ']': + cur += 1; + _cur_lexeme = lex_close_square_brace; + + break; + + case ',': + cur += 1; + _cur_lexeme = lex_comma; + + break; + + case '/': + if (*(cur+1) == '/') + { + cur += 2; + _cur_lexeme = lex_double_slash; + } + else + { + cur += 1; + _cur_lexeme = lex_slash; + } + break; + + case '.': + if (*(cur+1) == '.') + { + cur += 2; + _cur_lexeme = lex_double_dot; + } + else if (PUGI__IS_CHARTYPEX(*(cur+1), ctx_digit)) + { + _cur_lexeme_contents.begin = cur; // . + + ++cur; + + while (PUGI__IS_CHARTYPEX(*cur, ctx_digit)) cur++; + + _cur_lexeme_contents.end = cur; + + _cur_lexeme = lex_number; + } + else + { + cur += 1; + _cur_lexeme = lex_dot; + } + break; + + case '@': + cur += 1; + _cur_lexeme = lex_axis_attribute; + + break; + + case '"': + case '\'': + { + char_t terminator = *cur; + + ++cur; + + _cur_lexeme_contents.begin = cur; + while (*cur && *cur != terminator) cur++; + _cur_lexeme_contents.end = cur; + + if (!*cur) + _cur_lexeme = lex_none; + else + { + cur += 1; + _cur_lexeme = lex_quoted_string; + } + + break; + } + + case ':': + if (*(cur+1) == ':') + { + cur += 2; + _cur_lexeme = lex_double_colon; + } + else + { + _cur_lexeme = lex_none; + } + break; + + default: + if (PUGI__IS_CHARTYPEX(*cur, ctx_digit)) + { + _cur_lexeme_contents.begin = cur; + + while (PUGI__IS_CHARTYPEX(*cur, ctx_digit)) cur++; + + if (*cur == '.') + { + cur++; + + while (PUGI__IS_CHARTYPEX(*cur, ctx_digit)) cur++; + } + + _cur_lexeme_contents.end = cur; + + _cur_lexeme = lex_number; + } + else if (PUGI__IS_CHARTYPEX(*cur, ctx_start_symbol)) + { + _cur_lexeme_contents.begin = cur; + + while (PUGI__IS_CHARTYPEX(*cur, ctx_symbol)) cur++; + + if (cur[0] == ':') + { + if (cur[1] == '*') // namespace test ncname:* + { + cur += 2; // :* + } + else if (PUGI__IS_CHARTYPEX(cur[1], ctx_symbol)) // namespace test qname + { + cur++; // : + + while (PUGI__IS_CHARTYPEX(*cur, ctx_symbol)) cur++; + } + } + + _cur_lexeme_contents.end = cur; + + _cur_lexeme = lex_string; + } + else + { + _cur_lexeme = lex_none; + } + } + + _cur = cur; + } + + lexeme_t current() const + { + return _cur_lexeme; + } + + const char_t* current_pos() const + { + return _cur_lexeme_pos; + } + + const xpath_lexer_string& contents() const + { + assert(_cur_lexeme == lex_var_ref || _cur_lexeme == lex_number || _cur_lexeme == lex_string || _cur_lexeme == lex_quoted_string); + + return _cur_lexeme_contents; + } + }; + + enum ast_type_t + { + ast_unknown, + ast_op_or, // left or right + ast_op_and, // left and right + ast_op_equal, // left = right + ast_op_not_equal, // left != right + ast_op_less, // left < right + ast_op_greater, // left > right + ast_op_less_or_equal, // left <= right + ast_op_greater_or_equal, // left >= right + ast_op_add, // left + right + ast_op_subtract, // left - right + ast_op_multiply, // left * right + ast_op_divide, // left / right + ast_op_mod, // left % right + ast_op_negate, // left - right + ast_op_union, // left | right + ast_predicate, // apply predicate to set; next points to next predicate + ast_filter, // select * from left where right + ast_string_constant, // string constant + ast_number_constant, // number constant + ast_variable, // variable + ast_func_last, // last() + ast_func_position, // position() + ast_func_count, // count(left) + ast_func_id, // id(left) + ast_func_local_name_0, // local-name() + ast_func_local_name_1, // local-name(left) + ast_func_namespace_uri_0, // namespace-uri() + ast_func_namespace_uri_1, // namespace-uri(left) + ast_func_name_0, // name() + ast_func_name_1, // name(left) + ast_func_string_0, // string() + ast_func_string_1, // string(left) + ast_func_concat, // concat(left, right, siblings) + ast_func_starts_with, // starts_with(left, right) + ast_func_contains, // contains(left, right) + ast_func_substring_before, // substring-before(left, right) + ast_func_substring_after, // substring-after(left, right) + ast_func_substring_2, // substring(left, right) + ast_func_substring_3, // substring(left, right, third) + ast_func_string_length_0, // string-length() + ast_func_string_length_1, // string-length(left) + ast_func_normalize_space_0, // normalize-space() + ast_func_normalize_space_1, // normalize-space(left) + ast_func_translate, // translate(left, right, third) + ast_func_boolean, // boolean(left) + ast_func_not, // not(left) + ast_func_true, // true() + ast_func_false, // false() + ast_func_lang, // lang(left) + ast_func_number_0, // number() + ast_func_number_1, // number(left) + ast_func_sum, // sum(left) + ast_func_floor, // floor(left) + ast_func_ceiling, // ceiling(left) + ast_func_round, // round(left) + ast_step, // process set left with step + ast_step_root, // select root node + + ast_opt_translate_table, // translate(left, right, third) where right/third are constants + ast_opt_compare_attribute // @name = 'string' + }; + + enum axis_t + { + axis_ancestor, + axis_ancestor_or_self, + axis_attribute, + axis_child, + axis_descendant, + axis_descendant_or_self, + axis_following, + axis_following_sibling, + axis_namespace, + axis_parent, + axis_preceding, + axis_preceding_sibling, + axis_self + }; + + enum nodetest_t + { + nodetest_none, + nodetest_name, + nodetest_type_node, + nodetest_type_comment, + nodetest_type_pi, + nodetest_type_text, + nodetest_pi, + nodetest_all, + nodetest_all_in_namespace + }; + + enum predicate_t + { + predicate_default, + predicate_posinv, + predicate_constant, + predicate_constant_one + }; + + enum nodeset_eval_t + { + nodeset_eval_all, + nodeset_eval_any, + nodeset_eval_first + }; + + template struct axis_to_type + { + static const axis_t axis; + }; + + template const axis_t axis_to_type::axis = N; + + class xpath_ast_node + { + private: + // node type + char _type; + char _rettype; + + // for ast_step + char _axis; + + // for ast_step/ast_predicate/ast_filter + char _test; + + // tree node structure + xpath_ast_node* _left; + xpath_ast_node* _right; + xpath_ast_node* _next; + + union + { + // value for ast_string_constant + const char_t* string; + // value for ast_number_constant + double number; + // variable for ast_variable + xpath_variable* variable; + // node test for ast_step (node name/namespace/node type/pi target) + const char_t* nodetest; + // table for ast_opt_translate_table + const unsigned char* table; + } _data; + + xpath_ast_node(const xpath_ast_node&); + xpath_ast_node& operator=(const xpath_ast_node&); + + template static bool compare_eq(xpath_ast_node* lhs, xpath_ast_node* rhs, const xpath_context& c, const xpath_stack& stack, const Comp& comp) + { + xpath_value_type lt = lhs->rettype(), rt = rhs->rettype(); + + if (lt != xpath_type_node_set && rt != xpath_type_node_set) + { + if (lt == xpath_type_boolean || rt == xpath_type_boolean) + return comp(lhs->eval_boolean(c, stack), rhs->eval_boolean(c, stack)); + else if (lt == xpath_type_number || rt == xpath_type_number) + return comp(lhs->eval_number(c, stack), rhs->eval_number(c, stack)); + else if (lt == xpath_type_string || rt == xpath_type_string) + { + xpath_allocator_capture cr(stack.result); + + xpath_string ls = lhs->eval_string(c, stack); + xpath_string rs = rhs->eval_string(c, stack); + + return comp(ls, rs); + } + } + else if (lt == xpath_type_node_set && rt == xpath_type_node_set) + { + xpath_allocator_capture cr(stack.result); + + xpath_node_set_raw ls = lhs->eval_node_set(c, stack, nodeset_eval_all); + xpath_node_set_raw rs = rhs->eval_node_set(c, stack, nodeset_eval_all); + + for (const xpath_node* li = ls.begin(); li != ls.end(); ++li) + for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri) + { + xpath_allocator_capture cri(stack.result); + + if (comp(string_value(*li, stack.result), string_value(*ri, stack.result))) + return true; + } + + return false; + } + else + { + if (lt == xpath_type_node_set) + { + swap(lhs, rhs); + swap(lt, rt); + } + + if (lt == xpath_type_boolean) + return comp(lhs->eval_boolean(c, stack), rhs->eval_boolean(c, stack)); + else if (lt == xpath_type_number) + { + xpath_allocator_capture cr(stack.result); + + double l = lhs->eval_number(c, stack); + xpath_node_set_raw rs = rhs->eval_node_set(c, stack, nodeset_eval_all); + + for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri) + { + xpath_allocator_capture cri(stack.result); + + if (comp(l, convert_string_to_number(string_value(*ri, stack.result).c_str()))) + return true; + } + + return false; + } + else if (lt == xpath_type_string) + { + xpath_allocator_capture cr(stack.result); + + xpath_string l = lhs->eval_string(c, stack); + xpath_node_set_raw rs = rhs->eval_node_set(c, stack, nodeset_eval_all); + + for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri) + { + xpath_allocator_capture cri(stack.result); + + if (comp(l, string_value(*ri, stack.result))) + return true; + } + + return false; + } + } + + assert(!"Wrong types"); + return false; + } + + static bool eval_once(xpath_node_set::type_t type, nodeset_eval_t eval) + { + return type == xpath_node_set::type_sorted ? eval != nodeset_eval_all : eval == nodeset_eval_any; + } + + template static bool compare_rel(xpath_ast_node* lhs, xpath_ast_node* rhs, const xpath_context& c, const xpath_stack& stack, const Comp& comp) + { + xpath_value_type lt = lhs->rettype(), rt = rhs->rettype(); + + if (lt != xpath_type_node_set && rt != xpath_type_node_set) + return comp(lhs->eval_number(c, stack), rhs->eval_number(c, stack)); + else if (lt == xpath_type_node_set && rt == xpath_type_node_set) + { + xpath_allocator_capture cr(stack.result); + + xpath_node_set_raw ls = lhs->eval_node_set(c, stack, nodeset_eval_all); + xpath_node_set_raw rs = rhs->eval_node_set(c, stack, nodeset_eval_all); + + for (const xpath_node* li = ls.begin(); li != ls.end(); ++li) + { + xpath_allocator_capture cri(stack.result); + + double l = convert_string_to_number(string_value(*li, stack.result).c_str()); + + for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri) + { + xpath_allocator_capture crii(stack.result); + + if (comp(l, convert_string_to_number(string_value(*ri, stack.result).c_str()))) + return true; + } + } + + return false; + } + else if (lt != xpath_type_node_set && rt == xpath_type_node_set) + { + xpath_allocator_capture cr(stack.result); + + double l = lhs->eval_number(c, stack); + xpath_node_set_raw rs = rhs->eval_node_set(c, stack, nodeset_eval_all); + + for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri) + { + xpath_allocator_capture cri(stack.result); + + if (comp(l, convert_string_to_number(string_value(*ri, stack.result).c_str()))) + return true; + } + + return false; + } + else if (lt == xpath_type_node_set && rt != xpath_type_node_set) + { + xpath_allocator_capture cr(stack.result); + + xpath_node_set_raw ls = lhs->eval_node_set(c, stack, nodeset_eval_all); + double r = rhs->eval_number(c, stack); + + for (const xpath_node* li = ls.begin(); li != ls.end(); ++li) + { + xpath_allocator_capture cri(stack.result); + + if (comp(convert_string_to_number(string_value(*li, stack.result).c_str()), r)) + return true; + } + + return false; + } + else + { + assert(!"Wrong types"); + return false; + } + } + + static void apply_predicate_boolean(xpath_node_set_raw& ns, size_t first, xpath_ast_node* expr, const xpath_stack& stack, bool once) + { + assert(ns.size() >= first); + assert(expr->rettype() != xpath_type_number); + + size_t i = 1; + size_t size = ns.size() - first; + + xpath_node* last = ns.begin() + first; + + // remove_if... or well, sort of + for (xpath_node* it = last; it != ns.end(); ++it, ++i) + { + xpath_context c(*it, i, size); + + if (expr->eval_boolean(c, stack)) + { + *last++ = *it; + + if (once) break; + } + } + + ns.truncate(last); + } + + static void apply_predicate_number(xpath_node_set_raw& ns, size_t first, xpath_ast_node* expr, const xpath_stack& stack, bool once) + { + assert(ns.size() >= first); + assert(expr->rettype() == xpath_type_number); + + size_t i = 1; + size_t size = ns.size() - first; + + xpath_node* last = ns.begin() + first; + + // remove_if... or well, sort of + for (xpath_node* it = last; it != ns.end(); ++it, ++i) + { + xpath_context c(*it, i, size); + + if (expr->eval_number(c, stack) == i) + { + *last++ = *it; + + if (once) break; + } + } + + ns.truncate(last); + } + + static void apply_predicate_number_const(xpath_node_set_raw& ns, size_t first, xpath_ast_node* expr, const xpath_stack& stack) + { + assert(ns.size() >= first); + assert(expr->rettype() == xpath_type_number); + + size_t size = ns.size() - first; + + xpath_node* last = ns.begin() + first; + + xpath_context c(xpath_node(), 1, size); + + double er = expr->eval_number(c, stack); + + if (er >= 1.0 && er <= size) + { + size_t eri = static_cast(er); + + if (er == eri) + { + xpath_node r = last[eri - 1]; + + *last++ = r; + } + } + + ns.truncate(last); + } + + void apply_predicate(xpath_node_set_raw& ns, size_t first, const xpath_stack& stack, bool once) + { + if (ns.size() == first) return; + + assert(_type == ast_filter || _type == ast_predicate); + + if (_test == predicate_constant || _test == predicate_constant_one) + apply_predicate_number_const(ns, first, _right, stack); + else if (_right->rettype() == xpath_type_number) + apply_predicate_number(ns, first, _right, stack, once); + else + apply_predicate_boolean(ns, first, _right, stack, once); + } + + void apply_predicates(xpath_node_set_raw& ns, size_t first, const xpath_stack& stack, nodeset_eval_t eval) + { + if (ns.size() == first) return; + + bool last_once = eval_once(ns.type(), eval); + + for (xpath_ast_node* pred = _right; pred; pred = pred->_next) + pred->apply_predicate(ns, first, stack, !pred->_next && last_once); + } + + bool step_push(xpath_node_set_raw& ns, xml_attribute_struct* a, xml_node_struct* parent, xpath_allocator* alloc) + { + assert(a); + + const char_t* name = a->name ? a->name + 0 : PUGIXML_TEXT(""); + + switch (_test) + { + case nodetest_name: + if (strequal(name, _data.nodetest) && is_xpath_attribute(name)) + { + ns.push_back(xpath_node(xml_attribute(a), xml_node(parent)), alloc); + return true; + } + break; + + case nodetest_type_node: + case nodetest_all: + if (is_xpath_attribute(name)) + { + ns.push_back(xpath_node(xml_attribute(a), xml_node(parent)), alloc); + return true; + } + break; + + case nodetest_all_in_namespace: + if (starts_with(name, _data.nodetest) && is_xpath_attribute(name)) + { + ns.push_back(xpath_node(xml_attribute(a), xml_node(parent)), alloc); + return true; + } + break; + + default: + ; + } + + return false; + } + + bool step_push(xpath_node_set_raw& ns, xml_node_struct* n, xpath_allocator* alloc) + { + assert(n); + + xml_node_type type = PUGI__NODETYPE(n); + + switch (_test) + { + case nodetest_name: + if (type == node_element && n->name && strequal(n->name, _data.nodetest)) + { + ns.push_back(xml_node(n), alloc); + return true; + } + break; + + case nodetest_type_node: + ns.push_back(xml_node(n), alloc); + return true; + + case nodetest_type_comment: + if (type == node_comment) + { + ns.push_back(xml_node(n), alloc); + return true; + } + break; + + case nodetest_type_text: + if (type == node_pcdata || type == node_cdata) + { + ns.push_back(xml_node(n), alloc); + return true; + } + break; + + case nodetest_type_pi: + if (type == node_pi) + { + ns.push_back(xml_node(n), alloc); + return true; + } + break; + + case nodetest_pi: + if (type == node_pi && n->name && strequal(n->name, _data.nodetest)) + { + ns.push_back(xml_node(n), alloc); + return true; + } + break; + + case nodetest_all: + if (type == node_element) + { + ns.push_back(xml_node(n), alloc); + return true; + } + break; + + case nodetest_all_in_namespace: + if (type == node_element && n->name && starts_with(n->name, _data.nodetest)) + { + ns.push_back(xml_node(n), alloc); + return true; + } + break; + + default: + assert(!"Unknown axis"); + } + + return false; + } + + template void step_fill(xpath_node_set_raw& ns, xml_node_struct* n, xpath_allocator* alloc, bool once, T) + { + const axis_t axis = T::axis; + + switch (axis) + { + case axis_attribute: + { + for (xml_attribute_struct* a = n->first_attribute; a; a = a->next_attribute) + if (step_push(ns, a, n, alloc) & once) + return; + + break; + } + + case axis_child: + { + for (xml_node_struct* c = n->first_child; c; c = c->next_sibling) + if (step_push(ns, c, alloc) & once) + return; + + break; + } + + case axis_descendant: + case axis_descendant_or_self: + { + if (axis == axis_descendant_or_self) + if (step_push(ns, n, alloc) & once) + return; + + xml_node_struct* cur = n->first_child; + + while (cur) + { + if (step_push(ns, cur, alloc) & once) + return; + + if (cur->first_child) + cur = cur->first_child; + else + { + while (!cur->next_sibling) + { + cur = cur->parent; + + if (cur == n) return; + } + + cur = cur->next_sibling; + } + } + + break; + } + + case axis_following_sibling: + { + for (xml_node_struct* c = n->next_sibling; c; c = c->next_sibling) + if (step_push(ns, c, alloc) & once) + return; + + break; + } + + case axis_preceding_sibling: + { + for (xml_node_struct* c = n->prev_sibling_c; c->next_sibling; c = c->prev_sibling_c) + if (step_push(ns, c, alloc) & once) + return; + + break; + } + + case axis_following: + { + xml_node_struct* cur = n; + + // exit from this node so that we don't include descendants + while (!cur->next_sibling) + { + cur = cur->parent; + + if (!cur) return; + } + + cur = cur->next_sibling; + + while (cur) + { + if (step_push(ns, cur, alloc) & once) + return; + + if (cur->first_child) + cur = cur->first_child; + else + { + while (!cur->next_sibling) + { + cur = cur->parent; + + if (!cur) return; + } + + cur = cur->next_sibling; + } + } + + break; + } + + case axis_preceding: + { + xml_node_struct* cur = n; + + // exit from this node so that we don't include descendants + while (!cur->prev_sibling_c->next_sibling) + { + cur = cur->parent; + + if (!cur) return; + } + + cur = cur->prev_sibling_c; + + while (cur) + { + if (cur->first_child) + cur = cur->first_child->prev_sibling_c; + else + { + // leaf node, can't be ancestor + if (step_push(ns, cur, alloc) & once) + return; + + while (!cur->prev_sibling_c->next_sibling) + { + cur = cur->parent; + + if (!cur) return; + + if (!node_is_ancestor(cur, n)) + if (step_push(ns, cur, alloc) & once) + return; + } + + cur = cur->prev_sibling_c; + } + } + + break; + } + + case axis_ancestor: + case axis_ancestor_or_self: + { + if (axis == axis_ancestor_or_self) + if (step_push(ns, n, alloc) & once) + return; + + xml_node_struct* cur = n->parent; + + while (cur) + { + if (step_push(ns, cur, alloc) & once) + return; + + cur = cur->parent; + } + + break; + } + + case axis_self: + { + step_push(ns, n, alloc); + + break; + } + + case axis_parent: + { + if (n->parent) + step_push(ns, n->parent, alloc); + + break; + } + + default: + assert(!"Unimplemented axis"); + } + } + + template void step_fill(xpath_node_set_raw& ns, xml_attribute_struct* a, xml_node_struct* p, xpath_allocator* alloc, bool once, T v) + { + const axis_t axis = T::axis; + + switch (axis) + { + case axis_ancestor: + case axis_ancestor_or_self: + { + if (axis == axis_ancestor_or_self && _test == nodetest_type_node) // reject attributes based on principal node type test + if (step_push(ns, a, p, alloc) & once) + return; + + xml_node_struct* cur = p; + + while (cur) + { + if (step_push(ns, cur, alloc) & once) + return; + + cur = cur->parent; + } + + break; + } + + case axis_descendant_or_self: + case axis_self: + { + if (_test == nodetest_type_node) // reject attributes based on principal node type test + step_push(ns, a, p, alloc); + + break; + } + + case axis_following: + { + xml_node_struct* cur = p; + + while (cur) + { + if (cur->first_child) + cur = cur->first_child; + else + { + while (!cur->next_sibling) + { + cur = cur->parent; + + if (!cur) return; + } + + cur = cur->next_sibling; + } + + if (step_push(ns, cur, alloc) & once) + return; + } + + break; + } + + case axis_parent: + { + step_push(ns, p, alloc); + + break; + } + + case axis_preceding: + { + // preceding:: axis does not include attribute nodes and attribute ancestors (they are the same as parent's ancestors), so we can reuse node preceding + step_fill(ns, p, alloc, once, v); + break; + } + + default: + assert(!"Unimplemented axis"); + } + } + + template void step_fill(xpath_node_set_raw& ns, const xpath_node& xn, xpath_allocator* alloc, bool once, T v) + { + const axis_t axis = T::axis; + const bool axis_has_attributes = (axis == axis_ancestor || axis == axis_ancestor_or_self || axis == axis_descendant_or_self || axis == axis_following || axis == axis_parent || axis == axis_preceding || axis == axis_self); + + if (xn.node()) + step_fill(ns, xn.node().internal_object(), alloc, once, v); + else if (axis_has_attributes && xn.attribute() && xn.parent()) + step_fill(ns, xn.attribute().internal_object(), xn.parent().internal_object(), alloc, once, v); + } + + template xpath_node_set_raw step_do(const xpath_context& c, const xpath_stack& stack, nodeset_eval_t eval, T v) + { + const axis_t axis = T::axis; + const bool axis_reverse = (axis == axis_ancestor || axis == axis_ancestor_or_self || axis == axis_preceding || axis == axis_preceding_sibling); + const xpath_node_set::type_t axis_type = axis_reverse ? xpath_node_set::type_sorted_reverse : xpath_node_set::type_sorted; + + bool once = + (axis == axis_attribute && _test == nodetest_name) || + (!_right && eval_once(axis_type, eval)) || + (_right && !_right->_next && _right->_test == predicate_constant_one); + + xpath_node_set_raw ns; + ns.set_type(axis_type); + + if (_left) + { + xpath_node_set_raw s = _left->eval_node_set(c, stack, nodeset_eval_all); + + // self axis preserves the original order + if (axis == axis_self) ns.set_type(s.type()); + + for (const xpath_node* it = s.begin(); it != s.end(); ++it) + { + size_t size = ns.size(); + + // in general, all axes generate elements in a particular order, but there is no order guarantee if axis is applied to two nodes + if (axis != axis_self && size != 0) ns.set_type(xpath_node_set::type_unsorted); + + step_fill(ns, *it, stack.result, once, v); + if (_right) apply_predicates(ns, size, stack, eval); + } + } + else + { + step_fill(ns, c.n, stack.result, once, v); + if (_right) apply_predicates(ns, 0, stack, eval); + } + + // child, attribute and self axes always generate unique set of nodes + // for other axis, if the set stayed sorted, it stayed unique because the traversal algorithms do not visit the same node twice + if (axis != axis_child && axis != axis_attribute && axis != axis_self && ns.type() == xpath_node_set::type_unsorted) + ns.remove_duplicates(); + + return ns; + } + + public: + xpath_ast_node(ast_type_t type, xpath_value_type rettype_, const char_t* value): + _type(static_cast(type)), _rettype(static_cast(rettype_)), _axis(0), _test(0), _left(0), _right(0), _next(0) + { + assert(type == ast_string_constant); + _data.string = value; + } + + xpath_ast_node(ast_type_t type, xpath_value_type rettype_, double value): + _type(static_cast(type)), _rettype(static_cast(rettype_)), _axis(0), _test(0), _left(0), _right(0), _next(0) + { + assert(type == ast_number_constant); + _data.number = value; + } + + xpath_ast_node(ast_type_t type, xpath_value_type rettype_, xpath_variable* value): + _type(static_cast(type)), _rettype(static_cast(rettype_)), _axis(0), _test(0), _left(0), _right(0), _next(0) + { + assert(type == ast_variable); + _data.variable = value; + } + + xpath_ast_node(ast_type_t type, xpath_value_type rettype_, xpath_ast_node* left = 0, xpath_ast_node* right = 0): + _type(static_cast(type)), _rettype(static_cast(rettype_)), _axis(0), _test(0), _left(left), _right(right), _next(0) + { + } + + xpath_ast_node(ast_type_t type, xpath_ast_node* left, axis_t axis, nodetest_t test, const char_t* contents): + _type(static_cast(type)), _rettype(xpath_type_node_set), _axis(static_cast(axis)), _test(static_cast(test)), _left(left), _right(0), _next(0) + { + assert(type == ast_step); + _data.nodetest = contents; + } + + xpath_ast_node(ast_type_t type, xpath_ast_node* left, xpath_ast_node* right, predicate_t test): + _type(static_cast(type)), _rettype(xpath_type_node_set), _axis(0), _test(static_cast(test)), _left(left), _right(right), _next(0) + { + assert(type == ast_filter || type == ast_predicate); + } + + void set_next(xpath_ast_node* value) + { + _next = value; + } + + void set_right(xpath_ast_node* value) + { + _right = value; + } + + bool eval_boolean(const xpath_context& c, const xpath_stack& stack) + { + switch (_type) + { + case ast_op_or: + return _left->eval_boolean(c, stack) || _right->eval_boolean(c, stack); + + case ast_op_and: + return _left->eval_boolean(c, stack) && _right->eval_boolean(c, stack); + + case ast_op_equal: + return compare_eq(_left, _right, c, stack, equal_to()); + + case ast_op_not_equal: + return compare_eq(_left, _right, c, stack, not_equal_to()); + + case ast_op_less: + return compare_rel(_left, _right, c, stack, less()); + + case ast_op_greater: + return compare_rel(_right, _left, c, stack, less()); + + case ast_op_less_or_equal: + return compare_rel(_left, _right, c, stack, less_equal()); + + case ast_op_greater_or_equal: + return compare_rel(_right, _left, c, stack, less_equal()); + + case ast_func_starts_with: + { + xpath_allocator_capture cr(stack.result); + + xpath_string lr = _left->eval_string(c, stack); + xpath_string rr = _right->eval_string(c, stack); + + return starts_with(lr.c_str(), rr.c_str()); + } + + case ast_func_contains: + { + xpath_allocator_capture cr(stack.result); + + xpath_string lr = _left->eval_string(c, stack); + xpath_string rr = _right->eval_string(c, stack); + + return find_substring(lr.c_str(), rr.c_str()) != 0; + } + + case ast_func_boolean: + return _left->eval_boolean(c, stack); + + case ast_func_not: + return !_left->eval_boolean(c, stack); + + case ast_func_true: + return true; + + case ast_func_false: + return false; + + case ast_func_lang: + { + if (c.n.attribute()) return false; + + xpath_allocator_capture cr(stack.result); + + xpath_string lang = _left->eval_string(c, stack); + + for (xml_node n = c.n.node(); n; n = n.parent()) + { + xml_attribute a = n.attribute(PUGIXML_TEXT("xml:lang")); + + if (a) + { + const char_t* value = a.value(); + + // strnicmp / strncasecmp is not portable + for (const char_t* lit = lang.c_str(); *lit; ++lit) + { + if (tolower_ascii(*lit) != tolower_ascii(*value)) return false; + ++value; + } + + return *value == 0 || *value == '-'; + } + } + + return false; + } + + case ast_opt_compare_attribute: + { + const char_t* value = (_right->_type == ast_string_constant) ? _right->_data.string : _right->_data.variable->get_string(); + + xml_attribute attr = c.n.node().attribute(_left->_data.nodetest); + + return attr && strequal(attr.value(), value) && is_xpath_attribute(attr.name()); + } + + case ast_variable: + { + assert(_rettype == _data.variable->type()); + + if (_rettype == xpath_type_boolean) + return _data.variable->get_boolean(); + + // fallthrough to type conversion + } + + default: + { + switch (_rettype) + { + case xpath_type_number: + return convert_number_to_boolean(eval_number(c, stack)); + + case xpath_type_string: + { + xpath_allocator_capture cr(stack.result); + + return !eval_string(c, stack).empty(); + } + + case xpath_type_node_set: + { + xpath_allocator_capture cr(stack.result); + + return !eval_node_set(c, stack, nodeset_eval_any).empty(); + } + + default: + assert(!"Wrong expression for return type boolean"); + return false; + } + } + } + } + + double eval_number(const xpath_context& c, const xpath_stack& stack) + { + switch (_type) + { + case ast_op_add: + return _left->eval_number(c, stack) + _right->eval_number(c, stack); + + case ast_op_subtract: + return _left->eval_number(c, stack) - _right->eval_number(c, stack); + + case ast_op_multiply: + return _left->eval_number(c, stack) * _right->eval_number(c, stack); + + case ast_op_divide: + return _left->eval_number(c, stack) / _right->eval_number(c, stack); + + case ast_op_mod: + return fmod(_left->eval_number(c, stack), _right->eval_number(c, stack)); + + case ast_op_negate: + return -_left->eval_number(c, stack); + + case ast_number_constant: + return _data.number; + + case ast_func_last: + return static_cast(c.size); + + case ast_func_position: + return static_cast(c.position); + + case ast_func_count: + { + xpath_allocator_capture cr(stack.result); + + return static_cast(_left->eval_node_set(c, stack, nodeset_eval_all).size()); + } + + case ast_func_string_length_0: + { + xpath_allocator_capture cr(stack.result); + + return static_cast(string_value(c.n, stack.result).length()); + } + + case ast_func_string_length_1: + { + xpath_allocator_capture cr(stack.result); + + return static_cast(_left->eval_string(c, stack).length()); + } + + case ast_func_number_0: + { + xpath_allocator_capture cr(stack.result); + + return convert_string_to_number(string_value(c.n, stack.result).c_str()); + } + + case ast_func_number_1: + return _left->eval_number(c, stack); + + case ast_func_sum: + { + xpath_allocator_capture cr(stack.result); + + double r = 0; + + xpath_node_set_raw ns = _left->eval_node_set(c, stack, nodeset_eval_all); + + for (const xpath_node* it = ns.begin(); it != ns.end(); ++it) + { + xpath_allocator_capture cri(stack.result); + + r += convert_string_to_number(string_value(*it, stack.result).c_str()); + } + + return r; + } + + case ast_func_floor: + { + double r = _left->eval_number(c, stack); + + return r == r ? floor(r) : r; + } + + case ast_func_ceiling: + { + double r = _left->eval_number(c, stack); + + return r == r ? ceil(r) : r; + } + + case ast_func_round: + return round_nearest_nzero(_left->eval_number(c, stack)); + + case ast_variable: + { + assert(_rettype == _data.variable->type()); + + if (_rettype == xpath_type_number) + return _data.variable->get_number(); + + // fallthrough to type conversion + } + + default: + { + switch (_rettype) + { + case xpath_type_boolean: + return eval_boolean(c, stack) ? 1 : 0; + + case xpath_type_string: + { + xpath_allocator_capture cr(stack.result); + + return convert_string_to_number(eval_string(c, stack).c_str()); + } + + case xpath_type_node_set: + { + xpath_allocator_capture cr(stack.result); + + return convert_string_to_number(eval_string(c, stack).c_str()); + } + + default: + assert(!"Wrong expression for return type number"); + return 0; + } + + } + } + } + + xpath_string eval_string_concat(const xpath_context& c, const xpath_stack& stack) + { + assert(_type == ast_func_concat); + + xpath_allocator_capture ct(stack.temp); + + // count the string number + size_t count = 1; + for (xpath_ast_node* nc = _right; nc; nc = nc->_next) count++; + + // gather all strings + xpath_string static_buffer[4]; + xpath_string* buffer = static_buffer; + + // allocate on-heap for large concats + if (count > sizeof(static_buffer) / sizeof(static_buffer[0])) + { + buffer = static_cast(stack.temp->allocate(count * sizeof(xpath_string))); + assert(buffer); + } + + // evaluate all strings to temporary stack + xpath_stack swapped_stack = {stack.temp, stack.result}; + + buffer[0] = _left->eval_string(c, swapped_stack); + + size_t pos = 1; + for (xpath_ast_node* n = _right; n; n = n->_next, ++pos) buffer[pos] = n->eval_string(c, swapped_stack); + assert(pos == count); + + // get total length + size_t length = 0; + for (size_t i = 0; i < count; ++i) length += buffer[i].length(); + + // create final string + char_t* result = static_cast(stack.result->allocate((length + 1) * sizeof(char_t))); + assert(result); + + char_t* ri = result; + + for (size_t j = 0; j < count; ++j) + for (const char_t* bi = buffer[j].c_str(); *bi; ++bi) + *ri++ = *bi; + + *ri = 0; + + return xpath_string::from_heap_preallocated(result, ri); + } + + xpath_string eval_string(const xpath_context& c, const xpath_stack& stack) + { + switch (_type) + { + case ast_string_constant: + return xpath_string::from_const(_data.string); + + case ast_func_local_name_0: + { + xpath_node na = c.n; + + return xpath_string::from_const(local_name(na)); + } + + case ast_func_local_name_1: + { + xpath_allocator_capture cr(stack.result); + + xpath_node_set_raw ns = _left->eval_node_set(c, stack, nodeset_eval_first); + xpath_node na = ns.first(); + + return xpath_string::from_const(local_name(na)); + } + + case ast_func_name_0: + { + xpath_node na = c.n; + + return xpath_string::from_const(qualified_name(na)); + } + + case ast_func_name_1: + { + xpath_allocator_capture cr(stack.result); + + xpath_node_set_raw ns = _left->eval_node_set(c, stack, nodeset_eval_first); + xpath_node na = ns.first(); + + return xpath_string::from_const(qualified_name(na)); + } + + case ast_func_namespace_uri_0: + { + xpath_node na = c.n; + + return xpath_string::from_const(namespace_uri(na)); + } + + case ast_func_namespace_uri_1: + { + xpath_allocator_capture cr(stack.result); + + xpath_node_set_raw ns = _left->eval_node_set(c, stack, nodeset_eval_first); + xpath_node na = ns.first(); + + return xpath_string::from_const(namespace_uri(na)); + } + + case ast_func_string_0: + return string_value(c.n, stack.result); + + case ast_func_string_1: + return _left->eval_string(c, stack); + + case ast_func_concat: + return eval_string_concat(c, stack); + + case ast_func_substring_before: + { + xpath_allocator_capture cr(stack.temp); + + xpath_stack swapped_stack = {stack.temp, stack.result}; + + xpath_string s = _left->eval_string(c, swapped_stack); + xpath_string p = _right->eval_string(c, swapped_stack); + + const char_t* pos = find_substring(s.c_str(), p.c_str()); + + return pos ? xpath_string::from_heap(s.c_str(), pos, stack.result) : xpath_string(); + } + + case ast_func_substring_after: + { + xpath_allocator_capture cr(stack.temp); + + xpath_stack swapped_stack = {stack.temp, stack.result}; + + xpath_string s = _left->eval_string(c, swapped_stack); + xpath_string p = _right->eval_string(c, swapped_stack); + + const char_t* pos = find_substring(s.c_str(), p.c_str()); + if (!pos) return xpath_string(); + + const char_t* rbegin = pos + p.length(); + const char_t* rend = s.c_str() + s.length(); + + return s.uses_heap() ? xpath_string::from_heap(rbegin, rend, stack.result) : xpath_string::from_const(rbegin); + } + + case ast_func_substring_2: + { + xpath_allocator_capture cr(stack.temp); + + xpath_stack swapped_stack = {stack.temp, stack.result}; + + xpath_string s = _left->eval_string(c, swapped_stack); + size_t s_length = s.length(); + + double first = round_nearest(_right->eval_number(c, stack)); + + if (is_nan(first)) return xpath_string(); // NaN + else if (first >= s_length + 1) return xpath_string(); + + size_t pos = first < 1 ? 1 : static_cast(first); + assert(1 <= pos && pos <= s_length + 1); + + const char_t* rbegin = s.c_str() + (pos - 1); + const char_t* rend = s.c_str() + s.length(); + + return s.uses_heap() ? xpath_string::from_heap(rbegin, rend, stack.result) : xpath_string::from_const(rbegin); + } + + case ast_func_substring_3: + { + xpath_allocator_capture cr(stack.temp); + + xpath_stack swapped_stack = {stack.temp, stack.result}; + + xpath_string s = _left->eval_string(c, swapped_stack); + size_t s_length = s.length(); + + double first = round_nearest(_right->eval_number(c, stack)); + double last = first + round_nearest(_right->_next->eval_number(c, stack)); + + if (is_nan(first) || is_nan(last)) return xpath_string(); + else if (first >= s_length + 1) return xpath_string(); + else if (first >= last) return xpath_string(); + else if (last < 1) return xpath_string(); + + size_t pos = first < 1 ? 1 : static_cast(first); + size_t end = last >= s_length + 1 ? s_length + 1 : static_cast(last); + + assert(1 <= pos && pos <= end && end <= s_length + 1); + const char_t* rbegin = s.c_str() + (pos - 1); + const char_t* rend = s.c_str() + (end - 1); + + return (end == s_length + 1 && !s.uses_heap()) ? xpath_string::from_const(rbegin) : xpath_string::from_heap(rbegin, rend, stack.result); + } + + case ast_func_normalize_space_0: + { + xpath_string s = string_value(c.n, stack.result); + + char_t* begin = s.data(stack.result); + char_t* end = normalize_space(begin); + + return xpath_string::from_heap_preallocated(begin, end); + } + + case ast_func_normalize_space_1: + { + xpath_string s = _left->eval_string(c, stack); + + char_t* begin = s.data(stack.result); + char_t* end = normalize_space(begin); + + return xpath_string::from_heap_preallocated(begin, end); + } + + case ast_func_translate: + { + xpath_allocator_capture cr(stack.temp); + + xpath_stack swapped_stack = {stack.temp, stack.result}; + + xpath_string s = _left->eval_string(c, stack); + xpath_string from = _right->eval_string(c, swapped_stack); + xpath_string to = _right->_next->eval_string(c, swapped_stack); + + char_t* begin = s.data(stack.result); + char_t* end = translate(begin, from.c_str(), to.c_str(), to.length()); + + return xpath_string::from_heap_preallocated(begin, end); + } + + case ast_opt_translate_table: + { + xpath_string s = _left->eval_string(c, stack); + + char_t* begin = s.data(stack.result); + char_t* end = translate_table(begin, _data.table); + + return xpath_string::from_heap_preallocated(begin, end); + } + + case ast_variable: + { + assert(_rettype == _data.variable->type()); + + if (_rettype == xpath_type_string) + return xpath_string::from_const(_data.variable->get_string()); + + // fallthrough to type conversion + } + + default: + { + switch (_rettype) + { + case xpath_type_boolean: + return xpath_string::from_const(eval_boolean(c, stack) ? PUGIXML_TEXT("true") : PUGIXML_TEXT("false")); + + case xpath_type_number: + return convert_number_to_string(eval_number(c, stack), stack.result); + + case xpath_type_node_set: + { + xpath_allocator_capture cr(stack.temp); + + xpath_stack swapped_stack = {stack.temp, stack.result}; + + xpath_node_set_raw ns = eval_node_set(c, swapped_stack, nodeset_eval_first); + return ns.empty() ? xpath_string() : string_value(ns.first(), stack.result); + } + + default: + assert(!"Wrong expression for return type string"); + return xpath_string(); + } + } + } + } + + xpath_node_set_raw eval_node_set(const xpath_context& c, const xpath_stack& stack, nodeset_eval_t eval) + { + switch (_type) + { + case ast_op_union: + { + xpath_allocator_capture cr(stack.temp); + + xpath_stack swapped_stack = {stack.temp, stack.result}; + + xpath_node_set_raw ls = _left->eval_node_set(c, swapped_stack, eval); + xpath_node_set_raw rs = _right->eval_node_set(c, stack, eval); + + // we can optimize merging two sorted sets, but this is a very rare operation, so don't bother + rs.set_type(xpath_node_set::type_unsorted); + + rs.append(ls.begin(), ls.end(), stack.result); + rs.remove_duplicates(); + + return rs; + } + + case ast_filter: + { + xpath_node_set_raw set = _left->eval_node_set(c, stack, _test == predicate_constant_one ? nodeset_eval_first : nodeset_eval_all); + + // either expression is a number or it contains position() call; sort by document order + if (_test != predicate_posinv) set.sort_do(); + + bool once = eval_once(set.type(), eval); + + apply_predicate(set, 0, stack, once); + + return set; + } + + case ast_func_id: + return xpath_node_set_raw(); + + case ast_step: + { + switch (_axis) + { + case axis_ancestor: + return step_do(c, stack, eval, axis_to_type()); + + case axis_ancestor_or_self: + return step_do(c, stack, eval, axis_to_type()); + + case axis_attribute: + return step_do(c, stack, eval, axis_to_type()); + + case axis_child: + return step_do(c, stack, eval, axis_to_type()); + + case axis_descendant: + return step_do(c, stack, eval, axis_to_type()); + + case axis_descendant_or_self: + return step_do(c, stack, eval, axis_to_type()); + + case axis_following: + return step_do(c, stack, eval, axis_to_type()); + + case axis_following_sibling: + return step_do(c, stack, eval, axis_to_type()); + + case axis_namespace: + // namespaced axis is not supported + return xpath_node_set_raw(); + + case axis_parent: + return step_do(c, stack, eval, axis_to_type()); + + case axis_preceding: + return step_do(c, stack, eval, axis_to_type()); + + case axis_preceding_sibling: + return step_do(c, stack, eval, axis_to_type()); + + case axis_self: + return step_do(c, stack, eval, axis_to_type()); + + default: + assert(!"Unknown axis"); + return xpath_node_set_raw(); + } + } + + case ast_step_root: + { + assert(!_right); // root step can't have any predicates + + xpath_node_set_raw ns; + + ns.set_type(xpath_node_set::type_sorted); + + if (c.n.node()) ns.push_back(c.n.node().root(), stack.result); + else if (c.n.attribute()) ns.push_back(c.n.parent().root(), stack.result); + + return ns; + } + + case ast_variable: + { + assert(_rettype == _data.variable->type()); + + if (_rettype == xpath_type_node_set) + { + const xpath_node_set& s = _data.variable->get_node_set(); + + xpath_node_set_raw ns; + + ns.set_type(s.type()); + ns.append(s.begin(), s.end(), stack.result); + + return ns; + } + + // fallthrough to type conversion + } + + default: + assert(!"Wrong expression for return type node set"); + return xpath_node_set_raw(); + } + } + + void optimize(xpath_allocator* alloc) + { + if (_left) _left->optimize(alloc); + if (_right) _right->optimize(alloc); + if (_next) _next->optimize(alloc); + + optimize_self(alloc); + } + + void optimize_self(xpath_allocator* alloc) + { + // Rewrite [position()=expr] with [expr] + // Note that this step has to go before classification to recognize [position()=1] + if ((_type == ast_filter || _type == ast_predicate) && + _right->_type == ast_op_equal && _right->_left->_type == ast_func_position && _right->_right->_rettype == xpath_type_number) + { + _right = _right->_right; + } + + // Classify filter/predicate ops to perform various optimizations during evaluation + if (_type == ast_filter || _type == ast_predicate) + { + assert(_test == predicate_default); + + if (_right->_type == ast_number_constant && _right->_data.number == 1.0) + _test = predicate_constant_one; + else if (_right->_rettype == xpath_type_number && (_right->_type == ast_number_constant || _right->_type == ast_variable || _right->_type == ast_func_last)) + _test = predicate_constant; + else if (_right->_rettype != xpath_type_number && _right->is_posinv_expr()) + _test = predicate_posinv; + } + + // Rewrite descendant-or-self::node()/child::foo with descendant::foo + // The former is a full form of //foo, the latter is much faster since it executes the node test immediately + // Do a similar kind of rewrite for self/descendant/descendant-or-self axes + // Note that we only rewrite positionally invariant steps (//foo[1] != /descendant::foo[1]) + if (_type == ast_step && (_axis == axis_child || _axis == axis_self || _axis == axis_descendant || _axis == axis_descendant_or_self) && _left && + _left->_type == ast_step && _left->_axis == axis_descendant_or_self && _left->_test == nodetest_type_node && !_left->_right && + is_posinv_step()) + { + if (_axis == axis_child || _axis == axis_descendant) + _axis = axis_descendant; + else + _axis = axis_descendant_or_self; + + _left = _left->_left; + } + + // Use optimized lookup table implementation for translate() with constant arguments + if (_type == ast_func_translate && _right->_type == ast_string_constant && _right->_next->_type == ast_string_constant) + { + unsigned char* table = translate_table_generate(alloc, _right->_data.string, _right->_next->_data.string); + + if (table) + { + _type = ast_opt_translate_table; + _data.table = table; + } + } + + // Use optimized path for @attr = 'value' or @attr = $value + if (_type == ast_op_equal && + _left->_type == ast_step && _left->_axis == axis_attribute && _left->_test == nodetest_name && !_left->_left && !_left->_right && + (_right->_type == ast_string_constant || (_right->_type == ast_variable && _right->_rettype == xpath_type_string))) + { + _type = ast_opt_compare_attribute; + } + } + + bool is_posinv_expr() const + { + switch (_type) + { + case ast_func_position: + case ast_func_last: + return false; + + case ast_string_constant: + case ast_number_constant: + case ast_variable: + return true; + + case ast_step: + case ast_step_root: + return true; + + case ast_predicate: + case ast_filter: + return true; + + default: + if (_left && !_left->is_posinv_expr()) return false; + + for (xpath_ast_node* n = _right; n; n = n->_next) + if (!n->is_posinv_expr()) return false; + + return true; + } + } + + bool is_posinv_step() const + { + assert(_type == ast_step); + + for (xpath_ast_node* n = _right; n; n = n->_next) + { + assert(n->_type == ast_predicate); + + if (n->_test != predicate_posinv) + return false; + } + + return true; + } + + xpath_value_type rettype() const + { + return static_cast(_rettype); + } + }; + + struct xpath_parser + { + xpath_allocator* _alloc; + xpath_lexer _lexer; + + const char_t* _query; + xpath_variable_set* _variables; + + xpath_parse_result* _result; + + char_t _scratch[32]; + + #ifdef PUGIXML_NO_EXCEPTIONS + jmp_buf _error_handler; + #endif + + void throw_error(const char* message) + { + _result->error = message; + _result->offset = _lexer.current_pos() - _query; + + #ifdef PUGIXML_NO_EXCEPTIONS + longjmp(_error_handler, 1); + #else + throw xpath_exception(*_result); + #endif + } + + void throw_error_oom() + { + #ifdef PUGIXML_NO_EXCEPTIONS + throw_error("Out of memory"); + #else + throw std::bad_alloc(); + #endif + } + + void* alloc_node() + { + void* result = _alloc->allocate_nothrow(sizeof(xpath_ast_node)); + + if (!result) throw_error_oom(); + + return result; + } + + const char_t* alloc_string(const xpath_lexer_string& value) + { + if (value.begin) + { + size_t length = static_cast(value.end - value.begin); + + char_t* c = static_cast(_alloc->allocate_nothrow((length + 1) * sizeof(char_t))); + if (!c) throw_error_oom(); + assert(c); // workaround for clang static analysis + + memcpy(c, value.begin, length * sizeof(char_t)); + c[length] = 0; + + return c; + } + else return 0; + } + + xpath_ast_node* parse_function_helper(ast_type_t type0, ast_type_t type1, size_t argc, xpath_ast_node* args[2]) + { + assert(argc <= 1); + + if (argc == 1 && args[0]->rettype() != xpath_type_node_set) throw_error("Function has to be applied to node set"); + + return new (alloc_node()) xpath_ast_node(argc == 0 ? type0 : type1, xpath_type_string, args[0]); + } + + xpath_ast_node* parse_function(const xpath_lexer_string& name, size_t argc, xpath_ast_node* args[2]) + { + switch (name.begin[0]) + { + case 'b': + if (name == PUGIXML_TEXT("boolean") && argc == 1) + return new (alloc_node()) xpath_ast_node(ast_func_boolean, xpath_type_boolean, args[0]); + + break; + + case 'c': + if (name == PUGIXML_TEXT("count") && argc == 1) + { + if (args[0]->rettype() != xpath_type_node_set) throw_error("Function has to be applied to node set"); + return new (alloc_node()) xpath_ast_node(ast_func_count, xpath_type_number, args[0]); + } + else if (name == PUGIXML_TEXT("contains") && argc == 2) + return new (alloc_node()) xpath_ast_node(ast_func_contains, xpath_type_boolean, args[0], args[1]); + else if (name == PUGIXML_TEXT("concat") && argc >= 2) + return new (alloc_node()) xpath_ast_node(ast_func_concat, xpath_type_string, args[0], args[1]); + else if (name == PUGIXML_TEXT("ceiling") && argc == 1) + return new (alloc_node()) xpath_ast_node(ast_func_ceiling, xpath_type_number, args[0]); + + break; + + case 'f': + if (name == PUGIXML_TEXT("false") && argc == 0) + return new (alloc_node()) xpath_ast_node(ast_func_false, xpath_type_boolean); + else if (name == PUGIXML_TEXT("floor") && argc == 1) + return new (alloc_node()) xpath_ast_node(ast_func_floor, xpath_type_number, args[0]); + + break; + + case 'i': + if (name == PUGIXML_TEXT("id") && argc == 1) + return new (alloc_node()) xpath_ast_node(ast_func_id, xpath_type_node_set, args[0]); + + break; + + case 'l': + if (name == PUGIXML_TEXT("last") && argc == 0) + return new (alloc_node()) xpath_ast_node(ast_func_last, xpath_type_number); + else if (name == PUGIXML_TEXT("lang") && argc == 1) + return new (alloc_node()) xpath_ast_node(ast_func_lang, xpath_type_boolean, args[0]); + else if (name == PUGIXML_TEXT("local-name") && argc <= 1) + return parse_function_helper(ast_func_local_name_0, ast_func_local_name_1, argc, args); + + break; + + case 'n': + if (name == PUGIXML_TEXT("name") && argc <= 1) + return parse_function_helper(ast_func_name_0, ast_func_name_1, argc, args); + else if (name == PUGIXML_TEXT("namespace-uri") && argc <= 1) + return parse_function_helper(ast_func_namespace_uri_0, ast_func_namespace_uri_1, argc, args); + else if (name == PUGIXML_TEXT("normalize-space") && argc <= 1) + return new (alloc_node()) xpath_ast_node(argc == 0 ? ast_func_normalize_space_0 : ast_func_normalize_space_1, xpath_type_string, args[0], args[1]); + else if (name == PUGIXML_TEXT("not") && argc == 1) + return new (alloc_node()) xpath_ast_node(ast_func_not, xpath_type_boolean, args[0]); + else if (name == PUGIXML_TEXT("number") && argc <= 1) + return new (alloc_node()) xpath_ast_node(argc == 0 ? ast_func_number_0 : ast_func_number_1, xpath_type_number, args[0]); + + break; + + case 'p': + if (name == PUGIXML_TEXT("position") && argc == 0) + return new (alloc_node()) xpath_ast_node(ast_func_position, xpath_type_number); + + break; + + case 'r': + if (name == PUGIXML_TEXT("round") && argc == 1) + return new (alloc_node()) xpath_ast_node(ast_func_round, xpath_type_number, args[0]); + + break; + + case 's': + if (name == PUGIXML_TEXT("string") && argc <= 1) + return new (alloc_node()) xpath_ast_node(argc == 0 ? ast_func_string_0 : ast_func_string_1, xpath_type_string, args[0]); + else if (name == PUGIXML_TEXT("string-length") && argc <= 1) + return new (alloc_node()) xpath_ast_node(argc == 0 ? ast_func_string_length_0 : ast_func_string_length_1, xpath_type_number, args[0]); + else if (name == PUGIXML_TEXT("starts-with") && argc == 2) + return new (alloc_node()) xpath_ast_node(ast_func_starts_with, xpath_type_boolean, args[0], args[1]); + else if (name == PUGIXML_TEXT("substring-before") && argc == 2) + return new (alloc_node()) xpath_ast_node(ast_func_substring_before, xpath_type_string, args[0], args[1]); + else if (name == PUGIXML_TEXT("substring-after") && argc == 2) + return new (alloc_node()) xpath_ast_node(ast_func_substring_after, xpath_type_string, args[0], args[1]); + else if (name == PUGIXML_TEXT("substring") && (argc == 2 || argc == 3)) + return new (alloc_node()) xpath_ast_node(argc == 2 ? ast_func_substring_2 : ast_func_substring_3, xpath_type_string, args[0], args[1]); + else if (name == PUGIXML_TEXT("sum") && argc == 1) + { + if (args[0]->rettype() != xpath_type_node_set) throw_error("Function has to be applied to node set"); + return new (alloc_node()) xpath_ast_node(ast_func_sum, xpath_type_number, args[0]); + } + + break; + + case 't': + if (name == PUGIXML_TEXT("translate") && argc == 3) + return new (alloc_node()) xpath_ast_node(ast_func_translate, xpath_type_string, args[0], args[1]); + else if (name == PUGIXML_TEXT("true") && argc == 0) + return new (alloc_node()) xpath_ast_node(ast_func_true, xpath_type_boolean); + + break; + + default: + break; + } + + throw_error("Unrecognized function or wrong parameter count"); + + return 0; + } + + axis_t parse_axis_name(const xpath_lexer_string& name, bool& specified) + { + specified = true; + + switch (name.begin[0]) + { + case 'a': + if (name == PUGIXML_TEXT("ancestor")) + return axis_ancestor; + else if (name == PUGIXML_TEXT("ancestor-or-self")) + return axis_ancestor_or_self; + else if (name == PUGIXML_TEXT("attribute")) + return axis_attribute; + + break; + + case 'c': + if (name == PUGIXML_TEXT("child")) + return axis_child; + + break; + + case 'd': + if (name == PUGIXML_TEXT("descendant")) + return axis_descendant; + else if (name == PUGIXML_TEXT("descendant-or-self")) + return axis_descendant_or_self; + + break; + + case 'f': + if (name == PUGIXML_TEXT("following")) + return axis_following; + else if (name == PUGIXML_TEXT("following-sibling")) + return axis_following_sibling; + + break; + + case 'n': + if (name == PUGIXML_TEXT("namespace")) + return axis_namespace; + + break; + + case 'p': + if (name == PUGIXML_TEXT("parent")) + return axis_parent; + else if (name == PUGIXML_TEXT("preceding")) + return axis_preceding; + else if (name == PUGIXML_TEXT("preceding-sibling")) + return axis_preceding_sibling; + + break; + + case 's': + if (name == PUGIXML_TEXT("self")) + return axis_self; + + break; + + default: + break; + } + + specified = false; + return axis_child; + } + + nodetest_t parse_node_test_type(const xpath_lexer_string& name) + { + switch (name.begin[0]) + { + case 'c': + if (name == PUGIXML_TEXT("comment")) + return nodetest_type_comment; + + break; + + case 'n': + if (name == PUGIXML_TEXT("node")) + return nodetest_type_node; + + break; + + case 'p': + if (name == PUGIXML_TEXT("processing-instruction")) + return nodetest_type_pi; + + break; + + case 't': + if (name == PUGIXML_TEXT("text")) + return nodetest_type_text; + + break; + + default: + break; + } + + return nodetest_none; + } + + // PrimaryExpr ::= VariableReference | '(' Expr ')' | Literal | Number | FunctionCall + xpath_ast_node* parse_primary_expression() + { + switch (_lexer.current()) + { + case lex_var_ref: + { + xpath_lexer_string name = _lexer.contents(); + + if (!_variables) + throw_error("Unknown variable: variable set is not provided"); + + xpath_variable* var = 0; + if (!get_variable_scratch(_scratch, _variables, name.begin, name.end, &var)) + throw_error_oom(); + + if (!var) + throw_error("Unknown variable: variable set does not contain the given name"); + + _lexer.next(); + + return new (alloc_node()) xpath_ast_node(ast_variable, var->type(), var); + } + + case lex_open_brace: + { + _lexer.next(); + + xpath_ast_node* n = parse_expression(); + + if (_lexer.current() != lex_close_brace) + throw_error("Unmatched braces"); + + _lexer.next(); + + return n; + } + + case lex_quoted_string: + { + const char_t* value = alloc_string(_lexer.contents()); + + xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_string_constant, xpath_type_string, value); + _lexer.next(); + + return n; + } + + case lex_number: + { + double value = 0; + + if (!convert_string_to_number_scratch(_scratch, _lexer.contents().begin, _lexer.contents().end, &value)) + throw_error_oom(); + + xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_number_constant, xpath_type_number, value); + _lexer.next(); + + return n; + } + + case lex_string: + { + xpath_ast_node* args[2] = {0}; + size_t argc = 0; + + xpath_lexer_string function = _lexer.contents(); + _lexer.next(); + + xpath_ast_node* last_arg = 0; + + if (_lexer.current() != lex_open_brace) + throw_error("Unrecognized function call"); + _lexer.next(); + + if (_lexer.current() != lex_close_brace) + args[argc++] = parse_expression(); + + while (_lexer.current() != lex_close_brace) + { + if (_lexer.current() != lex_comma) + throw_error("No comma between function arguments"); + _lexer.next(); + + xpath_ast_node* n = parse_expression(); + + if (argc < 2) args[argc] = n; + else last_arg->set_next(n); + + argc++; + last_arg = n; + } + + _lexer.next(); + + return parse_function(function, argc, args); + } + + default: + throw_error("Unrecognizable primary expression"); + + return 0; + } + } + + // FilterExpr ::= PrimaryExpr | FilterExpr Predicate + // Predicate ::= '[' PredicateExpr ']' + // PredicateExpr ::= Expr + xpath_ast_node* parse_filter_expression() + { + xpath_ast_node* n = parse_primary_expression(); + + while (_lexer.current() == lex_open_square_brace) + { + _lexer.next(); + + xpath_ast_node* expr = parse_expression(); + + if (n->rettype() != xpath_type_node_set) throw_error("Predicate has to be applied to node set"); + + n = new (alloc_node()) xpath_ast_node(ast_filter, n, expr, predicate_default); + + if (_lexer.current() != lex_close_square_brace) + throw_error("Unmatched square brace"); + + _lexer.next(); + } + + return n; + } + + // Step ::= AxisSpecifier NodeTest Predicate* | AbbreviatedStep + // AxisSpecifier ::= AxisName '::' | '@'? + // NodeTest ::= NameTest | NodeType '(' ')' | 'processing-instruction' '(' Literal ')' + // NameTest ::= '*' | NCName ':' '*' | QName + // AbbreviatedStep ::= '.' | '..' + xpath_ast_node* parse_step(xpath_ast_node* set) + { + if (set && set->rettype() != xpath_type_node_set) + throw_error("Step has to be applied to node set"); + + bool axis_specified = false; + axis_t axis = axis_child; // implied child axis + + if (_lexer.current() == lex_axis_attribute) + { + axis = axis_attribute; + axis_specified = true; + + _lexer.next(); + } + else if (_lexer.current() == lex_dot) + { + _lexer.next(); + + return new (alloc_node()) xpath_ast_node(ast_step, set, axis_self, nodetest_type_node, 0); + } + else if (_lexer.current() == lex_double_dot) + { + _lexer.next(); + + return new (alloc_node()) xpath_ast_node(ast_step, set, axis_parent, nodetest_type_node, 0); + } + + nodetest_t nt_type = nodetest_none; + xpath_lexer_string nt_name; + + if (_lexer.current() == lex_string) + { + // node name test + nt_name = _lexer.contents(); + _lexer.next(); + + // was it an axis name? + if (_lexer.current() == lex_double_colon) + { + // parse axis name + if (axis_specified) throw_error("Two axis specifiers in one step"); + + axis = parse_axis_name(nt_name, axis_specified); + + if (!axis_specified) throw_error("Unknown axis"); + + // read actual node test + _lexer.next(); + + if (_lexer.current() == lex_multiply) + { + nt_type = nodetest_all; + nt_name = xpath_lexer_string(); + _lexer.next(); + } + else if (_lexer.current() == lex_string) + { + nt_name = _lexer.contents(); + _lexer.next(); + } + else throw_error("Unrecognized node test"); + } + + if (nt_type == nodetest_none) + { + // node type test or processing-instruction + if (_lexer.current() == lex_open_brace) + { + _lexer.next(); + + if (_lexer.current() == lex_close_brace) + { + _lexer.next(); + + nt_type = parse_node_test_type(nt_name); + + if (nt_type == nodetest_none) throw_error("Unrecognized node type"); + + nt_name = xpath_lexer_string(); + } + else if (nt_name == PUGIXML_TEXT("processing-instruction")) + { + if (_lexer.current() != lex_quoted_string) + throw_error("Only literals are allowed as arguments to processing-instruction()"); + + nt_type = nodetest_pi; + nt_name = _lexer.contents(); + _lexer.next(); + + if (_lexer.current() != lex_close_brace) + throw_error("Unmatched brace near processing-instruction()"); + _lexer.next(); + } + else + throw_error("Unmatched brace near node type test"); + + } + // QName or NCName:* + else + { + if (nt_name.end - nt_name.begin > 2 && nt_name.end[-2] == ':' && nt_name.end[-1] == '*') // NCName:* + { + nt_name.end--; // erase * + + nt_type = nodetest_all_in_namespace; + } + else nt_type = nodetest_name; + } + } + } + else if (_lexer.current() == lex_multiply) + { + nt_type = nodetest_all; + _lexer.next(); + } + else throw_error("Unrecognized node test"); + + xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_step, set, axis, nt_type, alloc_string(nt_name)); + + xpath_ast_node* last = 0; + + while (_lexer.current() == lex_open_square_brace) + { + _lexer.next(); + + xpath_ast_node* expr = parse_expression(); + + xpath_ast_node* pred = new (alloc_node()) xpath_ast_node(ast_predicate, 0, expr, predicate_default); + + if (_lexer.current() != lex_close_square_brace) + throw_error("Unmatched square brace"); + _lexer.next(); + + if (last) last->set_next(pred); + else n->set_right(pred); + + last = pred; + } + + return n; + } + + // RelativeLocationPath ::= Step | RelativeLocationPath '/' Step | RelativeLocationPath '//' Step + xpath_ast_node* parse_relative_location_path(xpath_ast_node* set) + { + xpath_ast_node* n = parse_step(set); + + while (_lexer.current() == lex_slash || _lexer.current() == lex_double_slash) + { + lexeme_t l = _lexer.current(); + _lexer.next(); + + if (l == lex_double_slash) + n = new (alloc_node()) xpath_ast_node(ast_step, n, axis_descendant_or_self, nodetest_type_node, 0); + + n = parse_step(n); + } + + return n; + } + + // LocationPath ::= RelativeLocationPath | AbsoluteLocationPath + // AbsoluteLocationPath ::= '/' RelativeLocationPath? | '//' RelativeLocationPath + xpath_ast_node* parse_location_path() + { + if (_lexer.current() == lex_slash) + { + _lexer.next(); + + xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_step_root, xpath_type_node_set); + + // relative location path can start from axis_attribute, dot, double_dot, multiply and string lexemes; any other lexeme means standalone root path + lexeme_t l = _lexer.current(); + + if (l == lex_string || l == lex_axis_attribute || l == lex_dot || l == lex_double_dot || l == lex_multiply) + return parse_relative_location_path(n); + else + return n; + } + else if (_lexer.current() == lex_double_slash) + { + _lexer.next(); + + xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_step_root, xpath_type_node_set); + n = new (alloc_node()) xpath_ast_node(ast_step, n, axis_descendant_or_self, nodetest_type_node, 0); + + return parse_relative_location_path(n); + } + + // else clause moved outside of if because of bogus warning 'control may reach end of non-void function being inlined' in gcc 4.0.1 + return parse_relative_location_path(0); + } + + // PathExpr ::= LocationPath + // | FilterExpr + // | FilterExpr '/' RelativeLocationPath + // | FilterExpr '//' RelativeLocationPath + // UnionExpr ::= PathExpr | UnionExpr '|' PathExpr + // UnaryExpr ::= UnionExpr | '-' UnaryExpr + xpath_ast_node* parse_path_or_unary_expression() + { + // Clarification. + // PathExpr begins with either LocationPath or FilterExpr. + // FilterExpr begins with PrimaryExpr + // PrimaryExpr begins with '$' in case of it being a variable reference, + // '(' in case of it being an expression, string literal, number constant or + // function call. + + if (_lexer.current() == lex_var_ref || _lexer.current() == lex_open_brace || + _lexer.current() == lex_quoted_string || _lexer.current() == lex_number || + _lexer.current() == lex_string) + { + if (_lexer.current() == lex_string) + { + // This is either a function call, or not - if not, we shall proceed with location path + const char_t* state = _lexer.state(); + + while (PUGI__IS_CHARTYPE(*state, ct_space)) ++state; + + if (*state != '(') return parse_location_path(); + + // This looks like a function call; however this still can be a node-test. Check it. + if (parse_node_test_type(_lexer.contents()) != nodetest_none) return parse_location_path(); + } + + xpath_ast_node* n = parse_filter_expression(); + + if (_lexer.current() == lex_slash || _lexer.current() == lex_double_slash) + { + lexeme_t l = _lexer.current(); + _lexer.next(); + + if (l == lex_double_slash) + { + if (n->rettype() != xpath_type_node_set) throw_error("Step has to be applied to node set"); + + n = new (alloc_node()) xpath_ast_node(ast_step, n, axis_descendant_or_self, nodetest_type_node, 0); + } + + // select from location path + return parse_relative_location_path(n); + } + + return n; + } + else if (_lexer.current() == lex_minus) + { + _lexer.next(); + + // precedence 7+ - only parses union expressions + xpath_ast_node* expr = parse_expression_rec(parse_path_or_unary_expression(), 7); + + return new (alloc_node()) xpath_ast_node(ast_op_negate, xpath_type_number, expr); + } + else + return parse_location_path(); + } + + struct binary_op_t + { + ast_type_t asttype; + xpath_value_type rettype; + int precedence; + + binary_op_t(): asttype(ast_unknown), rettype(xpath_type_none), precedence(0) + { + } + + binary_op_t(ast_type_t asttype_, xpath_value_type rettype_, int precedence_): asttype(asttype_), rettype(rettype_), precedence(precedence_) + { + } + + static binary_op_t parse(xpath_lexer& lexer) + { + switch (lexer.current()) + { + case lex_string: + if (lexer.contents() == PUGIXML_TEXT("or")) + return binary_op_t(ast_op_or, xpath_type_boolean, 1); + else if (lexer.contents() == PUGIXML_TEXT("and")) + return binary_op_t(ast_op_and, xpath_type_boolean, 2); + else if (lexer.contents() == PUGIXML_TEXT("div")) + return binary_op_t(ast_op_divide, xpath_type_number, 6); + else if (lexer.contents() == PUGIXML_TEXT("mod")) + return binary_op_t(ast_op_mod, xpath_type_number, 6); + else + return binary_op_t(); + + case lex_equal: + return binary_op_t(ast_op_equal, xpath_type_boolean, 3); + + case lex_not_equal: + return binary_op_t(ast_op_not_equal, xpath_type_boolean, 3); + + case lex_less: + return binary_op_t(ast_op_less, xpath_type_boolean, 4); + + case lex_greater: + return binary_op_t(ast_op_greater, xpath_type_boolean, 4); + + case lex_less_or_equal: + return binary_op_t(ast_op_less_or_equal, xpath_type_boolean, 4); + + case lex_greater_or_equal: + return binary_op_t(ast_op_greater_or_equal, xpath_type_boolean, 4); + + case lex_plus: + return binary_op_t(ast_op_add, xpath_type_number, 5); + + case lex_minus: + return binary_op_t(ast_op_subtract, xpath_type_number, 5); + + case lex_multiply: + return binary_op_t(ast_op_multiply, xpath_type_number, 6); + + case lex_union: + return binary_op_t(ast_op_union, xpath_type_node_set, 7); + + default: + return binary_op_t(); + } + } + }; + + xpath_ast_node* parse_expression_rec(xpath_ast_node* lhs, int limit) + { + binary_op_t op = binary_op_t::parse(_lexer); + + while (op.asttype != ast_unknown && op.precedence >= limit) + { + _lexer.next(); + + xpath_ast_node* rhs = parse_path_or_unary_expression(); + + binary_op_t nextop = binary_op_t::parse(_lexer); + + while (nextop.asttype != ast_unknown && nextop.precedence > op.precedence) + { + rhs = parse_expression_rec(rhs, nextop.precedence); + + nextop = binary_op_t::parse(_lexer); + } + + if (op.asttype == ast_op_union && (lhs->rettype() != xpath_type_node_set || rhs->rettype() != xpath_type_node_set)) + throw_error("Union operator has to be applied to node sets"); + + lhs = new (alloc_node()) xpath_ast_node(op.asttype, op.rettype, lhs, rhs); + + op = binary_op_t::parse(_lexer); + } + + return lhs; + } + + // Expr ::= OrExpr + // OrExpr ::= AndExpr | OrExpr 'or' AndExpr + // AndExpr ::= EqualityExpr | AndExpr 'and' EqualityExpr + // EqualityExpr ::= RelationalExpr + // | EqualityExpr '=' RelationalExpr + // | EqualityExpr '!=' RelationalExpr + // RelationalExpr ::= AdditiveExpr + // | RelationalExpr '<' AdditiveExpr + // | RelationalExpr '>' AdditiveExpr + // | RelationalExpr '<=' AdditiveExpr + // | RelationalExpr '>=' AdditiveExpr + // AdditiveExpr ::= MultiplicativeExpr + // | AdditiveExpr '+' MultiplicativeExpr + // | AdditiveExpr '-' MultiplicativeExpr + // MultiplicativeExpr ::= UnaryExpr + // | MultiplicativeExpr '*' UnaryExpr + // | MultiplicativeExpr 'div' UnaryExpr + // | MultiplicativeExpr 'mod' UnaryExpr + xpath_ast_node* parse_expression() + { + return parse_expression_rec(parse_path_or_unary_expression(), 0); + } + + xpath_parser(const char_t* query, xpath_variable_set* variables, xpath_allocator* alloc, xpath_parse_result* result): _alloc(alloc), _lexer(query), _query(query), _variables(variables), _result(result) + { + } + + xpath_ast_node* parse() + { + xpath_ast_node* result = parse_expression(); + + if (_lexer.current() != lex_eof) + { + // there are still unparsed tokens left, error + throw_error("Incorrect query"); + } + + return result; + } + + static xpath_ast_node* parse(const char_t* query, xpath_variable_set* variables, xpath_allocator* alloc, xpath_parse_result* result) + { + xpath_parser parser(query, variables, alloc, result); + + #ifdef PUGIXML_NO_EXCEPTIONS + int error = setjmp(parser._error_handler); + + return (error == 0) ? parser.parse() : 0; + #else + return parser.parse(); + #endif + } + }; + + struct xpath_query_impl + { + static xpath_query_impl* create() + { + void* memory = xml_memory::allocate(sizeof(xpath_query_impl)); + if (!memory) return 0; + + return new (memory) xpath_query_impl(); + } + + static void destroy(xpath_query_impl* impl) + { + // free all allocated pages + impl->alloc.release(); + + // free allocator memory (with the first page) + xml_memory::deallocate(impl); + } + + xpath_query_impl(): root(0), alloc(&block) + { + block.next = 0; + block.capacity = sizeof(block.data); + } + + xpath_ast_node* root; + xpath_allocator alloc; + xpath_memory_block block; + }; + + PUGI__FN xpath_string evaluate_string_impl(xpath_query_impl* impl, const xpath_node& n, xpath_stack_data& sd) + { + if (!impl) return xpath_string(); + + #ifdef PUGIXML_NO_EXCEPTIONS + if (setjmp(sd.error_handler)) return xpath_string(); + #endif + + xpath_context c(n, 1, 1); + + return impl->root->eval_string(c, sd.stack); + } + + PUGI__FN impl::xpath_ast_node* evaluate_node_set_prepare(xpath_query_impl* impl) + { + if (!impl) return 0; + + if (impl->root->rettype() != xpath_type_node_set) + { + #ifdef PUGIXML_NO_EXCEPTIONS + return 0; + #else + xpath_parse_result res; + res.error = "Expression does not evaluate to node set"; + + throw xpath_exception(res); + #endif + } + + return impl->root; + } +PUGI__NS_END + +namespace pugi +{ +#ifndef PUGIXML_NO_EXCEPTIONS + PUGI__FN xpath_exception::xpath_exception(const xpath_parse_result& result_): _result(result_) + { + assert(_result.error); + } + + PUGI__FN const char* xpath_exception::what() const throw() + { + return _result.error; + } + + PUGI__FN const xpath_parse_result& xpath_exception::result() const + { + return _result; + } +#endif + + PUGI__FN xpath_node::xpath_node() + { + } + + PUGI__FN xpath_node::xpath_node(const xml_node& node_): _node(node_) + { + } + + PUGI__FN xpath_node::xpath_node(const xml_attribute& attribute_, const xml_node& parent_): _node(attribute_ ? parent_ : xml_node()), _attribute(attribute_) + { + } + + PUGI__FN xml_node xpath_node::node() const + { + return _attribute ? xml_node() : _node; + } + + PUGI__FN xml_attribute xpath_node::attribute() const + { + return _attribute; + } + + PUGI__FN xml_node xpath_node::parent() const + { + return _attribute ? _node : _node.parent(); + } + + PUGI__FN static void unspecified_bool_xpath_node(xpath_node***) + { + } + + PUGI__FN xpath_node::operator xpath_node::unspecified_bool_type() const + { + return (_node || _attribute) ? unspecified_bool_xpath_node : 0; + } + + PUGI__FN bool xpath_node::operator!() const + { + return !(_node || _attribute); + } + + PUGI__FN bool xpath_node::operator==(const xpath_node& n) const + { + return _node == n._node && _attribute == n._attribute; + } + + PUGI__FN bool xpath_node::operator!=(const xpath_node& n) const + { + return _node != n._node || _attribute != n._attribute; + } + +#ifdef __BORLANDC__ + PUGI__FN bool operator&&(const xpath_node& lhs, bool rhs) + { + return (bool)lhs && rhs; + } + + PUGI__FN bool operator||(const xpath_node& lhs, bool rhs) + { + return (bool)lhs || rhs; + } +#endif + + PUGI__FN void xpath_node_set::_assign(const_iterator begin_, const_iterator end_, type_t type_) + { + assert(begin_ <= end_); + + size_t size_ = static_cast(end_ - begin_); + + if (size_ <= 1) + { + // deallocate old buffer + if (_begin != &_storage) impl::xml_memory::deallocate(_begin); + + // use internal buffer + if (begin_ != end_) _storage = *begin_; + + _begin = &_storage; + _end = &_storage + size_; + _type = type_; + } + else + { + // make heap copy + xpath_node* storage = static_cast(impl::xml_memory::allocate(size_ * sizeof(xpath_node))); + + if (!storage) + { + #ifdef PUGIXML_NO_EXCEPTIONS + return; + #else + throw std::bad_alloc(); + #endif + } + + memcpy(storage, begin_, size_ * sizeof(xpath_node)); + + // deallocate old buffer + if (_begin != &_storage) impl::xml_memory::deallocate(_begin); + + // finalize + _begin = storage; + _end = storage + size_; + _type = type_; + } + } + +#if __cplusplus >= 201103 + PUGI__FN void xpath_node_set::_move(xpath_node_set& rhs) + { + _type = rhs._type; + _storage = rhs._storage; + _begin = (rhs._begin == &rhs._storage) ? &_storage : rhs._begin; + _end = _begin + (rhs._end - rhs._begin); + + rhs._type = type_unsorted; + rhs._begin = &rhs._storage; + rhs._end = rhs._begin; + } +#endif + + PUGI__FN xpath_node_set::xpath_node_set(): _type(type_unsorted), _begin(&_storage), _end(&_storage) + { + } + + PUGI__FN xpath_node_set::xpath_node_set(const_iterator begin_, const_iterator end_, type_t type_): _type(type_unsorted), _begin(&_storage), _end(&_storage) + { + _assign(begin_, end_, type_); + } + + PUGI__FN xpath_node_set::~xpath_node_set() + { + if (_begin != &_storage) + impl::xml_memory::deallocate(_begin); + } + + PUGI__FN xpath_node_set::xpath_node_set(const xpath_node_set& ns): _type(type_unsorted), _begin(&_storage), _end(&_storage) + { + _assign(ns._begin, ns._end, ns._type); + } + + PUGI__FN xpath_node_set& xpath_node_set::operator=(const xpath_node_set& ns) + { + if (this == &ns) return *this; + + _assign(ns._begin, ns._end, ns._type); + + return *this; + } + +#if __cplusplus >= 201103 + PUGI__FN xpath_node_set::xpath_node_set(xpath_node_set&& rhs): _type(type_unsorted), _begin(&_storage), _end(&_storage) + { + _move(rhs); + } + + PUGI__FN xpath_node_set& xpath_node_set::operator=(xpath_node_set&& rhs) + { + if (this == &rhs) return *this; + + if (_begin != &_storage) + impl::xml_memory::deallocate(_begin); + + _move(rhs); + + return *this; + } +#endif + + PUGI__FN xpath_node_set::type_t xpath_node_set::type() const + { + return _type; + } + + PUGI__FN size_t xpath_node_set::size() const + { + return _end - _begin; + } + + PUGI__FN bool xpath_node_set::empty() const + { + return _begin == _end; + } + + PUGI__FN const xpath_node& xpath_node_set::operator[](size_t index) const + { + assert(index < size()); + return _begin[index]; + } + + PUGI__FN xpath_node_set::const_iterator xpath_node_set::begin() const + { + return _begin; + } + + PUGI__FN xpath_node_set::const_iterator xpath_node_set::end() const + { + return _end; + } + + PUGI__FN void xpath_node_set::sort(bool reverse) + { + _type = impl::xpath_sort(_begin, _end, _type, reverse); + } + + PUGI__FN xpath_node xpath_node_set::first() const + { + return impl::xpath_first(_begin, _end, _type); + } + + PUGI__FN xpath_parse_result::xpath_parse_result(): error("Internal error"), offset(0) + { + } + + PUGI__FN xpath_parse_result::operator bool() const + { + return error == 0; + } + + PUGI__FN const char* xpath_parse_result::description() const + { + return error ? error : "No error"; + } + + PUGI__FN xpath_variable::xpath_variable(xpath_value_type type_): _type(type_), _next(0) + { + } + + PUGI__FN const char_t* xpath_variable::name() const + { + switch (_type) + { + case xpath_type_node_set: + return static_cast(this)->name; + + case xpath_type_number: + return static_cast(this)->name; + + case xpath_type_string: + return static_cast(this)->name; + + case xpath_type_boolean: + return static_cast(this)->name; + + default: + assert(!"Invalid variable type"); + return 0; + } + } + + PUGI__FN xpath_value_type xpath_variable::type() const + { + return _type; + } + + PUGI__FN bool xpath_variable::get_boolean() const + { + return (_type == xpath_type_boolean) ? static_cast(this)->value : false; + } + + PUGI__FN double xpath_variable::get_number() const + { + return (_type == xpath_type_number) ? static_cast(this)->value : impl::gen_nan(); + } + + PUGI__FN const char_t* xpath_variable::get_string() const + { + const char_t* value = (_type == xpath_type_string) ? static_cast(this)->value : 0; + return value ? value : PUGIXML_TEXT(""); + } + + PUGI__FN const xpath_node_set& xpath_variable::get_node_set() const + { + return (_type == xpath_type_node_set) ? static_cast(this)->value : impl::dummy_node_set; + } + + PUGI__FN bool xpath_variable::set(bool value) + { + if (_type != xpath_type_boolean) return false; + + static_cast(this)->value = value; + return true; + } + + PUGI__FN bool xpath_variable::set(double value) + { + if (_type != xpath_type_number) return false; + + static_cast(this)->value = value; + return true; + } + + PUGI__FN bool xpath_variable::set(const char_t* value) + { + if (_type != xpath_type_string) return false; + + impl::xpath_variable_string* var = static_cast(this); + + // duplicate string + size_t size = (impl::strlength(value) + 1) * sizeof(char_t); + + char_t* copy = static_cast(impl::xml_memory::allocate(size)); + if (!copy) return false; + + memcpy(copy, value, size); + + // replace old string + if (var->value) impl::xml_memory::deallocate(var->value); + var->value = copy; + + return true; + } + + PUGI__FN bool xpath_variable::set(const xpath_node_set& value) + { + if (_type != xpath_type_node_set) return false; + + static_cast(this)->value = value; + return true; + } + + PUGI__FN xpath_variable_set::xpath_variable_set() + { + for (size_t i = 0; i < sizeof(_data) / sizeof(_data[0]); ++i) + _data[i] = 0; + } + + PUGI__FN xpath_variable_set::~xpath_variable_set() + { + for (size_t i = 0; i < sizeof(_data) / sizeof(_data[0]); ++i) + _destroy(_data[i]); + } + + PUGI__FN xpath_variable_set::xpath_variable_set(const xpath_variable_set& rhs) + { + for (size_t i = 0; i < sizeof(_data) / sizeof(_data[0]); ++i) + _data[i] = 0; + + _assign(rhs); + } + + PUGI__FN xpath_variable_set& xpath_variable_set::operator=(const xpath_variable_set& rhs) + { + if (this == &rhs) return *this; + + _assign(rhs); + + return *this; + } + +#if __cplusplus >= 201103 + PUGI__FN xpath_variable_set::xpath_variable_set(xpath_variable_set&& rhs) + { + for (size_t i = 0; i < sizeof(_data) / sizeof(_data[0]); ++i) + { + _data[i] = rhs._data[i]; + rhs._data[i] = 0; + } + } + + PUGI__FN xpath_variable_set& xpath_variable_set::operator=(xpath_variable_set&& rhs) + { + for (size_t i = 0; i < sizeof(_data) / sizeof(_data[0]); ++i) + { + _destroy(_data[i]); + + _data[i] = rhs._data[i]; + rhs._data[i] = 0; + } + + return *this; + } +#endif + + PUGI__FN void xpath_variable_set::_assign(const xpath_variable_set& rhs) + { + xpath_variable_set temp; + + for (size_t i = 0; i < sizeof(_data) / sizeof(_data[0]); ++i) + if (rhs._data[i] && !_clone(rhs._data[i], &temp._data[i])) + return; + + _swap(temp); + } + + PUGI__FN void xpath_variable_set::_swap(xpath_variable_set& rhs) + { + for (size_t i = 0; i < sizeof(_data) / sizeof(_data[0]); ++i) + { + xpath_variable* chain = _data[i]; + + _data[i] = rhs._data[i]; + rhs._data[i] = chain; + } + } + + PUGI__FN xpath_variable* xpath_variable_set::_find(const char_t* name) const + { + const size_t hash_size = sizeof(_data) / sizeof(_data[0]); + size_t hash = impl::hash_string(name) % hash_size; + + // look for existing variable + for (xpath_variable* var = _data[hash]; var; var = var->_next) + if (impl::strequal(var->name(), name)) + return var; + + return 0; + } + + PUGI__FN bool xpath_variable_set::_clone(xpath_variable* var, xpath_variable** out_result) + { + xpath_variable* last = 0; + + while (var) + { + // allocate storage for new variable + xpath_variable* nvar = impl::new_xpath_variable(var->_type, var->name()); + if (!nvar) return false; + + // link the variable to the result immediately to handle failures gracefully + if (last) + last->_next = nvar; + else + *out_result = nvar; + + last = nvar; + + // copy the value; this can fail due to out-of-memory conditions + if (!impl::copy_xpath_variable(nvar, var)) return false; + + var = var->_next; + } + + return true; + } + + PUGI__FN void xpath_variable_set::_destroy(xpath_variable* var) + { + while (var) + { + xpath_variable* next = var->_next; + + impl::delete_xpath_variable(var->_type, var); + + var = next; + } + } + + PUGI__FN xpath_variable* xpath_variable_set::add(const char_t* name, xpath_value_type type) + { + const size_t hash_size = sizeof(_data) / sizeof(_data[0]); + size_t hash = impl::hash_string(name) % hash_size; + + // look for existing variable + for (xpath_variable* var = _data[hash]; var; var = var->_next) + if (impl::strequal(var->name(), name)) + return var->type() == type ? var : 0; + + // add new variable + xpath_variable* result = impl::new_xpath_variable(type, name); + + if (result) + { + result->_next = _data[hash]; + + _data[hash] = result; + } + + return result; + } + + PUGI__FN bool xpath_variable_set::set(const char_t* name, bool value) + { + xpath_variable* var = add(name, xpath_type_boolean); + return var ? var->set(value) : false; + } + + PUGI__FN bool xpath_variable_set::set(const char_t* name, double value) + { + xpath_variable* var = add(name, xpath_type_number); + return var ? var->set(value) : false; + } + + PUGI__FN bool xpath_variable_set::set(const char_t* name, const char_t* value) + { + xpath_variable* var = add(name, xpath_type_string); + return var ? var->set(value) : false; + } + + PUGI__FN bool xpath_variable_set::set(const char_t* name, const xpath_node_set& value) + { + xpath_variable* var = add(name, xpath_type_node_set); + return var ? var->set(value) : false; + } + + PUGI__FN xpath_variable* xpath_variable_set::get(const char_t* name) + { + return _find(name); + } + + PUGI__FN const xpath_variable* xpath_variable_set::get(const char_t* name) const + { + return _find(name); + } + + PUGI__FN xpath_query::xpath_query(const char_t* query, xpath_variable_set* variables): _impl(0) + { + impl::xpath_query_impl* qimpl = impl::xpath_query_impl::create(); + + if (!qimpl) + { + #ifdef PUGIXML_NO_EXCEPTIONS + _result.error = "Out of memory"; + #else + throw std::bad_alloc(); + #endif + } + else + { + using impl::auto_deleter; // MSVC7 workaround + auto_deleter impl(qimpl, impl::xpath_query_impl::destroy); + + qimpl->root = impl::xpath_parser::parse(query, variables, &qimpl->alloc, &_result); + + if (qimpl->root) + { + qimpl->root->optimize(&qimpl->alloc); + + _impl = impl.release(); + _result.error = 0; + } + } + } + + PUGI__FN xpath_query::xpath_query(): _impl(0) + { + } + + PUGI__FN xpath_query::~xpath_query() + { + if (_impl) + impl::xpath_query_impl::destroy(static_cast(_impl)); + } + +#if __cplusplus >= 201103 + PUGI__FN xpath_query::xpath_query(xpath_query&& rhs) + { + _impl = rhs._impl; + _result = rhs._result; + rhs._impl = 0; + rhs._result = xpath_parse_result(); + } + + PUGI__FN xpath_query& xpath_query::operator=(xpath_query&& rhs) + { + if (this == &rhs) return *this; + + if (_impl) + impl::xpath_query_impl::destroy(static_cast(_impl)); + + _impl = rhs._impl; + _result = rhs._result; + rhs._impl = 0; + rhs._result = xpath_parse_result(); + + return *this; + } +#endif + + PUGI__FN xpath_value_type xpath_query::return_type() const + { + if (!_impl) return xpath_type_none; + + return static_cast(_impl)->root->rettype(); + } + + PUGI__FN bool xpath_query::evaluate_boolean(const xpath_node& n) const + { + if (!_impl) return false; + + impl::xpath_context c(n, 1, 1); + impl::xpath_stack_data sd; + + #ifdef PUGIXML_NO_EXCEPTIONS + if (setjmp(sd.error_handler)) return false; + #endif + + return static_cast(_impl)->root->eval_boolean(c, sd.stack); + } + + PUGI__FN double xpath_query::evaluate_number(const xpath_node& n) const + { + if (!_impl) return impl::gen_nan(); + + impl::xpath_context c(n, 1, 1); + impl::xpath_stack_data sd; + + #ifdef PUGIXML_NO_EXCEPTIONS + if (setjmp(sd.error_handler)) return impl::gen_nan(); + #endif + + return static_cast(_impl)->root->eval_number(c, sd.stack); + } + +#ifndef PUGIXML_NO_STL + PUGI__FN string_t xpath_query::evaluate_string(const xpath_node& n) const + { + impl::xpath_stack_data sd; + + impl::xpath_string r = impl::evaluate_string_impl(static_cast(_impl), n, sd); + + return string_t(r.c_str(), r.length()); + } +#endif + + PUGI__FN size_t xpath_query::evaluate_string(char_t* buffer, size_t capacity, const xpath_node& n) const + { + impl::xpath_stack_data sd; + + impl::xpath_string r = impl::evaluate_string_impl(static_cast(_impl), n, sd); + + size_t full_size = r.length() + 1; + + if (capacity > 0) + { + size_t size = (full_size < capacity) ? full_size : capacity; + assert(size > 0); + + memcpy(buffer, r.c_str(), (size - 1) * sizeof(char_t)); + buffer[size - 1] = 0; + } + + return full_size; + } + + PUGI__FN xpath_node_set xpath_query::evaluate_node_set(const xpath_node& n) const + { + impl::xpath_ast_node* root = impl::evaluate_node_set_prepare(static_cast(_impl)); + if (!root) return xpath_node_set(); + + impl::xpath_context c(n, 1, 1); + impl::xpath_stack_data sd; + + #ifdef PUGIXML_NO_EXCEPTIONS + if (setjmp(sd.error_handler)) return xpath_node_set(); + #endif + + impl::xpath_node_set_raw r = root->eval_node_set(c, sd.stack, impl::nodeset_eval_all); + + return xpath_node_set(r.begin(), r.end(), r.type()); + } + + PUGI__FN xpath_node xpath_query::evaluate_node(const xpath_node& n) const + { + impl::xpath_ast_node* root = impl::evaluate_node_set_prepare(static_cast(_impl)); + if (!root) return xpath_node(); + + impl::xpath_context c(n, 1, 1); + impl::xpath_stack_data sd; + + #ifdef PUGIXML_NO_EXCEPTIONS + if (setjmp(sd.error_handler)) return xpath_node(); + #endif + + impl::xpath_node_set_raw r = root->eval_node_set(c, sd.stack, impl::nodeset_eval_first); + + return r.first(); + } + + PUGI__FN const xpath_parse_result& xpath_query::result() const + { + return _result; + } + + PUGI__FN static void unspecified_bool_xpath_query(xpath_query***) + { + } + + PUGI__FN xpath_query::operator xpath_query::unspecified_bool_type() const + { + return _impl ? unspecified_bool_xpath_query : 0; + } + + PUGI__FN bool xpath_query::operator!() const + { + return !_impl; + } + + PUGI__FN xpath_node xml_node::select_node(const char_t* query, xpath_variable_set* variables) const + { + xpath_query q(query, variables); + return select_node(q); + } + + PUGI__FN xpath_node xml_node::select_node(const xpath_query& query) const + { + return query.evaluate_node(*this); + } + + PUGI__FN xpath_node_set xml_node::select_nodes(const char_t* query, xpath_variable_set* variables) const + { + xpath_query q(query, variables); + return select_nodes(q); + } + + PUGI__FN xpath_node_set xml_node::select_nodes(const xpath_query& query) const + { + return query.evaluate_node_set(*this); + } + + PUGI__FN xpath_node xml_node::select_single_node(const char_t* query, xpath_variable_set* variables) const + { + xpath_query q(query, variables); + return select_single_node(q); + } + + PUGI__FN xpath_node xml_node::select_single_node(const xpath_query& query) const + { + return query.evaluate_node(*this); + } +} + +#endif + +#ifdef __BORLANDC__ +# pragma option pop +#endif + +// Intel C++ does not properly keep warning state for function templates, +// so popping warning state at the end of translation unit leads to warnings in the middle. +#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) +# pragma warning(pop) +#endif + +// Undefine all local macros (makes sure we're not leaking macros in header-only mode) +#undef PUGI__NO_INLINE +#undef PUGI__UNLIKELY +#undef PUGI__STATIC_ASSERT +#undef PUGI__DMC_VOLATILE +#undef PUGI__MSVC_CRT_VERSION +#undef PUGI__NS_BEGIN +#undef PUGI__NS_END +#undef PUGI__FN +#undef PUGI__FN_NO_INLINE +#undef PUGI__GETPAGE_IMPL +#undef PUGI__GETPAGE +#undef PUGI__NODETYPE +#undef PUGI__IS_CHARTYPE_IMPL +#undef PUGI__IS_CHARTYPE +#undef PUGI__IS_CHARTYPEX +#undef PUGI__ENDSWITH +#undef PUGI__SKIPWS +#undef PUGI__OPTSET +#undef PUGI__PUSHNODE +#undef PUGI__POPNODE +#undef PUGI__SCANFOR +#undef PUGI__SCANWHILE +#undef PUGI__SCANWHILE_UNROLL +#undef PUGI__ENDSEG +#undef PUGI__THROW_ERROR +#undef PUGI__CHECK_ERROR + +#endif + +/** + * Copyright (c) 2006-2015 Arseny Kapoulkine + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ From e0d24e26643cd938f25a676c2c5dec7ff723bbeb Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 25 Dec 2015 11:45:10 +0100 Subject: [PATCH 032/217] Reading and writing text mixed content (WIP) --- emscripten/build.sh | 3 ++- include/vrv/iomei.h | 4 +++- java/build.sh | 2 ++ python/setup.py | 2 ++ src/iomei.cpp | 34 +++++++++++++++++++++++++++++----- tools/CMakeLists.txt | 3 ++- 6 files changed, 40 insertions(+), 8 deletions(-) diff --git a/emscripten/build.sh b/emscripten/build.sh index 98fb065b296..02367efa3e8 100755 --- a/emscripten/build.sh +++ b/emscripten/build.sh @@ -141,11 +141,12 @@ python $EMCC $CHATTY \ $VEROVIO_ROOT/src/svgdevicecontext.cpp \ $VEROVIO_ROOT/src/syl.cpp \ $VEROVIO_ROOT/src/system.cpp \ + $VEROVIO_ROOT/src/text.cpp \ $VEROVIO_ROOT/src/textdirective.cpp \ $VEROVIO_ROOT/src/textdirinterface.cpp \ + $VEROVIO_ROOT/src/textelement.cpp \ $VEROVIO_ROOT/src/tie.cpp \ $VEROVIO_ROOT/src/timeinterface.cpp \ - $VEROVIO_ROOT/src/trem.cpp \ $VEROVIO_ROOT/src/toolkit.cpp \ $VEROVIO_ROOT/src/tuplet.cpp \ $VEROVIO_ROOT/src/verse.cpp \ diff --git a/include/vrv/iomei.h b/include/vrv/iomei.h index 240ec3e53c2..d3b9a1ac225 100644 --- a/include/vrv/iomei.h +++ b/include/vrv/iomei.h @@ -353,7 +353,7 @@ class MeiInput: public FileInputStream */ ///@{ bool ReadMeiRend( Object *parent, pugi::xml_node rend ); - bool ReadMeiText( Object *parent, pugi::xml_node text ); + bool ReadMeiText( Object *parent, pugi::xml_node text, bool trimLeft, bool trimRight ); ///@} /** @@ -437,6 +437,8 @@ class MeiInput: public FileInputStream DocType StrToDocType(std::string type); /** Extract the uuid for references to uuids with ..#uuid values */ std::string ExtractUuidFragment(std::string refUuid); + std::wstring LeftTrim(std::wstring str); + std::wstring RightTrim(std::wstring str); ///@} public: diff --git a/java/build.sh b/java/build.sh index ca7100fb204..d8b4fd5dcfb 100755 --- a/java/build.sh +++ b/java/build.sh @@ -56,8 +56,10 @@ FILES="../src/accid.cpp \ ../src/svgdevicecontext.cpp \ ../src/syl.cpp \ ../src/system.cpp \ + ../src/text.cpp \ ../src/textdirective.cpp \ ../src/textdirinterface.cpp \ + ../src/textelement.cpp \ ../src/tie.cpp \ ../src/timeinterface.cpp \ ../src/trem.cpp \ diff --git a/python/setup.py b/python/setup.py index d2ecec8ee6b..f70380d1e6d 100755 --- a/python/setup.py +++ b/python/setup.py @@ -60,8 +60,10 @@ '../src/svgdevicecontext.cpp', '../src/syl.cpp', '../src/system.cpp', + '../src/text.cpp', '../src/textdirective.cpp', '../src/textdirinterface.cpp', + '../src/textelement.cpp', '../src/tie.cpp', '../src/timeinterface.cpp', '../src/trem.cpp', diff --git a/src/iomei.cpp b/src/iomei.cpp index 4fdac3ba6df..41dd62c455e 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -1027,7 +1027,7 @@ bool MeiInput::ImportFile( ) try { m_doc->Reset( Raw ); pugi::xml_document doc; - pugi::xml_parse_result result = doc.load_file( m_filename.c_str() ); + pugi::xml_parse_result result = doc.load_file( m_filename.c_str(), pugi::parse_default & ~pugi::parse_eol ); if (!result) { return false; @@ -1046,7 +1046,7 @@ bool MeiInput::ImportString( const std::string mei ) try { m_doc->Reset( Raw ); pugi::xml_document doc; - doc.load( mei.c_str() ); + doc.load( mei.c_str(), pugi::parse_default & ~pugi::parse_eol ); pugi::xml_node root = doc.first_child(); return ReadMei( root ); } @@ -2159,6 +2159,7 @@ bool MeiInput::ReadMeiTextChildren( Object *parent, pugi::xml_node parentNode, O bool success = true; pugi::xml_node xmlElement; std::string elementName; + int i = 0; for( xmlElement = parentNode.first_child( ); xmlElement; xmlElement = xmlElement.next_sibling( ) ) { if (!success) { break; @@ -2178,12 +2179,15 @@ bool MeiInput::ReadMeiTextChildren( Object *parent, pugi::xml_node parentNode, O success = ReadMeiSupplied( parent, xmlElement, EDITORIAL_TEXT, filter ); } else if ( xmlElement.text() ) { - success = ReadMeiText( parent, xmlElement ); + bool trimLeft = (i == 0); + bool trimRight = (!xmlElement.next_sibling()); + success = ReadMeiText( parent, xmlElement, trimLeft, trimRight ); } // unknown else { LogDebug("Element %s ignored", xmlElement.name() ); } + i++; } return success; @@ -2201,12 +2205,16 @@ bool MeiInput::ReadMeiRend( Object *parent, pugi::xml_node rend ) return ReadMeiTextChildren(vrvRend, rend); } -bool MeiInput::ReadMeiText( Object *parent, pugi::xml_node text ) +bool MeiInput::ReadMeiText( Object *parent, pugi::xml_node text, bool trimLeft, bool trimRight ) { Text *vrvText = new Text(); assert( text.text() ); - vrvText->SetText(UTF8to16( text.text().as_string() )); + std::wstring str = UTF8to16( text.text().as_string() ); + if (trimLeft) str = this->LeftTrim( str ); + if (trimRight) str = this->RightTrim( str ); + + vrvText->SetText( str ); AddTextElement(parent, vrvText); return true; @@ -2731,6 +2739,22 @@ std::string MeiInput::ExtractUuidFragment(std::string refUuid) } return refUuid; } + +std::wstring MeiInput::LeftTrim(std::wstring str) +{ + std::wstring::size_type pos = 0; + while (pos < str.size() && iswspace(str[pos])) pos++; + str.erase(0, pos); + return str; +} +std::wstring MeiInput::RightTrim(std::wstring str) +{ + std::wstring::size_type pos = str.size(); + while (pos > 0 && iswspace(str[pos - 1])) pos--; + str.erase(pos); + return str; +} + } // namespace vrv diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 1607ea45cc9..ee4ed1c64c6 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -65,11 +65,12 @@ add_executable (verovio ../src/svgdevicecontext.cpp ../src/syl.cpp ../src/system.cpp + ../src/text.cpp ../src/textdirective.cpp ../src/textdirinterface.cpp + ../src/textelement.cpp ../src/tie.cpp ../src/timeinterface.cpp - ../src/trem.cpp ../src/toolkit.cpp ../src/tuplet.cpp ../src/verse.cpp From 58d7a5e308073f4095382e03d61d7560059a7ebb Mon Sep 17 00:00:00 2001 From: Don Byrd Date: Sat, 26 Dec 2015 09:46:58 -0500 Subject: [PATCH 033/217] Fix typos. --- include/vrv/object.h | 4 ++-- src/measure.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/vrv/object.h b/include/vrv/object.h index 22a916d9fe8..5c60cd7ec9e 100644 --- a/include/vrv/object.h +++ b/include/vrv/object.h @@ -77,8 +77,8 @@ class Object ///@} /** - * @name Methods for checking if an object is part of a group of classId. - * For example, all LayerElement child class classId is in between LAYER_ELEMENT and LAYER_ELEMENT_max. + * @name Methods for checking if an object is part of a group of classId's. + * For example, all LayerElement child class classId's are between LAYER_ELEMENT and LAYER_ELEMENT_max. * See classId enum. */ ///@{ diff --git a/src/measure.cpp b/src/measure.cpp index a1bb1a1bc43..3807dedb1c9 100644 --- a/src/measure.cpp +++ b/src/measure.cpp @@ -202,7 +202,7 @@ int Measure::IntegrateBoundingBoxXShift( ArrayPtrVoid *params ) { // param 0: the cumulated shift (unused) // param 1: the cumulated justifiable shift (unused) - // param 2: the minimum measure with (unused) + // param 2: the minimum measure width (unused) // param 3: the doc for accessing drawing parameters (unused) // param 4: the functor to be redirected to Aligner Functor *integrateBoundingBoxShift = static_cast((*params).at(4)); From 84f59171645951953546c7ef477a51f7125e60d0 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sun, 27 Dec 2015 15:51:10 +0100 Subject: [PATCH 034/217] Rendering mixed content text (WIP) --- Verovio.xcodeproj/project.pbxproj | 6 ++ include/vrv/bboxdevicecontext.h | 5 ++ include/vrv/devicecontext.h | 15 +++++ include/vrv/svgdevicecontext.h | 20 +++++- include/vrv/view.h | 25 +++++++ src/bboxdevicecontext.cpp | 7 ++ src/object.cpp | 16 +++-- src/svgdevicecontext.cpp | 108 ++++++++++++++++++------------ src/view_floating.cpp | 2 +- src/view_page.cpp | 35 ++++++++++ src/view_text.cpp | 70 +++++++++++++++++++ 11 files changed, 260 insertions(+), 49 deletions(-) create mode 100644 src/view_text.cpp diff --git a/Verovio.xcodeproj/project.pbxproj b/Verovio.xcodeproj/project.pbxproj index 3e7d4d7db8f..4c1e3e6cbc5 100644 --- a/Verovio.xcodeproj/project.pbxproj +++ b/Verovio.xcodeproj/project.pbxproj @@ -83,6 +83,8 @@ 4DCA95D81A515D0E008AD7E9 /* editorial.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DCA95D71A515D0E008AD7E9 /* editorial.cpp */; }; 4DCA95D91A515D0E008AD7E9 /* editorial.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DCA95D71A515D0E008AD7E9 /* editorial.cpp */; }; 4DCA95DB1A515D33008AD7E9 /* editorial.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DCA95DA1A515D33008AD7E9 /* editorial.h */; }; + 4DDBBCC51C2EBAE7001AB50A /* view_text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DDBBCC41C2EBAE7001AB50A /* view_text.cpp */; }; + 4DDBBCC61C2EBAE7001AB50A /* view_text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DDBBCC41C2EBAE7001AB50A /* view_text.cpp */; }; 4DEE291B1940BCC100C76319 /* atts_shared.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEE29091940BCC100C76319 /* atts_shared.cpp */; }; 4DF289FD1A7545CC00BA9F7D /* timeinterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DF289FC1A7545CC00BA9F7D /* timeinterface.h */; }; 4DF289FF1A7545E500BA9F7D /* timeinterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DF289FE1A7545E500BA9F7D /* timeinterface.cpp */; }; @@ -289,6 +291,7 @@ 4DC34BA719BC4A83006175CD /* dot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = dot.cpp; path = src/dot.cpp; sourceTree = ""; }; 4DCA95D71A515D0E008AD7E9 /* editorial.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = editorial.cpp; path = src/editorial.cpp; sourceTree = ""; }; 4DCA95DA1A515D33008AD7E9 /* editorial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = editorial.h; path = include/vrv/editorial.h; sourceTree = ""; }; + 4DDBBCC41C2EBAE7001AB50A /* view_text.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = view_text.cpp; path = src/view_text.cpp; sourceTree = ""; }; 4DEE28ED1940BCC100C76319 /* atts_analysis.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atts_analysis.cpp; path = libmei/atts_analysis.cpp; sourceTree = ""; }; 4DEE28EE1940BCC100C76319 /* atts_analysis.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = atts_analysis.h; path = libmei/atts_analysis.h; sourceTree = ""; }; 4DEE28EF1940BCC100C76319 /* atts_cmn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atts_cmn.cpp; path = libmei/atts_cmn.cpp; sourceTree = ""; }; @@ -678,6 +681,7 @@ 8F086EDD188539540037FD8E /* view_graph.cpp */, 4D43C30B1A9BB22A00EA28F3 /* view_mensural.cpp */, 8F086EDE188539540037FD8E /* view_page.cpp */, + 4DDBBCC41C2EBAE7001AB50A /* view_text.cpp */, 8F086EDF188539540037FD8E /* view_tuplet.cpp */, ); name = view; @@ -920,6 +924,7 @@ 8F086EF6188539540037FD8E /* mensur.cpp in Sources */, 4DB726C51B8BB0E80040231B /* text.cpp in Sources */, 4D798CBD1B8AEDBA007281CA /* drawinginterface.cpp in Sources */, + 4DDBBCC51C2EBAE7001AB50A /* view_text.cpp in Sources */, 8F086EF7188539540037FD8E /* multirest.cpp in Sources */, 8F086EF8188539540037FD8E /* note.cpp in Sources */, 8F086EF9188539540037FD8E /* object.cpp in Sources */, @@ -995,6 +1000,7 @@ 4DF28A001A7545E500BA9F7D /* timeinterface.cpp in Sources */, 4DF9D2841C18DC490069E8C8 /* atts_mei.cpp in Sources */, 4DA60EE71B6307B9006E2DFC /* textdirinterface.cpp in Sources */, + 4DDBBCC61C2EBAE7001AB50A /* view_text.cpp in Sources */, 8F3DD34618854B2E0051330C /* layerelement.cpp in Sources */, 4D798CBE1B8AEDBA007281CA /* drawinginterface.cpp in Sources */, 8F3DD34818854B2E0051330C /* mensur.cpp in Sources */, diff --git a/include/vrv/bboxdevicecontext.h b/include/vrv/bboxdevicecontext.h index f3354305d0b..b976def2bcc 100644 --- a/include/vrv/bboxdevicecontext.h +++ b/include/vrv/bboxdevicecontext.h @@ -95,6 +95,11 @@ class BBoxDeviceContext: public DeviceContext virtual void StartText(int x, int y, char alignement = LEFT ); virtual void EndText(); + /** + * Move a text to the specified position, for example when starting a new line. + */ + virtual void MoveTextTo(int x, int y); + /** * @name Method for starting and ending a graphic */ diff --git a/include/vrv/devicecontext.h b/include/vrv/devicecontext.h index 08f6840ca31..a5b21474656 100644 --- a/include/vrv/devicecontext.h +++ b/include/vrv/devicecontext.h @@ -116,6 +116,12 @@ class DeviceContext virtual void StartText(int x, int y, char alignement = LEFT ) = 0; virtual void EndText() = 0; + /** + * Move a text to the specified position, for example when starting a new line. + * This method should be called only between a StartText and EndText call. + */ + virtual void MoveTextTo(int x, int y) = 0; + /** * @name Temporarily deactivate a graphic * This can be used for example for not taking into account the bounding box of parts of the graphic. @@ -144,6 +150,15 @@ class DeviceContext ///@{ virtual void ResumeGraphic( DocObject *object, std::string gId ) = 0; virtual void EndResumedGraphic( DocObject *object, View *view ) = 0; + ///@} + + /** + * @name Method for starting and ending a text graphic when it needs to be different from a normal graphic. + * For example, in SVG, a text graphic is a (and not a ) + */ + ///@{ + virtual void StartTextGraphic( DocObject *object, std::string gClass, std::string gId ) { StartGraphic(object, gClass, gId); } + virtual void EndTextGraphic( DocObject *object, View *view ) { EndGraphic(object, view); } ///@} /** diff --git a/include/vrv/svgdevicecontext.h b/include/vrv/svgdevicecontext.h index 24b787f42d3..ae096ef329c 100644 --- a/include/vrv/svgdevicecontext.h +++ b/include/vrv/svgdevicecontext.h @@ -95,6 +95,11 @@ class SvgDeviceContext: public DeviceContext virtual void StartText(int x, int y, char alignement = LEFT ); virtual void EndText(); + /** + * Move a text to the specified position, for example when starting a new line. + */ + virtual void MoveTextTo(int x, int y); + /** * @name Method for starting and ending a graphic */ @@ -111,6 +116,15 @@ class SvgDeviceContext: public DeviceContext virtual void EndResumedGraphic( DocObject *object, View *view ); ///@} + + /** + * @name Method for starting and ending a text () text graphic. + */ + ///@{ + virtual void StartTextGraphic( DocObject *object, std::string gClass, std::string gId ); + virtual void EndTextGraphic( DocObject *object, View *view ); + ///@} + /** * @name Method for starting and ending page */ @@ -120,13 +134,17 @@ class SvgDeviceContext: public DeviceContext ///@} private: - /** * Copy the content of a file to the output stream. * This is used for copying items. */ bool CopyFileToStream(const std::string& filename, std::ostream& dest); + /** + * Internal method for drawing debug SVG bounding box + */ + void DrawSvgBoundingBox(DocObject *object, View *view); + // we use a std::stringstream because we want to prepend the which will know only when we reach the end of the page // some viewer seem to support to have the at the end, but some do not (pdf2svg, for example) // for this reason, the full svg is finally written a string from the destructor or when Flush() is called diff --git a/include/vrv/view.h b/include/vrv/view.h index b32af7903e7..6193c4a5439 100644 --- a/include/vrv/view.h +++ b/include/vrv/view.h @@ -28,11 +28,14 @@ class Layer; class LayerElement; class Measure; class Page; +class Rend; class Slur; class Staff; class Syl; class System; class Tempo; +class Text; +class TextElement; class Tie; class Tuplet; class Verse; @@ -174,6 +177,7 @@ class View void DrawMeasureChildren( DeviceContext *dc, Object *parent, Measure *measure, System *system ); void DrawStaffChildren( DeviceContext *dc, Object *parent, Staff *staff, Measure *measure ); void DrawLayerChildren( DeviceContext *dc, Object *parent, Layer *layer, Staff *staff, Measure *measure ); + void DrawTextChildren( DeviceContext *dc, Object *parent, int x, int y, bool setX, bool setY ); ///@} /** @@ -185,6 +189,7 @@ class View void DrawMeasureEditorialElement( DeviceContext *dc, EditorialElement *element, Measure *measure, System *system ); void DrawStaffEditorialElement( DeviceContext *dc, EditorialElement *element, Staff *staff, Measure *measure ); void DrawLayerEditorialElement( DeviceContext *dc, EditorialElement *element, Layer *layer, Staff *staff, Measure *measure ); + void DrawTextEditorialElement( DeviceContext *dc, EditorialElement *element, int x, int y, bool &setX, bool &setY ); ///@} /** @@ -250,6 +255,26 @@ class View void DrawTrill(DeviceContext *dc, LayerElement *element, Staff *staff ); ///@} + /** + * @name Top level method for drawing TextElement. + * This can be called recursively for text elements containing other text elements. + * Defined in view_text.cpp + */ + ///@{ + void DrawTextElement( DeviceContext *dc, TextElement *element, int x, int y, bool setX, bool setY ); + ///@} + + /** + * @name Methods for drawing LayerElement child classes. + * They are base drawing methods that are called directly from DrawLayerElement + * Because some elements draw their children recursively (e.g., Note) they must all + * have the same parameters + * Defined in view_element.cpp + */ + ///@{ + void DrawRend( DeviceContext *dc, Rend *rend, int x, int y, bool &setX, bool &setY ); + void DrawText( DeviceContext *dc, Text *text, int x, int y, bool &setX, bool &setY ); + /** * @name Method for drawing Beam and FTrem. * Defined in view_beam.cpp diff --git a/src/bboxdevicecontext.cpp b/src/bboxdevicecontext.cpp index b77f07249b2..b40adbbee37 100644 --- a/src/bboxdevicecontext.cpp +++ b/src/bboxdevicecontext.cpp @@ -300,6 +300,13 @@ void BBoxDeviceContext::EndText() { m_drawingText = false; } + +void BBoxDeviceContext::MoveTextTo(int x, int y) +{ + assert( m_drawingText ); + m_textX = x; + m_textY = y; +} void BBoxDeviceContext::DrawText(const std::string& text, const std::wstring wtext) { diff --git a/src/object.cpp b/src/object.cpp index 0862d5ffcc2..756f39fdeb2 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -27,6 +27,8 @@ #include "page.h" #include "staff.h" #include "system.h" +#include "textdirective.h" +#include "textelement.h" #include "vrv.h" namespace vrv { @@ -327,14 +329,16 @@ void Object::SetParent( Object *parent ) void Object::AddEditorialElement( EditorialElement *child ) { assert( - dynamic_cast(this) - || dynamic_cast(this) - || dynamic_cast(this) - || dynamic_cast(this) + dynamic_cast(this) || dynamic_cast(this) - || dynamic_cast(this) || dynamic_cast(this) - || dynamic_cast(this) + || dynamic_cast(this) + || dynamic_cast(this) + || dynamic_cast(this) + || dynamic_cast(this) + || dynamic_cast(this) + || dynamic_cast(this) + || dynamic_cast(this) ); child->SetParent( this ); m_children.push_back( child ); diff --git a/src/svgdevicecontext.cpp b/src/svgdevicecontext.cpp index 03b6921e94c..246e2fb08d2 100644 --- a/src/svgdevicecontext.cpp +++ b/src/svgdevicecontext.cpp @@ -148,9 +148,6 @@ void SvgDeviceContext::Commit( bool xml_declaration ) { void SvgDeviceContext::StartGraphic( DocObject *object, std::string gClass, std::string gId ) { - //Pen currentPen = m_penStack.top(); - //Brush currentBrush = m_brushStack.top(); - std::string baseClass = object->GetClassName(); std::transform( baseClass.begin(), baseClass.begin() + 1, baseClass.begin(), ::tolower ); if (gClass.length() > 0) { @@ -164,6 +161,20 @@ void SvgDeviceContext::StartGraphic( DocObject *object, std::string gClass, std: //m_currentNode.append_attribute( "style" ) = StringFormat("stroke: #%s; stroke-opacity: %f; fill: #%s; fill-opacity: %f;", GetColour(currentPen.GetColour()).c_str(), currentPen.GetOpacity(), GetColour(currentBrush.GetColour()).c_str(), currentBrush.GetOpacity()).c_str(); } +void SvgDeviceContext::StartTextGraphic( DocObject *object, std::string gClass, std::string gId ) +{ + std::string baseClass = object->GetClassName(); + std::transform( baseClass.begin(), baseClass.begin() + 1, baseClass.begin(), ::tolower ); + if (gClass.length() > 0) { + baseClass.append(" " + gClass); + } + + m_currentNode = m_currentNode.append_child("tspan"); + m_svgNodeStack.push_back(m_currentNode); + m_currentNode.append_attribute( "class" ) = baseClass.c_str(); + m_currentNode.append_attribute( "id" ) = gId.c_str(); +} + void SvgDeviceContext::ResumeGraphic( DocObject *object, std::string gId ) { std::string xpath = "//g[@id=\"" + gId + "\"]"; @@ -173,51 +184,22 @@ void SvgDeviceContext::ResumeGraphic( DocObject *object, std::string gId ) } m_svgNodeStack.push_back(m_currentNode); } - - + void SvgDeviceContext::EndGraphic(DocObject *object, View *view ) { - - bool drawBoundingBox = false; - if (drawBoundingBox && view) // && view->DrawBoundingBoxes()) // DrawBoundingBoxes is not defined - { - SetPen( AxRED, 10, AxDOT_DASH ); - SetBrush( AxWHITE, AxTRANSPARENT ); - StartGraphic( object, "self-bounding-box", "0"); - if ( object->HasSelfBB() ) { - this->DrawRectangle( view->ToDeviceContextX( object->GetDrawingX() + object->m_selfBB_x1 ), - view->ToDeviceContextY( object->GetDrawingY() + object->m_selfBB_y1 ), - view->ToDeviceContextX( object->GetDrawingX() + object->m_selfBB_x2 ) - - view->ToDeviceContextX( object->GetDrawingX() + object->m_selfBB_x1 ), - view->ToDeviceContextY( object->GetDrawingY() + object->m_selfBB_y2 ) - - view->ToDeviceContextY( object->GetDrawingY() + object->m_selfBB_y1 )); - } - - EndGraphic( object, NULL ); - - SetPen( AxBLUE, 10, AxDOT_DASH ); - StartGraphic( object, "content-bounding-box", "0"); - if ( object->HasContentBB() ) { - this->DrawRectangle( view->ToDeviceContextX( object->GetDrawingX() + object->m_contentBB_x1 ), - view->ToDeviceContextY( object->GetDrawingY() + object->m_contentBB_y1 ), - view->ToDeviceContextX( object->GetDrawingX() + object->m_contentBB_x2 ) - - view->ToDeviceContextX( object->GetDrawingX() + object->m_contentBB_x1 ), - view->ToDeviceContextY( object->GetDrawingY() + object->m_contentBB_y2 ) - - view->ToDeviceContextY( object->GetDrawingY() + object->m_contentBB_y1 )); - this->DrawRectangle( view->ToDeviceContextX( object->GetDrawingX() ), view->ToDeviceContextY( object->GetDrawingY() ), 5, 300); - } - EndGraphic( object, NULL ); - - SetPen( AxBLACK, 1, AxSOLID); - SetBrush(AxBLACK, AxSOLID); - - } - + DrawSvgBoundingBox(object, view); m_svgNodeStack.pop_back(); m_currentNode = m_svgNodeStack.back(); } void SvgDeviceContext::EndResumedGraphic(DocObject *object, View *view ) +{ + DrawSvgBoundingBox(object, view); + m_svgNodeStack.pop_back(); + m_currentNode = m_svgNodeStack.back(); +} + +void SvgDeviceContext::EndTextGraphic(DocObject *object, View *view ) { m_svgNodeStack.pop_back(); m_currentNode = m_svgNodeStack.back(); @@ -486,6 +468,12 @@ void SvgDeviceContext::StartText(int x, int y, char alignement) m_currentNode.append_attribute("font-size") = StringFormat("0px").c_str(); } +void SvgDeviceContext::MoveTextTo(int x, int y) +{ + m_currentNode.append_attribute( "x" ) = x; + m_currentNode.append_attribute( "y" ) = y; +} + void SvgDeviceContext::EndText() { m_svgNodeStack.pop_back(); @@ -519,6 +507,7 @@ void SvgDeviceContext::DrawText(const std::string& text, const std::wstring wtex textChild.append_attribute("font-weight") = "bold"; } } + textChild.append_attribute("class") = "text"; textChild.append_child(pugi::node_pcdata).set_value(text.c_str()); } @@ -617,5 +606,42 @@ std::string SvgDeviceContext::GetStringSVG( bool xml_declaration ) return m_outdata.str(); } + +void SvgDeviceContext::DrawSvgBoundingBox(DocObject *object, View *view) +{ + bool drawBoundingBox = false; + if (drawBoundingBox && view) // && view->DrawBoundingBoxes()) // DrawBoundingBoxes is not defined + { + SetPen( AxRED, 10, AxDOT_DASH ); + SetBrush( AxWHITE, AxTRANSPARENT ); + StartGraphic( object, "self-bounding-box", "0"); + if ( object->HasSelfBB() ) { + this->DrawRectangle( view->ToDeviceContextX( object->GetDrawingX() + object->m_selfBB_x1 ), + view->ToDeviceContextY( object->GetDrawingY() + object->m_selfBB_y1 ), + view->ToDeviceContextX( object->GetDrawingX() + object->m_selfBB_x2 ) - + view->ToDeviceContextX( object->GetDrawingX() + object->m_selfBB_x1 ), + view->ToDeviceContextY( object->GetDrawingY() + object->m_selfBB_y2 ) - + view->ToDeviceContextY( object->GetDrawingY() + object->m_selfBB_y1 )); + } + + EndGraphic( object, NULL ); + + SetPen( AxBLUE, 10, AxDOT_DASH ); + StartGraphic( object, "content-bounding-box", "0"); + if ( object->HasContentBB() ) { + this->DrawRectangle( view->ToDeviceContextX( object->GetDrawingX() + object->m_contentBB_x1 ), + view->ToDeviceContextY( object->GetDrawingY() + object->m_contentBB_y1 ), + view->ToDeviceContextX( object->GetDrawingX() + object->m_contentBB_x2 ) - + view->ToDeviceContextX( object->GetDrawingX() + object->m_contentBB_x1 ), + view->ToDeviceContextY( object->GetDrawingY() + object->m_contentBB_y2 ) - + view->ToDeviceContextY( object->GetDrawingY() + object->m_contentBB_y1 )); + this->DrawRectangle( view->ToDeviceContextX( object->GetDrawingX() ), view->ToDeviceContextY( object->GetDrawingY() ), 5, 300); + } + EndGraphic( object, NULL ); + + SetPen( AxBLACK, 1, AxSOLID); + SetBrush(AxBLACK, AxSOLID); + } +} } // namespace vrv diff --git a/src/view_floating.cpp b/src/view_floating.cpp index 0b6ad592f4a..6dd31d08043 100644 --- a/src/view_floating.cpp +++ b/src/view_floating.cpp @@ -1066,7 +1066,7 @@ void View::DrawTempo( DeviceContext *dc, Tempo *tempo, Measure *measure, System dc->SetFont( &tempoTxt ); dc->StartText( ToDeviceContextX( x ), ToDeviceContextY( y ), LEFT ); - dc->DrawText( UTF16to8( tempo->GetText().c_str() ), tempo->GetText() ); + DrawTextChildren(dc, tempo, x, y, false, false); dc->EndText( ); dc->ResetFont(); diff --git a/src/view_page.cpp b/src/view_page.cpp index e7c2f0d813b..b5bf69d66e8 100644 --- a/src/view_page.cpp +++ b/src/view_page.cpp @@ -32,6 +32,7 @@ #include "style.h" #include "system.h" #include "syl.h" +#include "text.h" #include "tuplet.h" #include "vrv.h" @@ -1092,6 +1093,26 @@ void View::DrawLayerChildren( DeviceContext *dc, Object *parent, Layer *layer, S } } +void View::DrawTextChildren( DeviceContext *dc, Object *parent, int x, int y, bool setX, bool setY ) +{ + assert( dc ); + assert( parent ); + + Object* current; + for (current = parent->GetFirst( ); current; current = parent->GetNext( ) ) + { + if (current->IsTextElement()) { + DrawTextElement( dc, dynamic_cast(current), x, y, setX, setY ); + } + else if (current->IsEditorialElement()) { + // cast to EditorialElement check in DrawLayerEditorialElement + DrawTextEditorialElement( dc , dynamic_cast(current), x, y, setX, setY); + } + else { + assert(false); + } + } +} //---------------------------------------------------------------------------- // View - Editorial @@ -1153,6 +1174,20 @@ void View::DrawLayerEditorialElement( DeviceContext *dc, EditorialElement *eleme dc->EndGraphic( element, this ); } +void View::DrawTextEditorialElement( DeviceContext *dc, EditorialElement *element, int x, int y, bool &setX, bool &setY ) +{ + assert( element ); + if ( element->Is() == APP ) { + assert( dynamic_cast(element)->GetLevel() == EDITORIAL_TEXT ); + } + + dc->StartTextGraphic( element, "", element->GetUuid()); + if (element->m_visibility == Visible) { + DrawTextChildren(dc, element, x, y, setX, setY); + } + dc->EndTextGraphic( element, this ); +} + } // namespace vrv diff --git a/src/view_text.cpp b/src/view_text.cpp new file mode 100644 index 00000000000..e514fe74589 --- /dev/null +++ b/src/view_text.cpp @@ -0,0 +1,70 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: view_text.cpp +// Author: Laurent Pugin +// Created: 2015 +// Copyright (c) Authors and others. All rights reserved. +///////////////////////////////////////////////////////////////////////////// + + +#include "view.h" + +//---------------------------------------------------------------------------- + +#include +#include +#include + +//---------------------------------------------------------------------------- + +#include "devicecontext.h" +#include "doc.h" +#include "style.h" +#include "text.h" +#include "vrv.h" + +namespace vrv { + +//---------------------------------------------------------------------------- +// View - TextElement +//---------------------------------------------------------------------------- + +void View::DrawTextElement( DeviceContext *dc, TextElement *element, int x, int y, bool setX, bool setY ) +{ + assert( dc ); + assert( element ); + + if (element->Is() == REND) { + Rend *rend = dynamic_cast(element); + assert(rend); + DrawRend( dc, rend, x, y, setX, setY ); + } + else if (element->Is() == TEXT) { + Text *text = dynamic_cast(element); + assert(text); + DrawText( dc, text, x, y, setX, setY ); + } +} + +void View::DrawRend( DeviceContext *dc, Rend *rend, int x, int y, bool &setX, bool &setY ) +{ + assert( dc ); + assert( rend ); + + dc->StartTextGraphic( rend, "", rend->GetUuid()); + + DrawTextChildren( dc, rend, x, y, setX, setY); + + dc->EndTextGraphic( rend, this ); + +} + +void View::DrawText( DeviceContext *dc, Text *text, int x, int y, bool &setX, bool &setY ) +{ + assert( dc ); + assert( text ); + + dc->DrawText( UTF16to8( text->GetText().c_str() ), text->GetText() ); +} + +} // namespace vrv + From 2d11e1d094d7ca716d8973c77493bccf0bb26fcf Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sun, 27 Dec 2015 16:08:58 +0100 Subject: [PATCH 035/217] Updating makefiles and fixing parameters in text drawing methods --- emscripten/build.sh | 1 + include/vrv/view.h | 6 +++--- java/build.sh | 1 + python/setup.py | 1 + src/view_floating.cpp | 5 ++++- src/view_page.cpp | 2 +- src/view_text.cpp | 2 +- tools/CMakeLists.txt | 1 + 8 files changed, 13 insertions(+), 6 deletions(-) diff --git a/emscripten/build.sh b/emscripten/build.sh index 02367efa3e8..33c8eeb3a4c 100755 --- a/emscripten/build.sh +++ b/emscripten/build.sh @@ -157,6 +157,7 @@ python $EMCC $CHATTY \ $VEROVIO_ROOT/src/view_graph.cpp \ $VEROVIO_ROOT/src/view_mensural.cpp \ $VEROVIO_ROOT/src/view_page.cpp \ + $VEROVIO_ROOT/src/view_text.cpp \ $VEROVIO_ROOT/src/view_tuplet.cpp \ $VEROVIO_ROOT/src/vrv.cpp \ $VEROVIO_ROOT/src/pugixml.cpp \ diff --git a/include/vrv/view.h b/include/vrv/view.h index 6193c4a5439..655fcaf49a1 100644 --- a/include/vrv/view.h +++ b/include/vrv/view.h @@ -177,7 +177,7 @@ class View void DrawMeasureChildren( DeviceContext *dc, Object *parent, Measure *measure, System *system ); void DrawStaffChildren( DeviceContext *dc, Object *parent, Staff *staff, Measure *measure ); void DrawLayerChildren( DeviceContext *dc, Object *parent, Layer *layer, Staff *staff, Measure *measure ); - void DrawTextChildren( DeviceContext *dc, Object *parent, int x, int y, bool setX, bool setY ); + void DrawTextChildren( DeviceContext *dc, Object *parent, int x, int y, bool &setX, bool &setY ); ///@} /** @@ -261,7 +261,7 @@ class View * Defined in view_text.cpp */ ///@{ - void DrawTextElement( DeviceContext *dc, TextElement *element, int x, int y, bool setX, bool setY ); + void DrawTextElement( DeviceContext *dc, TextElement *element, int x, int y, bool &setX, bool &setY ); ///@} /** @@ -273,7 +273,7 @@ class View */ ///@{ void DrawRend( DeviceContext *dc, Rend *rend, int x, int y, bool &setX, bool &setY ); - void DrawText( DeviceContext *dc, Text *text, int x, int y, bool &setX, bool &setY ); + void DrawText( DeviceContext *dc, Text *text, int x, int y, bool &setX, bool &setY ); /** * @name Method for drawing Beam and FTrem. diff --git a/java/build.sh b/java/build.sh index d8b4fd5dcfb..7f1088bc9e4 100755 --- a/java/build.sh +++ b/java/build.sh @@ -73,6 +73,7 @@ FILES="../src/accid.cpp \ ../src/view_graph.cpp \ ../src/view_mensural.cpp \ ../src/view_page.cpp \ + ../src/view_text.cpp \ ../src/view_tuplet.cpp \ ../src/vrv.cpp \ ../src/pugixml.cpp \ diff --git a/python/setup.py b/python/setup.py index f70380d1e6d..1b88a50c250 100755 --- a/python/setup.py +++ b/python/setup.py @@ -77,6 +77,7 @@ '../src/view_graph.cpp', '../src/view_mensural.cpp', '../src/view_page.cpp', + '../src/view_text.cpp', '../src/view_tuplet.cpp', '../src/vrv.cpp', '../src/pugixml.cpp', diff --git a/src/view_floating.cpp b/src/view_floating.cpp index 6dd31d08043..6d3025c3205 100644 --- a/src/view_floating.cpp +++ b/src/view_floating.cpp @@ -1049,6 +1049,9 @@ void View::DrawTempo( DeviceContext *dc, Tempo *tempo, Measure *measure, System x += pos->GetXRel(); } + bool setX = false; + bool setY = false; + std::vector::iterator iter; std::vector staffList = tempo->GetStaff(); for (iter = staffList.begin(); iter != staffList.end(); iter++) { @@ -1066,7 +1069,7 @@ void View::DrawTempo( DeviceContext *dc, Tempo *tempo, Measure *measure, System dc->SetFont( &tempoTxt ); dc->StartText( ToDeviceContextX( x ), ToDeviceContextY( y ), LEFT ); - DrawTextChildren(dc, tempo, x, y, false, false); + DrawTextChildren(dc, tempo, x, y, setX, setY); dc->EndText( ); dc->ResetFont(); diff --git a/src/view_page.cpp b/src/view_page.cpp index b5bf69d66e8..8f62e1aab11 100644 --- a/src/view_page.cpp +++ b/src/view_page.cpp @@ -1093,7 +1093,7 @@ void View::DrawLayerChildren( DeviceContext *dc, Object *parent, Layer *layer, S } } -void View::DrawTextChildren( DeviceContext *dc, Object *parent, int x, int y, bool setX, bool setY ) +void View::DrawTextChildren( DeviceContext *dc, Object *parent, int x, int y, bool &setX, bool &setY ) { assert( dc ); assert( parent ); diff --git a/src/view_text.cpp b/src/view_text.cpp index e514fe74589..1cc5c83d11b 100644 --- a/src/view_text.cpp +++ b/src/view_text.cpp @@ -28,7 +28,7 @@ namespace vrv { // View - TextElement //---------------------------------------------------------------------------- -void View::DrawTextElement( DeviceContext *dc, TextElement *element, int x, int y, bool setX, bool setY ) +void View::DrawTextElement( DeviceContext *dc, TextElement *element, int x, int y, bool &setX, bool &setY ) { assert( dc ); assert( element ); diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index ee4ed1c64c6..752f70b5b0c 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -81,6 +81,7 @@ add_executable (verovio ../src/view_graph.cpp ../src/view_mensural.cpp ../src/view_page.cpp + ../src/view_text.cpp ../src/view_tuplet.cpp ../src/vrv.cpp ../src/pugixml.cpp From 96725e9e1b9ad0d912d685bf3d6e67a200b93200 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sun, 27 Dec 2015 17:38:55 +0100 Subject: [PATCH 036/217] Updating VerovioText font and default font size in SVG --- data/woff.xml | 2 +- fonts/VerovioText-1.0.otf | Bin 8668 -> 12988 bytes fonts/VerovioText-1.0.sfd | 1785 +++++++++++-------------------- fonts/VerovioText-1.0.ttf | Bin 8804 -> 6232 bytes fonts/VerovioText-1.0.woff | Bin 5636 -> 5092 bytes include/vrv/bboxdevicecontext.h | 2 +- include/vrv/devicecontext.h | 2 +- include/vrv/svgdevicecontext.h | 2 +- src/bboxdevicecontext.cpp | 2 +- src/svgdevicecontext.cpp | 8 +- src/view_floating.cpp | 2 +- src/view_graph.cpp | 5 +- src/view_page.cpp | 4 +- src/view_text.cpp | 13 + 14 files changed, 676 insertions(+), 1151 deletions(-) diff --git a/data/woff.xml b/data/woff.xml index 917bf4beab0..7968a87128a 100644 --- a/data/woff.xml +++ b/data/woff.xml @@ -1,7 +1,7 @@