summaryrefslogtreecommitdiffabout
path: root/lib/chunk.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) (unidiff)
tree9df6334cb1a61efebe68f7bcef9aa119a823626a /lib/chunk.cc
parent9bcc235e575a95989a5903394c127accbeef2e0f (diff)
downloadmidillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.zip
midillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.tar.gz
midillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.tar.bz2
initial commit into repository0.0
Diffstat (limited to 'lib/chunk.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/chunk.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/chunk.cc b/lib/chunk.cc
new file mode 100644
index 0000000..7cc15ff
--- a/dev/null
+++ b/lib/chunk.cc
@@ -0,0 +1,31 @@
1#include <midillo/chunk.h>
2#include <midillo/util.h>
3#include <midillo/exception.h>
4
5namespace midillo {
6
7 void chunk_header_t::load(istream& s) {
8 s.read((char*)id_chars,sizeof(id_chars));
9 if(!s.good())
10 throw exception_input_error(CODEPOINT,"Error reading chunk header");
11 length = read32(s);
12 }
13
14 void chunk_header_t::save(ostream& s) const {
15 s.write((char*)id_chars,sizeof(id_chars));
16 if(!s.good())
17 throw exception_output_error(CODEPOINT,"Error writing chunk header");
18 write32(s,length);
19 }
20
21 void chunk_header_t::dump(ostream& s) const {
22 std::ios::fmtflags ff = s.flags();
23 s.unsetf(std::ios::hex); s.setf(std::ios::dec);
24 s
25 << id_chars[0] << id_chars[1]
26 << id_chars[2] << id_chars[3]
27 << " chunk of " << length << " byte(s)";
28 s.flags(ff);
29 }
30
31}