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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/g4tools/include/tools/wroot/named (Version 11.3.0) and /externals/g4tools/include/tools/wroot/named (Version 11.2)


  1 // Copyright (C) 2010, Guy Barrand. All rights      1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  2 // See the file tools.license for terms.            2 // See the file tools.license for terms.
  3                                                     3 
  4 #ifndef tools_wroot_named                           4 #ifndef tools_wroot_named
  5 #define tools_wroot_named                           5 #define tools_wroot_named
  6                                                     6 
  7 #include "buffer"                                   7 #include "buffer"
  8 #include "../vmanip"                                8 #include "../vmanip"
  9 //#include "../vdata"                               9 //#include "../vdata"
 10                                                    10 
 11 namespace tools {                                  11 namespace tools {
 12 namespace wroot {                                  12 namespace wroot {
 13                                                    13 
 14 inline bool Object_stream(buffer& a_buffer) {      14 inline bool Object_stream(buffer& a_buffer) {
 15   short v = 1;                                     15   short v = 1;
 16   if(!a_buffer.write_version(v)) return false;     16   if(!a_buffer.write_version(v)) return false;
 17   if(!a_buffer.write((unsigned int)0)) return      17   if(!a_buffer.write((unsigned int)0)) return false;
 18   static const unsigned int kNotDeleted = 0x02     18   static const unsigned int kNotDeleted = 0x02000000;
 19   if(!a_buffer.write(kNotDeleted)) return fals     19   if(!a_buffer.write(kNotDeleted)) return false;
 20   return true;                                     20   return true;
 21 }                                                  21 }
 22                                                    22 
 23 inline bool Named_stream(buffer& a_buffer,cons     23 inline bool Named_stream(buffer& a_buffer,const std::string& a_name,const std::string& a_title) {
 24   unsigned int beg;                                24   unsigned int beg;
 25   if(!a_buffer.write_version(1,beg)) return fa     25   if(!a_buffer.write_version(1,beg)) return false;
 26   if(!Object_stream(a_buffer)) return false;       26   if(!Object_stream(a_buffer)) return false;
 27   if(!a_buffer.write(a_name)) return false;        27   if(!a_buffer.write(a_name)) return false;
 28   if(!a_buffer.write(a_title)) return false;       28   if(!a_buffer.write(a_title)) return false;
 29   if(!a_buffer.set_byte_count(beg)) return fal     29   if(!a_buffer.set_byte_count(beg)) return false;
 30   return true;                                     30   return true;
 31 }                                                  31 }
 32                                                    32 
 33 template <class T>                                 33 template <class T>
 34 class obj_array : public virtual ibo, public s     34 class obj_array : public virtual ibo, public std::vector<T*> {
 35   static unsigned int kNullTag() {return 0;}       35   static unsigned int kNullTag() {return 0;}
 36 public: //ibo                                      36 public: //ibo
 37   virtual const std::string& store_cls() const     37   virtual const std::string& store_cls() const {
 38     static const std::string s_v("TObjArray");     38     static const std::string s_v("TObjArray");
 39     return s_v;                                    39     return s_v;
 40   }                                                40   }
 41   virtual bool stream(buffer& a_buffer) const      41   virtual bool stream(buffer& a_buffer) const {
 42     unsigned int c;                                42     unsigned int c;
 43     if(!a_buffer.write_version(3,c)) return fa     43     if(!a_buffer.write_version(3,c)) return false;
 44     if(!Object_stream(a_buffer)) return false;     44     if(!Object_stream(a_buffer)) return false;
 45     if(!a_buffer.write(std::string(""))) retur     45     if(!a_buffer.write(std::string(""))) return false;
 46     int nobjects = int(std::vector<T*>::size()     46     int nobjects = int(std::vector<T*>::size());
 47     if(!a_buffer.write(nobjects)) return false     47     if(!a_buffer.write(nobjects)) return false;
 48     int lowerBound = 0;                            48     int lowerBound = 0;
 49     if(!a_buffer.write(lowerBound)) return fal     49     if(!a_buffer.write(lowerBound)) return false;
 50                                                    50 
 51     typedef typename std::vector<T*>::const_it     51     typedef typename std::vector<T*>::const_iterator it_t;
 52     it_t it;                                       52     it_t it;
 53     for(it=std::vector<T*>::begin();it!=std::v     53     for(it=std::vector<T*>::begin();it!=std::vector<T*>::end();++it) {
 54       if(*it) {                                    54       if(*it) {
 55         if(!a_buffer.write_object(*(*it))) ret     55         if(!a_buffer.write_object(*(*it))) return false;
 56       } else { //Could happen with branch::m_b     56       } else { //Could happen with branch::m_baskets.
 57         if(!a_buffer.write(kNullTag())) return     57         if(!a_buffer.write(kNullTag())) return false;
 58       }                                            58       }
 59     }                                              59     }
 60     if(!a_buffer.set_byte_count(c)) return fal     60     if(!a_buffer.set_byte_count(c)) return false;
 61     return true;                                   61     return true;
 62   }                                                62   }
 63 public:                                            63 public:
 64   obj_array(){}                                    64   obj_array(){}
 65   virtual ~obj_array(){safe_clear<T>(*this);}      65   virtual ~obj_array(){safe_clear<T>(*this);}
 66 public:                                            66 public:
 67   obj_array(const obj_array& a_from): ibo(a_fr     67   obj_array(const obj_array& a_from): ibo(a_from),std::vector<T*>() {
 68     typedef typename std::vector<T*>::const_it     68     typedef typename std::vector<T*>::const_iterator it_t;
 69     it_t it;                                       69     it_t it;
 70     for(it=a_from.begin();it!=a_from.end();++i     70     for(it=a_from.begin();it!=a_from.end();++it) {
 71       std::vector<T*>::push_back((*it)->copy()     71       std::vector<T*>::push_back((*it)->copy());
 72     }                                              72     }
 73   }                                                73   }
 74   obj_array& operator=(const obj_array& a_from     74   obj_array& operator=(const obj_array& a_from){
 75     if(&a_from==this) return *this;                75     if(&a_from==this) return *this;
 76     safe_clear<T>(*this);                          76     safe_clear<T>(*this);
 77                                                    77 
 78     typedef typename std::vector<T*>::const_it     78     typedef typename std::vector<T*>::const_iterator it_t;
 79     it_t it;                                       79     it_t it;
 80     for(it=a_from.begin();it!=a_from.end();++i     80     for(it=a_from.begin();it!=a_from.end();++it) {
 81       std::vector<T*>::push_back((*it)->copy()     81       std::vector<T*>::push_back((*it)->copy());
 82     }                                              82     }
 83     return *this;                                  83     return *this;
 84   }                                                84   }
 85 public:                                            85 public:
 86   void clear_objs() {safe_clear<T>(*this);}        86   void clear_objs() {safe_clear<T>(*this);}
 87 };                                                 87 };
 88                                                    88 
 89 template <class T>                                 89 template <class T>
 90 class obj_list : public virtual ibo, public st     90 class obj_list : public virtual ibo, public std::vector<T*> {
 91 public: //ibo                                      91 public: //ibo
 92   virtual const std::string& store_cls() const     92   virtual const std::string& store_cls() const {
 93     static const std::string s_v("TList");         93     static const std::string s_v("TList");
 94     return s_v;                                    94     return s_v;
 95   }                                                95   }
 96   virtual bool stream(buffer& a_buffer) const      96   virtual bool stream(buffer& a_buffer) const {
 97     unsigned int c;                                97     unsigned int c;
 98     if(!a_buffer.write_version(4,c)) return fa     98     if(!a_buffer.write_version(4,c)) return false;
 99     if(!Object_stream(a_buffer)) return false;     99     if(!Object_stream(a_buffer)) return false;
100     if(!a_buffer.write(std::string(""))) retur    100     if(!a_buffer.write(std::string(""))) return false; //fName
101     int nobjects = int(std::vector<T*>::size()    101     int nobjects = int(std::vector<T*>::size());
102     if(!a_buffer.write(nobjects)) return false    102     if(!a_buffer.write(nobjects)) return false;
103                                                   103 
104     typedef typename std::vector<T*>::const_it    104     typedef typename std::vector<T*>::const_iterator it_t;
105     it_t it;                                      105     it_t it;
106     for(it=std::vector<T*>::begin();it!=std::v    106     for(it=std::vector<T*>::begin();it!=std::vector<T*>::end();++it) {
107       if(!a_buffer.write_object(*(*it))) retur    107       if(!a_buffer.write_object(*(*it))) return false;
108       std::string opt;                            108       std::string opt;
109       unsigned char nch = (unsigned char)opt.s    109       unsigned char nch = (unsigned char)opt.size();
110       if(!a_buffer.write(nch)) return false;      110       if(!a_buffer.write(nch)) return false;
111       if(!a_buffer.write_fast_array<char>(opt.    111       if(!a_buffer.write_fast_array<char>(opt.c_str(),nch)) return false;
112     }                                             112     }
113     if(!a_buffer.set_byte_count(c)) return fal    113     if(!a_buffer.set_byte_count(c)) return false;
114     return true;                                  114     return true;
115   }                                               115   }
116 public:                                           116 public:
117   obj_list(){}                                    117   obj_list(){}
118   virtual ~obj_list(){safe_clear<T>(*this);}      118   virtual ~obj_list(){safe_clear<T>(*this);}
119 protected:                                        119 protected:
120   obj_list(const obj_list& a_from):ibo(a_from)    120   obj_list(const obj_list& a_from):ibo(a_from),std::vector<T*>(){}
121   obj_list& operator=(const obj_list&){return     121   obj_list& operator=(const obj_list&){return *this;}
122 };                                                122 };
123                                                   123 
124 inline bool AttLine_stream(buffer& a_buffer){     124 inline bool AttLine_stream(buffer& a_buffer){
125   short fLineColor = 1;                           125   short fLineColor = 1;
126   short fLineStyle = 1;                           126   short fLineStyle = 1;
127   short fLineWidth = 1;                           127   short fLineWidth = 1;
128   unsigned int c;                                 128   unsigned int c;
129   if(!a_buffer.write_version(1,c)) return fals    129   if(!a_buffer.write_version(1,c)) return false;
130   if(!a_buffer.write(fLineColor)) return false    130   if(!a_buffer.write(fLineColor)) return false;
131   if(!a_buffer.write(fLineStyle)) return false    131   if(!a_buffer.write(fLineStyle)) return false;
132   if(!a_buffer.write(fLineWidth)) return false    132   if(!a_buffer.write(fLineWidth)) return false;
133   if(!a_buffer.set_byte_count(c)) return false    133   if(!a_buffer.set_byte_count(c)) return false;
134   return true;                                    134   return true;
135 }                                                 135 }
136                                                   136 
137 inline bool AttFill_stream(buffer& a_buffer){     137 inline bool AttFill_stream(buffer& a_buffer){
138   short fFillColor = 0;                           138   short fFillColor = 0;
139   short fFillStyle = 101;                         139   short fFillStyle = 101;
140   unsigned int c;                                 140   unsigned int c;
141   if(!a_buffer.write_version(1,c)) return fals    141   if(!a_buffer.write_version(1,c)) return false;
142   if(!a_buffer.write(fFillColor)) return false    142   if(!a_buffer.write(fFillColor)) return false;
143   if(!a_buffer.write(fFillStyle)) return false    143   if(!a_buffer.write(fFillStyle)) return false;
144   if(!a_buffer.set_byte_count(c)) return false    144   if(!a_buffer.set_byte_count(c)) return false;
145   return true;                                    145   return true;
146 }                                                 146 }
147                                                   147 
148 inline bool AttMarker_stream(buffer& a_buffer)    148 inline bool AttMarker_stream(buffer& a_buffer) {
149   short fMarkerColor = 1;                         149   short fMarkerColor = 1;
150   short fMarkerStyle = 1;                         150   short fMarkerStyle = 1;
151   float fMarkerWidth = 1;                         151   float fMarkerWidth = 1;
152   unsigned int c;                                 152   unsigned int c;
153   if(!a_buffer.write_version(1,c)) return fals    153   if(!a_buffer.write_version(1,c)) return false;
154   if(!a_buffer.write(fMarkerColor)) return fal    154   if(!a_buffer.write(fMarkerColor)) return false;
155   if(!a_buffer.write(fMarkerStyle)) return fal    155   if(!a_buffer.write(fMarkerStyle)) return false;
156   if(!a_buffer.write(fMarkerWidth)) return fal    156   if(!a_buffer.write(fMarkerWidth)) return false;
157   if(!a_buffer.set_byte_count(c)) return false    157   if(!a_buffer.set_byte_count(c)) return false;
158   return true;                                    158   return true;
159 }                                                 159 }
160                                                   160 
161 inline bool Att3D_stream(buffer& a_buffer){       161 inline bool Att3D_stream(buffer& a_buffer){
162   unsigned int c;                                 162   unsigned int c;
163   if(!a_buffer.write_version(1,c)) return fals    163   if(!a_buffer.write_version(1,c)) return false;
164   if(!a_buffer.set_byte_count(c)) return false    164   if(!a_buffer.set_byte_count(c)) return false;
165   return true;                                    165   return true;
166 }                                                 166 }
167                                                   167 
168 //template <class T>                              168 //template <class T>
169 //inline bool Array_stream(buffer& a_buffer,co    169 //inline bool Array_stream(buffer& a_buffer,const std::vector<T>& a_v) {
170 //  if(!a_buffer.write((int)a_v.size())) retur    170 //  if(!a_buffer.write((int)a_v.size())) return false;
171 //  if(!a_buffer.write_fast_array(vec_data(a_v    171 //  if(!a_buffer.write_fast_array(vec_data(a_v),a_v.size())) return false;
172 //  return true;                                  172 //  return true;
173 //}                                               173 //}
174                                                   174 
175 }}                                                175 }}
176                                                   176 
177 #endif                                            177 #endif