mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-28 19:25:27 +08:00
Introduce cstring_view and cwstring_view
This commit is contained in:
parent
a9a8772ad4
commit
8a21d95f5b
@ -2,6 +2,40 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace vcpkg
|
||||
{
|
||||
struct cstring_view
|
||||
{
|
||||
cstring_view(const char* cstr) : cstr(cstr) {}
|
||||
cstring_view(const std::string& str) : cstr(str.c_str()) {}
|
||||
|
||||
operator const char*() const { return cstr; }
|
||||
|
||||
const char* c_str() const { return cstr; }
|
||||
|
||||
private:
|
||||
const char* cstr;
|
||||
};
|
||||
|
||||
inline const char* to_printf_arg(const cstring_view spec) { return spec.c_str(); }
|
||||
|
||||
|
||||
struct cwstring_view
|
||||
{
|
||||
cwstring_view(const wchar_t* cstr) : cstr(cstr) {}
|
||||
cwstring_view(const std::wstring& str) : cstr(str.c_str()) {}
|
||||
|
||||
operator const wchar_t*() const { return cstr; }
|
||||
|
||||
const wchar_t* c_str() const { return cstr; }
|
||||
|
||||
private:
|
||||
const wchar_t* cstr;
|
||||
};
|
||||
|
||||
inline const wchar_t* to_wprintf_arg(const cwstring_view spec) { return spec.c_str(); }
|
||||
}
|
||||
|
||||
namespace vcpkg::Strings::details
|
||||
{
|
||||
inline const char* to_printf_arg(const std::string& s)
|
||||
|
Loading…
x
Reference in New Issue
Block a user