wstring_encode.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Filename: wstring_encode.h
  2. // Created by: drose (29Jun09)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. #ifndef WSTRING_ENCODE_H
  15. #define WSTRING_ENCODE_H
  16. #include <string>
  17. using namespace std;
  18. // Presently, these two functions are implemented only for Windows,
  19. // which is the only place they are needed. (Only Windows requires
  20. // wstrings for filenames.)
  21. #ifdef _WIN32
  22. bool wstring_to_string(string &result, const wstring &source);
  23. bool string_to_wstring(wstring &result, const string &source);
  24. // We declare this inline so it won't conflict with the similar
  25. // function defined in Panda's textEncoder.h.
  26. inline ostream &operator << (ostream &out, const wstring &str) {
  27. string result;
  28. if (wstring_to_string(result, str)) {
  29. out << result;
  30. }
  31. return out;
  32. }
  33. #endif // _WIN32
  34. #endif