Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/io/irbuf is written in an unsupported language. File is not indexed.

0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003 
0004 #ifndef tools_io_irbuf
0005 #define tools_io_irbuf
0006 
0007 #include "../typedefs"
0008 
0009 #include <vector>
0010 #include <string>
0011 
0012 #ifdef TOOLS_MEM
0013 #include "../mem"
0014 #endif
0015 
0016 namespace tools {
0017 namespace io {
0018 
0019 class irbuf {
0020 public:
0021   virtual ~irbuf() {}
0022 public:
0023   virtual bool read(uchar&) = 0;
0024   virtual bool read(char&) = 0;
0025   virtual bool read(uint16&) = 0;
0026   virtual bool read(int16&) = 0;
0027   virtual bool read(uint32&) = 0;
0028   virtual bool read(int32&) = 0;
0029   virtual bool read(uint64&) = 0;
0030   virtual bool read(int64&) = 0;
0031   virtual bool read(float&) = 0;
0032   virtual bool read(double&) = 0;
0033   virtual bool read(bool&) = 0;
0034 
0035   virtual bool read_vec(uint32&,uchar*&) = 0;
0036   virtual bool read_vec(uint32&,char*&) = 0;
0037   virtual bool read_vec(uint32&,uint16*&) = 0;
0038   virtual bool read_vec(uint32&,int16*&) = 0;
0039   virtual bool read_vec(uint32&,uint32*&) = 0;
0040   virtual bool read_vec(uint32&,int32*&) = 0;
0041   virtual bool read_vec(uint32&,uint64*&) = 0;
0042   virtual bool read_vec(uint32&,int64*&) = 0;
0043   virtual bool read_vec(uint32&,float*&) = 0;
0044   virtual bool read_vec(uint32&,double*&) = 0;
0045   virtual bool read_vec(uint32&,bool*&) = 0;
0046 
0047   virtual bool read_vec(std::vector<std::string>&) = 0;
0048 
0049   virtual bool read_cstr(char*&) = 0;
0050   virtual bool read_img(uint32&,uint32&,uint32&,uchar*&) = 0;
0051 
0052   typedef std::vector< std::vector<unsigned int> > std_vec_vec_uint_t;
0053   virtual bool read_std_vec_vec(std_vec_vec_uint_t&) = 0;
0054 
0055   typedef std::vector< std::vector<float> > std_vec_vec_float_t;
0056   virtual bool read_std_vec_vec(std_vec_vec_float_t&) = 0;
0057 
0058   typedef std::vector< std::vector<double> > std_vec_vec_double_t;
0059   virtual bool read_std_vec_vec(std_vec_vec_double_t&) = 0;
0060 
0061   typedef std::vector< std::vector<std::string> > std_vec_vec_string_t;
0062   virtual bool read_std_vec_vec(std_vec_vec_string_t&) = 0;
0063 public: //helpers
0064   template <class T>
0065   bool read_std_vec(std::vector<T>& a_x) {
0066     uint32 n;
0067     T* v;
0068     if(!read_vec(n,v)) return false;
0069     a_x.resize(n);
0070     for(uint32 index=0;index<n;index++) a_x[index] = v[index];
0071     delete [] v;
0072 #ifdef TOOLS_MEM
0073     mem::decrement(s_new().c_str());
0074 #endif
0075     return true;
0076   }
0077 
0078 };
0079 
0080 }}
0081 
0082 #endif