Ticket #5876: boost.serrialization.patch
File boost.serrialization.patch, 9.4 KB (added by , 11 years ago) |
---|
-
boost/archive/basic_archive.hpp
210 210 } 211 211 }; 212 212 213 struct tracking_level_type { 214 int t; 215 explicit tracking_level_type(const int t_ = 0) 216 : t(t_) 217 {}; 218 tracking_level_type(const tracking_level_type & t_) 219 : t(t_.t) 220 {} 221 operator int () const { 222 return t; 223 }; 224 operator int & () { 225 return t; 226 }; 227 tracking_level_type & operator=(const int t_){ 228 t = t_; 229 return *this; 230 } 231 bool operator==(const tracking_level_type & rhs) const { 232 return t == rhs.t; 233 } 234 bool operator==(const int & rhs) const { 235 return t == rhs; 236 } 237 tracking_level_type & operator=(const tracking_level_type & rhs){ 238 t = rhs.t; 239 return *this; 240 } 241 }; 242 213 243 struct class_name_type : 214 244 private boost::noncopyable 215 245 { -
boost/archive/detail/basic_iserializer.hpp
57 57 #endif 58 58 ~basic_iserializer(); 59 59 public: 60 bool serialized_as_pointer() const {60 bool maybe_serialized_as_pointer() const { 61 61 return m_bpis != NULL; 62 62 } 63 63 void set_bpis(basic_pointer_iserializer *bpis){ … … 73 73 ) const = 0; 74 74 // returns true if class_info should be saved 75 75 virtual bool class_info() const = 0 ; 76 // returns t rue if objects should be tracked77 virtual bool tracking(const unsigned int) const = 0 ;76 // returns the tracking level 77 virtual int tracking() const = 0 ; 78 78 // returns class version 79 79 virtual version_type version() const = 0 ; 80 80 // returns true if this class is polymorphic -
boost/archive/detail/basic_oserializer.hpp
58 58 #endif 59 59 ~basic_oserializer(); 60 60 public: 61 bool serialized_as_pointer() const {61 bool maybe_serialized_as_pointer() const { 62 62 return m_bpos != NULL; 63 63 } 64 64 void set_bpos(basic_pointer_oserializer *bpos){ … … 72 72 ) const = 0; 73 73 // returns true if class_info should be saved 74 74 virtual bool class_info() const = 0; 75 // returns t rue if objects should be tracked76 virtual bool tracking(const unsigned int flags) const = 0;75 // returns the tracking level 76 virtual int tracking() const = 0; 77 77 // returns class version 78 78 virtual version_type version() const = 0; 79 79 // returns true if this class is polymorphic -
boost/archive/detail/iserializer.hpp
142 142 return boost::serialization::implementation_level< T >::value 143 143 >= boost::serialization::object_class_info; 144 144 } 145 virtual bool tracking(const unsigned int /* flags */) const { 146 return boost::serialization::tracking_level< T >::value 147 == boost::serialization::track_always 148 || ( boost::serialization::tracking_level< T >::value 149 == boost::serialization::track_selectively 150 && serialized_as_pointer()); 145 virtual int tracking() const { 146 return boost::serialization::tracking_level< T >::value; 151 147 } 152 148 virtual version_type version() const { 153 149 return version_type(::boost::serialization::version< T >::value); -
boost/archive/detail/oserializer.hpp
119 119 return boost::serialization::implementation_level< T >::value 120 120 >= boost::serialization::object_class_info; 121 121 } 122 virtual bool tracking(const unsigned int /* flags */) const { 123 return boost::serialization::tracking_level< T >::value == boost::serialization::track_always 124 || (boost::serialization::tracking_level< T >::value == boost::serialization::track_selectively 125 && serialized_as_pointer()); 122 virtual int tracking() const { 123 return boost::serialization::tracking_level< T >::value; 126 124 } 127 125 virtual version_type version() const { 128 126 return version_type(::boost::serialization::version< T >::value); -
libs/serialization/src/basic_iarchive.cpp
135 135 const basic_iserializer * bis_ptr; 136 136 const basic_pointer_iserializer * bpis_ptr; 137 137 version_type file_version; 138 tracking_ type tracking_level;138 tracking_level_type tracking_level; 139 139 bool initialized; 140 140 141 141 cobject_id(const basic_iserializer & bis_) : … … 318 318 if(! co.initialized){ 319 319 if(co.bis_ptr->class_info()){ 320 320 class_id_optional_type cid(class_id_type(0)); 321 load(ar, cid); // to be thrown away 322 load(ar, co.tracking_level); 323 load(ar, co.file_version); 321 load(ar, cid); // to be thrown away 322 323 tracking_type tracking; 324 load(ar, tracking); 325 co.tracking_level = tracking ? track_always : track_never; 326 327 load(ar, co.file_version); 324 328 } 325 329 else{ 326 330 // override tracking with indicator from class information 327 co.tracking_level = co.bis_ptr->tracking( m_flags);331 co.tracking_level = co.bis_ptr->tracking(); 328 332 co.file_version = version_type( 329 333 co.bis_ptr->version() 330 334 ); … … 373 377 boost::serialization::state_saver<object_id_type> w(moveable_objects_start); 374 378 375 379 // note: extra line used to evade borland issue 376 const bool tracking = co.tracking_level ;380 const bool tracking = co.tracking_level == tracking_level_type(track_always); 377 381 378 382 object_id_type this_id; 379 383 moveable_objects_start = … … 446 450 load_preamble(ar, co); 447 451 448 452 // extra line to evade borland issue 449 const bool tracking = co.tracking_level ;453 const bool tracking = co.tracking_level != tracking_level_type(track_never); 450 454 // if we're tracking and the pointer has already been read 451 455 if(tracking && ! track(ar, t)) 452 456 // we're done -
libs/serialization/src/basic_oarchive.cpp
181 181 BOOST_ASSERT(false); 182 182 return false; 183 183 } 184 // returns t rue if objects should be tracked185 bool tracking(const unsigned int) const {184 // returns the tracking level 185 int tracking() const { 186 186 BOOST_ASSERT(false); 187 187 return false; 188 188 } … … 255 255 return; 256 256 } 257 257 258 const tracking_type tracking( 259 bos.tracking() == track_selectively && bos.maybe_serialized_as_pointer() 260 || bos.tracking() == track_always 261 ); 262 258 263 // get class information for this object 259 264 const cobject_type & co = register_type(bos); 260 265 if(bos.class_info()){ 261 266 if( ! co.m_initialized){ 262 267 ar.vsave(class_id_optional_type(co.m_class_id)); 263 ar.vsave(tracking _type(bos.tracking(m_flags)));268 ar.vsave(tracking); 264 269 ar.vsave(version_type(bos.version())); 265 270 (const_cast<cobject_type &>(co)).m_initialized = true; 266 271 } 267 272 } 268 273 269 274 // we're not tracking this type of object 270 if(! bos.tracking(m_flags)){275 if(!tracking){ 271 276 // just windup the preamble - no object id to write 272 277 ar.end_preamble(); 273 278 // and save the data … … 317 322 const basic_oserializer & bos = bpos_ptr->get_basic_serializer(); 318 323 std::size_t original_count = cobject_info_set.size(); 319 324 const cobject_type & co = register_type(bos); 325 326 const tracking_type tracking( 327 bos.tracking() == track_selectively && bos.maybe_serialized_as_pointer() 328 || bos.tracking() == track_always 329 ); 330 320 331 if(! co.m_initialized){ 321 332 ar.vsave(co.m_class_id); 322 333 // if its a previously unregistered class … … 343 354 } 344 355 } 345 356 if(bos.class_info()){ 346 ar.vsave(tracking _type(bos.tracking(m_flags)));357 ar.vsave(tracking); 347 358 ar.vsave(version_type(bos.version())); 348 359 } 349 360 (const_cast<cobject_type &>(co)).m_initialized = true; … … 353 364 } 354 365 355 366 // if we're not tracking 356 if(! bos.tracking(m_flags)){367 if(!tracking){ 357 368 // just save the data itself 358 369 ar.end_preamble(); 359 370 serialization::state_saver<const void *> x(pending_object);