text: // MusicXML Class Library
  // Copyright (c) by Matthew James Briggs
  // Distributed under the MIT License
  
  #include "mx/core/elements/LyricAttributes.h"
  #include "mx/core/FromXElement.h"
  #include <iostream>
  
  namespace mx
  {
      namespace core
      {
          LyricAttributes::LyricAttributes()
          :number()
          ,name()
          ,justify( LeftCenterRight::center )
          ,defaultX()
          ,defaultY()
          ,relativeX()
          ,relativeY()
          ,placement( AboveBelow::below )
          ,color()
          ,printObject( YesNo::no )
          ,hasNumber( false )
          ,hasName( false )
          ,hasJustify( false )
          ,hasDefaultX( false )
          ,hasDefaultY( false )
          ,hasRelativeX( false )
          ,hasRelativeY( false )
          ,hasPlacement( false )
          ,hasColor( false )
          ,hasPrintObject( false )
          {}
  
  
          bool LyricAttributes::hasValues() const
          {
              return hasNumber ||
              hasName ||
              hasJustify ||
              hasDefaultX ||
              hasDefaultY ||
              hasRelativeX ||
              hasRelativeY ||
              hasPlacement ||
              hasColor ||
              hasPrintObject;
          }
  
  
          std::ostream& LyricAttributes::toStream( std::ostream& os ) const
          {
              if ( hasValues() )
              {
                  streamAttribute( os, number, "number", hasNumber );
                  streamAttribute( os, name, "name", hasName );
                  streamAttribute( os, justify, "justify", hasJustify );
                  streamAttribute( os, defaultX, "default-x", hasDefaultX );
                  streamAttribute( os, defaultY, "default-y", hasDefaultY );
                  streamAttribute( os, relativeX, "relative-x", hasRelativeX );
                  streamAttribute( os, relativeY, "relative-y", hasRelativeY );
                  streamAttribute( os, placement, "placement", hasPlacement );
                  streamAttribute( os, color, "color", hasColor );
                  streamAttribute( os, printObject, "print-object", hasPrintObject );
              }
              return os;
          }
  
  
          bool LyricAttributes::fromXElementImpl( std::ostream& message, xml::XElement& xelement )
          {
              const char* const className = "LyricAttributes";
              bool isSuccess = true;
          
              auto it = xelement.attributesBegin();
              auto endIter = xelement.attributesEnd();
          
              for( ; it != endIter; ++it )
              {
                  if( parseAttribute( message, it, className, isSuccess, number, hasNumber, "number" ) ) { continue; }
                  if( parseAttribute( message, it, className, isSuccess, name, hasName, "name" ) ) { continue; }
                  if( parseAttribute( message, it, className, isSuccess, justify, hasJustify, "justify", &parseLeftCenterRight ) ) { continue; }
                  if( parseAttribute( message, it, className, isSuccess, defaultX, hasDefaultX, "default-x" ) ) { continue; }
                  if( parseAttribute( message, it, className, isSuccess, defaultY, hasDefaultY, "default-y" ) ) { continue; }
                  if( parseAttribute( message, it, className, isSuccess, relativeX, hasRelativeX, "relative-x" ) ) { continue; }
                  if( parseAttribute( message, it, className, isSuccess, relativeY, hasRelativeY, "relative-y" ) ) { continue; }
                  if( parseAttribute( message, it, className, isSuccess, placement, hasPlacement, "placement", &parseAboveBelow ) ) { continue; }
                  if( parseAttribute( message, it, className, isSuccess, color, hasColor, "color" ) ) { continue; }
                  if( parseAttribute( message, it, className, isSuccess, printObject, hasPrintObject, "print-object", &parseYesNo ) ) { continue; }
              }
          
          
              MX_RETURN_IS_SUCCESS;
          }
  
      }
  }
  