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 'include/midillo/util.h') diff --git a/include/midillo/util.h b/include/midillo/util.h new file mode 100644 index 0000000..f9c8430 --- a/dev/null +++ b/include/midillo/util.h @@ -0,0 +1,63 @@ +#ifndef __MIDILLO_UTIL_H +#define __MIDILLO_UTIL_H + +#include +#include + +/** + * @file + * @brief utilities + */ + +namespace midillo { + using std::istream; + using std::ostream; + + /** + * read 32 bits word from the stream + * @param s input stream + * @return the data acquired + */ + unsigned long read32(istream& s); + /** + * read 16 bits word from the stream + * @param s input stream + * @return the data acquired + */ + unsigned int read16(istream& s); + /** + * read the variable length quantity from the stream + * @param s input stream + * @return the data acquired + */ + unsigned long readVL(istream& s); + + /** + * write 32 bits word to the stream + * @param s output stream + * @param d data to write + */ + void write32(ostream& s,unsigned long d); + /** + * write 16 bits word to the stream + * @param s output stream + * @param d data to write + */ + void write16(ostream& s,unsigned int d); + /** + * write the variable length quantity to the stream + * @param s output stream + * @param d data to write + */ + void writeVL(ostream& s,unsigned long d); + + /** + * calculate the amount of data that would be written by writeVL + * @param d data that would be written + * @return the number of bytes + */ + unsigned long calcVLsize(unsigned long d); + +} + +#endif /* __MIDILLO_UTIL_H */ -- cgit v0.9.0.2