Hosted by
|
with Token_Readers; use Token_Readers;
with Integer_Strings; use Integer_Strings;
with Enum_Strings; use Enum_Strings;
with Readers; use Readers;
with Dir_Types.MusicXML; use Dir_Types.MusicXML;
package body Music.Directions.MusicXML is
function Read_Direction
(XML : access XML_Reader)
return Direction_Access
is
Result : Direction_Access;
begin
Assert_Attribute_Name(XML, "placement");
Read_Attribute_Value(XML);
Result := Create(To_Placement_Enum(Get_Token(XML)));
Exit_Tag(XML);
while Descend(XML) loop
if Found(XML, "direction-type") then
Set_Dir_Type(Result, Read_Dir_Type(XML));
elsif Found(XML, "offset") then
Exit_Tag(XML);
Set_Offset(Result, To_Number(Read_Data(XML)));
else
XML_Expect_Error(XML, "/direction",
"direction-type" / "offset");
end if;
Exit_Element(XML);
end loop;
Exit_Tag(XML);
return Result;
end Read_Direction;
procedure Write_Direction
(XML : access XML_Writer;
This : access Direction)
is
begin
Start_Element(XML, "direction",
"placement", To_XML(Get_Placement(This)'Img));
Write_Dir_Type(XML, Get_Dir_Type(This));
if Get_Offset(This) /= 0 then
Write_Element(XML, "offset", To_String(Get_Offset(This)));
end if;
Close_Element(XML, "direction");
end Write_Direction;
end Music.Directions.MusicXML;
|