Hosted by
|
with Token_Readers; use Token_Readers;
with Integer_Strings; use Integer_Strings;
package body Clefs.MusicXML is
function Read_Clef
(XML : access XML_Reader)
return Clef_Access
is
Number : Natural := 0;
Sign : Sign_Enum := G;
Line : Integer := 0;
begin
if not End_Of_Tag(XML) then
Assert_Attribute_Name(XML, "number");
Read_Attribute_Value(XML);
Number := To_Number(Get_Token(XML));
end if;
Exit_Tag(XML);
while Descend(XML) loop
Exit_Tag(XML);
if Context_Is(XML, "sign") then
Sign := To_Sign_Enum(Read_Data(XML));
elsif Context_Is(XML, "line") then
Line := To_Number(Read_Data(XML));
end if;
Exit_Element(XML);
end loop;
Exit_Tag(XML);
return Create(Number, Sign, Line);
end Read_Clef;
procedure Write_Clef
(XML : access XML_Writer;
This : access Clef)
is
begin
if Get_Number(This) = 0 then
Start_Element(XML, "clef");
else
Start_Element(XML, "clef", "number", To_String(Get_Number(This)));
end if;
Write_Element(XML, "sign", Get_Sign(This)'Img);
Write_Element(XML, "line", To_String(Get_Line(This)));
Close_Element(XML, "clef");
end Write_Clef;
end Clefs.MusicXML;
|