author | Michael Krelin <hacker@klever.net> | 2006-08-11 16:01:56 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2006-08-11 16:01:56 (UTC) |
commit | 0c21a7a0d5b84dc6726462f0fbe51b8c32433262 (patch) (unidiff) | |
tree | 9df6334cb1a61efebe68f7bcef9aa119a823626a /lib/MTrk.cc | |
parent | 9bcc235e575a95989a5903394c127accbeef2e0f (diff) | |
download | midillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.zip midillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.tar.gz midillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.tar.bz2 |
initial commit into repository0.0
-rw-r--r-- | lib/MTrk.cc | 34 |
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 @@ | |||
1 | #include <algorithm> | ||
2 | #include <iterator> | ||
3 | #include <midillo/MTrk.h> | ||
4 | #include <midillo/exception.h> | ||
5 | |||
6 | namespace midillo { | ||
7 | using std::copy; | ||
8 | using std::ostream_iterator; | ||
9 | using std::endl; | ||
10 | |||
11 | void MTrk_t::load(istream& s) { | ||
12 | header.load(s); | ||
13 | if(header.id_number!=chunk_id_MTrk) | ||
14 | throw exception_unexpected_input(CODEPOINT,"MTrk chunk expected"); | ||
15 | events.load(s); | ||
16 | } | ||
17 | |||
18 | void MTrk_t::save(ostream& s) const { | ||
19 | chunk_header_t h = header; | ||
20 | h.id_number = chunk_id_MTrk; | ||
21 | h.length = events.calculate_save_size(); | ||
22 | h.save(s); | ||
23 | events.save(s); | ||
24 | } | ||
25 | |||
26 | void MTrk_t::dump(ostream& s) const { | ||
27 | s << " " << header << endl | ||
28 | << " "; | ||
29 | copy( | ||
30 | events.begin(), events.end(), | ||
31 | ostream_iterator<event_t>(s,"\n ") ); | ||
32 | } | ||
33 | |||
34 | } | ||