Octane v1.01.20 - The Open Compression Toolkit for C++ http://octane.sourceforge.net/
Homepage | Main | Modules | Class Hierarchy | Compound List | File List | Compound Members | Related Pages

bitio/bitwriters.hpp

Go to the documentation of this file.
00001 //
00002 // bitwriters  --  bitwriter specializations
00003 //
00004 // Copyright (c) 2003 by Jørgen Ibsen / Jibz
00005 // All Rights Reserved
00006 //
00007 // http://www.ibsensoftware.com/
00008 //
00009 
00014 
00015 #ifndef BITWRITERS_HPP_INCLUDED
00016 #define BITWRITERS_HPP_INCLUDED
00017 
00018 #include <iostream>
00019 #include <vector>
00020 #include <string>
00021 
00022 #include "bitwriter.hpp"
00023 
00026 
00028 class null_bitwriter : public bitwriter {
00029 
00030 public:
00032     null_bitwriter() { ; }
00033 
00034     ~null_bitwriter() { finalize(); }
00035 
00036 protected:
00037     void write_next_byte(char c) { ; }
00038 };
00039 
00041 class stream_bitwriter : public bitwriter {
00042 
00043 public:
00046     stream_bitwriter(std::ostream &_s) : s(_s) { ; }
00047 
00048     ~stream_bitwriter() { finalize(); }
00049 
00050 protected:
00051     void write_next_byte(char c) { s.put(c); }
00052 
00053     std::ostream &s;
00054 };
00055 
00057 class vector_bitwriter : public bitwriter {
00058 
00059 public:
00062     vector_bitwriter(std::vector<char> &_s) : s(_s) { ; }
00063 
00064     ~vector_bitwriter() { finalize(); }
00065 
00066 protected:
00067     void write_next_byte(char c) { s.push_back(c); }
00068 
00069     std::vector<char> &s;
00070 };
00071 
00073 class string_bitwriter : public bitwriter {
00074 
00075 public:
00078     string_bitwriter(std::string &_s) : s(_s) { ; }
00079 
00080     ~string_bitwriter() { finalize(); }
00081 
00082 protected:
00083     void write_next_byte(char c) { s += c; }
00084 
00085     std::string &s;
00086 };
00087 
00089 class array_bitwriter : public bitwriter {
00090 
00091 public:
00094     array_bitwriter(char *_s) : s(_s) { ; }
00095 
00096     ~array_bitwriter() { finalize(); }
00097 
00098 protected:
00099     void write_next_byte(char c) { *s++ = c; }
00100 
00101     char *s;
00102 };
00103 
00105 
00106 #endif // BITWRITERS_HPP_INCLUDED
 
Generated on 20 May 2004 by doxygen 1.3.3