Go to the documentation of this file.00001 
00002 
00003 #ifndef OSL_BINARYIO_H
00004 #define OSL_BINARYIO_H
00005 #include <boost/scoped_ptr.hpp>
00006 #include <vector>
00007 #include <iosfwd>
00008 
00009 namespace osl
00010 {
00011   namespace misc
00012   {
00013     struct BinaryWriter
00014     {
00015       static void write(std::ostream&, const std::vector<int>& data);
00016       static void write(std::ostream&, const std::vector<double>& data);
00017     };
00018     template <class T>
00019     class BinaryReader
00020     {
00021     public:
00022       explicit BinaryReader(std::istream& is);
00023       ~BinaryReader();
00024       
00025       bool read(std::vector<T>& data);
00026       static size_t blockSize();
00027     private:
00028       struct State;
00029       boost::scoped_ptr<State> state;
00030     };
00031 
00032     template <class T>
00033     class BinaryElementReader
00034     {
00035     public:
00036       explicit BinaryElementReader(std::istream& is);
00037       ~BinaryElementReader();
00038 
00039       T read();
00040       bool hasNext() const;
00041       bool failed() const;
00042     private:
00043       struct State;
00044       boost::scoped_ptr<State> state;
00045     };
00046   }    
00047 }
00048 
00049 #endif 
00050 
00051 
00052 
00053