8#include "webcface/common/webcface-config.h"
13struct SharedStringData;
70template <
typename CharT>
72 std::shared_ptr<const internal::SharedStringData> s_data;
74 static inline CharT empty_buf[1] = {0};
77 TStringView() : std::basic_string_view<CharT>(empty_buf, 0) {}
80 std::shared_ptr<const internal::SharedStringData> s_data)
81 : std::basic_string_view<CharT>(data, size), s_data(std::move(s_data)) {
87 const CharT *
c_str()
const {
return this->data(); }
89 operator const CharT *()
const {
return this->data(); }
93 std::is_convertible_v<T, std::basic_string_view<CharT>>,
94 std::nullptr_t> =
nullptr>
96 return static_cast<std::basic_string_view<CharT>
>(*this) ==
97 std::basic_string_view<CharT>(other);
101 std::is_convertible_v<T, std::basic_string_view<CharT>>,
102 std::nullptr_t> =
nullptr>
104 return static_cast<std::basic_string_view<CharT>
>(*this) !=
105 std::basic_string_view<CharT>(other);
107 template <
typename T,
109 std::is_convertible_v<T, std::basic_string_view<CharT>>,
110 std::nullptr_t> =
nullptr>
112 return static_cast<std::basic_string_view<CharT>
>(*this) <=
113 std::basic_string_view<CharT>(other);
115 template <
typename T,
117 std::is_convertible_v<T, std::basic_string_view<CharT>>,
118 std::nullptr_t> =
nullptr>
120 return static_cast<std::basic_string_view<CharT>
>(*this) >=
121 std::basic_string_view<CharT>(other);
123 template <
typename T,
125 std::is_convertible_v<T, std::basic_string_view<CharT>>,
126 std::nullptr_t> =
nullptr>
128 return static_cast<std::basic_string_view<CharT>
>(*this) <
129 std::basic_string_view<CharT>(other);
131 template <
typename T,
133 std::is_convertible_v<T, std::basic_string_view<CharT>>,
134 std::nullptr_t> =
nullptr>
136 return static_cast<std::basic_string_view<CharT>
>(*this) >
137 std::basic_string_view<CharT>(other);
171 std::shared_ptr<internal::SharedStringData> data;
176 explicit SharedString(std::shared_ptr<internal::SharedStringData> data);
185 std::string_view u8StringView()
const;
187 std::string_view decode()
const;
189 std::wstring_view decodeW()
const;
192 static const std::string &emptyStr();
193 static const std::wstring &emptyStrW();
196 bool startsWith(std::string_view str)
const;
197 bool startsWith(
char str)
const;
199 std::size_t len = std::string::npos)
const;
200 std::size_t find(
char c, std::size_t pos = 0)
const;
215 return !(*
this == other);
218 return !(*
this >= other);
221 return !(*
this <= other);
244 template <
typename T,
245 typename std::enable_if_t<
246 std::conjunction_v<std::negation<std::is_void<T>>,
247 std::is_constructible<std::string, T>>,
248 std::nullptr_t> =
nullptr>
251 template <
typename T,
252 typename std::enable_if_t<
254 std::negation<std::is_void<T>>,
255 std::negation<std::is_constructible<std::string, T>>,
256 std::is_constructible<std::wstring, T>>,
257 std::nullptr_t> =
nullptr>
261 template <
typename CharT, std::size_t N,
262 typename std::enable_if_t<std::is_same_v<CharT, char> ||
263 std::is_same_v<CharT, wchar_t>,
264 std::nullptr_t> =
nullptr>
267 std::basic_string_view<CharT>(static_str, N - 1))) {}
278template <
typename CharT,
typename... Args>
279std::basic_string<CharT>
strJoin(std::basic_string_view<CharT> first_str,
281 std::basic_string<CharT> str;
282 str.reserve(first_str.size() +
283 (std::basic_string_view<CharT>(args).size() + ...));
284 str.append(first_str);
285 (str.append(std::basic_string_view<CharT>(args)), ...);
u8stringとstringとwstringをshared_ptrで持ち共有する
Definition encoding.h:170
bool operator!=(const SharedString &other) const
Definition encoding.h:214
bool operator<(const SharedString &other) const
Definition encoding.h:217
SharedString()
Definition encoding.h:174
SharedString(std::nullptr_t)
Definition encoding.h:175
bool operator>(const SharedString &other) const
Definition encoding.h:220
SharedString のpublicなコンストラクタインタフェース (入力専用)
Definition encoding.h:235
StringInitializer(const CharT(&static_str)[N])
Definition encoding.h:265
StringInitializer(const T &s)
Definition encoding.h:249
StringInitializer(std::wstring &&s)
Definition encoding.h:241
StringInitializer()
Definition encoding.h:237
StringInitializer(std::string &&s)
Definition encoding.h:239
webcfaceで管理されている文字列を参照するstring_view
Definition encoding.h:71
bool operator==(const T &other) const
Definition encoding.h:95
bool operator!=(const T &other) const
Definition encoding.h:103
bool operator>(const T &other) const
Definition encoding.h:135
bool operator<=(const T &other) const
Definition encoding.h:111
TStringView(const CharT *data, std::size_t size, std::shared_ptr< const internal::SharedStringData > s_data)
Definition encoding.h:79
const CharT * c_str() const
null終端の文字列ポインタを返す
Definition encoding.h:87
bool operator<(const T &other) const
Definition encoding.h:127
TStringView()
Definition encoding.h:77
bool operator>=(const T &other) const
Definition encoding.h:119
constexpr std::string_view field_separator_alt_sv
Definition encoding.h:58
std::string toNarrow(std::wstring_view name_ref)
wstringをstringに変換する
Definition encoding.cc:344
std::basic_string< CharT > strJoin(std::basic_string_view< CharT > first_str, Args &&...args)
string_viewやconst char*同士を連結しstringを返す
Definition encoding.h:279
void usingUTF8(bool flag)
webcfaceが使用するエンコーディングを設定する
Definition encoding.cc:81
bool operator==(const T &other, const InputRef &ref)
Definition text.h:608
std::wstring toWide(std::string_view name_ref)
stringをwstringに変換する
Definition encoding.cc:429
constexpr char field_separator
Definition encoding.h:49
constexpr char field_separator_alt
Definition encoding.h:54
constexpr std::string_view field_separator_sv
Definition encoding.h:50
#define WEBCFACE_DLL
Definition webcface-config.h:69
#define WEBCFACE_CALL
Definition webcface-config.h:106
#define WEBCFACE_NS_END
Definition webcface-config.h:113
#define WEBCFACE_NS_BEGIN
Definition webcface-config.h:112