summaryrefslogtreecommitdiffabout
path: root/lib/MTrk.cc
authorMichael Krelin <hacker@klever.net>2006-08-11 16:01:56 (UTC)
committer Michael Krelin <hacker@klever.net>2006-08-11 16:01:56 (UTC)
commit0c21a7a0d5b84dc6726462f0fbe51b8c32433262 (patch) (side-by-side diff)
tree9df6334cb1a61efebe68f7bcef9aa119a823626a /lib/MTrk.cc
parent9bcc235e575a95989a5903394c127accbeef2e0f (diff)
downloadmidillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.zip
midillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.tar.gz
midillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.tar.bz2
initial commit into repository0.0
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 ") );
+ }
+
+}