basic_text_oarchive.ipp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  2. // basic_text_oarchive.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 <string>
  9. #include <boost/assert.hpp>
  10. #include <cstring>
  11. #include <boost/config.hpp>
  12. #if defined(BOOST_NO_STDC_NAMESPACE)
  13. namespace std{
  14. using ::memcpy;
  15. }
  16. #endif
  17. #include <boost/archive/basic_text_oarchive.hpp>
  18. namespace boost {
  19. namespace archive {
  20. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  21. // implementation of basic_text_oarchive
  22. template<class Archive>
  23. BOOST_ARCHIVE_OR_WARCHIVE_DECL void
  24. basic_text_oarchive<Archive>::newtoken()
  25. {
  26. switch(delimiter){
  27. default:
  28. BOOST_ASSERT(false);
  29. break;
  30. case eol:
  31. this->This()->put('\n');
  32. delimiter = space;
  33. break;
  34. case space:
  35. this->This()->put(' ');
  36. break;
  37. case none:
  38. delimiter = space;
  39. break;
  40. }
  41. }
  42. template<class Archive>
  43. BOOST_ARCHIVE_OR_WARCHIVE_DECL void
  44. basic_text_oarchive<Archive>::init(){
  45. // write signature in an archive version independent manner
  46. const std::string file_signature(BOOST_ARCHIVE_SIGNATURE());
  47. * this->This() << file_signature;
  48. // write library version
  49. const library_version_type v(BOOST_ARCHIVE_VERSION());
  50. * this->This() << v;
  51. }
  52. } // namespace archive
  53. } // namespace boost