xtd.string - Reference Guide  0.1.1
Modern c++17 library to add string utilities on Windows, macOS, Linux, iOS and android.
strings.h
Go to the documentation of this file.
1 #pragma once
4 
6 #define __XTD_STRINGS_INCLUDE__
7 
9 #include "internal/__format.h"
10 #include "internal/__format_information.h"
11 #include "internal/__format_stringer.h"
12 #include "istring.h"
13 #include "string_comparison.h"
14 #include "string_split_options.h"
15 
16 #include <algorithm>
17 #include <bitset>
18 #include <cctype>
19 #include <vector>
20 
21 #if !defined(_WIN32)
22 #include <cxxabi.h>
23 #endif
24 
25 #undef max
26 #undef min
27 
29 template<typename char_t, typename ...args_t>
30 void __extract_format_arg(std::basic_string<char_t>& fmt, std::vector<__format_information<char_t>>& format, args_t&&... args);
32 
34 namespace xtd {
36  template<typename Value>
37  inline Value parse(const std::string& str);
38  template<typename Value>
39  inline Value parse(const std::wstring& str);
40  template<typename Value>
41  inline Value parse(const std::u16string& str);
42  template<typename Value>
43  inline Value parse(const std::u32string& str);
45 
47  class strings {
48  public:
50  strings() = delete;
52 
56  template<typename object_t>
57  static std::string full_class_name() {return demangle(typeid(object_t).name());}
58 
62  template<typename object_t>
63  static std::string full_class_name(const object_t& object) {return demangle(typeid(object).name());}
64 
65  static std::string full_class_name(const std::type_info& info) {return demangle(info.name());}
66 
70  template<typename object_t>
71  static std::string class_name() {return get_class_name(full_class_name<object_t>());}
72 
76  template<typename object_t>
77  static std::string class_name(const object_t& object) {return get_class_name(full_class_name(object));}
78 
79  static std::string class_name(const std::type_info& info) {return get_class_name(full_class_name(info));}
80 
90  template<typename char_t>
91  static int compare(const std::basic_string<char_t>& str_a, const std::basic_string<char_t>& str_b) noexcept {return compare(str_a, str_b, false);}
92 
94  template<typename char_t>
95  static int compare(const std::basic_string<char_t>& str_a, const char_t* str_b) noexcept {return compare(str_a, str_b, false);}
96  template<typename char_t>
97  static int compare(const char_t* str_a, const std::basic_string<char_t>& str_b) noexcept {return compare(str_a, str_b, false);}
98  template<typename char_t>
99  static int compare(const char_t* str_a, const char_t* str_b) noexcept {return compare(str_a, str_b, false);}
101 
102 
113  template<typename char_t>
114  static int compare(const std::basic_string<char_t>& str_a, const std::basic_string<char_t>& str_b, bool ignore_case) noexcept {return compare(str_a, str_b, ignore_case ? xtd::string_comparison::ordinal_ignore_case : xtd::string_comparison::ordinal);}
115 
117  template<typename char_t>
118  static int compare(const std::basic_string<char_t>& str_a, const char_t* str_b, bool ignore_case) noexcept {return compare(str_a, std::basic_string<char_t>(str_b), ignore_case);}
119  template<typename char_t>
120  static int compare(const char_t* str_a, const std::basic_string<char_t>& str_b, bool ignore_case) noexcept {return compare(std::basic_string<char_t>(str_a), str_b, ignore_case);}
121  template<typename char_t>
122  static int compare(const char_t* str_a, const char_t* str_b, bool ignore_case) noexcept {return compare(std::basic_string<char_t>(str_a), std::basic_string<char_t>(str_b), ignore_case);}
124 
135  template<typename char_t>
136  static int compare(const std::basic_string<char_t>& str_a, const std::basic_string<char_t>& str_b, xtd::string_comparison comparison_type) noexcept {
137  if (comparison_type == xtd::string_comparison::ordinal_ignore_case)
138  return to_lower(str_a).compare(to_lower(str_b));
139  return str_a.compare(str_b);
140  }
141 
143  template<typename char_t>
144  static int compare(const std::basic_string<char_t>& str_a, const char_t* str_b, xtd::string_comparison comparison_type) noexcept {return compare(str_a, std::basic_string<char_t>(str_b), comparison_type);}
145  template<typename char_t>
146  static int compare(const char_t* str_a, const std::basic_string<char_t>& str_b, xtd::string_comparison comparison_type) noexcept {return compare(std::basic_string<char_t>(str_a), str_b, comparison_type);}
147  template<typename char_t>
148  static int compare(const char_t* str_a, const char_t* str_b, xtd::string_comparison comparison_type) noexcept {return compare(std::basic_string<char_t>(str_a), std::basic_string<char_t>(str_b), comparison_type);}
150 
163  template<typename char_t>
164  static int compare(const std::basic_string<char_t>& str_a, size_t index_a, const std::basic_string<char_t>& str_b, size_t index_b, size_t length) noexcept {return compare(str_a, index_a, str_b, index_b, length, false);}
165 
167  template<typename char_t>
168  static int compare(const std::basic_string<char_t>& str_a, size_t index_a, const char_t* str_b, size_t index_b, size_t length) noexcept {return compare(str_a, index_a, str_b, index_b, length, false);}
169  template<typename char_t>
170  static int compare(const char_t* str_a, size_t index_a, const std::basic_string<char_t>& str_b, size_t index_b, size_t length) noexcept {return compare(str_a, index_a, str_b, index_b, length, false);}
171  template<typename char_t>
172  static int compare(const char_t* str_a, size_t index_a, const char_t* str_b, size_t index_b, size_t length) noexcept {return compare(str_a, index_a, str_b, index_b, length, false);}
174 
175 
189  template<typename char_t>
190  static int compare(const std::basic_string<char_t>& str_a, size_t index_a, const std::basic_string<char_t>& str_b, size_t index_b, size_t length, bool ignore_case) noexcept {
191  std::basic_string<char_t> sa(str_a.substr(index_a, length));
192  std::basic_string<char_t> sb(str_b.substr(index_b, length));
193  return compare(str_a, index_a, str_b, index_b, length, ignore_case ? xtd::string_comparison::ordinal_ignore_case : xtd::string_comparison::ordinal);
194  }
195 
197  template<typename char_t>
198  static int compare(const std::basic_string<char_t>& str_a, size_t index_a, const char_t* str_b, size_t index_b, size_t length, bool ignore_case) noexcept {return compare(str_a, index_a, std::basic_string<char_t>(str_b), index_b, length, ignore_case);}
199  template<typename char_t>
200  static int compare(const char_t* str_a, size_t index_a, const std::basic_string<char_t>& str_b, size_t index_b, size_t length, bool ignore_case) noexcept {return compare(std::basic_string<char_t>(str_a), index_a, str_b, index_b, length, ignore_case);}
201  template<typename char_t>
202  static int compare(const char_t* str_a, size_t index_a, const char_t* str_b, size_t index_b, size_t length, bool ignore_case) noexcept {return compare(std::basic_string<char_t>(str_a), index_a, std::basic_string<char_t>(str_b), index_b, length, ignore_case);}
204 
218  template<typename char_t>
219  static int compare(const std::basic_string<char_t>& str_a, size_t index_a, const std::basic_string<char_t>& str_b, size_t index_b, size_t length, xtd::string_comparison comparison_type) noexcept {
220  std::basic_string<char_t> sa(str_a.substr(index_a, length));
221  std::basic_string<char_t> sb(str_b.substr(index_b, length));
222  if (comparison_type == xtd::string_comparison::ordinal_ignore_case)
223  return to_lower(sa).compare(to_lower(sb));
224  return sa.compare(sb);
225  }
226 
228  template<typename char_t>
229  static int compare(const std::basic_string<char_t>& str_a, size_t index_a, const char_t* str_b, size_t index_b, size_t length, xtd::string_comparison comparison_type) noexcept {return compare(str_a, index_a, std::basic_string<char_t>(str_b), index_b, length, comparison_type);}
230  template<typename char_t>
231  static int compare(const char_t* str_a, size_t index_a, const std::basic_string<char_t>& str_b, size_t index_b, size_t length, xtd::string_comparison comparison_type) noexcept {return compare(std::basic_string<char_t>(str_a), index_a, str_b, index_b, length, comparison_type);}
232  template<typename char_t>
233  static int compare(const char_t* str_a, size_t index_a, const char_t* str_b, size_t index_b, size_t length, xtd::string_comparison comparison_type) noexcept {return compare(std::basic_string<char_t>(str_a), index_a, std::basic_string<char_t>(str_b), index_b, length, comparison_type);}
235 
242  template<typename char_t>
243  static std::basic_string<char_t> concat(const std::basic_string<char_t>& str_a, const std::basic_string<char_t>& str_b, const std::basic_string<char_t>& str_c, const std::basic_string<char_t>& str_d) noexcept {
244  std::basic_stringstream<char_t> ss;
245  ss << str_a;
246  ss << str_b;
247  ss << str_c;
248  ss << str_d;
249  return ss.str();
250  }
251 
258  template<typename char_t, typename ObjectA, typename ObjectB, typename ObjectC, typename ObjectD>
259  static std::basic_string<char_t> concat(ObjectA obj_a, ObjectB obj_b, ObjectC obj_c, ObjectD obj_d) noexcept {
260  std::basic_stringstream<char_t> ss;
261  ss << obj_a;
262  ss << obj_b;
263  ss << obj_c;
264  ss << obj_d;
265  return ss.str();
266  }
267 
274  template<typename ObjectA, typename ObjectB, typename ObjectC, typename ObjectD>
275  static std::string concat(ObjectA obj_a, ObjectB obj_b, ObjectC obj_c, ObjectD obj_d) noexcept {
276  std::stringstream ss;
277  ss << obj_a;
278  ss << obj_b;
279  ss << obj_c;
280  ss << obj_d;
281  return ss.str();
282  }
283 
289  template<typename char_t>
290  static std::basic_string<char_t> concat(const std::basic_string<char_t>& str_a, const std::basic_string<char_t>& str_b, const std::basic_string<char_t>& str_c) noexcept {
291  std::basic_stringstream<char_t> ss;
292  ss << str_a;
293  ss << str_b;
294  ss << str_c;
295  return ss.str();
296  }
297 
303  template<typename char_t, typename ObjectA, typename ObjectB, typename ObjectC>
304  static std::basic_string<char_t> concat(ObjectA obj_a, ObjectB obj_b, ObjectC obj_c) noexcept {
305  std::basic_stringstream<char_t> ss;
306  ss << obj_a;
307  ss << obj_b;
308  ss << obj_c;
309  return ss.str();
310  }
311 
317  template<typename ObjectA, typename ObjectB, typename ObjectC>
318  static std::string concat(ObjectA obj_a, ObjectB obj_b, ObjectC obj_c) noexcept {
319  std::stringstream ss;
320  ss << obj_a;
321  ss << obj_b;
322  ss << obj_c;
323  return ss.str();
324  }
325 
330  template<typename char_t>
331  static std::basic_string<char_t> concat(const std::basic_string<char_t>& str_a, const std::basic_string<char_t>& str_b) noexcept {
332  std::basic_stringstream<char_t> ss;
333  ss << str_a;
334  ss << str_b;
335  return ss.str();
336  }
337 
342  template<typename char_t, typename ObjectA, typename ObjectB>
343  static std::basic_string<char_t> concat(ObjectA obj_a, ObjectB obj_b) noexcept {
344  std::basic_stringstream<char_t> ss;
345  ss << obj_a;
346  ss << obj_b;
347  return ss.str();
348  }
349 
354  template<typename ObjectA, typename ObjectB>
355  static std::string concat(const ObjectA& obj_a, const ObjectB& obj_b) noexcept {
356  std::stringstream ss;
357  ss << obj_a;
358  ss << obj_b;
359  return ss.str();
360  }
361 
365  template<typename char_t>
366  static std::basic_string<char_t> concat(const std::vector<std::basic_string<char_t>>& values) noexcept {
367  std::basic_stringstream<char_t> ss;
368  for (const auto& item : values)
369  ss << item;
370  return ss.str();
371  }
372 
374  template<typename char_t>
375  static std::basic_string<char_t> concat(const std::vector<const char_t*>& values) noexcept {
376  std::basic_stringstream<char_t> ss;
377  for (const auto& item : values)
378  ss << item;
379  return ss.str();
380  }
381 
382  template<typename char_t>
383  static std::basic_string<char_t> concat(const std::initializer_list<std::basic_string<char_t>>& values) noexcept {
384  std::basic_stringstream<char_t> ss;
385  for (const auto& item : values)
386  ss << item;
387  return ss.str();
388  }
389 
390  template<typename char_t>
391  static std::basic_string<char_t> concat(const std::initializer_list<const char_t*>& values) noexcept {
392  std::basic_stringstream<char_t> ss;
393  for (const auto& item : values)
394  ss << item;
395  return ss.str();
396  }
398 
402  template<typename char_t, typename Object>
403  static std::basic_string<char_t> concat(const std::vector<Object>& args) noexcept {
404  std::basic_stringstream<char_t> ss;
405  for (const auto& item : args)
406  ss << item;
407  return ss.str();
408  }
409 
411  template<typename char_t, typename Object>
412  static std::basic_string<char_t> concat(const std::initializer_list<Object>& args) noexcept {
413  std::basic_stringstream<char_t> ss;
414  for (const auto& item : args)
415  ss << item;
416  return ss.str();
417  }
419 
423  template<typename Object>
424  static std::string concat(const std::vector<Object>& args) noexcept {
425  std::stringstream ss;
426  for (const auto& item : args)
427  ss << item;
428  return ss.str();
429  }
430 
432  template<typename Object>
433  static std::string concat(const std::initializer_list<Object>& args) noexcept {
434  std::stringstream ss;
435  for (const auto& item : args)
436  ss << item;
437  return ss.str();
438  }
440 
444  template<typename char_t, typename Value>
445  static std::basic_string<char_t> concat(Value value) noexcept {
446  std::basic_stringstream<char_t> ss;
447  ss << value;
448  return ss.str();
449  }
450 
454  template<typename Value>
455  static std::string concat(Value value) noexcept {
456  std::stringstream ss;
457  ss << value;
458  return ss.str();
459  }
460 
465  template<typename char_t>
466  static bool contains(const std::basic_string<char_t>& str, const std::basic_string<char_t>& value) noexcept {
467  return str.find(value) != str.npos;
468  }
469 
471  template<typename char_t>
472  static bool contains(const std::basic_string<char_t>& str, const char_t* value) noexcept {return contains(str, std::basic_string<char_t>(value));}
473  template<typename char_t>
474  static bool contains(const char_t* str, const std::basic_string<char_t>& value) noexcept {return contains(std::basic_string<char_t>(str), value);}
475  template<typename char_t>
476  static bool contains(const char_t* str, const char_t* value) noexcept {return contains(std::basic_string<char_t>(str), std::basic_string<char_t>(value));}
478 
479  template<typename char_t>
480  static std::basic_string<char_t> date_time_format(const std::basic_string<char_t>& fmt, const std::chrono::system_clock::time_point& date_time) {return date_time_format(fmt.c_str(), date_time);}
481 
482  template<typename char_t>
483  static std::basic_string<char_t> date_time_format(const std::basic_string<char_t>& fmt, time_t date_time) {return date_time_format(fmt.c_str(), date_time);}
484 
485  template<typename char_t>
486  static std::basic_string<char_t> date_time_format(const std::basic_string<char_t>& fmt, const std::tm& date_time) {return date_time_format(fmt.c_str(), date_time);}
487 
489  template<typename char_t>
490  static std::basic_string<char_t> date_time_format(const char_t* fmt, const std::chrono::system_clock::time_point& date_time) {return date_time_format(fmt, std::chrono::system_clock::to_time_t(date_time));}
491 
492  template<typename char_t>
493  static std::basic_string<char_t> date_time_format(const char_t* fmt, time_t date_time) {return date_time_format(fmt, localtime(&date_time));}
494 
495  template<typename char_t>
496  static std::basic_string<char_t> date_time_format(const char_t* fmt, const std::tm& date_time) {return date_time_format(fmt, &date_time);}
497 
498  template<typename char_t>
499  static std::basic_string<char_t> date_time_format(const std::basic_string<char_t>& fmt, const std::tm* date_time) {return date_time_format(fmt.c_str(), date_time);}
500 
501  template<typename char_t>
502  static std::basic_string<char_t> date_time_format(const char_t* fmt, const std::tm* date_time) {
503  std::basic_stringstream<char_t> result;
504  result << std::put_time(date_time, fmt);
505  return result.str();
506  }
508 
511  static std::string demangle(const std::string& name) {
512 #if defined(_WIN32)
513  std::vector<std::string> types = {"enum ", "class ", "union ", "struct "};
514  std::string result = name;
515  for (const std::string& item : types)
516  result = replace(result, item, "");
517  return result;
518 #else
519  class auto_delete_char_pointer {
520  public:
521  auto_delete_char_pointer(char* value) : value_(value) {}
522  ~auto_delete_char_pointer() {free(value_);}
523  char* operator()() const {return this->value_;}
524  private:
525  char* value_;
526  };
527  int32_t status = 0;
528  return auto_delete_char_pointer(abi::__cxa_demangle(name.c_str(), 0, 0, &status))();
529 #endif
530  }
531 
534  template<typename char_t>
535  static std::basic_string<char_t> empty() noexcept {return {};}
536 
539  static std::string empty() noexcept {return {};}
540 
545  template<typename char_t>
546  static bool ends_with(const std::basic_string<char_t>& str, char_t value) noexcept {return str.rfind(value) == str.size() - 1;}
547 
549  template<typename char_t>
550  static bool ends_with(const char_t* str, char_t value) noexcept {return ends_with(std::basic_string<char_t>(str), value);}
552 
557  template<typename char_t>
558  static bool ends_with(const std::basic_string<char_t>& str, const std::basic_string<char_t>& value) noexcept {return ends_with(str, value, false);}
559 
564  template<typename char_t>
565  static bool ends_with(const std::basic_string<char_t>& str, const std::basic_string<char_t>& value, bool ignore_case) noexcept {return ends_with(str, value, ignore_case ? xtd::string_comparison::ordinal_ignore_case : xtd::string_comparison::ordinal);}
566 
571  template<typename char_t>
572  static bool ends_with(const std::basic_string<char_t>& str, const std::basic_string<char_t>& value, xtd::string_comparison comparison_type) noexcept {
573  if (comparison_type == xtd::string_comparison::ordinal_ignore_case)
574  return to_lower(str).rfind(to_lower(value)) + to_lower(value).size() == str.size();
575  return str.rfind(value) + value.size() == str.size();
576  }
577 
579  template<typename char_t>
580  static bool ends_with(const std::basic_string<char_t>& str, const char_t* value) noexcept {return ends_with(str, std::basic_string<char_t>(value), false);}
581  template<typename char_t>
582  static bool ends_with(const char_t* str, const std::basic_string<char_t>& value) noexcept {return ends_with(std::basic_string<char_t>(str), value, false);}
583  template<typename char_t>
584  static bool ends_with(const char_t* str, const char_t* value) noexcept {return ends_with(std::basic_string<char_t>(str), std::basic_string<char_t>(value), false);}
585 
586  template<typename char_t>
587  static bool ends_with(const std::basic_string<char_t>& str, const char_t* value, bool ignore_case) noexcept {return ends_with(str, std::basic_string<char_t>(value), ignore_case);}
588  template<typename char_t>
589  static bool ends_with(const char_t* str, const std::basic_string<char_t>& value, bool ignore_case) noexcept {return ends_with(std::basic_string<char_t>(str), value, ignore_case);}
590  template<typename char_t>
591  static bool ends_with(const char_t* str, const char_t* value, bool ignore_case) noexcept {return ends_with(std::basic_string<char_t>(str), std::basic_string<char_t>(value), ignore_case);}
592 
593  template<typename char_t>
594  static bool ends_with(const std::basic_string<char_t>& str, const char_t* value, xtd::string_comparison comparison_type) noexcept {return ends_with(str, std::basic_string<char_t>(value), comparison_type);}
595  template<typename char_t>
596  static bool ends_with(const char_t* str, const std::basic_string<char_t>& value, xtd::string_comparison comparison_type) noexcept {return ends_with(std::basic_string<char_t>(str), value, comparison_type);}
597  template<typename char_t>
598  static bool ends_with(const char_t* str, const char_t* value, xtd::string_comparison comparison_type) noexcept {return ends_with(std::basic_string<char_t>(str), std::basic_string<char_t>(value), comparison_type);}
600 
606  template<typename char_t, typename ...args_t>
607  static std::basic_string<char_t> format(const std::basic_string<char_t>& fmt, args_t&&... args) {
608  std::basic_string<char_t> result;
609  size_t index = 0;
610  std::vector<__format_information<char_t>> formats;
611  typename std::basic_string<char_t>::const_iterator begin_format_iterator = fmt.cend();
612  typename std::basic_string<char_t>::const_iterator end_format_iterator = fmt.cend();
613  for (typename std::basic_string<char_t>::const_iterator iterator = fmt.cbegin(); iterator != fmt.cend(); ++iterator) {
614  if (*iterator == char_t('{')) {
615  ++iterator;
616  if (*iterator == char_t('{'))
617  result += *iterator;
618  else {
619  begin_format_iterator = iterator;
620  while (*iterator != char_t('}') && iterator != fmt.end()) ++iterator;
621  if (iterator == fmt.end())
622  throw std::invalid_argument("Invalid format expression : open bracket '}' without end bracket '{'");
623  end_format_iterator = iterator;
624  __format_information<char_t> fi;
625  fi.location = result.size();
626  std::basic_string<char_t> format {begin_format_iterator, end_format_iterator};
627  if (format.size() == 0)
628  fi.index = index++;
629  else {
630  size_t index_alignment_separator = index_of(format, char_t(','));
631  size_t index_format_separator = index_of(format, char_t(':'));
632 
633  if (index_alignment_separator != std::basic_string<char_t>::npos && index_format_separator != std::basic_string<char_t>::npos && index_alignment_separator > index_format_separator)
634  index_alignment_separator = std::basic_string<char_t>::npos;
635 
636  if (index_alignment_separator != std::basic_string<char_t>::npos)
637  fi.alignment = format.substr(index_alignment_separator + 1, index_format_separator != std::basic_string<char_t>::npos ? index_format_separator - index_alignment_separator - 1 : std::basic_string<char_t>::npos);
638 
639  if (index_format_separator != std::basic_string<char_t>::npos)
640  fi.format = format.substr(index_format_separator + 1);
641 
642  if (index_alignment_separator == 0 || index_format_separator == 0)
643  fi.index = index++;
644  else {
645  std::basic_string<char_t> index_str;
646  if (index_alignment_separator != std::basic_string<char_t>::npos)
647  index_str = format.substr(0, index_alignment_separator);
648  else if (index_format_separator != std::basic_string<char_t>::npos)
649  index_str = format.substr(0, index_format_separator);
650  else
651  index_str = format;
652  try {
653  for (auto c : index_str)
654  if (!std::isdigit(c)) throw std::invalid_argument("Invalid format expression : format argument must be start by ':'");
655  fi.index = std::stoi(index_str);
656  } catch(...) {
657  throw std::invalid_argument("Invalid format expression : format argument must be start by ':'");
658  }
659  }
660  }
661  formats.push_back(fi);
662  }
663  } else if (*iterator == char_t('}')) {
664  if (++iterator == fmt.cend())
665  throw std::invalid_argument("Invalid format expression : closing bracket '{' without open bracket '}'");
666  if (*iterator != char_t('}'))
667  throw std::invalid_argument("Invalid format expression : closing bracket '{' without open bracket '}'");
668  result += *iterator;
669  } else
670  result += *iterator;
671  }
672 
673  __extract_format_arg(result, formats, std::forward<args_t>(args)...);
674  return result;
675  }
676 
678  template<typename char_t, typename ...args_t>
679  static std::basic_string<char_t> format(const char_t* fmt, args_t&&... args) {return format(std::basic_string<char_t>(fmt), std::forward<args_t>(args)...);}
681 
740  template<typename char_t, typename ... args_t>
741  static std::basic_string<char_t> formatf(const std::basic_string<char_t>& fmt, args_t&& ... args) noexcept {return __formatf(fmt.c_str(), convert_param(std::forward<args_t>(args)) ...);}
742 
744  template<typename char_t, typename ... args_t>
745  static std::basic_string<char_t> formatf(const char_t* fmt, args_t&& ... args) noexcept {return formatf(std::basic_string<char_t>(fmt), std::forward<args_t>(args) ...);}
747 
750  template<typename char_t>
751  static size_t get_hash_code(const std::basic_string<char_t>& str) noexcept {return std::hash<std::basic_string<char_t>>()(str);}
752 
754  template<typename char_t>
755  static size_t get_hash_code(const char_t* str) noexcept {return std::hash<std::basic_string<char_t>>{}(std::basic_string<char_t>(str));}
757 
762  template<typename char_t>
763  static size_t index_of(const std::basic_string<char_t>& str, char_t value) noexcept {return index_of(str, value, 0, str.size());}
764 
769  template<typename char_t>
770  static size_t index_of(const std::basic_string<char_t>& str, const std::basic_string<char_t>& value) noexcept {return index_of(str, value, 0, str.size());}
771 
773  template<typename char_t>
774  static size_t index_of(const char_t* str, char_t value) noexcept {return index_of(std::basic_string<char_t>(str), value);}
775  template<typename char_t>
776  static size_t index_of(const std::basic_string<char_t>& str, const char_t* value) noexcept {return index_of(str, std::basic_string<char_t>(value));}
777  template<typename char_t>
778  static size_t index_of(const char_t* str, const std::basic_string<char_t>& value) noexcept {return index_of(std::basic_string<char_t>(str), value);}
779  template<typename char_t>
780  static size_t index_of(const char_t* str, const char_t* value) noexcept {return index_of(std::basic_string<char_t>(str), std::basic_string<char_t>(value));}
782 
788  template<typename char_t>
789  static size_t index_of(const std::basic_string<char_t>& str, char_t value, size_t start_index) noexcept {return index_of(str, value, start_index, str.size() - start_index);}
790 
796  template<typename char_t>
797  static size_t index_of(const std::basic_string<char_t>& str, const std::basic_string<char_t>& value, size_t start_index) noexcept {return index_of(str, value, start_index, str.size() - start_index);}
798 
800  template<typename char_t>
801  static size_t index_of(const char_t* str, char_t value, size_t start_index) noexcept {return index_of(std::basic_string<char_t>(str), value, start_index);}
802  template<typename char_t>
803  static size_t index_of(const std::basic_string<char_t>& str, const char_t* value, size_t start_index) noexcept {return index_of(str, std::basic_string<char_t>(value), start_index);}
804  template<typename char_t>
805  static size_t index_of(const char_t* str, const std::basic_string<char_t>& value, size_t start_index) noexcept {return index_of(std::basic_string<char_t>(str), value, start_index);}
806  template<typename char_t>
807  static size_t index_of(const char_t* str, const char_t* value, size_t start_index) noexcept {return index_of(std::basic_string<char_t>(str), std::basic_string<char_t>(value), start_index);}
809 
816  template<typename char_t>
817  static size_t index_of(const std::basic_string<char_t>& str, char_t value, size_t start_index, size_t count) noexcept {
818  size_t result = str.find(value, start_index);
819  return result > start_index + count ? std::basic_string<char_t>::npos : result;
820  }
821 
828  template<typename char_t>
829  static size_t index_of(const std::basic_string<char_t>& str, const std::basic_string<char_t>& value, size_t start_index, size_t count) noexcept {
830  size_t result = str.find(value, start_index);
831  return result > start_index + count ? std::basic_string<char_t>::npos : result;
832  }
833 
835  template<typename char_t>
836  static size_t index_of(const char_t* str, char_t value, size_t start_index, size_t count) noexcept {return index_of(std::basic_string<char_t>(str), value, start_index, count);}
837  template<typename char_t>
838  static size_t index_of(const std::basic_string<char_t>& str, const char_t* value, size_t start_index, size_t count) noexcept {return index_of(str, std::basic_string<char_t>(value), start_index, count);}
839  template<typename char_t>
840  static size_t index_of(const char_t* str, const std::basic_string<char_t>& value, size_t start_index, size_t count) noexcept {return index_of(std::basic_string<char_t>(str), value, start_index, count);}
841  template<typename char_t>
842  static size_t index_of(const char_t* str, const char_t* value, size_t start_index, size_t count) noexcept {return index_of(std::basic_string<char_t>(str), std::basic_string<char_t>(value), start_index, count);}
844 
849  template<typename char_t>
850  static size_t index_of_any(const std::basic_string<char_t>& str, const std::vector<char_t>& values) noexcept {return index_of_any(str, values, 0, str.size());}
851 
857  template<typename char_t>
858  static size_t index_of_any(const std::basic_string<char_t>& str, const std::vector<char_t>& values, size_t start_index) noexcept {return index_of_any(str, values, start_index, str.size() - start_index);}
859 
866  template<typename char_t>
867  static size_t index_of_any(const std::basic_string<char_t>& str, const std::vector<char_t>& values, size_t start_index, size_t count) noexcept {
868  size_t index = 0;
869  for (const auto& item : str) {
870  if (index++ < start_index) continue;
871  if (index - 1 > start_index + count) break;
872  if (std::find(values.begin(), values.end(), item) != values.end()) return index - 1;
873  }
874  return std::basic_string<char_t>::npos;
875  }
876 
878  template<typename char_t>
879  static size_t index_of_any(const std::basic_string<char_t>& str, const std::initializer_list<char_t>& values) noexcept {return index_of_any(str, std::vector<char_t>(values));}
880 
881  template<typename char_t>
882  static size_t index_of_any(const std::basic_string<char_t>& str, const std::initializer_list<char_t>& values, size_t start_index) noexcept {return index_of_any(str, std::vector<char_t>(values), start_index);}
883 
884  template<typename char_t>
885  static size_t index_of_any(const std::basic_string<char_t>& str, const std::initializer_list<char_t>& values, size_t start_index, size_t count) noexcept {return index_of_any(str, std::vector<char_t>(values), start_index, count);}
886 
887  template<typename char_t>
888  static size_t index_of_any(const char_t* str, const std::vector<char_t>& values) noexcept {return index_of_any(std::basic_string<char_t>(str), values);}
889 
890  template<typename char_t>
891  static size_t index_of_any(const char_t* str, const std::vector<char_t>& values, size_t start_index) noexcept {return index_of_any(std::basic_string<char_t>(str), values, start_index);}
892 
893  template<typename char_t>
894  static size_t index_of_any(const char_t* str, const std::vector<char_t>& values, size_t start_index, size_t count) noexcept {return index_of_any(std::basic_string<char_t>(str), std::vector<char_t>(values), start_index, count);}
895 
896  template<typename char_t>
897  static size_t index_of_any(const char_t* str, const std::initializer_list<char_t>& values) noexcept {return index_of_any(std::basic_string<char_t>(str), std::vector<char_t>(values));}
898 
899  template<typename char_t>
900  static size_t index_of_any(const char_t* str, const std::initializer_list<char_t>& values, size_t start_index) noexcept {return index_of_any(std::basic_string<char_t>(str), std::vector<char_t>(values), start_index);}
901 
902  template<typename char_t>
903  static size_t index_of_any(const char_t* str, const std::initializer_list<char_t>& values, size_t start_index, size_t count) noexcept {return index_of_any(std::basic_string<char_t>(str), std::vector<char_t>(values), start_index, count);}
905 
912  template<typename char_t>
913  static std::basic_string<char_t> insert(const std::basic_string<char_t>& str, size_t start_index, const std::basic_string<char_t>& value) noexcept {
914  std::basic_string<char_t> result(str);
915  result.insert(start_index, value);
916  return result;
917  }
918 
920  template<typename char_t>
921  static std::basic_string<char_t> insert(const char_t* str, size_t start_index, const std::basic_string<char_t>& value) noexcept {return insert(std::basic_string<char_t>(str), start_index, value);}
922  template<typename char_t>
923  static std::basic_string<char_t> insert(const std::basic_string<char_t>& str, size_t start_index, char_t* value) noexcept {return insert(str, start_index, std::basic_string<char_t>(value));}
924  template<typename char_t>
925  static std::basic_string<char_t> insert(const char_t* str, size_t start_index, const char_t* value) noexcept {return insert(std::basic_string<char_t>(str), start_index, std::basic_string<char_t>(value));}
927 
931  template<typename char_t>
932  static bool is_empty(const std::basic_string<char_t>& str) {return str.empty();}
933 
940  template<typename char_t, typename Collection>
941  static std::basic_string<char_t> join(const std::basic_string<char_t>& separator, const Collection& values) noexcept {return join(separator, values, 0, values.size());}
942 
950  template<typename char_t, typename Collection>
951  static std::basic_string<char_t> join(const std::basic_string<char_t>& separator, const Collection& values, size_t index) noexcept {return join(separator, values, index, values.size()-index);}
952 
961  template<typename char_t, typename Collection>
962  static std::basic_string<char_t> join(const std::basic_string<char_t>& separator, const Collection& values, size_t index, size_t count) noexcept {
963  size_t i = 0;
964  std::basic_stringstream<char_t> ss;
965  for (const auto& item : values) {
966  if (i >= index) {
967  if (i != index) ss << separator;
968  ss << item;
969  }
970  if (++i >= index + count) break;
971  }
972  return ss.str();
973  }
974 
976  template<typename char_t, typename Collection>
977  static std::basic_string<char_t> join(const char_t* separator, const Collection& values) noexcept {return join(std::basic_string<char_t>(separator), values);}
978  template<typename char_t, typename Collection>
979  static std::basic_string<char_t> join(const char_t* separator, const Collection& values, size_t index) noexcept {return join(std::basic_string<char_t>(separator), values, index);}
980  template<typename char_t, typename Collection>
981  static std::basic_string<char_t> join(const char_t* separator, const Collection& values, size_t index, size_t count) noexcept {return join(std::basic_string<char_t>(separator), values, index, count);}
982  template<typename char_t, typename Value>
983  static std::basic_string<char_t> join(const char_t* separator, const std::initializer_list<Value>& values) noexcept {return join(std::basic_string<char_t>(separator), values);}
984  template<typename char_t, typename Value>
985  static std::basic_string<char_t> join(const char_t* separator, const std::initializer_list<Value>& values, size_t index) noexcept {return join(std::basic_string<char_t>(separator), values, index);}
986  template<typename char_t, typename Value>
987  static std::basic_string<char_t> join(const char_t* separator, const std::initializer_list<Value>& values, size_t index, size_t count) noexcept {return join(std::basic_string<char_t>(separator), values, index, count);}
989 
994  template<typename char_t>
995  static size_t last_index_of(const std::basic_string<char_t>& str, char_t value) noexcept {return last_index_of(str, value, 0, str.size());}
996 
1001  template<typename char_t>
1002  static size_t last_index_of(const std::basic_string<char_t>& str, const std::basic_string<char_t>& value) noexcept {return last_index_of(str, value, 0, str.size());}
1003 
1005  template<typename char_t>
1006  static size_t last_index_of(const char_t* str, char_t value) noexcept {return last_index_of(std::basic_string<char_t>(str), value);}
1007  template<typename char_t>
1008  static size_t last_index_of(const std::basic_string<char_t>& str, const char_t* value) noexcept {return last_index_of(str, std::basic_string<char_t>(value));}
1009  template<typename char_t>
1010  static size_t last_index_of(const char_t* str, const std::basic_string<char_t>& value) noexcept {return last_index_of(std::basic_string<char_t>(str), value);}
1011  template<typename char_t>
1012  static size_t last_index_of(const char_t* str, const char_t* value) noexcept {return last_index_of(std::basic_string<char_t>(str), std::basic_string<char_t>(value));}
1014 
1020  template<typename char_t>
1021  static size_t last_index_of(const std::basic_string<char_t>& str, char_t value, size_t start_index) noexcept {return last_index_of(str, value, start_index, str.size() - start_index);}
1022 
1028  template<typename char_t>
1029  static size_t last_index_of(const std::basic_string<char_t>& str, const std::basic_string<char_t>& value, size_t start_index) noexcept {return last_index_of(str, value, start_index, str.size() - start_index);}
1030 
1032  template<typename char_t>
1033  static size_t last_index_of(const char_t* str, char_t value, size_t start_index) noexcept {return last_index_of(std::basic_string<char_t>(str), value, start_index);}
1034  template<typename char_t>
1035  static size_t last_index_of(const std::basic_string<char_t>& str, const char_t* value, size_t start_index) noexcept {return last_index_of(str, std::basic_string<char_t>(value), start_index);}
1036  template<typename char_t>
1037  static size_t last_index_of(const char_t* str, const std::basic_string<char_t>& value, size_t start_index) noexcept {return last_index_of(std::basic_string<char_t>(str), value, start_index);}
1038  template<typename char_t>
1039  static size_t last_index_of(const char_t* str, const char_t* value, size_t start_index) noexcept {return last_index_of(std::basic_string<char_t>(str), std::basic_string<char_t>(value), start_index);}
1041 
1048  template<typename char_t>
1049  static size_t last_index_of(const std::basic_string<char_t>& str, char_t value, size_t start_index, size_t count) noexcept {
1050  size_t result = str.rfind(value, start_index + count - 1);
1051  return result < start_index ? std::basic_string<char_t>::npos : result;
1052  }
1053 
1060  template<typename char_t>
1061  static size_t last_index_of(const std::basic_string<char_t>& str, const std::basic_string<char_t>& value, size_t start_index, size_t count) noexcept {
1062  size_t result = str.rfind(value, start_index + count - value.size());
1063  return result < start_index ? std::basic_string<char_t>::npos : result;
1064  }
1065 
1067  template<typename char_t>
1068  static size_t last_index_of(const char_t* str, char_t value, size_t start_index, size_t count) noexcept {return last_index_of(std::basic_string<char_t>(str), value, start_index, count);}
1069  template<typename char_t>
1070  static size_t last_index_of(const std::basic_string<char_t>& str, const char_t* value, size_t start_index, size_t count) noexcept {return last_index_of(str, std::basic_string<char_t>(value), start_index, count);}
1071  template<typename char_t>
1072  static size_t last_index_of(const char_t* str, const std::basic_string<char_t>& value, size_t start_index, size_t count) noexcept {return last_index_of(std::basic_string<char_t>(str), value, start_index, count);}
1073  template<typename char_t>
1074  static size_t last_index_of(const char_t* str, const char_t* value, size_t start_index, size_t count) noexcept {return last_index_of(std::basic_string<char_t>(str), std::basic_string<char_t>(value), start_index, count);}
1076 
1081  template<typename char_t>
1082  static size_t last_index_of_any(const std::basic_string<char_t>& str, const std::vector<char_t>& values) noexcept {return last_index_of_any(str, values, 0, str.size());}
1083 
1089  template<typename char_t>
1090  static size_t last_index_of_any(const std::basic_string<char_t>& str, const std::vector<char_t>& values, size_t start_index) noexcept {return last_index_of_any(str, values, start_index, str.size() - start_index);}
1091 
1098  template<typename char_t>
1099  static size_t last_index_of_any(const std::basic_string<char_t>& str, const std::vector<char_t>& values, size_t start_index, size_t count) noexcept {
1100  size_t index = str.size() - 1;
1101  for (typename std::basic_string<char_t>::const_reverse_iterator it = str.crbegin(); it != str.crend(); ++it) {
1102  if (index-- > start_index + count) continue;
1103  if (index + 1 < start_index) break;
1104  if (std::find(values.begin(), values.end(), *it) != values.end()) return index + 1;
1105  }
1106  return std::basic_string<char_t>::npos;
1107  }
1108 
1110  template<typename char_t>
1111  static size_t last_index_of_any(const std::basic_string<char_t>& str, const std::initializer_list<char_t>& values) noexcept {return last_index_of_any(str, std::vector<char_t>(values));}
1112 
1113  template<typename char_t>
1114  static size_t last_index_of_any(const std::basic_string<char_t>& str, const std::initializer_list<char_t>& values, size_t start_index) noexcept {return last_index_of_any(str, std::vector<char_t>(values), start_index);}
1115 
1116  template<typename char_t>
1117  static size_t last_index_of_any(const std::basic_string<char_t>& str, const std::initializer_list<char_t>& values, size_t start_index, size_t count) noexcept {return last_index_of_any(str, std::vector<char_t>(values), start_index, count);}
1118 
1119  template<typename char_t>
1120  static size_t last_index_of_any(const char_t* str, const std::vector<char_t>& values) noexcept {return last_index_of_any(std::basic_string<char_t>(str), values);}
1121 
1122  template<typename char_t>
1123  static size_t last_index_of_any(const char_t* str, const std::vector<char_t>& values, size_t start_index) noexcept {return last_index_of_any(std::basic_string<char_t>(str), values, start_index);}
1124 
1125  template<typename char_t>
1126  static size_t last_index_of_any(const char_t* str, const std::vector<char_t>& values, size_t start_index, size_t count) noexcept {return last_index_of_any(std::basic_string<char_t>(str), std::vector<char_t>(values), start_index, count);}
1127 
1128  template<typename char_t>
1129  static size_t last_index_of_any(const char_t* str, const std::initializer_list<char_t>& values) noexcept {return last_index_of_any(std::basic_string<char_t>(str), std::vector<char_t>(values));}
1130 
1131  template<typename char_t>
1132  static size_t last_index_of_any(const char_t* str, const std::initializer_list<char_t>& values, size_t start_index) noexcept {return last_index_of_any(std::basic_string<char_t>(str), std::vector<char_t>(values), start_index);}
1133 
1134  template<typename char_t>
1135  static size_t last_index_of_any(const char_t* str, const std::initializer_list<char_t>& values, size_t start_index, size_t count) noexcept {return last_index_of_any(std::basic_string<char_t>(str), std::vector<char_t>(values), start_index, count);}
1137 
1144  template<typename char_t>
1145  static std::basic_string<char_t> pad_left(const std::basic_string<char_t>& str, size_t total_width) noexcept {return pad_left(str, total_width, static_cast<char_t>(0x20));}
1146 
1154  template<typename char_t>
1155  static std::basic_string<char_t> pad_left(const std::basic_string<char_t>& str, size_t total_width, char_t padding_char) noexcept {
1156  if (total_width < str.size()) return str;
1157  return std::basic_string<char_t>(total_width - str.size(), padding_char).append(str);
1158  }
1159 
1161  template<typename char_t>
1162  static std::basic_string<char_t> pad_left(const char_t* str, size_t total_width) noexcept {return pad_left(std::basic_string<char_t>(str), total_width, static_cast<char_t>(0x20));}
1163 
1164  template<typename char_t>
1165  static std::basic_string<char_t> pad_left(const char_t* str, size_t total_width, char_t padding_char) noexcept {return pad_left(std::basic_string<char_t>(str), total_width, padding_char);}
1167 
1174  template<typename char_t>
1175  static std::basic_string<char_t> pad_right(const std::basic_string<char_t>& str, size_t total_width) noexcept {return pad_right(str, total_width, static_cast<char_t>(0x20));}
1176 
1184  template<typename char_t>
1185  static std::basic_string<char_t> pad_right(const std::basic_string<char_t>& str, size_t total_width, char_t padding_char) noexcept {
1186  if (total_width < str.size()) return str;
1187  return std::basic_string<char_t>(str).append(total_width - str.size(), padding_char);
1188  }
1189 
1191  template<typename char_t>
1192  static std::basic_string<char_t> pad_right(const char_t* str, size_t total_width) noexcept {return pad_right(std::basic_string<char_t>(str), total_width, static_cast<char_t>(0x20));}
1193 
1194  template<typename char_t>
1195  static std::basic_string<char_t> pad_right(const char_t* str, size_t total_width, char_t padding_char) noexcept {return pad_right(std::basic_string<char_t>(str), total_width, padding_char);}
1197 
1198  template<typename Value>
1199  static Value parse(const std::string& str) {
1200  return xtd::parse<Value>(str);
1201  }
1202 
1206  template<typename char_t>
1207  static std::basic_string<char_t> remove(const std::basic_string<char_t>& str, size_t start_index) noexcept {return remove(str, start_index, str.size() - start_index);}
1208 
1213  template<typename char_t>
1214  static std::basic_string<char_t> remove(const std::basic_string<char_t>& str, size_t start_index, size_t count) noexcept {
1215  if (start_index > str.size()) return str;
1216  std::basic_string<char_t> result(str);
1217  return result.erase(start_index, count);}
1218 
1220  template<typename char_t>
1221  static std::basic_string<char_t> remove(const char_t* str, size_t start_index) noexcept {return remove(std::basic_string<char_t>(str), start_index);}
1222  template<typename char_t>
1223  static std::basic_string<char_t> remove(const char_t* str, size_t start_index, size_t count) noexcept {return remove(std::basic_string<char_t>(str), start_index, count);}
1225 
1231  template<typename char_t>
1232  static std::basic_string<char_t> replace(const std::basic_string<char_t>& str, char_t old_char, char_t new_char) noexcept {return replace(str, std::basic_string<char_t>(1, old_char), std::basic_string<char_t>(1, new_char));}
1233 
1240  template<typename char_t>
1241  static std::basic_string<char_t> replace(const std::basic_string<char_t>& str, const std::basic_string<char_t>& old_string, const std::basic_string<char_t>& new_string) noexcept {
1242  std::basic_string<char_t> result(str);
1243  size_t index = 0;
1244  while (true) {
1245  index = result.find(old_string, index);
1246  if (index == std::string::npos) break;
1247  result.erase(index, old_string.size());
1248  result.insert(index, new_string);
1249  index += new_string.size();
1250  }
1251  return result;
1252  }
1253 
1255  template<typename char_t>
1256  static std::basic_string<char_t> replace(const char_t* str, char_t old_char, char_t new_char) noexcept {return replace(std::basic_string<char_t>(str), old_char, new_char);}
1257  template<typename char_t>
1258  static std::basic_string<char_t> replace(const char_t* str, const char_t* old_string, const char_t* new_string) noexcept {return replace(std::basic_string<char_t>(str), std::basic_string<char_t>(old_string), std::basic_string<char_t>(new_string));}
1259  template<typename char_t>
1260  static std::basic_string<char_t> replace(const std::basic_string<char_t>& str, const char_t* old_string, const char_t* new_string) noexcept {return replace(str, std::basic_string<char_t>(old_string), std::basic_string<char_t>(new_string));}
1261  template<typename char_t>
1262  static std::basic_string<char_t> replace(const char_t* str, std::basic_string<char_t>& old_string, const char_t* new_string) noexcept {return replace(std::basic_string<char_t>(str), old_string, std::basic_string<char_t>(new_string));}
1263  template<typename char_t>
1264  static std::basic_string<char_t> replace(const char_t* str, const char_t* old_string, const std::basic_string<char_t>& new_string) noexcept {return replace(std::basic_string<char_t>(str), std::basic_string<char_t>(old_string), new_string);}
1265  template<typename char_t>
1266  static std::basic_string<char_t> replace(const std::basic_string<char_t>& str, const std::basic_string<char_t>& old_string, const char_t* new_string) noexcept {return replace(str, old_string, std::basic_string<char_t>(new_string));}
1267  template<typename char_t>
1268  static std::basic_string<char_t> replace(const std::basic_string<char_t>& str, const char_t* old_string, const std::basic_string<char_t>& new_string) noexcept {return replace(str, std::basic_string<char_t>(old_string), new_string);}
1269  template<typename char_t>
1270  static std::basic_string<char_t> replace(const char_t* str, const std::basic_string<char_t>& old_string, const std::basic_string<char_t>& new_string) noexcept {return replace(std::basic_string<char_t>(str), old_string, new_string);}
1272 
1285  template<typename char_t>
1286  static std::vector<std::basic_string<char_t>> split(const std::basic_string<char_t>& str, const std::vector<char_t>& separators, size_t count, string_split_options options) noexcept {
1287  if (count == 0) return {};
1288  if (count == 1) return {str};
1289 
1290  std::vector<std::basic_string<char_t>> list;
1291  std::basic_string<char_t> subString;
1292  std::vector<char_t> split_char_separators = separators.size() == 0 ? std::vector<char_t> {9, 10, 11, 12, 13, 32} : separators;
1293  for (std::string::const_iterator it = str.begin(); it != str.end(); it++) {
1294  bool is_separator = std::find(split_char_separators.begin(), split_char_separators.end(), *it) != split_char_separators.end();
1295  if (!is_separator) subString.append(std::string(1, *it));
1296  if ((it - str.begin() == str.length() - 1 || is_separator) && (subString.length() > 0 || (subString.length() == 0 && options != string_split_options::remove_empty_entries))) {
1297  if (list.size() == count - 1) {
1298  list.push_back(subString + std::string(str.c_str(), it - str.begin() + (is_separator ? 0 : 1), str.length() - (it - str.begin()) + (is_separator ? 0 : 1)));
1299  return list;
1300  }
1301  list.push_back(subString);
1302  subString.clear();
1303  }
1304  }
1305 
1306  return list;
1307  }
1308 
1314  template<typename char_t>
1315  static std::vector<std::basic_string<char_t>> split(const std::basic_string<char_t>& str) noexcept {return split(str, std::vector<char_t> {9, 10, 11, 12, 13, 32}, std::numeric_limits<size_t>::max(), string_split_options::none);}
1316 
1323  template<typename char_t>
1324  static std::vector<std::basic_string<char_t>> split(const std::basic_string<char_t>& str, const std::vector<char_t>& separators) noexcept {return split(str, separators, std::numeric_limits<size_t>::max(), string_split_options::none);}
1325 
1343  template<typename char_t>
1344  static std::vector<std::basic_string<char_t>> split(const std::basic_string<char_t>& str, const std::vector<char_t>& separators, string_split_options options) noexcept {return split(str, separators, std::numeric_limits<size_t>::max(), options);}
1345 
1355  template<typename char_t>
1356  static std::vector<std::basic_string<char_t>> split(const std::basic_string<char_t>& str, const std::vector<char_t>& separators, size_t count) noexcept {return split(str, separators, count, string_split_options::none);}
1357 
1359  template<typename char_t>
1360  static std::vector<std::basic_string<char_t>> split(const char_t* str, const std::vector<char_t>& separators, size_t count, string_split_options options) noexcept {return split(std::basic_string<char_t>(str), separators, count, options);}
1361  template<typename char_t>
1362  static std::vector<std::basic_string<char_t>> split(const char_t* str) noexcept {return split(str, std::vector<char_t> {9, 10, 11, 12, 13, 32}, std::numeric_limits<size_t>::max(), string_split_options::none);}
1363  template<typename char_t>
1364  static std::vector<std::basic_string<char_t>> split(const char_t* str, const std::vector<char_t>& separators) noexcept {return split(str, separators, std::numeric_limits<size_t>::max(), string_split_options::none);}
1365  template<typename char_t>
1366  static std::vector<std::basic_string<char_t>> split(const char_t* str, const std::vector<char_t>& separators, string_split_options options) noexcept {return split(str, separators, std::numeric_limits<size_t>::max(), options);}
1367  template<typename char_t>
1368  static std::vector<std::basic_string<char_t>> split(const char_t* str, const std::vector<char_t>& separators, size_t count) noexcept {return split(str, separators, count, string_split_options::none);}
1370 
1376  template<typename char_t>
1377  static bool starts_with(const std::basic_string<char_t>& str, char_t value) noexcept {return starts_with(str, value, false);}
1378 
1385  template<typename char_t>
1386  static bool starts_with(const std::basic_string<char_t>& str, char_t value, bool ignore_case) noexcept {
1387  if (ignore_case)
1388  return to_lower(str).find(tolower(value)) == 0;
1389  return str.find(value) == 0;
1390  }
1391 
1397  template<typename char_t>
1398  static bool starts_with(const std::basic_string<char_t>& str, const std::basic_string<char_t>& value) noexcept {return starts_with(str, value, false);}
1399 
1406  template<typename char_t>
1407  static bool starts_with(const std::basic_string<char_t>& str, const std::basic_string<char_t>& value, bool ignore_case) noexcept {
1408  if (ignore_case)
1409  return to_lower(str).find(to_lower(value)) == 0;
1410  return str.find(value) == 0;
1411  }
1412 
1414  template<typename char_t>
1415  static bool starts_with(const char_t* str, char_t value) noexcept {return starts_with(std::basic_string<char_t>(str), value, false);}
1416  template<typename char_t>
1417  static bool starts_with(const char_t* str, char_t value, bool ignore_case) noexcept {return starts_with(std::basic_string<char_t>(str), value, ignore_case);}
1418  template<typename char_t>
1419  static bool starts_with(const std::basic_string<char_t>& str, const char_t* value) noexcept {return starts_with(str, std::basic_string<char_t>(value), false);}
1420  template<typename char_t>
1421  static bool starts_with(const char_t* str, const std::basic_string<char_t>& value) noexcept {return starts_with(std::basic_string<char_t>(str), value, false);}
1422  template<typename char_t>
1423  static bool starts_with(const char_t* str, const char_t* value) noexcept {return starts_with(std::basic_string<char_t>(str), std::basic_string<char_t>(value), false);}
1424 
1425  template<typename char_t>
1426  static bool starts_with(const std::basic_string<char_t>& str, const char_t* value, bool ignore_case) noexcept {return starts_with(str, std::basic_string<char_t>(value), ignore_case);}
1427  template<typename char_t>
1428  static bool starts_with(const char_t* str, const std::basic_string<char_t>& value, bool ignore_case) noexcept {return starts_with(std::basic_string<char_t>(str), value, ignore_case);}
1429  template<typename char_t>
1430  static bool starts_with(const char_t* str, const char_t* value, bool ignore_case) noexcept {return starts_with(std::basic_string<char_t>(str), std::basic_string<char_t>(value), ignore_case);}
1432 
1437  template<typename char_t>
1438  static std::basic_string<char_t> substring(const std::basic_string<char_t>& str, size_t start_index) noexcept {
1439  if (start_index >= str.size()) return "";
1440  return str.substr(start_index);
1441  }
1442 
1448  template<typename char_t>
1449  static std::basic_string<char_t> substring(const std::basic_string<char_t>& str, size_t start_index, size_t length) noexcept {
1450  if (start_index >= str.size()) return "";
1451  return str.substr(start_index, length);
1452  }
1453 
1455  template<typename char_t>
1456  static std::basic_string<char_t> substring(const char_t* str, size_t start_index) noexcept {return substring(std::basic_string<char_t>(str), start_index);}
1457  template<typename char_t>
1458  static std::basic_string<char_t> substring(const char_t* str, size_t start_index, size_t length) noexcept {return substring(std::basic_string<char_t>(str), start_index, length);}
1460 
1464  template<typename char_t>
1465  static const std::vector<char_t> to_array(const std::basic_string<char_t>& str) noexcept {return to_array(str, 0, str.size());}
1466 
1471  template<typename char_t>
1472  static const std::vector<char_t> to_array(const std::basic_string<char_t>& str, size_t start_index) noexcept {return to_array(str, start_index, str.size() - start_index);}
1473 
1479  template<typename char_t>
1480  static const std::vector<char_t> to_array(const std::basic_string<char_t>& str, size_t start_index, size_t length) noexcept {
1481  if (start_index >= str.size()) return {};
1482  if (start_index + length >= str.size()) return {str.begin() + start_index, str.end()};
1483  return {str.begin() + start_index, str.begin() + start_index + length};
1484  }
1485 
1487  template<typename char_t>
1488  static const std::vector<char_t> to_array(const char_t* str) noexcept {return to_array(std::basic_string<char_t>(str));}
1489  template<typename char_t>
1490  static const std::vector<char_t> to_array(const char_t* str, size_t start_index) noexcept {return to_array(std::basic_string<char_t>(str), start_index);}
1491  template<typename char_t>
1492  static const std::vector<char_t> to_array(const char_t* str, size_t start_index, size_t length) noexcept {return to_array(std::basic_string<char_t>(str), start_index, length);}
1494 
1495 
1499  template<typename char_t>
1500  static const std::basic_string<char_t> to_lower(const std::basic_string<char_t>& str) noexcept {
1501  std::basic_string<char_t> result;
1502  for(char c : str) result.push_back(tolower(c));
1503  return result;
1504  }
1505 
1507  static const std::basic_string<char16_t> to_lower(const std::basic_string<char16_t>& str) noexcept {
1508  std::basic_string<char16_t> result;
1509  for(char16_t c : str) result.push_back(c <= 0xFF ? static_cast<char16_t>(tolower(static_cast<char>(c))) : c);
1510  return result;
1511  }
1512 
1513  static const std::basic_string<char32_t> to_lower(const std::basic_string<char32_t>& str) noexcept {
1514  std::basic_string<char32_t> result;
1515  for(char32_t c : str) result.push_back(c <= 0xFF ? static_cast<char32_t>(tolower(static_cast<char>(c))) : c);
1516  return result;
1517  }
1518 
1519  template<typename char_t>
1520  static const std::basic_string<char_t> to_lower(const char_t* str) noexcept {return to_lower(std::basic_string<char_t>(str));}
1522 
1526  template<typename char_t>
1527  static const std::basic_string<char_t> to_upper(const std::basic_string<char_t>& str) noexcept {
1528  std::basic_string<char_t> result;
1529  for(char c : str) result.push_back(toupper(c));
1530  return result;
1531  }
1532 
1534  static const std::basic_string<char16_t> to_upper(const std::basic_string<char16_t>& str) noexcept {
1535  std::basic_string<char16_t> result;
1536  for(char16_t c : str) result.push_back(c <= 0xFF ? static_cast<char16_t>(toupper(static_cast<char>(c))) : c);
1537  return result;
1538  }
1539 
1540  static const std::basic_string<char32_t> to_upper(const std::basic_string<char32_t>& str) noexcept {
1541  std::basic_string<char32_t> result;
1542  for(char32_t c : str) result.push_back(c <= 0xFF ? static_cast<char32_t>(toupper(static_cast<char>(c))) : c);
1543  return result;
1544  }
1545 
1546  template<typename char_t>
1547  static const std::basic_string<char_t> to_upper(const char_t* str) noexcept {return to_upper(std::basic_string<char_t>(str));}
1549 
1554  template<typename char_t>
1555  static std::basic_string<char_t> trim(const std::basic_string<char_t>& str) noexcept {return trim(str, std::vector<char_t> {9, 10, 11, 12, 13, 32});}
1556 
1561  template<typename char_t>
1562  static std::basic_string<char_t> trim(const std::basic_string<char_t>& str, char_t trim_char) noexcept {return trim(str, std::vector<char_t> {trim_char});}
1563 
1568  template<typename char_t>
1569  static std::basic_string<char_t> trim(const std::basic_string<char_t>& str, const std::vector<char_t>& trim_chars) noexcept {return trim_end(trim_start(str, trim_chars), trim_chars);}
1570 
1572  template<typename char_t>
1573  static std::basic_string<char_t> trim(const char_t* str) noexcept {return trim(std::basic_string<char_t>(str), std::vector<char_t> {9, 10, 11, 12, 13, 32});}
1574 
1575  template<typename char_t>
1576  static std::basic_string<char_t> trim(const char_t* str, char_t trim_char) noexcept {return trim(std::basic_string<char_t>(str), std::vector<char_t> {trim_char});}
1577 
1578  template<typename char_t>
1579  static std::basic_string<char_t> trim(const char_t* str, const std::vector<char_t>& trim_chars) noexcept {return trim(std::basic_string<char_t>(str), trim_chars);}
1581 
1586  template<typename char_t>
1587  static std::basic_string<char_t> trim_end(const std::basic_string<char_t>& str) noexcept {return trim_end(str, std::vector<char_t> {9, 10, 11, 12, 13, 32});}
1588 
1593  template<typename char_t>
1594  static std::basic_string<char_t> trim_end(const std::basic_string<char_t>& str, char_t trim_char) noexcept {return trim_end(str, std::vector<char_t> {trim_char});}
1595 
1600  template<typename char_t>
1601  static std::basic_string<char_t> trim_end(const std::basic_string<char_t>& str, const std::vector<char_t>& trim_chars) noexcept {
1602  std::basic_string<char_t> result(str);
1603  while (std::find(trim_chars.begin(), trim_chars.end(), result[result.size() - 1]) != trim_chars.end())
1604  result.erase(result.size() - 1, 1);
1605  return result;
1606  }
1607 
1609  template<typename char_t>
1610  static std::basic_string<char_t> trim_end(const char_t* str) noexcept {return trim_end(std::basic_string<char_t>(str), std::vector<char_t> {9, 10, 11, 12, 13, 32});}
1611 
1612  template<typename char_t>
1613  static std::basic_string<char_t> trim_end(const char_t* str, char_t trim_char) noexcept {return trim_end(std::basic_string<char_t>(str), std::vector<char_t> {trim_char});}
1614 
1615  template<typename char_t>
1616  static std::basic_string<char_t> trim_end(const char_t* str, const std::vector<char_t>& trim_chars) noexcept {return trim_end(std::basic_string<char_t>(str), trim_chars);}
1618 
1623  template<typename char_t>
1624  static std::basic_string<char_t> trim_start(const std::basic_string<char_t>& str) noexcept {return trim_start(str, std::vector<char_t> {9, 10, 11, 12, 13, 32});}
1625 
1630  template<typename char_t>
1631  static std::basic_string<char_t> trim_start(const std::basic_string<char_t>& str, char_t trim_char) noexcept {return trim_start(str, std::vector<char_t> {trim_char});}
1632 
1637  template<typename char_t>
1638  static std::basic_string<char_t> trim_start(const std::basic_string<char_t>& str, const std::vector<char_t>& trim_chars) noexcept {
1639  std::basic_string<char_t> result(str);
1640  while (std::find(trim_chars.begin(), trim_chars.end(), result[0]) != trim_chars.end())
1641  result.erase(0, 1);
1642  return result;
1643  }
1644 
1646  template<typename char_t>
1647  static std::basic_string<char_t> trim_start(const char_t* str) noexcept {return trim_start(std::basic_string<char_t>(str), std::vector<char_t> {9, 10, 11, 12, 13, 32});}
1648 
1649  template<typename char_t>
1650  static std::basic_string<char_t> trim_start(const char_t* str, char_t trim_char) noexcept {return trim_start(std::basic_string<char_t>(str), std::vector<char_t> {trim_char});}
1651 
1652  template<typename char_t>
1653  static std::basic_string<char_t> trim_start(const char_t* str, const std::vector<char_t>& trim_chars) noexcept {return trim_start(std::basic_string<char_t>(str), trim_chars);}
1655 
1656  template<typename Value>
1657  static bool try_parse(const std::string& str, Value& value) {
1658  try {
1659  value = parse<Value>(str);
1660  return true;
1661  } catch(...) {
1662  return false;
1663  }
1664  }
1665 
1666  private:
1667  template<typename arg_t>
1668  static auto convert_param(arg_t&& arg) noexcept {
1669  if constexpr (std::is_same<std::remove_cv_t<std::remove_reference_t<arg_t>>, std::string>::value) return std::forward<arg_t>(arg).c_str();
1670  else if constexpr (std::is_same<std::remove_cv_t<std::remove_reference_t<arg_t>>, xtd::istring>::value) return std::forward<arg_t>(arg).c_str();
1671  else if constexpr (std::is_same<std::remove_cv_t<std::remove_reference_t<arg_t>>, std::wstring>::value) return std::forward<arg_t>(arg).c_str();
1672  else if constexpr (std::is_same<std::remove_cv_t<std::remove_reference_t<arg_t>>, xtd::iwstring>::value) return std::forward<arg_t>(arg).c_str();
1673  else return std::forward<arg_t>(arg);
1674  }
1675 
1676  static std::string get_class_name(const std::string& full_name) {
1677  size_t length = last_index_of(full_name, "<");
1678  if (length == -1) length = full_name.length();
1679  if (last_index_of(full_name, "::", 0, length) == -1) return full_name;
1680  return substring(full_name, last_index_of(full_name, "::", 0, length) + 2);
1681  }
1682  };
1683 }
1684 
1685 #include "parse.h"
1686 #include "to_string.h"
1687 
1688 template<typename char_t, typename arg_t>
1689 void __extract_format_arg(std::basic_string<char_t>& fmt, size_t& index, std::vector<__format_information<char_t>>& formats, arg_t&& arg) {
1690  size_t offset = 0;
1691  for (auto& format : formats) {
1692  format.location += offset;
1693  if (format.index == index) {
1694  std::basic_string<char_t> arg_str = format.format.empty() ? __format_stringer<char_t, arg_t>(arg) : xtd::to_string(arg, format.format);
1695 
1696  if (!format.alignment.empty()) {
1697  int alignment = 0;
1698  try {
1699  alignment = std::stoi(format.alignment);
1700  } catch(...) {
1701  throw std::invalid_argument("Invalid format expression");
1702  }
1703  if (alignment > 0) arg_str = xtd::strings::pad_left(arg_str, alignment);
1704  else if (alignment < 0) arg_str = xtd::strings::pad_right(arg_str, -alignment);
1705  }
1706  fmt.insert(format.location, arg_str);
1707  offset += arg_str.size();
1708  }
1709  }
1710  ++index;
1711 }
1712 
1713 template<typename char_t, typename ...args_t>
1714 void __extract_format_arg(std::basic_string<char_t>& fmt, std::vector<__format_information<char_t>>& formats, args_t&&... args) {
1715  size_t index = 0;
1716  (__extract_format_arg(fmt, index, formats, args),...);
1717 }
1718 
1720 #undef __XTD_STRINGS_INCLUDE__
1721 
static std::vector< std::basic_string< char_t > > split(const std::basic_string< char_t > &str, const std::vector< char_t > &separators, size_t count) noexcept
Splits a specified string into a maximum number of substrings based on the characters in an array...
Definition: strings.h:1356
static std::vector< std::basic_string< char_t > > split(const std::basic_string< char_t > &str, const std::vector< char_t > &separators, string_split_options options) noexcept
Splits a specified string into substrings based on the characters in an array.
Definition: strings.h:1344
Compare strings using ordinal (binary) sort rules and ignoring the case of the strings being compared...
static std::basic_string< char_t > concat(const std::basic_string< char_t > &str_a, const std::basic_string< char_t > &str_b, const std::basic_string< char_t > &str_c) noexcept
Concatenates three specified instances of string.
Definition: strings.h:290
static std::basic_string< char_t > trim(const std::basic_string< char_t > &str) noexcept
Removes all leading and trailing occurrences of white-space characters from the specifed String...
Definition: strings.h:1555
static size_t index_of(const std::basic_string< char_t > &str, char_t value, size_t start_index) noexcept
Reports the index of the first occurrence of the specified character in the spexified string...
Definition: strings.h:789
static std::basic_string< char_t > pad_right(const std::basic_string< char_t > &str, size_t total_width) noexcept
Left-aligns the characters in the specified string, padding with spaces on the right for a specified ...
Definition: strings.h:1175
static std::basic_string< char_t > concat(ObjectA obj_a, ObjectB obj_b, ObjectC obj_c) noexcept
Concatenates three specified instances of object.
Definition: strings.h:304
static size_t index_of(const std::basic_string< char_t > &str, const std::basic_string< char_t > &value, size_t start_index, size_t count) noexcept
Reports the index of the first occurrence of the specified character in the spexified string...
Definition: strings.h:829
static bool ends_with(const std::basic_string< char_t > &str, const std::basic_string< char_t > &value, bool ignore_case) noexcept
Determines whether the end of this string instance matches the specified string when compared using t...
Definition: strings.h:565
static size_t index_of(const std::basic_string< char_t > &str, char_t value) noexcept
Reports the index of the first occurrence of the specified character in the sĂȘcified tring...
Definition: strings.h:763
static bool contains(const std::basic_string< char_t > &str, const std::basic_string< char_t > &value) noexcept
Returns a value indicating whether a specified substring occurs within the specified string...
Definition: strings.h:466
static const std::vector< char_t > to_array(const std::basic_string< char_t > &str, size_t start_index) noexcept
Copies the characters in this instance to a Unicode character array starting at specitied index...
Definition: strings.h:1472
static std::string full_class_name(const object_t &object)
Gets the fully qualified class name of the specified object, including the namespace of the specified...
Definition: strings.h:63
static std::string concat(ObjectA obj_a, ObjectB obj_b, ObjectC obj_c, ObjectD obj_d) noexcept
Concatenates four specified instances of object.
Definition: strings.h:275
static std::string class_name(const object_t &object)
Gets the class name of the specified object.
Definition: strings.h:77
static size_t index_of_any(const std::basic_string< char_t > &str, const std::vector< char_t > &values, size_t start_index, size_t count) noexcept
Reports the index of the first occurrence in this instance of any character in a specified array of c...
Definition: strings.h:867
static std::vector< std::basic_string< char_t > > split(const std::basic_string< char_t > &str, const std::vector< char_t > &separators, size_t count, string_split_options options) noexcept
Splits a specified string into a maximum number of substrings based on the characters in an array...
Definition: strings.h:1286
static size_t last_index_of(const std::basic_string< char_t > &str, char_t value, size_t start_index, size_t count) noexcept
Reports the index of the last occurrence of the specified character in the spexified string...
Definition: strings.h:1049
static std::basic_string< char_t > concat(const std::vector< std::basic_string< char_t >> &values) noexcept
Concatenates the elements of a specified string array.
Definition: strings.h:366
Immutable basic_string<char_t>
Definition: istring.h:11
static bool starts_with(const std::basic_string< char_t > &str, const std::basic_string< char_t > &value) noexcept
Determines whether the beginning of an instance of String matches a specified String.
Definition: strings.h:1398
static size_t get_hash_code(const std::basic_string< char_t > &str) noexcept
Returns the hash code for this string.
Definition: strings.h:751
static int compare(const std::basic_string< char_t > &str_a, const std::basic_string< char_t > &str_b, xtd::string_comparison comparison_type) noexcept
Compares two specified String objects using the specified rules, and returns an integer that indicate...
Definition: strings.h:136
static std::basic_string< char_t > trim(const std::basic_string< char_t > &str, char_t trim_char) noexcept
Removes all eading and trailing occurrences of a character specified from the specifed String ...
Definition: strings.h:1562
static std::string concat(const std::vector< Object > &args) noexcept
Concatenates the string representations of the elements in a specified Object array.
Definition: strings.h:424
static std::basic_string< char_t > replace(const std::basic_string< char_t > &str, char_t old_char, char_t new_char) noexcept
Replaces all occurrences of a specified char_t in the specified string with another specified char_t...
Definition: strings.h:1232
static std::basic_string< char_t > substring(const std::basic_string< char_t > &str, size_t start_index) noexcept
Retrieves a substring from this instance.
Definition: strings.h:1438
static std::basic_string< char_t > empty() noexcept
Represents the empty string.
Definition: strings.h:535
Contains xtd::parse methods.
static bool starts_with(const std::basic_string< char_t > &str, const std::basic_string< char_t > &value, bool ignore_case) noexcept
Determines whether the beginning of an instance of String matches a specified String, ignoring or honoring their case.
Definition: strings.h:1407
static std::basic_string< char_t > concat(Value value) noexcept
Creates the string representation of a specified object.
Definition: strings.h:445
static std::basic_string< char_t > trim_start(const std::basic_string< char_t > &str) noexcept
Removes all leading occurrences of white-space characters from the specifed String.
Definition: strings.h:1624
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: format.h:8
static std::basic_string< char_t > concat(const std::basic_string< char_t > &str_a, const std::basic_string< char_t > &str_b, const std::basic_string< char_t > &str_c, const std::basic_string< char_t > &str_d) noexcept
Concatenates four specified instances of string.
Definition: strings.h:243
static int compare(const std::basic_string< char_t > &str_a, size_t index_a, const std::basic_string< char_t > &str_b, size_t index_b, size_t length) noexcept
Compares substrings of two specified String objects and returns an integer that indicates their relat...
Definition: strings.h:164
static size_t index_of_any(const std::basic_string< char_t > &str, const std::vector< char_t > &values) noexcept
Reports the index of the first occurrence in this instance of any character in a specified array of c...
Definition: strings.h:850
static int compare(const std::basic_string< char_t > &str_a, const std::basic_string< char_t > &str_b, bool ignore_case) noexcept
Compares two specified String objects, ignoring or honoring their case, and returns an integer that i...
Definition: strings.h:114
The strings Caintains string operation methods.
Definition: strings.h:47
static const std::basic_string< char_t > to_upper(const std::basic_string< char_t > &str) noexcept
Returns a copy of the specified string converted to uppercase.
Definition: strings.h:1527
static std::string class_name()
Gets the class name of the object_t.
Definition: strings.h:71
static std::basic_string< char_t > pad_right(const std::basic_string< char_t > &str, size_t total_width, char_t padding_char) noexcept
Left-aligns the characters in the specified string, padding with spaces on the right for a specified ...
Definition: strings.h:1185
static std::basic_string< char_t > pad_left(const std::basic_string< char_t > &str, size_t total_width) noexcept
Right-aligns the characters iin the specified string, padding with spaces on the left for a specified...
Definition: strings.h:1145
static std::basic_string< char_t > format(const std::basic_string< char_t > &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition: strings.h:607
static bool is_empty(const std::basic_string< char_t > &str)
Indicates whether the specified string is an empty string ("").
Definition: strings.h:932
static const std::basic_string< char_t > to_lower(const std::basic_string< char_t > &str) noexcept
Returns a copy of the specified string converted to lowercase.
Definition: strings.h:1500
static size_t index_of(const std::basic_string< char_t > &str, char_t value, size_t start_index, size_t count) noexcept
Reports the index of the first occurrence of the specified character in the spexified string...
Definition: strings.h:817
Contains xtd::to_string methods.
static size_t last_index_of(const std::basic_string< char_t > &str, const std::basic_string< char_t > &value, size_t start_index, size_t count) noexcept
Reports the index of the last occurrence of the specified character in the spexified string...
Definition: strings.h:1061
The return value does not include array elements that contain an empty string.
static std::string empty() noexcept
Represents the empty string.
Definition: strings.h:539
string_split_options
Specifies whether applicable strings::Split method overloads include or omit empty substrings from th...
Definition: string_split_options.h:11
static bool starts_with(const std::basic_string< char_t > &str, char_t value) noexcept
Determines whether the beginning of an instance of String matches a specified String.
Definition: strings.h:1377
static std::basic_string< char_t > join(const std::basic_string< char_t > &separator, const Collection &values, size_t index) noexcept
Concatenates a specified separator String between each element of a specified Object array...
Definition: strings.h:951
static const std::vector< char_t > to_array(const std::basic_string< char_t > &str) noexcept
Copies the characters in this instance to a Unicode character array.
Definition: strings.h:1465
static std::basic_string< char_t > trim_start(const std::basic_string< char_t > &str, const std::vector< char_t > &trim_chars) noexcept
Removes all leading occurrences of a set of characters specified in an array from the specified Strin...
Definition: strings.h:1638
static size_t last_index_of(const std::basic_string< char_t > &str, char_t value, size_t start_index) noexcept
Reports the index of the last occurrence of the specified character in the spexified string...
Definition: strings.h:1021
string_comparison
Specifies the culture, case, and sort rules to be used by certain overloads of the strings::compare(s...
Definition: string_comparison.h:11
static std::basic_string< char_t > concat(ObjectA obj_a, ObjectB obj_b, ObjectC obj_c, ObjectD obj_d) noexcept
Concatenates four specified instances of object.
Definition: strings.h:259
static size_t index_of_any(const std::basic_string< char_t > &str, const std::vector< char_t > &values, size_t start_index) noexcept
Reports the index of the first occurrence in this instance of any character in a specified array of c...
Definition: strings.h:858
static std::basic_string< char_t > join(const std::basic_string< char_t > &separator, const Collection &values) noexcept
Concatenates a specified separator String between each element of a specified Object array...
Definition: strings.h:941
static std::vector< std::basic_string< char_t > > split(const std::basic_string< char_t > &str) noexcept
Splits a specified string into substrings that are based on the default white-space characters...
Definition: strings.h:1315
static bool starts_with(const std::basic_string< char_t > &str, char_t value, bool ignore_case) noexcept
Determines whether the beginning of an instance of String matches a specified String, ignoring or honoring their case.
Definition: strings.h:1386
static std::basic_string< char_t > trim_end(const std::basic_string< char_t > &str, const std::vector< char_t > &trim_chars) noexcept
Removes all trailing occurrences of a set of characters specified in an array from the specified Stri...
Definition: strings.h:1601
static std::basic_string< char_t > pad_left(const std::basic_string< char_t > &str, size_t total_width, char_t padding_char) noexcept
Right-aligns the characters in the specified string, padding with spaces on the left for a specified ...
Definition: strings.h:1155
static size_t last_index_of_any(const std::basic_string< char_t > &str, const std::vector< char_t > &values, size_t start_index) noexcept
Reports the index of the last occurrence in this instance of any character in a specified array of ch...
Definition: strings.h:1090
static std::basic_string< char_t > substring(const std::basic_string< char_t > &str, size_t start_index, size_t length) noexcept
Retrieves a substring from this instance.
Definition: strings.h:1449
static size_t last_index_of(const std::basic_string< char_t > &str, char_t value) noexcept
Reports the index of the last occurrence of the specified character in the sĂȘcified tring...
Definition: strings.h:995
Contains xtd::immutable_basic_string class.
static std::basic_string< char_t > trim_end(const std::basic_string< char_t > &str, char_t trim_char) noexcept
Removes all trailing occurrences of a character specified from the specifed String ...
Definition: strings.h:1594
static bool ends_with(const std::basic_string< char_t > &str, const std::basic_string< char_t > &value) noexcept
Determines whether the end of the specified string matches the specified string.
Definition: strings.h:558
static std::vector< std::basic_string< char_t > > split(const std::basic_string< char_t > &str, const std::vector< char_t > &separators) noexcept
Splits a specified string into substrings that are based on the characters in an array.
Definition: strings.h:1324
static int compare(const std::basic_string< char_t > &str_a, size_t index_a, const std::basic_string< char_t > &str_b, size_t index_b, size_t length, bool ignore_case) noexcept
Compares substrings of two specified String objects, ignoring or honoring their case, and returns an integer that indicates their relative position in the sort order.
Definition: strings.h:190
static std::string demangle(const std::string &name)
Gets demangled string of name,.
Definition: strings.h:511
static std::string concat(const ObjectA &obj_a, const ObjectB &obj_b) noexcept
Concatenates two specified instances of object.
Definition: strings.h:355
static std::basic_string< char_t > concat(const std::vector< Object > &args) noexcept
Concatenates the string representations of the elements in a specified Object array.
Definition: strings.h:403
static std::basic_string< char_t > formatf(const std::basic_string< char_t > &fmt, args_t &&... args) noexcept
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition: strings.h:741
static std::basic_string< char_t > join(const std::basic_string< char_t > &separator, const Collection &values, size_t index, size_t count) noexcept
Concatenates a specified separator String between each element of a specified Object array...
Definition: strings.h:962
static bool ends_with(const std::basic_string< char_t > &str, char_t value) noexcept
Determines whether the end of the specified string matches the specified char_t.
Definition: strings.h:546
Compare strings using ordinal (binary) sort rules.
Contains xtd::string_split_options enum class.
static std::basic_string< char_t > trim_start(const std::basic_string< char_t > &str, char_t trim_char) noexcept
Removes all leading occurrences of a character specified from the specifed String ...
Definition: strings.h:1631
static std::string concat(ObjectA obj_a, ObjectB obj_b, ObjectC obj_c) noexcept
Concatenates three specified instances of object.
Definition: strings.h:318
Indicates that no style elements, such as leading or trailing white space, thousands separators...
static std::basic_string< char_t > trim(const std::basic_string< char_t > &str, const std::vector< char_t > &trim_chars) noexcept
Removes all eading and trailing occurrences of a set of characters specified in an array from the spe...
Definition: strings.h:1569
static std::basic_string< char_t > concat(const std::basic_string< char_t > &str_a, const std::basic_string< char_t > &str_b) noexcept
Concatenates two specified instances of string.
Definition: strings.h:331
static std::basic_string< char_t > trim_end(const std::basic_string< char_t > &str) noexcept
Removes all trailing occurrences of white-space characters from the specifed String.
Definition: strings.h:1587
static const std::vector< char_t > to_array(const std::basic_string< char_t > &str, size_t start_index, size_t length) noexcept
Copies the characters in this instance to a Unicode character array starting at specitied index with ...
Definition: strings.h:1480
static std::basic_string< char_t > insert(const std::basic_string< char_t > &str, size_t start_index, const std::basic_string< char_t > &value) noexcept
Inserts a specified instance of String at a specified index position in this instance.
Definition: strings.h:913
static size_t last_index_of(const std::basic_string< char_t > &str, const std::basic_string< char_t > &value) noexcept
Reports the index of the last occurrence of the specified string in the specified string...
Definition: strings.h:1002
static bool ends_with(const std::basic_string< char_t > &str, const std::basic_string< char_t > &value, xtd::string_comparison comparison_type) noexcept
Determines whether the end of the specified string matches the specified string when compared using t...
Definition: strings.h:572
static std::string full_class_name()
Gets the fully qualified class name of the objec_t, including the namespace of the objec_t...
Definition: strings.h:57
static std::basic_string< char_t > replace(const std::basic_string< char_t > &str, const std::basic_string< char_t > &old_string, const std::basic_string< char_t > &new_string) noexcept
Replaces all occurrences of a specified String in the specified string with another specified String...
Definition: strings.h:1241
static std::string concat(Value value) noexcept
Creates the string representation of a specified object.
Definition: strings.h:455
static size_t last_index_of_any(const std::basic_string< char_t > &str, const std::vector< char_t > &values, size_t start_index, size_t count) noexcept
Reports the index of the last occurrence in this instance of any character in a specified array of ch...
Definition: strings.h:1099
static size_t index_of(const std::basic_string< char_t > &str, const std::basic_string< char_t > &value) noexcept
Reports the index of the first occurrence of the specified string in the specified string...
Definition: strings.h:770
static int compare(const std::basic_string< char_t > &str_a, const std::basic_string< char_t > &str_b) noexcept
Compares two specified String objects and returns an integer that indicates their relative position i...
Definition: strings.h:91
Contains xtd::string_comparison enum class.
static int compare(const std::basic_string< char_t > &str_a, size_t index_a, const std::basic_string< char_t > &str_b, size_t index_b, size_t length, xtd::string_comparison comparison_type) noexcept
Compares substrings of two specified String objects using the specified rules, and returns an integer...
Definition: strings.h:219
static size_t last_index_of(const std::basic_string< char_t > &str, const std::basic_string< char_t > &value, size_t start_index) noexcept
Reports the index of the last occurrence of the specified character in the spexified string...
Definition: strings.h:1029
static std::basic_string< char_t > concat(ObjectA obj_a, ObjectB obj_b) noexcept
Concatenates two specified instances of object.
Definition: strings.h:343
static size_t last_index_of_any(const std::basic_string< char_t > &str, const std::vector< char_t > &values) noexcept
Reports the index of the last occurrence in this instance of any character in a specified array of ch...
Definition: strings.h:1082
static size_t index_of(const std::basic_string< char_t > &str, const std::basic_string< char_t > &value, size_t start_index) noexcept
Reports the index of the first occurrence of the specified character in the spexified string...
Definition: strings.h:797
Represent format output manipulator class.
Definition: format.h:11