xtd.string - Reference Guide  0.1.1
Modern c++17 library to add string utilities on Windows, macOS, Linux, iOS and android.
xtd Namespace Reference

The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more. More...

Classes

class  format
 Represent format output manipulator class. More...
 
class  immutable_basic_string
 Immutable basic_string<char_t> More...
 
class  strings
 The strings Caintains string operation methods. More...
 

Typedefs

using istring = immutable_basic_string< char, std::char_traits< char >>
 Immutable string<char_t> More...
 
using iu16string = immutable_basic_string< char16_t, std::char_traits< char16_t >>
 Immutable u16string<char_t> More...
 
using iu32string = immutable_basic_string< char32_t, std::char_traits< char32_t >>
 Immutable u32string<char_t> More...
 
using iwstring = immutable_basic_string< wchar_t, std::char_traits< wchar_t >>
 Immutable wstring<char_t> More...
 

Enumerations

enum  number_styles {
  number_styles::none = 0x0, number_styles::allow_leading_white = 0b1, number_styles::allow_trailing_white = 0b10, number_styles::allow_leading_sign = 0b100,
  number_styles::allow_trailing_sign = 0b1000, number_styles::allow_parentheses = 0b10000, number_styles::allow_decimal_point = 0b100000, number_styles::allow_thousands = 0b1000000,
  number_styles::allow_exponent = 0b10000000, number_styles::allow_currency_symbol = 0b100000000, number_styles::allow_hex_specifier = 0b1000000000, number_styles::allow_binary_specifier = 0b10000000000,
  number_styles::allow_octal_specifier = 0b100000000000, number_styles::integer = allow_leading_white + allow_trailing_white + allow_leading_sign, number_styles::number = allow_leading_white + allow_trailing_white + allow_leading_sign + allow_trailing_sign + allow_decimal_point + allow_thousands, number_styles::fixed_point = allow_leading_white + allow_trailing_white + allow_leading_sign + allow_decimal_point + allow_exponent,
  number_styles::currency = allow_leading_white + allow_trailing_white + allow_leading_sign + allow_trailing_sign + allow_parentheses + allow_decimal_point + allow_thousands + allow_currency_symbol, number_styles::any = allow_leading_white + allow_trailing_white + allow_leading_sign + allow_trailing_sign + allow_parentheses + allow_decimal_point + allow_thousands + allow_exponent + allow_currency_symbol, number_styles::hex_number = allow_leading_white + allow_trailing_white + allow_hex_specifier, number_styles::binary_number = allow_leading_white + allow_trailing_white + allow_binary_specifier,
  number_styles::octal_number = allow_leading_white + allow_trailing_white + allow_octal_specifier
}
 Determines the styles permitted in numeric string arguments that are passed to the xtd::parse and xtd::try_parse methods of the integral and floating-point numeric types. More...
 
enum  string_comparison { string_comparison::ordinal, string_comparison::ordinal_ignore_case }
 Specifies the culture, case, and sort rules to be used by certain overloads of the strings::compare(string, string) method. More...
 
enum  string_split_options { string_split_options::none, string_split_options::remove_empty_entries }
 Specifies whether applicable strings::Split method overloads include or omit empty substrings from the return value. More...
 

Functions

std::ostream & operator<< (std::ostream &os, xtd::string_split_options options)
 
template<typename value_t >
value_t parse (const std::string &str)
 
template<typename value_t >
value_t parse (const std::string &str, const std::string &fmt)
 
template<typename value_t >
value_t parse (const std::string &str, number_styles)
 
template<typename value_t >
value_t parse (const std::wstring &str)
 
template<typename value_t >
value_t parse (const std::u16string &str)
 
template<typename value_t >
value_t parse (const std::u32string &str)
 
template<>
bool parse< bool > (const std::string &str)
 
template<>
char parse< char > (const std::string &str, number_styles styles)
 
template<>
char parse< char > (const std::string &str)
 
template<>
double parse< double > (const std::string &str, number_styles styles)
 
template<>
double parse< double > (const std::string &str)
 
template<>
float parse< float > (const std::string &str, number_styles styles)
 
template<>
float parse< float > (const std::string &str)
 
template<>
int parse< int > (const std::string &str, number_styles styles)
 
template<>
int parse< int > (const std::string &str)
 
template<>
int8_t parse< int8_t > (const std::string &str, number_styles styles)
 
template<>
int8_t parse< int8_t > (const std::string &str)
 
template<>
long parse< long > (const std::string &str, number_styles styles)
 
template<>
long parse< long > (const std::string &str)
 
