xml_iarchive.hpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. #ifndef BOOST_ARCHIVE_XML_IARCHIVE_HPP
  2. #define BOOST_ARCHIVE_XML_IARCHIVE_HPP
  3. // MS compatible compilers support #pragma once
  4. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  5. # pragma once
  6. #endif
  7. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  8. // xml_iarchive.hpp
  9. // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
  10. // Use, modification and distribution is subject to the Boost Software
  11. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. // See http://www.boost.org for updates, documentation, and revision history.
  14. #include <istream>
  15. //#include <boost/scoped_ptr.hpp>
  16. #include <boost/archive/detail/auto_link_archive.hpp>
  17. #include <boost/archive/basic_text_iprimitive.hpp>
  18. #include <boost/archive/basic_xml_iarchive.hpp>
  19. #include <boost/archive/detail/register_archive.hpp>
  20. #include <boost/serialization/item_version_type.hpp>
  21. #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
  22. #ifdef BOOST_MSVC
  23. # pragma warning(push)
  24. # pragma warning(disable : 4511 4512)
  25. #endif
  26. namespace boost {
  27. namespace archive {
  28. template<class CharType>
  29. class basic_xml_grammar;
  30. typedef basic_xml_grammar<char> xml_grammar;
  31. template<class Archive>
  32. class xml_iarchive_impl :
  33. public basic_text_iprimitive<std::istream>,
  34. public basic_xml_iarchive<Archive>
  35. {
  36. #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
  37. public:
  38. #else
  39. friend class detail::interface_iarchive<Archive>;
  40. friend class basic_xml_iarchive<Archive>;
  41. friend class load_access;
  42. protected:
  43. #endif
  44. // instances of micro xml parser to parse start preambles
  45. // scoped_ptr doesn't play nice with borland - so use a naked pointer
  46. // scoped_ptr<xml_grammar> gimpl;
  47. xml_grammar *gimpl;
  48. std::istream & get_is(){
  49. return is;
  50. }
  51. template<class T>
  52. void load(T & t){
  53. basic_text_iprimitive<std::istream>::load(t);
  54. }
  55. void
  56. load(version_type & t){
  57. unsigned int v;
  58. load(v);
  59. t = version_type(v);
  60. }
  61. void
  62. load(boost::serialization::item_version_type & t){
  63. unsigned int v;
  64. load(v);
  65. t = boost::serialization::item_version_type(v);
  66. }
  67. BOOST_ARCHIVE_DECL(void)
  68. load(char * t);
  69. #ifndef BOOST_NO_INTRINSIC_WCHAR_T
  70. BOOST_ARCHIVE_DECL(void)
  71. load(wchar_t * t);
  72. #endif
  73. BOOST_ARCHIVE_DECL(void)
  74. load(std::string &s);
  75. #ifndef BOOST_NO_STD_WSTRING
  76. BOOST_ARCHIVE_DECL(void)
  77. load(std::wstring &ws);
  78. #endif
  79. template<class T>
  80. void load_override(T & t, BOOST_PFTO int){
  81. basic_xml_iarchive<Archive>::load_override(t, 0);
  82. }
  83. BOOST_ARCHIVE_DECL(void)
  84. load_override(class_name_type & t, int);
  85. BOOST_ARCHIVE_DECL(void)
  86. init();
  87. BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
  88. xml_iarchive_impl(std::istream & is, unsigned int flags);
  89. BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
  90. ~xml_iarchive_impl();
  91. };
  92. // do not derive from the classes below. If you want to extend this functionality
  93. // via inhertance, derived from text_iarchive_impl instead. This will
  94. // preserve correct static polymorphism.
  95. // same as xml_iarchive below - without the shared_ptr_helper
  96. class naked_xml_iarchive :
  97. public xml_iarchive_impl<naked_xml_iarchive>
  98. {
  99. public:
  100. naked_xml_iarchive(std::istream & is, unsigned int flags = 0) :
  101. xml_iarchive_impl<naked_xml_iarchive>(is, flags)
  102. {}
  103. ~naked_xml_iarchive(){}
  104. };
  105. } // namespace archive
  106. } // namespace boost
  107. #ifdef BOOST_MSVC
  108. #pragma warning(pop)
  109. #endif
  110. #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
  111. // note special treatment of shared_ptr. This type needs a special
  112. // structure associated with every archive. We created a "mix-in"
  113. // class to provide this functionality. Since shared_ptr holds a
  114. // special esteem in the boost library - we included it here by default.
  115. #include <boost/archive/shared_ptr_helper.hpp>
  116. #ifdef BOOST_MSVC
  117. # pragma warning(push)
  118. # pragma warning(disable : 4511 4512)
  119. #endif
  120. namespace boost {
  121. namespace archive {
  122. class xml_iarchive :
  123. public xml_iarchive_impl<xml_iarchive>,
  124. public detail::shared_ptr_helper
  125. {
  126. public:
  127. xml_iarchive(std::istream & is, unsigned int flags = 0) :
  128. xml_iarchive_impl<xml_iarchive>(is, flags)
  129. {}
  130. ~xml_iarchive(){};
  131. };
  132. } // namespace archive
  133. } // namespace boost
  134. // required by export
  135. BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_iarchive)
  136. #ifdef BOOST_MSVC
  137. #pragma warning(pop)
  138. #endif
  139. #endif // BOOST_ARCHIVE_XML_IARCHIVE_HPP