codecvt_null.hpp 3.0 KB

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