2016-09-18 20:50:08 -07:00
|
|
|
#pragma once
|
|
|
|
|
2016-11-02 19:34:30 -07:00
|
|
|
#include <vector>
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-01-05 12:47:08 -08:00
|
|
|
namespace vcpkg::Strings::details
|
2016-09-18 20:50:08 -07:00
|
|
|
{
|
|
|
|
inline const char* to_printf_arg(const std::string& s)
|
|
|
|
{
|
|
|
|
return s.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const char* to_printf_arg(const char* s)
|
|
|
|
{
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int to_printf_arg(const int s)
|
|
|
|
{
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2016-10-10 15:03:48 -07:00
|
|
|
inline double to_printf_arg(const double s)
|
|
|
|
{
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2016-09-30 11:21:51 -07:00
|
|
|
inline size_t to_printf_arg(const size_t s)
|
|
|
|
{
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2016-09-18 20:50:08 -07:00
|
|
|
std::string format_internal(const char* fmtstr, ...);
|
|
|
|
|
|
|
|
inline const wchar_t* to_wprintf_arg(const std::wstring& s)
|
|
|
|
{
|
|
|
|
return s.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const wchar_t* to_wprintf_arg(const wchar_t* s)
|
|
|
|
{
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2016-09-29 19:25:07 -07:00
|
|
|
std::wstring wformat_internal(const wchar_t* fmtstr, ...);
|
2017-01-05 12:47:08 -08:00
|
|
|
}
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-01-05 12:47:08 -08:00
|
|
|
namespace vcpkg::Strings
|
2016-09-18 20:50:08 -07:00
|
|
|
{
|
|
|
|
template <class...Args>
|
|
|
|
std::string format(const char* fmtstr, const Args&...args)
|
|
|
|
{
|
|
|
|
using vcpkg::Strings::details::to_printf_arg;
|
|
|
|
return details::format_internal(fmtstr, to_printf_arg(to_printf_arg(args))...);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class...Args>
|
2016-09-29 19:28:00 -07:00
|
|
|
std::wstring wformat(const wchar_t* fmtstr, const Args&...args)
|
2016-09-18 20:50:08 -07:00
|
|
|
{
|
|
|
|
using vcpkg::Strings::details::to_wprintf_arg;
|
2016-09-29 19:25:07 -07:00
|
|
|
return details::wformat_internal(fmtstr, to_wprintf_arg(to_wprintf_arg(args))...);
|
2016-09-18 20:50:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
std::wstring utf8_to_utf16(const std::string& s);
|
|
|
|
|
|
|
|
std::string utf16_to_utf8(const std::wstring& w);
|
|
|
|
|
2016-10-04 15:23:44 -07:00
|
|
|
std::string::const_iterator case_insensitive_ascii_find(const std::string& s, const std::string& pattern);
|
2016-10-04 14:44:19 -07:00
|
|
|
|
|
|
|
std::string ascii_to_lowercase(const std::string& input);
|
2016-11-02 19:34:30 -07:00
|
|
|
|
|
|
|
std::string join(const std::vector<std::string>& v, const std::string& delimiter);
|
2016-12-15 17:09:14 -08:00
|
|
|
|
|
|
|
void trim(std::string* s);
|
|
|
|
|
|
|
|
std::string trimmed(const std::string& s);
|
2016-12-16 16:02:19 -08:00
|
|
|
|
|
|
|
void trim_all_and_remove_whitespace_strings(std::vector<std::string>* strings);
|
2017-01-23 15:13:12 -08:00
|
|
|
|
|
|
|
std::vector<std::string> split(const std::string& s, const std::string& delimiter);
|
2017-01-05 12:47:08 -08:00
|
|
|
}
|