Hosted by
|
with Token_Readers; use Token_Readers;
with Integer_Strings; use Integer_Strings;
with Readers; use Readers;
package body Keys.MusicXML is
function Read_Key
(XML : access XML_Reader)
return Key_Access
is
Fifths : Integer := 0;
Mode : Mode_Enum := Default;
begin
while Descend(XML) loop
Exit_Tag(XML);
if Found(XML, "fifths") then
Fifths := To_Number(Read_Data(XML));
elsif Found(XML, "mode") then
Mode := To_Mode_Enum(Read_Data(XML));
else
XML_Expect_Error(XML, "/key",
"fifths" / "mode");
end if;
Exit_Element(XML);
end loop;
Exit_Tag(XML);
return Create(Fifths, Mode);
end Read_Key;
procedure Write_Key
(XML : access XML_Writer;
This : access Key)
is
begin
Start_Element(XML, "key");
Write_Element(XML, "fifths", To_String(Get_Fifths(This)));
if Get_Mode(This) /= Default then
Write_Element(XML, "mode", To_XML(Get_Mode(This)'Img));
end if;
Close_Element(XML, "key");
end Write_Key;
end Keys.MusicXML;
|