CLI11  2.5.0
Encoding.hpp
Go to the documentation of this file.
1 // Copyright (c) 2017-2025, University of Cincinnati, developed by Henry Schreiner
2 // under NSF AWARD 1414736 and by the respective contributors.
3 // All rights reserved.
4 //
5 // SPDX-License-Identifier: BSD-3-Clause
6 
7 #pragma once
8 
9 // IWYU pragma: private, include "CLI/CLI.hpp"
10 #include "Macros.hpp"
11 
12 // [CLI11:public_includes:set]
13 #include <string>
14 // [CLI11:public_includes:end]
15 
16 // [CLI11:encoding_includes:verbatim]
17 #ifdef CLI11_CPP17
18 #include <string_view>
19 #endif // CLI11_CPP17
20 
21 #if defined CLI11_HAS_FILESYSTEM && CLI11_HAS_FILESYSTEM > 0
22 #include <filesystem>
23 #include <string_view> // NOLINT(build/include)
24 #endif // CLI11_HAS_FILESYSTEM
25 // [CLI11:encoding_includes:end]
26 
27 namespace CLI {
28 // [CLI11:encoding_hpp:verbatim]
29 
31 CLI11_INLINE std::string narrow(const std::wstring &str);
32 CLI11_INLINE std::string narrow(const wchar_t *str);
33 CLI11_INLINE std::string narrow(const wchar_t *str, std::size_t size);
34 
36 CLI11_INLINE std::wstring widen(const std::string &str);
37 CLI11_INLINE std::wstring widen(const char *str);
38 CLI11_INLINE std::wstring widen(const char *str, std::size_t size);
39 
40 #ifdef CLI11_CPP17
41 CLI11_INLINE std::string narrow(std::wstring_view str);
42 CLI11_INLINE std::wstring widen(std::string_view str);
43 #endif // CLI11_CPP17
44 
45 #if defined CLI11_HAS_FILESYSTEM && CLI11_HAS_FILESYSTEM > 0
46 CLI11_INLINE std::filesystem::path to_path(std::string_view str);
48 #endif // CLI11_HAS_FILESYSTEM
49 
50 // [CLI11:encoding_hpp:end]
51 } // namespace CLI
52 
53 #ifndef CLI11_COMPILE
54 #include "impl/Encoding_inl.hpp" // IWYU pragma: export
55 #endif
Definition: App.hpp:36
CLI11_INLINE std::string narrow(const std::wstring &str)
Convert a wide string to a narrow string.
#define CLI11_INLINE
Definition: Macros.hpp:150
CLI11_INLINE std::wstring widen(const std::string &str)
Convert a narrow string to a wide string.