Encoding.hxx.in 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*============================================================================
  2. KWSys - Kitware System Library
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef @KWSYS_NAMESPACE@_Encoding_hxx
  11. #define @KWSYS_NAMESPACE@_Encoding_hxx
  12. #include <@KWSYS_NAMESPACE@/Configure.hxx>
  13. #include <@KWSYS_NAMESPACE@/stl/string>
  14. /* Define these macros temporarily to keep the code readable. */
  15. #if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
  16. # define kwsys_stl @KWSYS_NAMESPACE@_stl
  17. #endif
  18. namespace @KWSYS_NAMESPACE@
  19. {
  20. class @KWSYS_NAMESPACE@_EXPORT Encoding
  21. {
  22. public:
  23. /**
  24. * Convert between char and wchar_t
  25. */
  26. #if @KWSYS_NAMESPACE@_STL_HAS_WSTRING
  27. // Convert a narrow string to a wide string.
  28. // On Windows, UTF-8 is assumed, and on other platforms,
  29. // the current locale is assumed.
  30. static kwsys_stl::wstring ToWide(const kwsys_stl::string& str);
  31. static kwsys_stl::wstring ToWide(const char* str);
  32. // Convert a wide string to a narrow string.
  33. // On Windows, UTF-8 is assumed, and on other platforms,
  34. // the current locale is assumed.
  35. static kwsys_stl::string ToNarrow(const kwsys_stl::wstring& str);
  36. static kwsys_stl::string ToNarrow(const wchar_t* str);
  37. #endif // @KWSYS_NAMESPACE@_STL_HAS_WSTRING
  38. }; // class Encoding
  39. } // namespace @KWSYS_NAMESPACE@
  40. /* Undefine temporary macros. */
  41. #if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
  42. # undef kwsys_stl
  43. #endif
  44. #endif