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) (side-by-side diff)
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) (show 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 @@
+#include <midillo/chunk.h>
+#include <midillo/util.h>
+#include <midillo/exception.h>
+
+namespace midillo {
+
+ void chunk_header_t::load(istream& s) {
+ s.read((char*)id_chars,sizeof(id_chars));
+ if(!s.good())
+ throw exception_input_error(CODEPOINT,"Error reading chunk header");
+ length = read32(s);
+ }
+
+ void chunk_header_t::save(ostream& s) const {
+ s.write((char*)id_chars,sizeof(id_chars));
+ if(!s.good())
+ throw exception_output_error(CODEPOINT,"Error writing chunk header");
+ write32(s,length);
+ }
+
+ void chunk_header_t::dump(ostream& s) const {
+ std::ios::fmtflags ff = s.flags();
+ s.unsetf(std::ios::hex); s.setf(std::ios::dec);
+ s
+ << id_chars[0] << id_chars[1]
+ << id_chars[2] << id_chars[3]
+ << " chunk of " << length << " byte(s)";
+ s.flags(ff);
+ }
+
+}