![]() |
Lumino
|
Unicode 文字列を表します。 More...
#include <String.hpp>
Public Member Functions | |
bool | isEmpty () const noexcept |
文字列が空であるかを確認します。 | |
const Char * | c_str () const noexcept |
C 言語としての文字列表現を取得します。 | |
int | length () const noexcept |
文字列の長さを取得します。 | |
int | capacity () const noexcept |
メモリを再確保せずに格納できる最大の要素数を取得します。 | |
void | clear () |
文字列をクリアします。 | |
void | resize (int newLength) |
文字列の長さを変更します。 | |
void | resize (int newLength, Char ch) |
文字列の長さを変更します。増大した領域を ch で置き換えます。 | |
void | reserve (int size) |
サイズ変更の予定を指示します。 | |
void | assign (const Char *str) |
文字列の再代入します。 | |
void | assign (const Char *str, int length) |
void | assign (int count, Char ch) |
void | assign (const StringRef &str) |
void | append (const Char *str, int length) |
指定された文字列を追加します。 | |
void | append (const String &str) |
bool | contains (const StringRef &str, CaseSensitivity cs=CaseSensitivity::CaseSensitive) const |
指定した文字列がこの文字列内に存在するかを判断します。 More... | |
bool | contains (Char ch, CaseSensitivity cs=CaseSensitivity::CaseSensitive) const |
int | indexOf (const StringRef &str, int startIndex=0, CaseSensitivity cs=CaseSensitivity::CaseSensitive) const |
文字列を検索し、見つかった最初の文字のインデックスを返します。 More... | |
int | lastIndexOf (const StringRef &str, int startIndex=-1, int count=-1, CaseSensitivity cs=CaseSensitivity::CaseSensitive) const |
文字列を検索し、最後に見つかったインデックスを返します。 More... | |
int | lastIndexOf (Char ch, int startIndex=-1, int count=-1, CaseSensitivity cs=CaseSensitivity::CaseSensitive) const |
bool | startsWith (const StringRef &str, CaseSensitivity cs=CaseSensitivity::CaseSensitive) const |
この文字列の先頭が、指定した文字列と一致するかを判断します。 More... | |
bool | startsWith (Char ch, CaseSensitivity cs=CaseSensitivity::CaseSensitive) const |
bool | endsWith (const StringRef &str, CaseSensitivity cs=CaseSensitivity::CaseSensitive) const |
この文字列の末尾が、指定した文字列と一致するかを判断します。 More... | |
bool | endsWith (Char ch, CaseSensitivity cs=CaseSensitivity::CaseSensitive) const |
StringRef | substr (int start, int count=-1) const |
文字列の部分文字列を抽出します。 More... | |
StringRef | left (int count) const |
文字列の左側(先頭)から指定した文字数を抽出します。 More... | |
StringRef | right (int count) const |
文字列の右側(末尾)から指定した文字数を抽出します。 More... | |
String | trim () const |
文字列の先頭と末尾の空白を全て削除した文字列を返します。 | |
String | toUpper () const |
小文字を大文字に変換した文字列を返します。(ロケールの影響を受けません) | |
String | toLower () const |
大文字を小文字に変換した文字列を返します。(ロケールの影響を受けません) | |
String | toTitleCase () const |
先頭の文字を大文字、以降を小文字に変換した文字列を返します。(ロケールの影響を受けません) | |
String | remove (const StringRef &str, CaseSensitivity cs=CaseSensitivity::CaseSensitive) const |
この文字列から指定した文字をすべて取り除いた新しい文字列を返します。 More... | |
String | remove (Char ch, CaseSensitivity cs=CaseSensitivity::CaseSensitive) const |
String | replace (const StringRef &from, const StringRef &to, CaseSensitivity cs=CaseSensitivity::CaseSensitive) const |
文字列の置換を行います。 More... | |
String | insert (int startIndex, const StringRef &value) const |
指定したインデックス位置に文字列を挿入します。 More... | |
List< String > | split (const StringRef &delim, StringSplitOptions option=StringSplitOptions::None) const |
文字列をデリミタで分割します。 More... | |
int | toInt (int base=0) const |
この文字列を整数値に変換します。 More... | |
int16_t | toInt16 (int base=0) const |
この文字列を整数値に変換します。 More... | |
int32_t | toInt32 (int base=0) const |
この文字列を整数値に変換します。 More... | |
int64_t | toInt64 (int base=0) const |
この文字列を整数値に変換します。 More... | |
uint8_t | toUInt8 (int base=0) const |
この文字列を整数値に変換します。 More... | |
uint16_t | toUInt16 (int base=0) const |
この文字列を整数値に変換します。 More... | |
uint32_t | toUInt32 (int base=0) const |
この文字列を整数値に変換します。 More... | |
uint64_t | toUInt64 (int base=0) const |
この文字列を整数値に変換します。 More... | |
bool | tryToInt (int *outValue, int base=0) const |
この文字列を整数値に変換し、成否を返します。 More... | |
bool | tryToInt16 (int16_t *outValue, int base=0) const |
この文字列を整数値に変換し、成否を返します。 More... | |
bool | tryToInt32 (int32_t *outValue, int base=0) const |
この文字列を整数値に変換し、成否を返します。 More... | |
bool | tryToInt64 (int64_t *outValue, int base=0) const |
この文字列を整数値に変換し、成否を返します。 More... | |
bool | tryToUInt8 (uint8_t *outValue, int base=0) const |
この文字列を整数値に変換し、成否を返します。 More... | |
bool | tryToUInt16 (uint16_t *outValue, int base=0) const |
この文字列を整数値に変換し、成否を返します。 More... | |
bool | tryToUInt32 (uint32_t *outValue, int base=0) const |
この文字列を整数値に変換し、成否を返します。 More... | |
bool | tryToUInt64 (uint64_t *outValue, int base=0) const |
この文字列を整数値に変換し、成否を返します。 More... | |
std::string | toStdString (TextEncoding *encoding=nullptr) const |
ローカルの std::string 型文字列へ変換します。 | |
std::wstring | toStdWString () const |
ローカルの std::wstring 型文字列へ変換します。 | |
CharRef | operator[] (int index) |
任意の位置の要素へアクセスします。 | |
const Char & | operator[] (int index) const noexcept |
任意の位置の要素へアクセスします。 | |
Static Public Member Functions | |
static String | concat (const StringRef &str1, const StringRef &str2) |
指定した文字列を連結します。 | |
static String | concat (const StringRef &str1, const StringRef &str2, const StringRef &str3) |
static String | concat (const StringRef &str1, const StringRef &str2, const StringRef &str3, const StringRef &str4) |
static String | join (const List< String > &list, const StringRef &delim) |
指定した文字列リストを結合した 1 つの文字列を生成します。各要素の間には、指定した区切り記号が挿入されます。 | |
template<typename... TArgs> | |
static String | format (const StringRef &format, TArgs &&... args) |
複合書式文字列と可変長引数リストから文字列を生成します。 | |
template<typename... TArgs> | |
static String | format (const Locale &locale, const StringRef &format, TArgs &&... args) |
static int | compare (const String &str1, const String &str2, CaseSensitivity cs=CaseSensitivity::CaseSensitive) |
指定した2つの文字列を比較します。 More... | |
static int | compare (const StringRef &str1, int index1, const StringRef &str2, int index2, int length=-1, CaseSensitivity cs=CaseSensitivity::CaseSensitive) |
static String | fromCString (const char *str, int length=-1, TextEncoding *encoding=nullptr) |
ローカルの char 文字列を String へ変換します。 | |
static String | fromCString (const wchar_t *str, int length=-1) |
ローカルの wchar_t 文字列を String へ変換します。 | |
static String | fromStdString (const std::string &str, TextEncoding *encoding=nullptr) |
ローカルの std::string 型文字列を String へ変換します。 | |
static String | fromStdString (const std::wstring &str) |
ローカルの std::wstring 型文字列を String へ変換します。 | |
static String | fromNumber (int32_t value, Char format='D') |
数値を文字列に変換します。 More... | |
static String | fromNumber (int64_t value, Char format='D') |
static String | fromNumber (uint32_t value, Char format='D') |
static String | fromNumber (uint64_t value, Char format='D') |
static String | fromNumber (float value, Char format='F', int precision=6) |
static String | fromNumber (double value, Char format='F', int precision=6) |
static const String & | newLine () |
現在の環境で定義されている改行文字列を取得します。 | |
Unicode 文字列を表します。
String クラスは環境に依らず、UTF-16 コードで表現される文字の配列です。 文字は Char 型で表される 2Byte 値です。65535を 超えるコード値の文字は、サロゲートペア、つまり2つの連続した文字で格納されます。
文字列はメモリ上に連続的に確保され Null 終端文字を格納します。
void ln::String::append | ( | const String & | str | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void ln::String::assign | ( | const Char * | str, |
int | length | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void ln::String::assign | ( | int | count, |
Char | ch | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void ln::String::assign | ( | const StringRef & | str | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
static |
指定した2つの文字列を比較します。
[in] | str1 | : 比較文字列 |
[in] | index1 | : str1 内の部分文字列の開始位置 |
[in] | str2 | : 比較文字列 |
[in] | index2 | : str2 内の部分文字列の開始位置 |
[in] | length | : 比較する文字数 (-1 の場合、GetLength() の値を使用します) |
[in] | cs | : 大文字と小文字の区別設定 |
|
static |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
static |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
static |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool ln::String::contains | ( | const StringRef & | str, |
CaseSensitivity | cs = CaseSensitivity::CaseSensitive |
||
) | const |
指定した文字列がこの文字列内に存在するかを判断します。
[in] | str | : 検索文字列 |
[in] | cs | : 大文字と小文字の区別設定 |
bool ln::String::contains | ( | Char | ch, |
CaseSensitivity | cs = CaseSensitivity::CaseSensitive |
||
) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool ln::String::endsWith | ( | const StringRef & | str, |
CaseSensitivity | cs = CaseSensitivity::CaseSensitive |
||
) | const |
この文字列の末尾が、指定した文字列と一致するかを判断します。
[in] | str | : 検索文字列 |
str が空文字の場合は必ず true が返ります。
bool ln::String::endsWith | ( | Char | ch, |
CaseSensitivity | cs = CaseSensitivity::CaseSensitive |
||
) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlinestatic |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
static |
数値を文字列に変換します。
[in] | value | : 数値 |
[in] | format | : 書式 |
[in] | precision | : 小数の精度 (小数部の桁数) |
|
static |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
static |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
static |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
static |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
static |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
int ln::String::indexOf | ( | const StringRef & | str, |
int | startIndex = 0 , |
||
CaseSensitivity | cs = CaseSensitivity::CaseSensitive |
||
) | const |
文字列を検索し、見つかった最初の文字のインデックスを返します。
[in] | str | : 検索文字列 |
[in] | startIndex | : 検索を開始するインデックス (省略した場合は先頭から) |
[in] | cs | : 大文字と小文字の区別設定 |
指定したインデックス位置に文字列を挿入します。
[in] | startIndex | : インデックス位置 |
[in] | value | : 挿入する文字列 |
int ln::String::lastIndexOf | ( | const StringRef & | str, |
int | startIndex = -1 , |
||
int | count = -1 , |
||
CaseSensitivity | cs = CaseSensitivity::CaseSensitive |
||
) | const |
文字列を検索し、最後に見つかったインデックスを返します。
[in] | str | : 検索文字列 |
[in] | startIndex | : 検索を開始するインデックス (-1 を指定すると、文字列の末尾から検索を開始する) |
[in] | count | : 検索する文字数 (-1 を指定すると、文字列の先頭まで検索する) |
[in] | cs | : 大文字と小文字の区別設定 |
startIndex の位置から文字列の先頭に向かう count 文字分の領域から str を検索します。
int ln::String::lastIndexOf | ( | Char | ch, |
int | startIndex = -1 , |
||
int | count = -1 , |
||
CaseSensitivity | cs = CaseSensitivity::CaseSensitive |
||
) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
StringRef ln::String::left | ( | int | count | ) | const |
文字列の左側(先頭)から指定した文字数を抽出します。
[in] | count | : 文字数 |
String ln::String::remove | ( | const StringRef & | str, |
CaseSensitivity | cs = CaseSensitivity::CaseSensitive |
||
) | const |
この文字列から指定した文字をすべて取り除いた新しい文字列を返します。
[in] | str | : 削除する文字列 |
[in] | cs | : 大文字と小文字の区別設定 |
String ln::String::remove | ( | Char | ch, |
CaseSensitivity | cs = CaseSensitivity::CaseSensitive |
||
) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
String ln::String::replace | ( | const StringRef & | from, |
const StringRef & | to, | ||
CaseSensitivity | cs = CaseSensitivity::CaseSensitive |
||
) | const |
文字列の置換を行います。
[in] | from | : 置換される文字列 |
[in] | to | : from を置換する文字列 |
from に一致するすべての文字列を to に置換します。
StringRef ln::String::right | ( | int | count | ) | const |
文字列の右側(末尾)から指定した文字数を抽出します。
[in] | count | : 文字数 |
List<String> ln::String::split | ( | const StringRef & | delim, |
StringSplitOptions | option = StringSplitOptions::None |
||
) | const |
文字列をデリミタで分割します。
[in] | delim | : デリミタ文字列 |
[in] | option | : 分割方法 |
分割が発生しない場合は文字列全体を持つ要素数1の配列を返します。
bool ln::String::startsWith | ( | const StringRef & | str, |
CaseSensitivity | cs = CaseSensitivity::CaseSensitive |
||
) | const |
この文字列の先頭が、指定した文字列と一致するかを判断します。
[in] | str | : 検索文字列 |
str が空文字の場合は必ず true が返ります。
bool ln::String::startsWith | ( | Char | ch, |
CaseSensitivity | cs = CaseSensitivity::CaseSensitive |
||
) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
StringRef ln::String::substr | ( | int | start, |
int | count = -1 |
||
) | const |
文字列の部分文字列を抽出します。
[in] | start | : 開始文字インデックス |
[in] | count | : 文字数 (-1 の場合、末尾まで抽出する) |
int ln::String::toInt | ( | int | base = 0 | ) | const |
この文字列を整数値に変換します。
[in] | base | : 基数 (0、2、8、10、16 のいずれかであること) |
次の書式に従い、文字列を数値に変換します。
[whitespace] [{+ | – }] [0 [{ x | X }]] [digits | letters]
16 進数値のアルファベットは大文字と小文字を区別しません。
基数に 0 を指定すると、文字列の先頭文字から基数を自動判別します。 "0x" または "0X" であれば 16 進数、"0" であれば 8 進数、それ以外であれば 10 進数です。 基数に 8 または 16 が指定されている際、文字列の先頭は "0" または "0x" である必要はありません。
int16_t ln::String::toInt16 | ( | int | base = 0 | ) | const |
この文字列を整数値に変換します。
[in] | base | : 基数 (0、2、8、10、16 のいずれかであること) |
次の書式に従い、文字列を数値に変換します。
[whitespace] [{+ | – }] [0 [{ x | X }]] [digits | letters]
16 進数値のアルファベットは大文字と小文字を区別しません。
基数に 0 を指定すると、文字列の先頭文字から基数を自動判別します。 "0x" または "0X" であれば 16 進数、"0" であれば 8 進数、それ以外であれば 10 進数です。 基数に 8 または 16 が指定されている際、文字列の先頭は "0" または "0x" である必要はありません。
int32_t ln::String::toInt32 | ( | int | base = 0 | ) | const |
この文字列を整数値に変換します。
[in] | base | : 基数 (0、2、8、10、16 のいずれかであること) |
次の書式に従い、文字列を数値に変換します。
[whitespace] [{+ | – }] [0 [{ x | X }]] [digits | letters]
16 進数値のアルファベットは大文字と小文字を区別しません。
基数に 0 を指定すると、文字列の先頭文字から基数を自動判別します。 "0x" または "0X" であれば 16 進数、"0" であれば 8 進数、それ以外であれば 10 進数です。 基数に 8 または 16 が指定されている際、文字列の先頭は "0" または "0x" である必要はありません。
int64_t ln::String::toInt64 | ( | int | base = 0 | ) | const |
この文字列を整数値に変換します。
[in] | base | : 基数 (0、2、8、10、16 のいずれかであること) |
次の書式に従い、文字列を数値に変換します。
[whitespace] [{+ | – }] [0 [{ x | X }]] [digits | letters]
16 進数値のアルファベットは大文字と小文字を区別しません。
基数に 0 を指定すると、文字列の先頭文字から基数を自動判別します。 "0x" または "0X" であれば 16 進数、"0" であれば 8 進数、それ以外であれば 10 進数です。 基数に 8 または 16 が指定されている際、文字列の先頭は "0" または "0x" である必要はありません。
uint16_t ln::String::toUInt16 | ( | int | base = 0 | ) | const |
この文字列を整数値に変換します。
[in] | base | : 基数 (0、2、8、10、16 のいずれかであること) |
次の書式に従い、文字列を数値に変換します。
[whitespace] [{+ | – }] [0 [{ x | X }]] [digits | letters]
16 進数値のアルファベットは大文字と小文字を区別しません。
基数に 0 を指定すると、文字列の先頭文字から基数を自動判別します。 "0x" または "0X" であれば 16 進数、"0" であれば 8 進数、それ以外であれば 10 進数です。 基数に 8 または 16 が指定されている際、文字列の先頭は "0" または "0x" である必要はありません。
uint32_t ln::String::toUInt32 | ( | int | base = 0 | ) | const |
この文字列を整数値に変換します。
[in] | base | : 基数 (0、2、8、10、16 のいずれかであること) |
次の書式に従い、文字列を数値に変換します。
[whitespace] [{+ | – }] [0 [{ x | X }]] [digits | letters]
16 進数値のアルファベットは大文字と小文字を区別しません。
基数に 0 を指定すると、文字列の先頭文字から基数を自動判別します。 "0x" または "0X" であれば 16 進数、"0" であれば 8 進数、それ以外であれば 10 進数です。 基数に 8 または 16 が指定されている際、文字列の先頭は "0" または "0x" である必要はありません。
uint64_t ln::String::toUInt64 | ( | int | base = 0 | ) | const |
この文字列を整数値に変換します。
[in] | base | : 基数 (0、2、8、10、16 のいずれかであること) |
次の書式に従い、文字列を数値に変換します。
[whitespace] [{+ | – }] [0 [{ x | X }]] [digits | letters]
16 進数値のアルファベットは大文字と小文字を区別しません。
基数に 0 を指定すると、文字列の先頭文字から基数を自動判別します。 "0x" または "0X" であれば 16 進数、"0" であれば 8 進数、それ以外であれば 10 進数です。 基数に 8 または 16 が指定されている際、文字列の先頭は "0" または "0x" である必要はありません。
uint8_t ln::String::toUInt8 | ( | int | base = 0 | ) | const |
この文字列を整数値に変換します。
[in] | base | : 基数 (0、2、8、10、16 のいずれかであること) |
次の書式に従い、文字列を数値に変換します。
[whitespace] [{+ | – }] [0 [{ x | X }]] [digits | letters]
16 進数値のアルファベットは大文字と小文字を区別しません。
基数に 0 を指定すると、文字列の先頭文字から基数を自動判別します。 "0x" または "0X" であれば 16 進数、"0" であれば 8 進数、それ以外であれば 10 進数です。 基数に 8 または 16 が指定されている際、文字列の先頭は "0" または "0x" である必要はありません。
bool ln::String::tryToInt | ( | int * | outValue, |
int | base = 0 |
||
) | const |
この文字列を整数値に変換し、成否を返します。
[in] | outValue | : 結果を格納する変数のポインタ (nullptr を指定すると成否のみを返す) |
[in] | base | : 基数 (0、2、8、10、16 のいずれかであること) |
bool ln::String::tryToInt16 | ( | int16_t * | outValue, |
int | base = 0 |
||
) | const |
この文字列を整数値に変換し、成否を返します。
[in] | outValue | : 結果を格納する変数のポインタ (nullptr を指定すると成否のみを返す) |
[in] | base | : 基数 (0、2、8、10、16 のいずれかであること) |
bool ln::String::tryToInt32 | ( | int32_t * | outValue, |
int | base = 0 |
||
) | const |
この文字列を整数値に変換し、成否を返します。
[in] | outValue | : 結果を格納する変数のポインタ (nullptr を指定すると成否のみを返す) |
[in] | base | : 基数 (0、2、8、10、16 のいずれかであること) |
bool ln::String::tryToInt64 | ( | int64_t * | outValue, |
int | base = 0 |
||
) | const |
この文字列を整数値に変換し、成否を返します。
[in] | outValue | : 結果を格納する変数のポインタ (nullptr を指定すると成否のみを返す) |
[in] | base | : 基数 (0、2、8、10、16 のいずれかであること) |
bool ln::String::tryToUInt16 | ( | uint16_t * | outValue, |
int | base = 0 |
||
) | const |
この文字列を整数値に変換し、成否を返します。
[in] | outValue | : 結果を格納する変数のポインタ (nullptr を指定すると成否のみを返す) |
[in] | base | : 基数 (0、2、8、10、16 のいずれかであること) |
bool ln::String::tryToUInt32 | ( | uint32_t * | outValue, |
int | base = 0 |
||
) | const |
この文字列を整数値に変換し、成否を返します。
[in] | outValue | : 結果を格納する変数のポインタ (nullptr を指定すると成否のみを返す) |
[in] | base | : 基数 (0、2、8、10、16 のいずれかであること) |
bool ln::String::tryToUInt64 | ( | uint64_t * | outValue, |
int | base = 0 |
||
) | const |
この文字列を整数値に変換し、成否を返します。
[in] | outValue | : 結果を格納する変数のポインタ (nullptr を指定すると成否のみを返す) |
[in] | base | : 基数 (0、2、8、10、16 のいずれかであること) |
bool ln::String::tryToUInt8 | ( | uint8_t * | outValue, |
int | base = 0 |
||
) | const |
この文字列を整数値に変換し、成否を返します。
[in] | outValue | : 結果を格納する変数のポインタ (nullptr を指定すると成否のみを返す) |
[in] | base | : 基数 (0、2、8、10、16 のいずれかであること) |