1/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 file Copyright.txt or https://cmake.org/licensing#kwsys for details. */ 3#ifndef @KWSYS_NAMESPACE@_Encoding_hxx 4#define @KWSYS_NAMESPACE@_Encoding_hxx 5 6#include <@KWSYS_NAMESPACE@/Configure.hxx> 7 8#include <string> 9#include <vector> 10 11namespace @KWSYS_NAMESPACE@ { 12class @KWSYS_NAMESPACE@_EXPORT Encoding 13{ 14public: 15 // Container class for argc/argv. 16 class @KWSYS_NAMESPACE@_EXPORT CommandLineArguments 17 { 18 public: 19 // On Windows, get the program command line arguments 20 // in this Encoding module's 8 bit encoding. 21 // On other platforms the given argc/argv is used, and 22 // to be consistent, should be the argc/argv from main(). 23 static CommandLineArguments Main(int argc, char const* const* argv); 24 25 // Construct CommandLineArguments with the given 26 // argc/argv. It is assumed that the string is already 27 // in the encoding used by this module. 28 CommandLineArguments(int argc, char const* const* argv); 29 30 // Construct CommandLineArguments with the given 31 // argc and wide argv. This is useful if wmain() is used. 32 CommandLineArguments(int argc, wchar_t const* const* argv); 33 ~CommandLineArguments(); 34 CommandLineArguments(const CommandLineArguments&); 35 CommandLineArguments& operator=(const CommandLineArguments&); 36 37 int argc() const; 38 char const* const* argv() const; 39 40 protected: 41 std::vector<char*> argv_; 42 }; 43 44 /** 45 * Convert between char and wchar_t 46 */ 47 48#if @KWSYS_NAMESPACE@_STL_HAS_WSTRING 49 50 // Convert a narrow string to a wide string. 51 // On Windows, UTF-8 is assumed, and on other platforms, 52 // the current locale is assumed. 53 static std::wstring ToWide(const std::string& str); 54 static std::wstring ToWide(const char* str); 55 56 // Convert a wide string to a narrow string. 57 // On Windows, UTF-8 is assumed, and on other platforms, 58 // the current locale is assumed. 59 static std::string ToNarrow(const std::wstring& str); 60 static std::string ToNarrow(const wchar_t* str); 61 62# if defined(_WIN32) 63 /** 64 * Convert the path to an extended length path to avoid MAX_PATH length 65 * limitations on Windows. If the input is a local path the result will be 66 * prefixed with \\?\; if the input is instead a network path, the result 67 * will be prefixed with \\?\UNC\. All output will also be converted to 68 * absolute paths with Windows-style backslashes. 69 **/ 70 static std::wstring ToWindowsExtendedPath(std::string const&); 71 static std::wstring ToWindowsExtendedPath(const char* source); 72 static std::wstring ToWindowsExtendedPath(std::wstring const& wsource); 73# endif 74 75#endif // @KWSYS_NAMESPACE@_STL_HAS_WSTRING 76 77}; // class Encoding 78} // namespace @KWSYS_NAMESPACE@ 79 80#endif 81