From 0c21a7a0d5b84dc6726462f0fbe51b8c32433262 Mon Sep 17 00:00:00 2001 From: Michael Krelin Date: Fri, 11 Aug 2006 16:01:56 +0000 Subject: initial commit into repository --- (limited to 'lib/chunk.cc') 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 +#include +#include + +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); + } + +} -- cgit v0.9.0.2