Hosted by
|
with Ada.Tags; use Ada.Tags;
with Readers; use Readers;
with Writers; use Writers;
with Music.Notes; use Music.Notes;
with Music.Backups; use Music.Backups;
with Music.Forwards; use Music.Forwards;
with Music.Directions; use Music.Directions;
with Music.Barlines; use Music.Barlines;
with Music.Notes.MusicXML; use Music.Notes.MusicXML;
with Music.Backups.MusicXML; use Music.Backups.MusicXML;
with Music.Forwards.MusicXML; use Music.Forwards.MusicXML;
with Music.Directions.MusicXML; use Music.Directions.MusicXML;
with Music.Barlines.MusicXML; use Music.Barlines.MusicXML;
package body Music.MusicXML is
function Read_Music
(XML : access XML_Reader;
Final : in String)
return Music_Data_Access is
begin
if Context_Is(XML, "note") then
return Music_Data_Access(Read_Note(XML));
elsif Context_Is(XML, "backup") then
return Music_Data_Access(Read_Backup(XML));
elsif Context_Is(XML, "forward") then
return Music_Data_Access(Read_Forward(XML));
elsif Context_Is(XML, "direction") then
return Music_Data_Access(Read_Direction(XML));
elsif Context_Is(XML, "barline") then
return Music_Data_Access(Read_Barline(XML));
else
XML_Expect_Error(XML, Final,
"note" / "backup" / "forward" / "direction" / "barline");
end if;
return null;
end Read_Music;
procedure Write_Music
(XML : access XML_Writer;
This : access Music_Data'Class)
is
Tag : String := External_Tag(This.All'Tag);
begin
if Tag = Note_Tag then
Write_Note(XML, Note_Access(This));
elsif Tag = Backup_Tag then
Write_Backup(XML, Backup_Access(This));
elsif Tag = Forward_Tag then
Write_Forward(XML, Forward_Access(This));
elsif Tag = Direction_Tag then
Write_Direction(XML, Direction_Access(This));
elsif Tag = Barline_Tag then
Write_Barline(XML, Barline_Access(This));
else
Unknown_Tag_Error("Write_Music", Tag);
end if;
end Write_Music;
end Music.MusicXML;
|