summaryrefslogtreecommitdiffabout
path: root/lib/MTrk.cc
Side-by-side diff
Diffstat (limited to 'lib/MTrk.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/MTrk.cc34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/MTrk.cc b/lib/MTrk.cc
new file mode 100644
index 0000000..fa1e0f8
--- a/dev/null
+++ b/lib/MTrk.cc
@@ -0,0 +1,34 @@
+#include <algorithm>
+#include <iterator>
+#include <midillo/MTrk.h>
+#include <midillo/exception.h>
+
+namespace midillo {
+ using std::copy;
+ using std::ostream_iterator;
+ using std::endl;
+
+ void MTrk_t::load(istream& s) {
+ header.load(s);
+ if(header.id_number!=chunk_id_MTrk)
+ throw exception_unexpected_input(CODEPOINT,"MTrk chunk expected");
+ events.load(s);
+ }
+
+ void MTrk_t::save(ostream& s) const {
+ chunk_header_t h = header;
+ h.id_number = chunk_id_MTrk;
+ h.length = events.calculate_save_size();
+ h.save(s);
+ events.save(s);
+ }
+
+ void MTrk_t::dump(ostream& s) const {
+ s << " " << header << endl
+ << " ";
+ copy(
+ events.begin(), events.end(),
+ ostream_iterator<event_t>(s,"\n ") );
+ }
+
+}