template<>
long double parse< long double > (const std::string &str, number_styles styles)
 
template<>
long double parse< long double > (const std::string &str)
 
template<>
long long parse< long long > (const std::string &str, number_styles styles)
 
template<>
long long parse< long long > (const std::string &str)
 
template<>
short parse< short > (const std::string &str, number_styles styles)
 
template<>
short parse< short > (const std::string &str)
 
template<>
std::string parse< std::string > (const std::string &str)
 
template<>
unsigned char parse< unsigned char > (const std::string &str, number_styles styles)
 
template<>
unsigned char parse< unsigned char > (const std::string &str)
 
template<>
unsigned int parse< unsigned int > (const std::string &str, number_styles styles)
 
template<>
unsigned int parse< unsigned int > (const std::string &str)
 
template<>
unsigned long parse< unsigned long > (const std::string &str, number_styles styles)
 
template<>
unsigned long parse< unsigned long > (const std::string &str)
 
template<>
unsigned long long parse< unsigned long long > (const std::string &str, number_styles styles)
 
template<>
unsigned long long parse< unsigned long long > (const std::string &str)
 
template<>
unsigned short parse< unsigned short > (const std::string &str, number_styles styles)
 
template<>
unsigned short parse< unsigned short > (const std::string &str)
 
template<typename value_t >
std::string to_string (const value_t &value, const std::string &fmt, const std::locale &loc)
 
template<>
std::string to_string (const bool &value, const std::string &fmt, const std::locale &loc)
 
template<>
std::string to_string (const int8_t &value, const std::string &fmt, const std::locale &loc)
 
template<>
std::string to_string (const char &value, const std::string &fmt, const std::locale &loc)
 
template<>
std::string to_string (const unsigned char &value, const std::string &fmt, const std::locale &loc)
 
template<>
std::string to_string (const short &value, const std::string &fmt, const std::locale &loc)
 
template<>
std::string to_string (const unsigned short &value, const std::string &fmt, const std::locale &loc)
 
template<>
std::string to_string (const int &value, const std::string &fmt, const std::locale &loc)
 
template<>
std::string to_string (const unsigned int &value, const std::string &fmt, const std::locale &loc)
 
template<>
std::string to_string (const long &value, const std::string &fmt, const std::locale &loc)
 
template<>
std::string to_string (const unsigned long &value, const std::string &fmt, const std::locale &loc)
 
template<>
std::string to_string (const long long &value, const std::string &fmt, const std::locale &loc)
 
template<>
std::string to_string (const unsigned long long &value, const std::string &fmt, const std::locale &loc)
 
template<>
std::string to_string (const float &value, const std::string &fmt, const std::locale &loc)
 
template<>
std::string to_string (const double &value, const std::string &fmt, const std::locale &loc)
 
template<>
std::string to_string (const long double &value, const std::string &fmt, const std::locale &loc)
 
template<>
std::string to_string (const std::chrono::system_clock::time_point &value, const std::string &fmt, const std::locale &loc)
 
template<>
std::string to_string (const std::tm &value, const std::string &fmt, const std::locale &loc)
 
template<typename Type , typename Period >
std::string to_string (const std::chrono::duration< Type, Period > &value, const std::string &fmt, const std::locale &loc)
 
template<>
std::string to_string (const std::string &value, const std::string &fmt, const std::locale &loc)
 
template<>
std::string to_string (const xtd::istring &value, const std::string &fmt, const std::locale &loc)
 
template<>
std::string to_string (const char16_t &value, const std::string &fmt, const std::locale &loc)
 
template<>
std::string to_string (const char32_t &value, const std::string &fmt, const std::locale &loc)
 
template<>
std::string to_string (const wchar_t &value, const std::string &fmt, const std::locale &loc)
 
template<typename value_t >
std::string to_string (const value_t &value, const std::string &fmt)
 
template<typename value_t >
std::wstring to_string (const value_t &value, const std::wstring &fmt, const std::locale &loc)
 
template<>
std::wstring to_string (const bool &value, const std::wstring &fmt, const std::locale &loc)
 
template<>
std::wstring to_string (const int8_t &value, const std::wstring &fmt, const std::locale &loc)
 
template<>
std::wstring to_string (const char &value, const std::wstring &fmt, const std::locale &loc)
 
template<>
std::wstring to_string (const unsigned char &value, const std::wstring &fmt, const std::locale &loc)
 
template<>
std::wstring to_string (const short &value, const std::wstring &fmt, const std::locale &loc)
 
