inlib  1.2.0
/Users/barrand/private/dev/softinex/old/inexlib-1.2/inlib/inlib/io/irbuf
Go to the documentation of this file.
00001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
00002 // See the file inlib.license for terms.
00003 
00004 #ifndef inlib_io_irbuf
00005 #define inlib_io_irbuf
00006 
00007 #include "../typedefs"
00008 
00009 #include <vector>
00010 #include <string>
00011 
00012 namespace inlib {
00013 namespace io {
00014 
00015 class irbuf {
00016 public:
00017   virtual ~irbuf() {}
00018 public:
00019   virtual bool read(uchar&) = 0;
00020   virtual bool read(char&) = 0;
00021   virtual bool read(uint16&) = 0;
00022   virtual bool read(int16&) = 0;
00023   virtual bool read(uint32&) = 0;
00024   virtual bool read(int32&) = 0;
00025   virtual bool read(uint64&) = 0;
00026   virtual bool read(int64&) = 0;
00027   virtual bool read(float&) = 0;
00028   virtual bool read(double&) = 0;
00029   virtual bool read(bool&) = 0;
00030 
00031   virtual bool read_vec(uint32&,uchar*&) = 0;
00032   virtual bool read_vec(uint32&,char*&) = 0;
00033   virtual bool read_vec(uint32&,uint16*&) = 0;
00034   virtual bool read_vec(uint32&,int16*&) = 0;
00035   virtual bool read_vec(uint32&,uint32*&) = 0;
00036   virtual bool read_vec(uint32&,int32*&) = 0;
00037   virtual bool read_vec(uint32&,uint64*&) = 0;
00038   virtual bool read_vec(uint32&,int64*&) = 0;
00039   virtual bool read_vec(uint32&,float*&) = 0;
00040   virtual bool read_vec(uint32&,double*&) = 0;
00041   virtual bool read_vec(uint32&,bool*&) = 0;
00042 
00043   virtual bool read_vec(std::vector<std::string>&) = 0;
00044 
00045   virtual bool read_cstr(char*&) = 0;
00046 
00047   typedef std::vector< std::vector<unsigned int> > std_vec_vec_uint_t;
00048   virtual bool read_std_vec_vec(std_vec_vec_uint_t&) = 0;
00049 
00050   typedef std::vector< std::vector<float> > std_vec_vec_float_t;
00051   virtual bool read_std_vec_vec(std_vec_vec_float_t&) = 0;
00052 
00053   typedef std::vector< std::vector<std::string> > std_vec_vec_string_t;
00054   virtual bool read_std_vec_vec(std_vec_vec_string_t&) = 0;
00055 public: //helpers
00056   template <class T>
00057   bool read_std_vec(std::vector<T>& a_x) { 
00058     uint32 n;
00059     T* v;
00060     if(!read_vec(n,v)) return false;
00061     a_x.resize(n);
00062     for(uint32 index=0;index<n;index++) a_x[index] = v[index];
00063     delete [] v;
00064     return true;
00065   }
00066 
00067 };
00068 
00069 }}
00070 
00071 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines