codecvt_null.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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) && (_MSC_VER >= 1020)
  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. };
  50. template<>
  51. class codecvt_null<wchar_t> : public std::codecvt<wchar_t, char, std::mbstate_t>
  52. {
  53. virtual BOOST_WARCHIVE_DECL(std::codecvt_base::result)
  54. do_out(
  55. std::mbstate_t & state,
  56. const wchar_t * first1,
  57. const wchar_t * last1,
  58. const wchar_t * & next1,
  59. char * first2,
  60. char * last2,
  61. char * & next2
  62. ) const;
  63. virtual BOOST_WARCHIVE_DECL(std::codecvt_base::result)
  64. do_in(
  65. std::mbstate_t & state,
  66. const char * first1,
  67. const char * last1,
  68. const char * & next1,
  69. wchar_t * first2,
  70. wchar_t * last2,
  71. wchar_t * & next2
  72. ) const;
  73. virtual int do_encoding( ) const throw( ){
  74. return sizeof(wchar_t) / sizeof(char);
  75. }
  76. virtual int do_max_length( ) const throw( ){
  77. return do_encoding();
  78. }
  79. };
  80. } // namespace archive
  81. } // namespace boost
  82. #ifdef BOOST_MSVC
  83. # pragma warning(pop)
  84. #endif
  85. #include <boost/archive/detail/abi_suffix.hpp> // pop pragmas
  86. #endif //BOOST_ARCHIVE_CODECVT_NULL_HPP