template<>
std::wstring to_string (const unsigned short &value, const std::wstring &fmt, const std::locale &loc)
 
template<>
std::wstring to_string (const int &value, const std::wstring &fmt, const std::locale &loc)
 
template<>
std::wstring to_string (const unsigned int &value, const std::wstring &fmt, const std::locale &loc)
 
template<>
std::wstring to_string (const long &value, const std::wstring &fmt, const std::locale &loc)
 
template<>
std::wstring to_string (const unsigned long &value, const std::wstring &fmt, const std::locale &loc)
 
template<>
std::wstring to_string (const long long &value, const std::wstring &fmt, const std::locale &loc)
 
template<>
std::wstring to_string (const unsigned long long &value, const std::wstring &fmt, const std::locale &loc)
 
template<>
std::wstring to_string (const float &value, const std::wstring &fmt, const std::locale &loc)
 
template<>
std::wstring to_string (const double &value, const std::wstring &fmt, const std::locale &loc)
 
template<>
std::wstring to_string (const long double &value, const std::wstring &fmt, const std::locale &loc)
 
template<>
std::wstring to_string (const std::chrono::system_clock::time_point &value, const std::wstring &fmt, const std::locale &loc)
 
template<>
std::wstring to_string (const std::tm &value, const std::wstring &fmt, const std::locale &loc)
 
template<typename Type , typename Period >
std::wstring to_string (const std::chrono::duration< Type, Period > &value, const std::wstring &fmt, const std::locale &loc)
 
template<>
std::wstring to_string (const std::wstring &value, const std::wstring &fmt, const std::locale &loc)
 
template<>
std::wstring to_string (const xtd::iwstring &value, const std::wstring &fmt, const std::locale &loc)
 
template<>
std::wstring to_string (const char16_t &value, const std::wstring &fmt, const std::locale &loc)
 
template<>
std::wstring to_string (const char32_t &value, const std::wstring &fmt, const std::locale &loc)
 
template<>
std::wstring to_string (const wchar_t &value, const std::wstring &fmt, const std::locale &loc)
 
template<typename value_t >
std::wstring to_string (const value_t &value, const std::wstring &fmt)
 
template<typename value_t , typename char_t >
bool try_parse (const std::basic_string< char_t > &str, value_t &value)
 

Detailed Description

The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.

The xtd namespace contains all fundamental classes to access console.

Typedef Documentation

§ istring

using xtd::istring = typedef immutable_basic_string<char, std::char_traits<char>>

Immutable string<char_t>

Remarks
It can be replaced by const std::string<char_t>.

§ iu16string

using xtd::iu16string = typedef immutable_basic_string<char16_t, std::char_traits<char16_t>>

Immutable u16string<char_t>

Remarks
It can be replaced by const std::u16string<char_t>.

§ iu32string

using xtd::iu32string = typedef immutable_basic_string<char32_t, std::char_traits<char32_t>>

Immutable u32string<char_t>

Remarks
It can be replaced by const std::u32string<char_t>.

§ iwstring

using xtd::iwstring = typedef immutable_basic_string<wchar_t, std::char_traits<wchar_t>>

Immutable wstring<char_t>

Remarks
It can be replaced by const std::wstring<char_t>.

Enumeration Type Documentation

§ number_styles

enum xtd::number_styles
strong

Determines the styles permitted in numeric string arguments that are passed to the xtd::parse and xtd::try_parse methods of the integral and floating-point numeric types.

This enumeration has a flags attribute that allows a bitwise combination of its member values.

Enumerator
none 

Indicates that no style elements, such as leading or trailing white space, thousands separators, or a decimal separator, can be present in the parsed string. The string to be parsed must consist of integral decimal digits only.

allow_leading_white 

Indicates that leading white-space characters can be present in the parsed string. Valid white-space characters have the Unicode values U+0009, U+000A, U+000B, U+000C, U+000D, and U+0020. Note that this is a subset of the characters for which the std::isspace(char) method returns true.

allow_trailing_white 

Indicates that trailing white-space characters can be present in the parsed string. Valid white-space characters have the Unicode values U+0009, U+000A, U+000B, U+000C, U+000D, and U+0020. Note that this is a subset of the characters for which the std::isspace(char) method returns true.

allow_leading_sign 

Indicates that the numeric string can have a leading sign.

allow_trailing_sign 

Indicates that the numeric string can have a trailing sign. Valid trailing sign characters are determined by the positive_sign and negative_sign properties.

allow_parentheses 

Indicates that the numeric string can have one pair of parentheses enclosing the number. The parentheses indicate that the string to be parsed represents a negative number.

