-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
48 class TraitsT = std::char_traits<CharT>,
-
49 class AllocatorT = std::allocator<CharT>
-
-
-
-
-
-
-
-
-
-
59# pragma warning(disable: 4455)
-
-
-
-
63 inline CppString operator""_cs(
const char* str, std::size_t len);
-
64 inline CppWString operator""_cs(
const wchar_t* str, std::size_t len);
-
-
-
-
68 template<
typename IntT = std::
int64_t>
-
69 requires std::is_signed_v<IntT>
-
-
-
72 template<
typename IntT = std::
int64_t>
-
73 requires std::is_signed_v<IntT>
-
-
-
76 template<
typename IntT = std::
int64_t>
-
77 requires std::is_signed_v<IntT>
-
-
-
80 template<
typename IntT = std::
int64_t>
-
81 requires std::is_signed_v<IntT>
-
-
-
84 template<
typename IntT = std::
int64_t>
-
85 requires std::is_signed_v<IntT>
-
-
-
88 template<
typename IntT = std::
int64_t>
-
89 requires std::is_signed_v<IntT>
-
-
-
92 template<
typename IntT = std::
int64_t>
-
93 requires std::is_signed_v<IntT>
-
-
-
-
-
-
99 inline const bool is_alpha(
const CharT ch)
noexcept;
-
-
101 template<
class CharT>
-
102 inline const bool is_ascii(
const CharT ch)
noexcept;
-
-
104 template<
class CharT>
-
105 inline const bool is_decimal(
const CharT ch)
noexcept;
-
-
107 template<
class CharT>
-
108 inline const bool is_digit(
const CharT ch)
noexcept;
-
-
110 template<
class CharT>
-
-
-
113 template<
class CharT>
-
114 inline const bool is_id_start(
const CharT ch)
noexcept;
-
-
116 template<
class CharT>
-
117 inline const bool is_lower(
const CharT ch)
noexcept;
-
-
119 template<
class CharT>
-
120 inline const bool is_numeric(
const CharT ch)
noexcept;
-
-
122 template<
class CharT>
-
123 inline const bool is_printable(
const CharT ch)
noexcept;
-
-
125 template<
class CharT>
-
-
-
128 template<
class CharT>
-
129 inline const bool is_space(
const CharT ch)
noexcept;
-
-
131 template<
class CharT>
-
132 inline const bool is_upper(
const CharT ch)
noexcept;
-
-
134 template<
class CharT>
-
135 inline const CharT
swap_case(
const CharT ch)
noexcept;
-
-
137 template<
class CharT>
-
138 inline const CharT
to_lower(
const CharT ch)
noexcept;
-
-
140 template<
class CharT>
-
141 inline const CharT
to_upper(
const CharT ch)
noexcept;
-
-
-
-
164 template<
class CharT,
class TraitsT,
class AllocatorT>
-
165 class CppStringT :
public std::basic_string<CharT, TraitsT, AllocatorT>
-
-
-
-
169 using MyBaseClass = std::basic_string<CharT, TraitsT, AllocatorT>;
-
-
171 using traits_type = MyBaseClass::traits_type;
-
172 using value_type = MyBaseClass::value_type;
-
173 using allocator_type = MyBaseClass::allocator_type;
-
174 using size_type = MyBaseClass::size_type;
-
175 using difference_type = MyBaseClass::difference_type;
-
176 using reference = MyBaseClass::reference;
-
177 using const_reference = MyBaseClass::const_reference;
-
178 using pointer = MyBaseClass::pointer;
-
179 using const_pointer = MyBaseClass::const_pointer;
-
180 using iterator = MyBaseClass::iterator;
-
181 using const_iterator = MyBaseClass::const_iterator;
-
182 using reverse_iterator = MyBaseClass::reverse_iterator;
-
183 using const_reverse_iterator = MyBaseClass::const_reverse_iterator;
-
-
-
-
-
-
-
-
192 using key_type = CharT;
-
193 using value_type = CppStringT;
-
-
-
197 inline TransTable(
const std::map<key_type, value_type> trans_table)
-
198 : m_table{ trans_table }
-
-
-
-
-
209 assert(keys.size() == values.size());
-
210 auto val_it = values.cbegin();
-
211 for (
const auto k : keys)
-
212 m_table[k] = CppStringT(*val_it++);
-
-
-
223 TransTable(
const CppStringT& keys,
const CppStringT& values,
const CppStringT& not_translated)
-
-
225 assert(keys.size() == values.size());
-
226 auto val_it = values.cbegin();
-
227 for (
const auto k : keys)
-
228 m_table[k] = CppStringT(*val_it++);
-
229 for (
const auto k : not_translated)
-
230 m_table[k] = CppStringT();
-
-
-
239 inline TransTable(
const CppStringT& keys,
const std::initializer_list<CppStringT>& values)
-
-
241 assert(keys.size() == values.size());
-
242 auto val_it = values.begin();
-
243 for (
const auto k : keys)
-
244 m_table[k] = *val_it++;
-
-
-
255 inline TransTable(
const CppStringT& keys,
const std::initializer_list<CppStringT> values,
const CppStringT& not_translated)
-
-
257 assert(keys.size() == values.size());
-
258 auto val_it = values.begin();
-
259 for (
const auto k : keys)
-
260 m_table[k] = *val_it++;
-
261 for (
const auto k : not_translated)
-
262 m_table[k] = CppStringT();
-
-
-
-
-
273 while (*keys && *values)
-
274 m_table[*keys++] = value_type(*values++);
-
-
-
285 inline TransTable(
const CharT* keys,
const CharT* values,
const CharT* not_translated)
-
-
287 while (*keys && *values)
-
288 m_table[*keys++] = value_type(*values++);
-
289 while (*not_translated)
-
290 m_table[*not_translated++] = CppStringT();
-
-
-
299 template<
class KeyIt,
class ValueIt>
-
300 inline TransTable(KeyIt first_key, KeyIt last_key, ValueIt first_value, ValueIt last_value)
-
-
302 KeyIt key_it{ first_key };
-
303 ValueIt val_it{ first_value };
-
304 while (key_it != last_key && val_it != last_value)
-
305 m_table[*key_it++] = value_type(*val_it++);
-
-
-
316 template<
class Key1It,
class ValueIt,
class Key2It>
-
-
318 ValueIt first_value, ValueIt last_value,
-
319 Key2It first_not_translated, Key2It last_not_translated)
-
-
321 Key1It key1_it{ first_key };
-
322 ValueIt val_it{ first_value };
-
323 while (key1_it != last_key && val_it != last_value)
-
324 m_table[*key1_it++] = value_type(*val_it++);
-
325 Key2It key2_it{ first_not_translated };
-
326 while (key2_it != last_not_translated)
-
327 m_table[*key2_it++] = CppStringT();
-
-
-
-
337 template<
class StringViewLike>
-
338 explicit TransTable(
const StringViewLike& keys,
const StringViewLike& values)
-
-
340 assert(keys.size() == values.size());
-
341 auto val_it = values.cbegin();
-
342 for (
const auto k : keys)
-
343 m_table[(*k)[0]] = value_type(*val_it++);
-
-
-
-
-
-
-
-
-
-
-
-
-
357 inline
TransTable& operator= (const std::map<key_type, value_type>& trans_table) noexcept
-
-
359 m_table = trans_table;
-
-
-
-
-
-
-
367 auto it = m_table.find(ch);
-
368 if (it != m_table.end()) [[likely]] {
-
-
-
-
-
-
-
-
376 inline std::map<typename key_type, typename value_type>&
get_table() noexcept
-
-
-
-
-
-
382 std::map<typename key_type, typename value_type> m_table{};
-
-
-
-
-
-
388 inline CppStringT() : MyBaseClass() {}
-
389 inline CppStringT(
const CppStringT& other) : MyBaseClass(other) {}
-
390 inline CppStringT(
const CppStringT& other,
const AllocatorT& alloc) : MyBaseClass(other, alloc) {}
-
391 inline CppStringT(CppStringT&& other) noexcept : MyBaseClass(other) {}
-
392 inline CppStringT(CppStringT&& other,
const AllocatorT& alloc) noexcept : MyBaseClass(other, alloc) {}
-
393 inline CppStringT(MyBaseClass::size_type
count, CharT ch) : MyBaseClass(
count, ch) {}
-
394 inline CppStringT(
const CppStringT& other, size_type pos) : MyBaseClass(other, pos) {}
-
395 inline CppStringT(
const CppStringT& other, size_type pos, size_type
count) noexcept : MyBaseClass(other, pos,
count) {}
-
396 inline CppStringT(
const CharT* s)
-
397 : MyBaseClass(s ? s : CppStringT().c_str())
-
-
399 inline CppStringT(
const CharT* s, size_type
count)
-
400 : MyBaseClass(s ? s : CppStringT().c_str(),
count)
-
-
402 inline CppStringT(std::initializer_list<CharT> ilist) : MyBaseClass(ilist) {}
-
-
404 inline CppStringT(
const CharT ch) : MyBaseClass(1, ch) {}
-
-
406 inline CppStringT(
const MyBaseClass& other) : MyBaseClass(other) {}
-
407 inline CppStringT(
const MyBaseClass& other,
const AllocatorT& alloc) : MyBaseClass(other, alloc) {}
-
408 inline CppStringT(MyBaseClass&& other) : MyBaseClass(other) {}
-
409 inline CppStringT(MyBaseClass&& other,
const AllocatorT& alloc) : MyBaseClass(other, alloc) {}
-
-
411 template<
class InputIt>
-
412 inline CppStringT(InputIt first, InputIt last) : MyBaseClass(first, last) {}
-
-
414 template<
class StringViewLike>
-
415 explicit CppStringT(StringViewLike& svl) : MyBaseClass(svl) {}
-
-
417 template<
class StringViewLike>
-
418 CppStringT(StringViewLike& svl, size_type pos, size_type n) : MyBaseClass(svl, pos, n) {}
-
-
420 inline ~CppStringT() noexcept = default;
-
-
-
-
424 CppStringT& operator= (const CppStringT&) noexcept = default;
-
425 CppStringT& operator= (CppStringT&&) noexcept = default;
-
-
-
-
429 class NotFoundException : public std::logic_error
-
-
-
432 using MyBaseClass = std::logic_error;
-
-
434 inline NotFoundException(
const std::string& what_arg) : MyBaseClass(what_arg) {}
-
435 inline NotFoundException(
const char* what_arg) : MyBaseClass(what_arg) {}
-
-
-
-
-
-
-
-
-
445 CppStringT res(*
this);
-
446 if (!res.empty()) [[likely]] {
-
-
-
-
-
-
-
-
-
-
462 CppStringT
center(
const size_type width,
const value_type fillch = value_type(
' ')) const noexcept
-
-
464 const size_type len{ this->size() };
-
465 if (width <= len) [[unlikely]]
-
466 return CppStringT(*
this);
-
-
468 const size_type half{ (width - len) / 2 };
-
469 return CppStringT(half, fillch) + *
this + CppStringT(width - half - len, fillch);
-
-
-
-
-
-
-
-
481 if (
substr.empty()) [[unlikely]]
-
-
-
-
485#if (defined(_HAS_CXX23) && _HAS_CXX23) || (!defined(_HAS_CXX23) && __cplusplus >= 202302L)
-
-
487 return MyBaseClass::contains(
substr);
-
-
-
490 const size_type substr_width{
substr.size() };
-
491 const size_type width{ this->size() };
-
-
493 if (substr_width > width) [[unlikely]]
-
-
-
496 for (size_type
index = 0;
index <= width - substr_width; ++
index) [[likely]] {
-
-
-
-
-
-
-
-
-
-
-
-
512 inline constexpr bool contains_n(
const CppStringT& sub,
const size_type start,
const size_type
count = -1) const noexcept
-
-
-
-
-
-
-
-
-
-
-
-
-
526 constexpr size_type
count(
const CppStringT& sub,
const size_type start = 0,
const size_type end = -1) const noexcept
-
-
-
529 CppStringT tmp{ this->
substr(start, std::min(this->size(), end) - start + 1) };
-
-
531 size_type start_{ 0 };
-
532 size_type end_{ tmp.size() };
-
-
534 while ((start_ = tmp.
find(sub, start_, end_)) != CppStringT::npos) {
-
535 start_ += sub.size();
-
-
537 tmp = tmp.
substr(start_, std::min(tmp.size(), end_) + 1);
-
-
-
-
-
-
-
-
-
-
-
549 inline constexpr size_type
count_n(
const CppStringT& sub,
const size_type start,
const size_type length)
const noexcept
-
-
551 return count(sub, start, start + length - 1);
-
-
-
-
556 inline constexpr size_type
count_n(
const CppStringT& sub,
const size_type length)
const noexcept
-
-
558 return count(sub, 0, length - 1);
-
-
-
-
-
-
565 inline const bool endswith(
const CppStringT& suffix,
const size_type start,
const size_type end)
const noexcept
-
-
567 return this->
substr(start, end - start + 1).MyBaseClass::ends_with(suffix);
-
-
-
-
572 inline const bool endswith(
const CppStringT& suffix,
const size_type end)
const noexcept
-
-
574 return this->
substr(0, end).MyBaseClass::ends_with(suffix);
-
-
-
-
579 inline const bool endswith(
const CppStringT& suffix)
const noexcept
-
-
581 return static_cast<const bool>(MyBaseClass::ends_with(suffix));
-
-
-
-
586 const bool endswith(
const std::initializer_list<CppStringT>& suffixes,
const size_type start,
const size_type end)
const noexcept
-
-
588 if (start > end) [[unlikely]]
-
-
-
591 CppStringT tmp(this->
substr(start, end - start + 1));
-
592 for (
auto& suffix : suffixes) {
-
593 if (tmp.ends_with(suffix)) [[unlikely]]
-
-
-
-
-
-
-
-
-
603 inline const bool endswith_n(
const CppStringT& suffix,
const size_type start,
const size_type
count)
const noexcept
-
-
-
-
-
-
610 inline const bool endswith_n(
const CppStringT& suffix,
const size_type
count)
const noexcept
-
-
-
-
-
-
617 inline const bool endswith_n(
const std::initializer_list<CppStringT>& suffixes,
const size_type start,
const size_type
count)
const noexcept
-
-
-
-
-
-
-
-
626 CppStringT
expand_tabs(
const size_type tabsize = 8) const noexcept
-
-
628 const size_type tabsize_{ tabsize == 0 ? 1 : tabsize };
-
-
-
631 std::size_t current_pos{ 0 };
-
632 for (
const value_type ch : *
this) {
-
633 if (ch == value_type(
'\t')) [[unlikely]] {
-
-
635 ret += value_type(
' ');
-
-
637 }
while (current_pos % tabsize_ != 0);
-
-
639 else if (ch == value_type(
'\n') || ch == value_type(
'\r')) [[unlikely]] {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
666 constexpr size_type
find(
const CppStringT& sub,
const size_type start = 0,
const size_type end = -1) const noexcept
-
-
668 const size_type end_{ (end == -1) ? this->size() : end };
-
-
670 if (start > end_) [[unlikely]]
-
671 return CppStringT::npos;
-
-
673 return find_n(sub, start, end_ - start + 1);
-
-
-
-
-
-
691 inline constexpr size_type
find_n(
const CppStringT& sub,
const size_type start,
const size_type
count)
const noexcept
-
-
693 constexpr size_type npos{ CppStringT::npos };
-
-
-
696 const CppStringT sub_str{ this->
substr(start,
count) };
-
697 const size_type found_pos{ sub_str.MyBaseClass::find(sub) };
-
-
699 return (found_pos == npos) ? npos : found_pos + start;
-
-
-
-
-
-
-
-
719 inline constexpr size_type
find_n(
const CppStringT& sub,
const size_type
count)
const noexcept
-
-
-
-
-
-
-
727 template<
typename T,
class... ArgsT>
-
-
729 const std::basic_format_string<T, std::type_identity_t<ArgsT>...> frmt,
-
-
-
-
-
-
-
736 template<
class... ArgsT>
-
-
738 const std::basic_format_string<
char , std::type_identity_t<ArgsT>... > frmt,
-
-
-
-
742 return *
this = std::vformat(frmt.get(), std::make_format_args(args...));
-
-
-
745 template<
class... ArgsT>
-
-
747 const std::basic_format_string<
wchar_t, std::type_identity_t<ArgsT>... > frmt,
-
-
-
-
751 return *
this = std::vformat(frmt.get(), std::make_wformat_args(args...));
-
-
-
-
-
-
762 inline constexpr size_type
index(
const CppStringT& sub,
const size_type start = 0,
const size_type end = -1)
const
-
-
764 const size_type ret_value =
find(sub, start, end);
-
765 if (ret_value == CppStringT::npos)
-
766 throw NotFoundException(
"substring not found in string.");
-
-
-
-
-
-
-
-
779 inline constexpr size_type
index_n(
const CppStringT& sub,
const size_type start,
const size_type
count)
const
-
-
-
-
-
-
790 inline constexpr size_type
index_n(
const CppStringT& sub,
const size_type
count)
const
-
-
-
-
-
-
-
-
-
-
801 if (this->empty()) [[unlikely]]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
966 return !this->empty() && this->
title() == *
this;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
984 return !this->empty() &&
-
-
-
-
-
-
-
-
-
-
998 template<const std::
size_t N>
-
-
1000 CppStringT
join(
const std::array<CppStringT, N>& strs)
const noexcept
-
-
1002 if (strs.empty()) [[unlikely]]
-
1003 return CppStringT();
-
-
1005 auto str_it = strs.cbegin();
-
1006 CppStringT res{ *str_it++ };
-
1007 while (str_it != strs.cend()) [[likely]]
-
1008 res += *
this + *str_it++;
-
-
-
-
-
1017 CppStringT
join(
const std::vector<CppStringT>& strs)
const noexcept
-
-
1019 if (strs.empty()) [[unlikely]]
-
1020 return CppStringT();
-
-
1022 auto str_it = strs.cbegin();
-
1023 CppStringT res{ *str_it++ };
-
1024 while (str_it != strs.cend()) [[likely]]
-
1025 res += *
this + *str_it++;
-
-
-
-
1033 template<
class... NextCppStringsT>
-
-
1035 inline CppStringT
join(
const CppStringT& first,
const NextCppStringsT&... others)
const noexcept
-
1036 requires (
sizeof...(others) > 0)
-
-
1038 return first + *
this + this->
join(others...);
-
-
-
-
1043 inline CppStringT
join(
const CppStringT& s)
const noexcept
-
-
-
-
-
-
1050 inline const CppStringT
join() const noexcept
-
-
-
-
-
-
-
-
1063 inline CppStringT
ljust(
const size_type width,
const value_type fillch = value_type(
' ')) const noexcept
-
-
1065 if (this->size() >= width) [[unlikely]]
-
-
-
1068 return CppStringT(width - this->size(), fillch) + *
this;
-
-
-
-
-
-
-
-
-
-
-
1084 [&](value_type ch) {
return this->
lower(ch); }
-
-
-
-
-
-
1095 static inline const value_type
lower(
const value_type ch)
noexcept
-
-
1097 return value_type(std::tolower(ch));
-
-
-
-
-
-
1110 inline CppStringT
lstrip(
const CppStringT& removedchars)
const noexcept
-
-
1112 for (
auto it = this->cbegin(); it != this->cend(); ++it) [[likely]]
-
1113 if (std::none_of(removedchars.cbegin(), removedchars.cend(), [it](
const value_type ch) { return *it == ch; })) [[likely]]
-
1114 return CppStringT(it, this->cend());
-
1115 return CppStringT();
-
-
-
-
-
-
1122 for (
auto it = this->cbegin(); it != this->cend(); ++it) [[likely]]
-
1123 if (*it != value_type(
' ')) [[unlikely]]
-
1124 return CppStringT(it, this->cend());
-
1125 return CppStringT();
-
-
-
-
-
1141 template<
typename IntT>
-
1142 requires std::is_signed_v<IntT>
-
-
-
-
-
1147 if (slice.step() == 1) [[likely]] {
-
-
1149 if (slice.start() < slice.stop()) [[likely]]
-
1150 return this->
substr(size_type(slice.start()), size_type(slice.stop() - slice.start() + 1));
-
-
1152 return CppStringT();
-
-
-
-
-
-
1158 if (slice.step() == -1) {
-
-
1160 if (slice.stop() < slice.start()) [[likely]] {
-
1161 res = this->
substr(size_type(slice.stop()), size_type(slice.start() - slice.stop() + 1));
-
1162 std::ranges::reverse(res);
-
-
-
-
-
-
1168 for (slice.begin(*
this); !slice.end(); ++slice)
-
1169 res += (*this)[size_type(*slice)];
-
-
-
-
-
-
1176 inline CppStringT
operator() (
const long long start,
const long long stop,
const long long step = 1) const noexcept
-
-
-
1179 return (*
this)(slice);
-
-
-
-
-
-
-
-
1188 if (
count <= 0) [[unlikely]]
-
1189 return CppStringT();
-
-
1191 CppStringT res(*
this);
-
1192 while (--
count) [[likely]]
-
-
-
-
-
-
-
-
1205 std::vector<CppStringT>
partition(
const CppStringT& sep)
const noexcept
-
-
1207 const size_type sep_index =
find(sep);
-
1208 if (sep_index == CppStringT::npos) {
-
1209 const CppStringT empty{};
-
1210 return std::vector<CppStringT>({ *
this, empty, empty });
-
-
-
1213 const size_type third_index = sep_index + sep.size();
-
1214 const size_type third_size = this->size() - third_index + 1;
-
1215 return std::vector<CppStringT>({ this->
substr(0, sep_index), sep, this->
substr(third_index, third_size) });
-
-
-
-
-
-
-
-
-
-
1226 const size_type prefix_length = prefix.size();
-
1227 return this->
substr(prefix_length, this->size() - prefix_length + 1);
-
-
-
-
-
-
-
-
-
-
-
-
1240 const size_type suffix_length = suffix.size();
-
1241 return this->
substr(0, this->size() - suffix_length);
-
-
-
-
-
-
-
-
-
1251 CppStringT
replace(
const CppStringT& old,
const CppStringT& new_, size_type
count = -1) const noexcept
-
-
1253 if (old == new_ || old.empty()) [[unlikely]]
-
-
-
-
1257 size_type prev_index = 0;
-
1258 size_type current_index = 0;
-
1259 while (
count > 0 && (current_index = this->
find(old, prev_index)) != CppStringT::npos) {
-
1260 res += this->
substr(prev_index, current_index - prev_index) + new_;
-
1261 prev_index = current_index + 1;
-
-
-
-
1265 if (prev_index < this->size()) [[likely]]
-
1266 res += this->
substr(prev_index, this->size() - prev_index);
-
-
-
-
-
-
-
-
1288 inline constexpr size_type
rfind(
const CppStringT& sub,
const size_type start,
const size_type end)
const noexcept
-
-
1290 if (start > end) [[unlikely]]
-
1291 return CppStringT::npos;
-
1292 else if (sub.empty()) [[unlikely]]
-
-
-
1295 const size_type found_pos{ this->
substr(start, end - start + 1).
rfind(sub) };
-
1296 return (found_pos == CppStringT::npos) ? CppStringT::npos : found_pos + start;
-
-
-
-
-
-
1316 inline constexpr size_type
rfind(
const CppStringT& sub,
const size_type start)
const noexcept
-
-
1318 return rfind(sub, start, this->size() - 1);
-
-
-
-
-
1337 inline constexpr size_type
rfind(
const CppStringT& sub)
const noexcept
-
-
1339 return MyBaseClass::rfind(sub);
-
-
-
-
-
-
1353 inline constexpr size_type
rfind_n(
const CppStringT& sub,
const size_type start,
const size_type
count)
const noexcept
-
-
-
-
-
-
1367 inline constexpr size_type
rfind_n(
const CppStringT& sub,
const size_type
count)
const noexcept
-
-
1369 if (
count == 0) [[unlikely]]
-
1370 return CppStringT::npos;
-
-
-
-
-
-
-
-
1383 inline constexpr size_type
rindex(
const CppStringT& sub,
const size_type start,
const size_type end)
const
-
-
1385 const size_type ret_value =
rfind(sub, start, end);
-
1386 if (ret_value == CppStringT::npos)
-
1387 throw NotFoundException(
"substring not found in string");
-
-
-
-
-
-
1398 inline constexpr size_type
rindex(
const CppStringT& sub,
const size_type start)
const
-
-
1400 return rindex(sub, start, this->size() - 1);
-
-
-
-
1409 inline constexpr size_type
rindex(
const CppStringT& sub)
const
-
-
1411 return rindex(sub, 0, this->size() - 1);
-
-
-
-
-
-
1422 inline constexpr size_type
rindex_n(
const CppStringT& sub,
const size_type start,
const size_type
count)
const
-
-
-
-
-
-
1433 inline constexpr size_type
rindex_n(
const CppStringT& sub,
const size_type
count)
const
-
-
-
-
-
-
-
-
1446 inline CppStringT
rjust(
const size_type width,
const value_type fillch = value_type(
' ')) const noexcept
-
-
1448 if (this->size() >= width) [[unlikely]]
-
-
-
1451 return *
this + CppStringT(width - this->size(), fillch);
-
-
-
-
-
-
1462 std::vector<CppStringT>
rpartition(
const CppStringT& sep)
const noexcept
-
-
1464 const size_type sep_index =
rfind(sep);
-
1465 if (sep_index == CppStringT::npos) {
-
1466 const CppStringT empty{};
-
1467 return std::vector<CppStringT>({ *
this, empty, empty });
-
-
-
1470 const size_type third_index = sep_index + sep.size();
-
1471 const size_type third_size = this->size() - third_index + 1;
-
1472 return std::vector<CppStringT>({ this->
substr(0, sep_index), sep, this->
substr(third_index, third_size) });
-
-
-
-
-
-
-
1484 inline std::vector<CppStringT>
rsplit() noexcept
-
-
-
-
-
-
1491 inline std::vector<CppStringT>
rsplit(
const CppStringT& sep)
noexcept
-
-
-
-
-
-
1498 inline std::vector<CppStringT>
rsplit(
const size_type maxsplit)
noexcept
-
-
1500 return rsplit(CppStringT(value_type(
' ')), maxsplit);
-
-
-
-
1505 std::vector<CppStringT>
rsplit(
const CppStringT& sep,
const size_type maxsplit)
noexcept
-
-
1507 std::vector<CppStringT> res{};
-
-
1509 if (maxsplit == 0) [[unlikely]] {
-
1510 res.push_back({ *
this });
-
-
-
1513 const size_type sep_size{ sep.size() };
-
1514 std::vector<size_type> indexes{};
-
1515 CppStringT tmp{ *
this };
-
1516 size_type
count{ maxsplit };
-
1517 size_type
index{ 0 };
-
-
-
1520 indexes.insert(indexes.begin(),
index);
-
-
-
-
-
-
-
1527 if (indexes.size() == 0)
-
1528 res.push_back(*
this);
-
-
-
1531 for (
const size_type ndx : indexes) {
-
-
1533 index = ndx + sep_size;
-
-
-
1536 res.push_back(this->
substr(index, this->size() -
index));
-
-
-
-
-
-
-
-
-
1552 inline CppStringT
rstrip(
const CppStringT& removedchars)
const noexcept
-
-
1554 for (
auto it = this->crbegin(); it != this->crend(); ++it)
-
1555 if (std::none_of(removedchars.cbegin(), removedchars.cend(), [it](
const value_type ch) { return *it == ch; }))
-
1556 return CppStringT(this->cbegin(), this->cbegin() + this->size() - (it - this->crbegin()));
-
1557 return CppStringT();
-
-
-
-
-
-
1564 for (
auto it = this->crbegin(); it != this->crend(); ++it)
-
1565 if (*it != value_type(
' '))
-
1566 return CppStringT(this->cbegin(), this->cbegin() + this->size() - (it - this->crbegin()));
-
1567 return CppStringT();
-
-
-
-
-
-
1578 inline std::vector<CppStringT>
split() noexcept
-
-
1580 std::vector<CppStringT> res;
-
1581 const CppStringT whitespace(value_type(
' '));
-
1582 for (
const auto& word : *
this | std::views::split(whitespace))
-
1583 res.push_back(CppStringT(word.begin(), word.end()));
-
-
-
-
-
1597 inline std::vector<CppStringT>
split(
const CppStringT& sep)
noexcept
-
-
1599 std::vector<CppStringT> res;
-
1600 for (
const auto& word : *
this | std::views::split(sep))
-
1601 res.push_back(CppStringT(word.begin(), word.end()));
-
-
-
-
-
1607 inline std::vector<CppStringT>
split(
const size_type maxsplit)
noexcept
-
-
1609 return split(CppStringT(value_type(
' ')), maxsplit);
-
-
-
-
1614 std::vector<CppStringT>
split(
const CppStringT& sep,
const size_type maxsplit)
noexcept
-
-
1616 std::vector<CppStringT> res{};
-
-
1618 if (maxsplit == 0) [[unlikely]] {
-
1619 res.push_back(*
this);
-
-
-
1622 const size_type sep_size{ sep.size() };
-
1623 std::vector<size_type> indexes{};
-
1624 size_type
count{ maxsplit };
-
1625 size_type
index{ 0 };
-
-
-
1628 indexes.push_back(
index);
-
1629 if (
index == this->size())
-
-
-
-
-
-
1635 if (indexes.size() == 0)
-
1636 res.push_back(*
this);
-
-
-
1639 for (
const size_type ndx : indexes) {
-
-
1641 index = ndx + sep_size;
-
-
-
1644 res.push_back(this->
substr(index, this->size() -
index));
-
-
-
-
-
-
-
-
-
1671 std::vector<CppStringT>
splitlines(
const bool keep_end =
false) const noexcept
-
-
1673 std::vector<CppStringT> res{};
-
1674 CppStringT current{};
-
1675 bool prev_cr =
false;
-
-
1677 for (
const value_type ch : *
this) {
-
-
1679 case 0x0b: [[unlikely]]
-
1680 case 0x0c: [[unlikely]]
-
1681 case 0x1c: [[unlikely]]
-
1682 case 0x1d: [[unlikely]]
-
1683 case 0x1e: [[unlikely]]
-
-
-
-
1687 if (prev_cr) [[unlikely]] {
-
1688 res.push_back(current);
-
-
-
1691 if (keep_end) [[unlikely]]
-
-
1693 res.push_back(current);
-
-
-
-
-
1698 case value_type(
'\r'): [[unlikely]]
-
1699 if (prev_cr) [[unlikely]] {
-
1700 res.push_back(current);
-
-
-
1703 if (keep_end) [[unlikely]]
-
-
-
-
-
1708 case value_type(
'\n'): [[unlikely]]
-
1709 if (keep_end) [[unlikely]]
-
-
1711 res.push_back(current);
-
-
-
-
-
-
-
1718 if (prev_cr) [[unlikely]] {
-
1719 res.push_back(current);
-
-
-
-
-
-
-
-
-
1728 if (prev_cr) [[unlikely]] {
-
1729 res.push_back(current);
-
-
-
-
-
-
-
-
-
1739 inline const bool startswith(
const CppStringT& prefix,
const size_type start,
const size_type end)
const noexcept
-
-
1741 return this->
substr(start, end - start + 1).MyBaseClass::starts_with(prefix);
-
-
-
-
1746 inline const bool startswith(
const CppStringT& prefix,
const size_type start)
const noexcept
-
-
1748 return startswith(prefix, start, this->size() - 1);
-
-
-
-
1753 inline const bool startswith(
const CppStringT& prefix)
const noexcept
-
-
1755 return this->starts_with(prefix);
-
-
-
-
1760 inline const bool startswith(
const std::initializer_list<CppStringT>& prefixes,
const size_type start,
const size_type end)
const noexcept
-
-
-
-
-
1765 CppStringT tmp(this->
substr(start, end));
-
1766 for (
auto& prefix : prefixes) {
-
1767 if (tmp.starts_with(prefix))
-
-
-
-
-
-
-
-
-
1777 inline const bool startswith_n(
const CppStringT& prefix,
const size_type start,
const size_type
count)
const noexcept
-
-
1779 return this->
substr(start,
count).MyBaseClass::starts_with(prefix);
-
-
-
-
-
-
1786 return this->
substr(0,
count).MyBaseClass::starts_with(prefix);
-
-
-
-
1791 inline const bool startswith_n(
const std::initializer_list<CppStringT>& prefix,
const size_type start,
const size_type
count)
const noexcept
-
-
-
-
-
-
-
-
1805 inline CppStringT
strip(
const CppStringT& removedchars)
const noexcept
-
-
1807 return this->
rstrip(removedchars).
lstrip(removedchars);
-
-
-
-
1812 inline CppStringT
strip() const noexcept
-
-
-
-
-
-
-
-
1821 inline CppStringT
substr(
const size_type start,
const size_type
count = -1) const noexcept
-
-
1823 if (start > this->size()) [[unlikely]]
-
1824 return CppStringT();
-
-
1826 const size_type width{ std::min(
count, this->size() - start + 1) };
-
1827 return CppStringT(MyBaseClass::substr(start, width));
-
-
-
-
-
-
-
-
-
1840 std::ranges::transform(*
this, std::back_inserter(res), [](
const value_type c) -> value_type {
return pcs::swap_case(c); });
-
-
-
-
-
-
-
-
-
1850 const CppStringT whitespace(value_type(
' '));
-
-
1852 CppStringT res(*
this);
-
1853 std::vector<CppStringT> words = res.
split(whitespace);
-
-
1855 for (CppStringT& word : words)
-
1856 word = word.capitalize();
-
-
1858 return whitespace.
join(words);
-
-
-
-
-
-
-
-
-
1873 for (
auto ch : *
this) {
-
1874 try { res += table[ch]; }
-
1875 catch (...) { res += ch; }
-
-
-
-
-
-
-
-
-
-
1890 std::ranges::transform(*
this, std::back_inserter(res), [&](
const value_type ch) -> value_type {
return this->
upper(ch); });
-
-
-
-
-
1900 static inline const value_type
upper(
const value_type ch)
noexcept
-
-
1902 return value_type(std::toupper(ch));
-
-
-
-
-
-
1914 inline CppStringT
zfill(
const size_type width)
const noexcept
-
-
1916 if (this->size() >= width) [[unlikely]]
-
-
-
1919 const size_type padding_width = width - this->size();
-
1920 if ((*
this)[0] ==
'-' || (*
this)[0] ==
'+') [[unlikely]]
-
1921 return (*
this)[0] + this->
substr(1, this->size() - 1).
ljust(width - 1, value_type(
'0'));
-
-
1923 return this->
ljust(width, value_type(
'0'));
-
-
-
-
-
-
-
1931 inline CppString operator""_cs(
const char* str, std::size_t len)
-
-
1933 return CppString(CppString::MyBaseClass(str, len));
-
-
-
1937 inline CppWString operator""_cs(
const wchar_t* str, std::size_t len)
-
-
1939 return CppWString(CppWString::MyBaseClass(str, len));
-
-
-
-
-
-
1946 template<
typename IntT>
-
1947 requires std::is_signed_v<IntT>
-
-
-
-
1951 static constexpr IntT DEFAULT{ std::numeric_limits<IntT>::min() };
-
-
-
-
-
-
-
-
-
-
-
-
-
1964 template<typename CharT =
char>
-
1965#if (defined(_HAS_CXX20) && _HAS_CXX20)
-
1966 requires std::is_same_v<CharT, char> || std::is_same_v<CharT, char8_t> || std::is_same_v<CharT, char16_t> || std::is_same_v<CharT, char32_t> || std::is_same_v<CharT, wchar_t>
-
-
1968 requires std::is_same_v<CharT, char> || std::is_same_v<CharT, char16_t> || std::is_same_v<CharT, char32_t> || std::is_same_v<CharT, wchar_t>
-
-
-
-
1972 return _prepare_iterating(IntT(str.size()));
-
-
-
-
1976 inline const bool end() const noexcept
-
-
1978 return _step == 0 ? true : _step > 0 ? _index >= _stop : _index <= _stop;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
2001 inline IntT
stop() {
return _stop; }
-
2002 inline IntT
step() {
return _step; }
-
-
-
-
-
2007 IntT _stop{ DEFAULT };
-
-
-
-
-
-
2013 const IntT _prepare_iterating(
const IntT str_size)
noexcept
-
-
2015 if (_start == DEFAULT) {
-
2016 if (_step < 0 && _step != DEFAULT) [[unlikely]]
-
2017 _start = str_size - 1;
-
-
-
-
2021 else if (_start < 0) {
-
-
2023 if (_start < 0) [[unlikely]]
-
-
-
2026 else if (_start >= str_size) {
-
2027 if (_step < 0 && _step != DEFAULT)
-
2028 _start = str_size - 1;
-
-
-
2031 if (_stop == DEFAULT) {
-
2032 if (_step < 0 && _step != DEFAULT) [[unlikely]]
-
-
-
-
-
2037 else if (_stop < 0) {
-
-
-
-
-
2042 else if (_stop > str_size)
-
-
-
2045 if (_step == DEFAULT) [[likely]]
-
-
2047 if (_step < 0) [[unlikely]] {
-
2048 if (_start <= _stop)
-
-
-
-
2052 if (_start >= _stop)
-
-
-
-
2056 return _index = _start;
-
-
-
-
-
2062 template<
typename IntT>
-
2063 requires std::is_signed_v<IntT>
-
-
-
-
-
-
-
2070 : MyBaseClass(
start, MyBaseClass::DEFAULT, 1)
-
-
-
-
-
-
-
2078 template<typename IntT>
-
2079 requires std::is_signed_v<IntT>
-
-
-
-
-
-
-
2086 : MyBaseClass(MyBaseClass::DEFAULT,
stop, 1)
-
-
-
-
-
-
-
2094 template<typename IntT>
-
2095 requires std::is_signed_v<IntT>
-
-
-
-
-
-
-
2102 : MyBaseClass(MyBaseClass::DEFAULT, MyBaseClass::DEFAULT,
step)
-
-
-
-
-
-
-
2110 template<typename IntT>
-
2111 requires std::is_signed_v<IntT>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
2126 template<typename IntT>
-
2127 requires std::is_signed_v<IntT>
-
-
-
-
-
-
-
2134 : MyBaseClass(
start, MyBaseClass::DEFAULT,
step)
-
-
-
-
-
-
-
-
2143 template<typename IntT>
-
2144 requires std::is_signed_v<IntT>
-
-
-
-
-
-
-
2151 : MyBaseClass(MyBaseClass::DEFAULT,
stop,
step)
-
-
-
-
-
-
-
-
-
2161 template<class CharT>
-
-
-
-
-
-
-
-
-
-
-
2173 return static_cast<const bool>(std::isalpha(
static_cast<unsigned char>(ch)));
-
-
-
-
-
-
-
2181 return static_cast<const bool>(std::iswalpha(ch));
-
-
-
-
-
2187 template<
class CharT>
-
-
-
-
2191 return CharT(0x00) <= ch && ch <= CharT(0x7f);
-
-
-
-
-
2197 template<
class CharT>
-
-
-
-
-
-
-
-
-
-
-
2209 return static_cast<const bool>(std::isdigit(
static_cast<unsigned char>(ch)));
-
-
-
-
-
-
-
2217 return (
const bool)std::iswdigit(ch);
-
-
-
-
-
2223 template<
class CharT>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
2249 template<
class CharT>
-
-
-
-
-
-
-
-
-
2259 template<
class CharT>
-
-
-
-
-
-
-
-
-
2269 template<
class CharT>
-
-
-
-
-
-
-
-
-
-
-
2281 return std::islower(
static_cast<unsigned char>(ch));
-
-
-
-
-
-
-
2289 return std::iswlower(ch);
-
-
-
-
-
2295 template<
class CharT>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
2321 template<
class CharT>
-
-
-
-
-
-
-
-
-
-
-
2333 return static_cast<const bool>(std::isprint(
static_cast<unsigned char>(ch)));
-
-
-
-
-
-
-
2341 return static_cast<const bool>(std::iswprint(ch));
-
-
-
-
-
2347 template<
class CharT>
-
-
-
-
-
-
-
-
-
-
-
2359 return static_cast<const bool>(std::ispunct(
static_cast<unsigned char>(ch)));
-
-
-
-
-
-
-
2367 return static_cast<const bool>(std::iswpunct(ch));
-
-
-
-
-
2373 template<
class CharT>
-
-
-
-
-
-
-
-
-
-
-
2385 return static_cast<const bool>(std::isspace(
static_cast<unsigned char>(ch)));
-
-
-
-
-
-
-
2393 return static_cast<const bool>(std::iswspace(ch));
-
-
-
-
-
2399 template<
class CharT>
-
-
-
-
-
-
-
-
-
-
-
2411 return static_cast<const bool>(std::isupper(
static_cast<unsigned char>(ch)));
-
-
-
-
-
-
-
2419 return static_cast<const bool>(std::iswupper(ch));
-
-
-
-
-
2425 template<
class CharT>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
2440 template<
class CharT>
-
-
-
-
-
-
-
-
-
-
-
2452 return std::tolower(
static_cast<unsigned char>(ch));
-
-
-
-
-
-
-
2460 return std::towlower(ch);
-
-
-
-
-
2466 template<
class CharT>
-
-
-
-
-
-
-
-
-
-
-
2478 return std::toupper(
static_cast<unsigned char>(ch));
-
-
-
-
-
-
-
2486 return std::towupper(ch);
-
-
-
2489#if defined(_MSC_VER)
-
2490# pragma warning(pop)
-
-
-
-
TransTable(Key1It first_key, Key1It last_key, ValueIt first_value, ValueIt last_value, Key2It first_not_translated, Key2It last_not_translated)
Creates a TransTable from three containers iterators (#9).
Definition cppstrings.h:317
-
TransTable(const std::map< key_type, value_type > trans_table)
Creates a TransTable from a standard map (#1).
Definition cppstrings.h:197
-
TransTable(const StringViewLike &keys, const StringViewLike &values)
Creates a TransTable from two string views (#10).
Definition cppstrings.h:338
-
TransTable(KeyIt first_key, KeyIt last_key, ValueIt first_value, ValueIt last_value)
Creates a TransTable from two containers iterators (#8).
Definition cppstrings.h:300
-
TransTable(const CppStringT &keys, const CppStringT &values)
Creates a TransTable from two strings (#2).
Definition cppstrings.h:207
-
TransTable(const CharT *keys, const CharT *values, const CharT *not_translated)
Creates a TransTable from three pointers to null-terminated lists of characters (#7).
Definition cppstrings.h:285
-
TransTable() noexcept=default
Default empty constructor.
-
value_type operator[](const key_type ch) noexcept
Indexing operator.
Definition cppstrings.h:365
-
TransTable(const CharT *keys, const CharT *values)
Creates a TransTable from two pointers to null-terminated lists of characters (#6).
Definition cppstrings.h:271
-
TransTable(const CppStringT &keys, const CppStringT &values, const CppStringT ¬_translated)
Creates a TransTable from three strings (#3).
Definition cppstrings.h:223
-
TransTable(const CppStringT &keys, const std::initializer_list< CppStringT > &values)
Creates a TransTable from a string and an initalization list (#4).
Definition cppstrings.h:239
-
std::map< typename key_type, typename value_type > & get_table() noexcept
< for tests purposes
Definition cppstrings.h:376
-
TransTable(const CppStringT &keys, const std::initializer_list< CppStringT > values, const CppStringT ¬_translated)
Creates a TransTable from a string, an initalization list and a string (#5).
Definition cppstrings.h:255
-
This is the templated base class for all CppString classes.
Definition cppstrings.h:166
-
CppStringT strip(const CppStringT &removedchars) const noexcept
Returns a copy of the string with the leading and trailing characters removed.
Definition cppstrings.h:1805
-
constexpr bool contains_n(const CppStringT &sub, const size_type start, const size_type count=-1) const noexcept
Returns true if the passed string is found within the slice str[start:start+count-1],...
Definition cppstrings.h:512
-
std::vector< CppStringT > rsplit(const CppStringT &sep) noexcept
Returns a vector of the words in the whole string, using sep as the delimiter string.
Definition cppstrings.h:1491
-
CppStringT removeprefix(const CppStringT &prefix) const noexcept
If the string starts with the prefix string, returns a new string with the prefix removed....
Definition cppstrings.h:1223
-
constexpr bool contains(const CppStringT &substr) const noexcept
Returns true if this string contains the passed string, or false otherwise.
Definition cppstrings.h:479
-
CppStringT operator*(std::int64_t count) const noexcept
Generates a new string with count times the content of this string.
Definition cppstrings.h:1186
-
const bool isdecimal() const noexcept
Returns true if all characters in the string are decimal characters and there is at least one charact...
Definition cppstrings.h:841
-
std::vector< CppStringT > splitlines(const bool keep_end=false) const noexcept
Return a list of the lines in the string, breaking at line boundaries.
Definition cppstrings.h:1671
-
CppStringT strip() const noexcept
Returns a copy of the string with the leading and trailing whitespaces removed.
Definition cppstrings.h:1812
-
CppStringT title() const noexcept
Returns a titlecased copy of the string where words start with an uppercase character and the remaini...
Definition cppstrings.h:1848
-
constexpr size_type index_n(const CppStringT &sub, const size_type count) const
Like find_n(sub, count), but raises NotFoundException when the substring is not found.
Definition cppstrings.h:790
-
CppStringT & format(const std::basic_format_string< char, std::type_identity_t< ArgsT >... > frmt, ArgsT &&... args)
Definition cppstrings.h:737
-
CppStringT operator()(Slice< IntT > slice) const noexcept
Generates a new string according to the specified slice.
Definition cppstrings.h:1144
-
const bool isdigit() const noexcept
Returns true if all characters in the string are digits and there is at least one character,...
Definition cppstrings.h:862
-
constexpr size_type find(const CppStringT &sub, const size_type start=0, const size_type end=-1) const noexcept
Returns the lowest index in the string where substring sub is found within the slice str[start:end],...
Definition cppstrings.h:666
-
constexpr size_type index(const CppStringT &sub, const size_type start=0, const size_type end=-1) const
Definition cppstrings.h:762
-
const bool ispunctuation() const noexcept
Returns true if the string contains only one character and if this character belongs to the ASCII pun...
Definition cppstrings.h:938
-
CppStringT translate(TransTable &table) noexcept
Returns a copy of the string in which each character has been mapped through the given translation ta...
Definition cppstrings.h:1870
-
constexpr size_type rindex(const CppStringT &sub, const size_type start) const
Like rfind(sub, start), but raises NotFoundException when the substring is not found.
Definition cppstrings.h:1398
-
CppStringT expand_tabs(const size_type tabsize=8) const noexcept
Returns a copy of the string where all tab characters are replaced by one or more spaces,...
Definition cppstrings.h:626
-
CppStringT join(const CppStringT &s) const noexcept
Single parameter signature. Returns a copy of this parameter.
Definition cppstrings.h:1043
-
const bool startswith(const std::initializer_list< CppStringT > &prefixes, const size_type start, const size_type end) const noexcept
Returns true if the string starts with any of the specified prefixes, otherwise returns false....
Definition cppstrings.h:1760
-
std::vector< CppStringT > rsplit(const size_type maxsplit) noexcept
Returns a vector of the words in the string, as seperated with whitespace strings....
Definition cppstrings.h:1498
-
const bool startswith_n(const CppStringT &prefix, const size_type start, const size_type count) const noexcept
Returns true if the string starts with the specified suffix, otherwise returns false....
Definition cppstrings.h:1777
-
const bool endswith(const CppStringT &suffix) const noexcept
Returns true if the string ends with the specified suffix, otherwise returns false....
Definition cppstrings.h:579
-
const bool endswith(const CppStringT &suffix, const size_type start, const size_type end) const noexcept
Returns true if the string ends with the specified suffix, otherwise returns false....
Definition cppstrings.h:565
-
const bool isalpha() const noexcept
Returns true if all characters in the string are alphabetic and there is at least one character,...
Definition cppstrings.h:815
-
CppStringT capitalize() noexcept
Returns a copy of the string with its first character capitalized and the rest lowercased.
Definition cppstrings.h:443
-
const bool endswith_n(const std::initializer_list< CppStringT > &suffixes, const size_type start, const size_type count) const noexcept
Returns true if the string ends with any of the specified suffixes, otherwise returns false....
Definition cppstrings.h:617
-
constexpr size_type rfind_n(const CppStringT &sub, const size_type start, const size_type count) const noexcept
Returns the highest index in the string where substring sub is found within the slice str[start:start...
Definition cppstrings.h:1353
-
CppStringT join(const CppStringT &first, const NextCppStringsT &... others) const noexcept
Returns a string which is the concatenation of the strings in the parameters list.
Definition cppstrings.h:1035
-
constexpr size_type rindex(const CppStringT &sub) const
Like rfind(sub), but raises NotFoundException when the substring is not found.
Definition cppstrings.h:1409
-
std::vector< CppStringT > split(const CppStringT &sep, const size_type maxsplit) noexcept
Returns a vector of the words in the string, using sep as the delimiter string. At most maxsplit spli...
Definition cppstrings.h:1614
-
const bool isnumeric() const noexcept
Returns true if all characters in the string are numeric characters, and there is at least one charac...
Definition cppstrings.h:915
-
constexpr size_type count_n(const CppStringT &sub, const size_type length) const noexcept
Returns the number of non-overlapping occurrences of substring sub in the range [0,...
Definition cppstrings.h:556
-
const bool startswith(const CppStringT &prefix, const size_type start, const size_type end) const noexcept
Returns true if the string starts with the specified prefix, otherwise returns false....
Definition cppstrings.h:1739
-
CppStringT & format(const std::basic_format_string< T, std::type_identity_t< ArgsT >... > frmt, ArgsT &&... args)
Formats this string according to c++20 std::format() specification. Returns this string.
Definition cppstrings.h:728
-
std::vector< CppStringT > rpartition(const CppStringT &sep) const noexcept
Splits the string at the last occurrence of sep, and returns a 3-items vector containing the part bef...
Definition cppstrings.h:1462
-
const bool endswith_n(const CppStringT &suffix, const size_type count) const noexcept
Returns true if the string ends with the specified suffix, otherwise returns false....
Definition cppstrings.h:610
-
CppStringT rjust(const size_type width, const value_type fillch=value_type(' ')) const noexcept
Returns the string right justified in a string of length width.
Definition cppstrings.h:1446
-
const bool isprintable() const noexcept
Returns true if all characters in the string are printable or if the string is empty,...
Definition cppstrings.h:929
-
constexpr size_type rindex(const CppStringT &sub, const size_type start, const size_type end) const
Like rfind(sub, start, end), but raises NotFoundException when the substring is not found.
Definition cppstrings.h:1383
-
CppStringT & upper() noexcept
In-place replaces all characters of the string with their uppercase conversion. Returns a reference t...
Definition cppstrings.h:1887
-
CppStringT swapcase() const noexcept
Returns a copy of the string with uppercase characters converted to lowercase and vice versa.
Definition cppstrings.h:1837
-
constexpr size_type find_n(const CppStringT &sub, const size_type count) const noexcept
Returns the lowest index in the string where substring sub is found within the slice str[0:count-1],...
Definition cppstrings.h:719
-
static const value_type lower(const value_type ch) noexcept
Returns lowercase conversion of the character.
Definition cppstrings.h:1095
-
const bool endswith(const CppStringT &suffix, const size_type end) const noexcept
Returns true if the string ends with the specified suffix, otherwise returns false....
Definition cppstrings.h:572
-
const bool isascii() const noexcept
Returns true if the string is empty or all characters in the string are ASCII, or false otherwise.
Definition cppstrings.h:827
-
const bool is_words_sep() const noexcept
Returns true if there are only whitespace and punctuation characters in the string and there is at le...
Definition cppstrings.h:982
-
constexpr size_type count_n(const CppStringT &sub, const size_type start, const size_type length) const noexcept
Returns the number of non-overlapping occurrences of substring sub in the range [start,...
Definition cppstrings.h:549
-
constexpr size_type rfind_n(const CppStringT &sub, const size_type count) const noexcept
Returns the highest index in the string where substring sub is found within the slice str[0:count-1],...
Definition cppstrings.h:1367
-
constexpr size_type count(const CppStringT &sub, const size_type start=0, const size_type end=-1) const noexcept
Returns the number of non-overlapping occurrences of substring sub in the range [start,...
Definition cppstrings.h:526
-
std::vector< CppStringT > split() noexcept
Returns a vector of the words in the whole string, as seperated with whitespace strings.
Definition cppstrings.h:1578
-
const bool endswith_n(const CppStringT &suffix, const size_type start, const size_type count) const noexcept
Returns true if the string ends with the specified suffix, otherwise returns false....
Definition cppstrings.h:603
-
std::vector< CppStringT > rsplit() noexcept
Returns a vector of the words in the whole string, as seperated with whitespace strings.
Definition cppstrings.h:1484
-
CppStringT rstrip() const noexcept
Returns a copy of the string with trailing whitespaces removed.
Definition cppstrings.h:1562
-
const bool endswith(const std::initializer_list< CppStringT > &suffixes, const size_type start, const size_type end) const noexcept
Returns true if the string ends with any of the specified suffixes, otherwise returns false....
Definition cppstrings.h:586
-
CppStringT rstrip(const CppStringT &removedchars) const noexcept
Returns a copy of the string with trailing characters removed.
Definition cppstrings.h:1552
-
std::vector< CppStringT > split(const size_type maxsplit) noexcept
Returns a vector of the words in the string, as seperated with whitespace strings....
Definition cppstrings.h:1607
-
const bool isalnum() const noexcept
Returns true if all characters in the string are alphanumeric and there is at least one character,...
Definition cppstrings.h:799
-
const bool isidentifier() const noexcept
Returns true if the string is not empty and is a valid identifier according to the language definitio...
Definition cppstrings.h:889
-
CppStringT & format(const std::basic_format_string< wchar_t, std::type_identity_t< ArgsT >... > frmt, ArgsT &&... args)
Definition cppstrings.h:746
-
const bool isspace() const noexcept
Returns true if there are only whitespace characters in the string and there is at least one characte...
Definition cppstrings.h:947
-
CppStringT substr(const size_type start, const size_type count=-1) const noexcept
Definition cppstrings.h:1821
-
CppStringT join(const std::vector< CppStringT > &strs) const noexcept
Returns a string which is the concatenation of the strings in the vector parameter.
Definition cppstrings.h:1017
-
constexpr size_type rfind(const CppStringT &sub, const size_type start) const noexcept
Returns the highest index in the string where substring sub is found starting at start position in st...
Definition cppstrings.h:1316
-
const CppStringT join() const noexcept
Empty parameters list signature. Returns a copy of current string.
Definition cppstrings.h:1050
-
std::vector< CppStringT > rsplit(const CppStringT &sep, const size_type maxsplit) noexcept
Returns a vector of the words in the string, using sep as the delimiter string. At most maxsplit spli...
Definition cppstrings.h:1505
-
const bool startswith_n(const std::initializer_list< CppStringT > &prefix, const size_type start, const size_type count) const noexcept
Returns true if the string starts with any of the specified suffixes, otherwise returns false....
Definition cppstrings.h:1791
-
constexpr size_type rfind(const CppStringT &sub) const noexcept
Returns the highest index in the string where C-substring sub is found in the whole string,...
Definition cppstrings.h:1337
-
CppStringT lstrip() const noexcept
Returns a copy of the string with leading whitespaces removed.
Definition cppstrings.h:1120
-
CppStringT join(const std::array< CppStringT, N > &strs) const noexcept
Returns a string which is the concatenation of the strings in the array parameter.
Definition cppstrings.h:1000
-
constexpr size_type rindex_n(const CppStringT &sub, const size_type count) const
Like rfind_n(sub, count), but raises NotFoundException when the substring is not found.
Definition cppstrings.h:1433
-
constexpr size_type find_n(const CppStringT &sub, const size_type start, const size_type count) const noexcept
Returns the lowest index in the string where substring sub is found within the slice str[start:start+...
Definition cppstrings.h:691
-
std::vector< CppStringT > partition(const CppStringT &sep) const noexcept
Splits the string at the first occurrence of sep, and returns a 3-items vector containing the part be...
Definition cppstrings.h:1205
-
std::vector< CppStringT > split(const CppStringT &sep) noexcept
Returns a vector of the words in the whole string, using sep as the delimiter string.
Definition cppstrings.h:1597
-
const bool startswith(const CppStringT &prefix, const size_type start) const noexcept
Returns true if the string starts with the specified prefix, otherwise returns false....
Definition cppstrings.h:1746
-
CppStringT zfill(const size_type width) const noexcept
Returns a copy of the string left filled with ASCII '0' digits to make a string of length width.
Definition cppstrings.h:1914
-
CppStringT replace(const CppStringT &old, const CppStringT &new_, size_type count=-1) const noexcept
Returns a copy of the string with first count occurrences of substring 'old' replaced by 'new_'.
Definition cppstrings.h:1251
-
CppStringT & lower() noexcept
In-place replaces all characters of the string with their lowercase conversion. Returns a reference t...
Definition cppstrings.h:1078
-
CppStringT removesuffix(const CppStringT &suffix) const noexcept
If the string ends with the suffix string, returns a new string with the suffix removed....
Definition cppstrings.h:1237
-
const bool istitle() const noexcept
Returns true if the string is a titlecased string and there is at least one character,...
Definition cppstrings.h:964
-
const bool startswith_n(const CppStringT &prefix, const size_type count) const noexcept
Returns true if the string starts with the specified suffix, otherwise returns false....
Definition cppstrings.h:1784
-
const bool startswith(const CppStringT &prefix) const noexcept
Returns true if the string starts with the specified prefix, otherwise returns false....
Definition cppstrings.h:1753
-
const bool islower() const noexcept
Returns true if all cased characters in the string are lowercase and there is at least one cased char...
Definition cppstrings.h:898
-
CppStringT ljust(const size_type width, const value_type fillch=value_type(' ')) const noexcept
Returns the string left justified in a string of length width.
Definition cppstrings.h:1063
-
CppStringT lstrip(const CppStringT &removedchars) const noexcept
Returns a copy of the string with leading characters removed.
Definition cppstrings.h:1110
-
constexpr size_type index_n(const CppStringT &sub, const size_type start, const size_type count) const
Like find_n(sub, start, count), but raises NotFoundException when the substring is not found.
Definition cppstrings.h:779
-
CppStringT center(const size_type width, const value_type fillch=value_type(' ')) const noexcept
Returns a copy of the string centered in a string of length width.
Definition cppstrings.h:462
-
const bool isupper() const noexcept
Returns true if all cased characters in the string are uppercase and there is at least one cased char...
Definition cppstrings.h:973
-
constexpr size_type rfind(const CppStringT &sub, const size_type start, const size_type end) const noexcept
Returns the highest index in the string where substring sub is found within the slice str[start:end],...
Definition cppstrings.h:1288
-
static const value_type upper(const value_type ch) noexcept
Returns uppercase conversion of the character.
Definition cppstrings.h:1900
-
constexpr size_type rindex_n(const CppStringT &sub, const size_type start, const size_type count) const
Like rfind_n(sub, start, count), but raises NotFoundException when the substring is not found.
Definition cppstrings.h:1422
-
Base class for slices, with start, stop and step specified values.
Definition cppstrings.h:1949
-
IntT stop()
Returns the stop index of this slide.
Definition cppstrings.h:2001
-
IntT start()
Returns the start index of this slide.
Definition cppstrings.h:2000
-
IntT step()
Returns the step value of this slide.
Definition cppstrings.h:2002
-
Slice operator++() noexcept
< iterates one step, pre-increment. Caution: index may be out of bounds. Check '!end()' before derefe...
Definition cppstrings.h:1981
-
Slice operator++(int) noexcept
< iterates one step, post-increment. Caution: index may be out of bounds. Check '!...
Definition cppstrings.h:1987
-
Slice(const IntT start=DEFAULT, const IntT stop=DEFAULT, const IntT step=DEFAULT) noexcept
< Valued constructor
Definition cppstrings.h:1954
-
const IntT begin(const CppStringT< CharT > &str) noexcept
< starts iterating on specified CppString.
Definition cppstrings.h:1970
-
virtual ~Slice() noexcept=default
Default destructor.
-
const bool end() const noexcept
< returns true when iterating is over, or false otherwise.
Definition cppstrings.h:1976
-
const IntT operator*() noexcept
< dereferences the slice.
Definition cppstrings.h:1994
-
Definition cppstrings.h:41
-
const bool is_digit< wchar_t >(const wchar_t ch) noexcept
Returns true if character is a decimal digit, or false otherwise.
Definition cppstrings.h:2241
-
const bool is_punctuation(const CharT ch) noexcept
Returns true if character ch is punctuation, or false otherwise.
Definition cppstrings.h:2349
-
const bool is_alpha< wchar_t >(const wchar_t ch) noexcept
Returns true if character ch is alphabetic, or false otherwise. Conforms to the current locale settin...
Definition cppstrings.h:2179
-
CppStringT< char > CppString
Specialization of basic class with template argument 'char'.
Definition cppstrings.h:53
-
const bool is_printable< char >(const char ch) noexcept
Returns true if character ch is printable, or false otherwise.
Definition cppstrings.h:2331
-
const bool is_numeric< char >(const char ch) noexcept
Returns true if character is a decimal digit, or false otherwise.
Definition cppstrings.h:2305
-
const bool is_decimal< char >(const char ch) noexcept
Returns true if character is a decimal digit, or false otherwise.
Definition cppstrings.h:2207
-
const bool is_lower< char >(const char ch) noexcept
Returns true if character ch is lowercase, or false otherwise. Conforms to the current locale setting...
Definition cppstrings.h:2279
-
const bool is_printable< wchar_t >(const wchar_t ch) noexcept
Returns true if character ch is punctuation, or false otherwise. Conforms to the current locale setti...
Definition cppstrings.h:2339
-
const bool is_punctuation< wchar_t >(const wchar_t ch) noexcept
Returns true if character ch is punctuation, or false otherwise. Conforms to the current locale setti...
Definition cppstrings.h:2365
-
const bool is_alpha(const CharT ch) noexcept
struct of slices with default start values
Definition cppstrings.h:2163
-
const char to_lower< char >(const char ch) noexcept
Returns the lowercase form of character ch if it exists, or ch itself otherwise. Conforms to the curr...
Definition cppstrings.h:2450
-
const bool is_printable(const CharT ch) noexcept
Returns true if character ch is printable, or false otherwise.
Definition cppstrings.h:2323
-
const bool is_digit(const CharT ch) noexcept
Returns true if character is a decimal digit, or false otherwise.
Definition cppstrings.h:2225
-
const bool is_space< wchar_t >(const wchar_t ch) noexcept
Returns true if character ch is alphabetic, or false otherwise. Conforms to the current locale settin...
Definition cppstrings.h:2391
-
const CharT to_upper(const CharT ch) noexcept
Returns the uppercase form of character ch if it exists, or ch itself otherwise.
Definition cppstrings.h:2468
-
const bool is_decimal< wchar_t >(const wchar_t ch) noexcept
Returns true if character is a decimal digit, or false otherwise.
Definition cppstrings.h:2215
-
const bool is_space< char >(const char ch) noexcept
Returns true if character ch is alphabetic, or false otherwise. Conforms to the current locale settin...
Definition cppstrings.h:2383
-
CppStringT< wchar_t > CppWString
Specialization of basic class with template argument 'wchar_t'.
Definition cppstrings.h:54
-
const bool is_upper(const CharT ch) noexcept
Returns true if character is uppercase, or false otherwise.
Definition cppstrings.h:2401
-
const CharT to_lower(const CharT ch) noexcept
Returns the lowercase form of character ch if it exists, or ch itself otherwise.
Definition cppstrings.h:2442
-
const bool is_decimal(const CharT ch) noexcept
Returns true if character is a decimal digit, or false otherwise.
Definition cppstrings.h:2199
-
const bool is_punctuation< char >(const char ch) noexcept
Returns true if character ch is punctuation, or false otherwise. Conforms to the current locale setti...
Definition cppstrings.h:2357
-
const wchar_t to_upper< wchar_t >(const wchar_t ch) noexcept
Returns the uppercase form of character ch if it exists, or ch itself otherwise. Conforms to the curr...
Definition cppstrings.h:2484
-
const wchar_t to_lower< wchar_t >(const wchar_t ch) noexcept
Returns the lowercase form of character ch if it exists, or ch itself otherwise. Conforms to the curr...
Definition cppstrings.h:2458
-
const bool is_upper< wchar_t >(const wchar_t ch) noexcept
Returns true if character ch is uppercase, or false otherwise. Conforms to the current locale setting...
Definition cppstrings.h:2417
-
const char to_upper< char >(const char ch) noexcept
Returns the uppercase form of character ch if it exists, or ch itself otherwise. Conforms to the curr...
Definition cppstrings.h:2476
-
const bool is_id_start(const CharT ch) noexcept
Returns true if character is a starting char for identifiers, or false otherwise.
Definition cppstrings.h:2261
-
const bool is_upper< char >(const char ch) noexcept
Returns true if character ch is uppercase, or false otherwise. Conforms to the current locale setting...
Definition cppstrings.h:2409
-
const CharT swap_case(const CharT ch) noexcept
Returns the swapped case form of character ch if it exists, or ch itself otherwise.
Definition cppstrings.h:2427
-
const bool is_ascii(const CharT ch) noexcept
Returns true if character ch gets ASCII code, or false otherwise.
Definition cppstrings.h:2189
-
const bool is_numeric< wchar_t >(const wchar_t ch) noexcept
Returns true if character is a decimal digit, or false otherwise.
Definition cppstrings.h:2313
-
const bool is_lower< wchar_t >(const wchar_t ch) noexcept
Returns true if character ch is lowercase, or false otherwise. Conforms to the current locale setting...
Definition cppstrings.h:2287
-
const bool is_alpha< char >(const char ch) noexcept
Returns true if character ch is alphabetic, or false otherwise. Conforms to the current locale settin...
Definition cppstrings.h:2171
-
const bool is_lower(const CharT ch) noexcept
Returns true if character is lowercase, or false otherwise.
Definition cppstrings.h:2271
-
const bool is_id_continue(const CharT ch) noexcept
Returns true if character is a continuing char for identifiers, or false otherwise.
Definition cppstrings.h:2251
-
const bool is_space(const CharT ch) noexcept
Returns true if character ch is white space, or false otherwise.
Definition cppstrings.h:2375
-
const bool is_numeric(const CharT ch) noexcept
Returns true if character is a decimal digit, or false otherwise.
Definition cppstrings.h:2297
-
const bool is_digit< char >(const char ch) noexcept
Returns true if character is a decimal digit, or false otherwise.
Definition cppstrings.h:2233
-
Base class for slices, with start, stop and step specified values.
Definition cppstrings.h:2065
-
virtual ~StartSlice() noexcept=default
Default destructor.
-
StartSlice(const IntT start=MyBaseClass::DEFAULT) noexcept
< Valued constructor
Definition cppstrings.h:2069
-
struct of slices with default step values
Definition cppstrings.h:2129
-
StartStepSlice(const IntT start=MyBaseClass::DEFAULT, const IntT step=MyBaseClass::DEFAULT) noexcept
< Valued constructor
Definition cppstrings.h:2133
-
virtual ~StartStepSlice() noexcept=default
Default destructor.
-
struct of slices with default start and stop values
Definition cppstrings.h:2113
-
StartStopSlice(const IntT start=MyBaseClass::DEFAULT, const IntT stop=MyBaseClass::DEFAULT) noexcept
< Valued constructor
Definition cppstrings.h:2117
-
virtual ~StartStopSlice() noexcept=default
Default destructor.
-
struct of slices with default start and step values
Definition cppstrings.h:2097
-
virtual ~StepSlice() noexcept=default
Default destructor.
-
StepSlice(const IntT step=MyBaseClass::DEFAULT) noexcept
< Valued constructor
Definition cppstrings.h:2101
-
struct of slices with default stop and step values
Definition cppstrings.h:2081
-
virtual ~StopSlice() noexcept=default
Default destructor.
-
StopSlice(const IntT stop=MyBaseClass::DEFAULT) noexcept
< Valued constructor
Definition cppstrings.h:2085
-
struct of slices with default stop values
Definition cppstrings.h:2146
-
StopStepSlice(const IntT stop=MyBaseClass::DEFAULT, const IntT step=MyBaseClass::DEFAULT) noexcept
< Valued constructor
Definition cppstrings.h:2150
-
virtual ~StopStepSlice() noexcept=default
Default destructor.
-