Hosted by
|
with Integer_Strings; use Integer_Strings;
with Enum_Strings; use Enum_Strings;
with Readers; use Readers;
with Token_Readers; use Token_Readers;
with Writers; use Writers;
with Indent_Writers; use Indent_Writers;
package body Notations.Slurs.MusicXML is
function Read_Slur
(XML : access XML_Reader)
return Slur_Access
is
use Placements;
Slur_Type : Slur_Type_Enum;
Placement : Placement_Enum := Default;
Number : Positive;
begin
while not End_Of_Tag(XML) loop
Read_Attribute_Name(XML);
if Found(XML, "type") then
Read_Attribute_Value(XML);
Slur_Type := To_Slur_Type_Enum(Get_Token(XML));
elsif Found(XML, "placement") then
Read_Attribute_Value(XML);
Placement := To_Placement_Enum(Get_Token(XML));
elsif Found(XML, "number") then
Read_Attribute_Value(XML);
Number := To_Number(Get_Token(XML));
else
XML_Expect_Error(XML, "",
"type" / "placement" / "number");
end if;
end loop;
Exit_Tag(XML);
return Create(Slur_Type, Placement, Number);
end Read_Slur;
procedure Write_Slur
(XML : access XML_Writer;
This : access Slur)
is
begin
Write_Indent(XML);
Start_Tag(XML, "slur");
Write_Attribute(XML, "type", To_XML(Get_Slur_Type(This)'Img));
if Get_Placement(This) /= Default then
Write_Attribute(XML, "placement", To_XML(Get_Placement(This)'Img));
end if;
Write_Attribute(XML, "number", To_String(Get_Number(This)));
Close_Tag(XML, "/");
New_Line(XML);
end Write_Slur;
end Notations.Slurs.MusicXML;
|