allow_decimal_point 

Indicates that the numeric string can have a decimal point. If the number_styles value includes the allow_currency_symbol flag and the parsed string includes a currency symbol, the decimal separator character is determined by the std::use_facet<std::numpunct<char>>(std::locale()).decimal_point() method.

allow_thousands 

Indicates that the numeric string can have group separators, such as symbols that separate hundreds from thousands. If the number_styles value includes the allow_currency_symbol flag and the string to be parsed includes a currency symbol, the valid group separator character is determined by the currency_group_separator property, and the number of digits in each group is determined by the currency_Group_sizes property. Otherwise, the valid group separator character is determined by the number_group_separator property, and the number of digits in each group is determined by the number_group_sizes property.

allow_exponent 

Indicates that the numeric string can be in exponential notation. The allow_exponent flag allows the parsed string to contain an exponent that begins with the "E" or "e" character and that is followed by an optional positive or negative sign and an integer. In other words, it successfully parses strings in the form nnnExx, nnnE+xx, and nnnE-xx. It does not allow a decimal separator or sign in the significand or mantissa; to allow these elements in the string to be parsed, use the allow_decimal_point and allow_leading_sign flags, or use a composite style that includes these individual flags.

allow_currency_symbol 

Indicates that the numeric string can contain a currency symbol. Valid currency symbols are determined by the std::use_facet<std::moneypunct<char>>(std::locale()).curr_symbol() method.

allow_hex_specifier 

Indicates that the numeric string represents a hexadecimal value. Valid hexadecimal values include the numeric digits 0-9 and the hexadecimal digits A-F and a-f. Strings that are parsed using this style can be prefixed with "0x". A string that is parsed with the allow_hex_specifier style will always be interpreted as a hexadecimal value. The only flags that can be combined with allow_hex_specifier are allow_leading_white and allow_trailing_white. The number_styles enumeration includes a composite style, hex_number, that consists of these three flags.

allow_binary_specifier 

Indicates that the numeric string represents a binary value. Valid binary values include the numeric digits 0 and 1. Strings that are parsed using this style can be prefixed with "0b". A string that is parsed with the allow_binary_specifier style will always be interpreted as a binary value. The only flags that can be combined with allow_binary_specifier are allow_leading_white and allow_trailing_white. The number_styles enumeration includes a composite style, binary_number, that consists of these three flags.

allow_octal_specifier 

Indicates that the numeric string represents a octal value. Valid octal values include the numeric digits 0-7. Strings that are parsed using this style can be prefixed with "0". A string that is parsed with the allow_octal_specifier style will always be interpreted as an octal value. The only flags that can be combined with allow_octal_specifier are allow_leading_white and allow_trailing_white. The number_styles enumeration includes a composite style, octal_number, that consists of these three flags.

integer 

Indicates that the allow_leading_white, allow_trailing_white, and allow_leading_sign styles are used. This is a composite number style.

number 

Indicates that the allow_leading_white, allow_trailing_white, allow_leading_sign, allow_trailing_sign, allow_decimal_point, and allow_thousands styles are used. This is a composite number style.

fixed_point 

Indicates that the allow_leading_white, allow_trailing_white, allow_leading_sign, allow_decimal_point, and allow_exponent styles are used. This is a composite number style.

currency 

Indicates that all styles except allow_exponent, allow_hex_specifier, allow_binary_specifier and allow_octal_specifier are used. This is a composite number style.

any 

Indicates that all styles except allow_binary_specifier, allow_octal_specifier and allow_hex_specifier are used. This is a composite number style.

hex_number 

Indicates that the allow_leading_white, allow_trailing_white, and allow_hex_specifier styles are used. This is a composite number style.

binary_number 

Indicates that the allow_leading_white, allow_trailing_white, and allow_binary_specifier styles are used. This is a composite number style.

octal_number 

Indicates that the allow_leading_white, allow_trailing_white, and allow_octal_specifier styles are used. This is a composite number style.

§ string_comparison

Specifies the culture, case, and sort rules to be used by certain overloads of the strings::compare(string, string) method.

See also
xtd::strings
Enumerator
ordinal 

Compare strings using ordinal (binary) sort rules.

ordinal_ignore_case 

Compare strings using ordinal (binary) sort rules and ignoring the case of the strings being compared.

§ string_split_options

Specifies whether applicable strings::Split method overloads include or omit empty substrings from the return value.

See also
xtd::strings
Enumerator
none 

The return value includes array elements that contain an empty string.

remove_empty_entries 

The return value does not include array elements that contain an empty string.