codecvt_null.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #ifndef BOOST_ARCHIVE_CODECVT_NULL_HPP
  2. #define BOOST_ARCHIVE_CODECVT_NULL_HPP
  3. // MS compatible compilers support #pragma once
  4. #if defined(_MSC_VER)
  5. # pragma once
  6. #endif
  7. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  8. // codecvt_null.hpp:
  9. // (C) Copyright 2004 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 <locale>
  15. #include <cstddef> // NULL, size_t
  16. #ifndef BOOST_NO_CWCHAR
  17. #include <cwchar> // for mbstate_t
  18. #endif
  19. #include <boost/config.hpp>
  20. #include <boost/serialization/force_include.hpp>
  21. #include <boost/archive/detail/auto_link_archive.hpp>
  22. #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
  23. #if defined(BOOST_NO_STDC_NAMESPACE)
  24. namespace std {
  25. // For STLport on WinCE, BOOST_NO_STDC_NAMESPACE can get defined if STLport is putting symbols in its own namespace.
  26. // In the case of codecvt, however, this does not mean that codecvt is in the global namespace (it will be in STLport's namespace)
  27. # if !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
  28. using ::codecvt;
  29. # endif
  30. using ::mbstate_t;
  31. using ::size_t;
  32. } // namespace
  33. #endif
  34. #ifdef BOOST_MSVC
  35. # pragma warning(push)
  36. # pragma warning(disable : 4511 4512)
  37. #endif
  38. namespace boost {
  39. namespace archive {
  40. template<class Ch>
  41. class codecvt_null;
  42. template<>
  43. class codecvt_null<char> : public std::codecvt<char, char, std::mbstate_t>
  44. {
  45. virtual bool do_always_noconv() const throw() {
  46. return true;
  47. }
  48. public:
  49. explicit codecvt_null(std::size_t no_locale_manage = 0) :
  50. std::codecvt<char, char, std::mbstate_t>(no_locale_manage)
  51. {}
  52. virtual ~codecvt_null(){};
  53. };
  54. template<>
  55. class BOOST_WARCHIVE_DECL codecvt_null<wchar_t> :
  56. public std::codecvt<wchar_t, char, std::mbstate_t>
  57. {
  58. virtual std::codecvt_base::result
  59. do_out(
  60. std::mbstate_t & state,
  61. const wchar_t * first1,
  62. const wchar_t * last1,
  63. const wchar_t * & next1,
  64. char * first2,
  65. char * last2,
  66. char * & next2
  67. ) const;
  68. virtual std::codecvt_base::result
  69. do_in(
  70. std::mbstate_t & state,
  71. const char * first1,
  72. const char * last1,
  73. const char * & next1,
  74. wchar_t * first2,
  75. wchar_t * last2,
  76. wchar_t * & next2
  77. ) const;
  78. virtual int do_encoding( ) const throw( ){
  79. return sizeof(wchar_t) / sizeof(char);
  80. }
  81. virtual int do_max_length( ) const throw( ){
  82. return do_encoding();
  83. }
  84. public:
  85. explicit codecvt_null(std::size_t no_locale_manage = 0) :
  86. std::codecvt<wchar_t, char, std::mbstate_t>(no_locale_manage)
  87. {}
  88. //virtual ~codecvt_null(){};
  89. };
  90. } // namespace archive
  91. } // namespace boost
  92. #ifdef BOOST_MSVC
  93. # pragma warning(pop)
  94. #endif
  95. #include <boost/archive/detail/abi_suffix.hpp> // pop pragmas
  96. #endif //BOOST_ARCHIVE_CODECVT_NULL_HPP