/Src/Dependencies/Boost/boost/archive/impl/basic_xml_iarchive.ipp

http://hadesmem.googlecode.com/ · C++ Header · 114 lines · 84 code · 16 blank · 14 comment · 15 complexity · d4c52a0097455f1e66ff8b63b05c5f8f MD5 · raw file

  1. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  2. // basic_xml_iarchive.ipp:
  3. // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
  4. // Use, modification and distribution is subject to the Boost Software
  5. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. // See http://www.boost.org for updates, documentation, and revision history.
  8. #include <boost/assert.hpp>
  9. #include <cstddef> // NULL
  10. #include <algorithm>
  11. #include <boost/serialization/throw_exception.hpp>
  12. #include <boost/archive/xml_archive_exception.hpp>
  13. #include <boost/archive/basic_xml_iarchive.hpp>
  14. #include <boost/serialization/tracking.hpp>
  15. namespace boost {
  16. namespace archive {
  17. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  18. // implementation of xml_text_archive
  19. template<class Archive>
  20. BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
  21. basic_xml_iarchive<Archive>::load_start(const char *name){
  22. // if there's no name
  23. if(NULL == name)
  24. return;
  25. bool result = this->This()->gimpl->parse_start_tag(this->This()->get_is());
  26. if(true != result){
  27. boost::serialization::throw_exception(
  28. archive_exception(archive_exception::input_stream_error)
  29. );
  30. }
  31. // don't check start tag at highest level
  32. ++depth;
  33. return;
  34. }
  35. template<class Archive>
  36. BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
  37. basic_xml_iarchive<Archive>::load_end(const char *name){
  38. // if there's no name
  39. if(NULL == name)
  40. return;
  41. bool result = this->This()->gimpl->parse_end_tag(this->This()->get_is());
  42. if(true != result){
  43. boost::serialization::throw_exception(
  44. archive_exception(archive_exception::input_stream_error)
  45. );
  46. }
  47. // don't check start tag at highest level
  48. if(0 == --depth)
  49. return;
  50. if(0 == (this->get_flags() & no_xml_tag_checking)){
  51. // double check that the tag matches what is expected - useful for debug
  52. if(0 != name[this->This()->gimpl->rv.object_name.size()]
  53. || ! std::equal(
  54. this->This()->gimpl->rv.object_name.begin(),
  55. this->This()->gimpl->rv.object_name.end(),
  56. name
  57. )
  58. ){
  59. boost::serialization::throw_exception(
  60. xml_archive_exception(
  61. xml_archive_exception::xml_archive_tag_mismatch,
  62. name
  63. )
  64. );
  65. }
  66. }
  67. }
  68. template<class Archive>
  69. BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
  70. basic_xml_iarchive<Archive>::load_override(object_id_type & t, int){
  71. t = object_id_type(this->This()->gimpl->rv.object_id);
  72. }
  73. template<class Archive>
  74. BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
  75. basic_xml_iarchive<Archive>::load_override(version_type & t, int){
  76. t = version_type(this->This()->gimpl->rv.version);
  77. }
  78. template<class Archive>
  79. BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
  80. basic_xml_iarchive<Archive>::load_override(class_id_type & t, int){
  81. t = class_id_type(this->This()->gimpl->rv.class_id);
  82. }
  83. template<class Archive>
  84. BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
  85. basic_xml_iarchive<Archive>::load_override(tracking_type & t, int){
  86. t = this->This()->gimpl->rv.tracking_level;
  87. }
  88. template<class Archive>
  89. BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
  90. basic_xml_iarchive<Archive>::basic_xml_iarchive(unsigned int flags) :
  91. detail::common_iarchive<Archive>(flags),
  92. depth(0)
  93. {}
  94. template<class Archive>
  95. BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
  96. basic_xml_iarchive<Archive>::~basic_xml_iarchive(){}
  97. } // namespace archive
  98. } // namespace boost