wchar[] text;
static TypeInfo charType();
static TypeInfo textType();
static Text wrap(wchar[] arg
);
ラップ。
tchar[]そのものをTextに取り込む。
- Examples:
tstring src="abc";
tchar[] buffer=src.dup;
auto t=Text.wrap(buffer);
t[2] = 'C';
assert(buffer == "abC");
assert(buffer is t.text);
static const(Text) iwrap(tstring arg
);
ラップ。
Text.wrapの書き換えないバージョン。
deprecated static Text emptyText();
空文字列の作成。
- History:
- 1.100:
[S] とりあえずpure/refに。
1.00β15:
[S] finalだったのを修正。クラスにしようか迷っていたときの名残か…。
- Deprecated:
- Text.initでいいじゃん。
static immutable Text newline;
const wchar* ptr(bool NonTextIsNull
= false);
Windows用文字列の生成。
- Params:
-
- bool NonTextIsNull
- trueの場合に文字列が空ならnullを返す。
- Returns:
- textの0終端文字列を生成。
誰かに渡さないとGCの対象になるんで注意。
- History:
- 1.100:
[P] 挙動の変更。
[F] 引数追加。
const size_t length();
文字列の配列長を取得。
UTF-16が一文字純正だったら素敵。
size_t length(size_t Size
);
文字列の配列長の設定。
- Params:
-
- size_t Size
- 設定する配列長。
- History:
- 1.100:
[S] 配列のサイズを返す。
[S] nothrow。
const bool validate();
Unicode文字列判定。
現在の文字列がUnicodeで合法かどうかを判定。
const size_t countCharacter();
文字列長取得。
現在のUnicode文字列長を取得。
length()と違い文字列の長さを取得する。
const Text dup();
const tstring idup();
T toNumber(T, string _file = __FILE__, int _line = __LINE__)();
数値変換。
現在の文字列からTに対応する数値を取得。
- Throws:
- 変換に失敗した場合はNeGuiException。
- Examples:
auto t=Text("123");
assert(t.toNumber!(int) == 123);
bool tryNumber(T)(out T Value
);
数値変換。
toNumber()と違い例外出力を行わない。
- Examples:
auto t=Text("123");
int result;
if(t.tryNumber!(int)(result)) {
assert(result == 123);
}
Text numberSplit(T)(T number
, tchar SplitChar
= ',', size_t SplitCount
= 3);
数値に区切り追加。
1000を1,000のように変換。
- Params:
-
- number
- 変換する数値。
- SplitChar
- 区切りにする文字。
- SplitCount
- SplitCharを設定する桁数。
- Examples:
assert(Text.numberSplit(1000) == Text("1,000"));
assert(Text.numberSplit(1000, '.') == Text("1.000"));
assert(Text.numberSplit(1000, ',', 1) == Text("1,0,0,0"));
static int numeralChatToNum(char c
);
文字からn進数取得。
- Params:
-
- char c
- n進数の最大値を表す文字。
- Throws:
- 失敗時にNeGuiException。
- Note:
-
一応公開してるけどユーザー側で使うことはまず無い。
Text toNumeral(T, BASE : int)(in T number
, in BASE n
= 16, in size_t Increment
= BUFFER.INCREMENT);
Text toNumeral(T, BASE = char)(in T number
, in BASE c
= 'F', in size_t Increment
= BUFFER.INCREMENT);
T toNumeral10(T, BASE : int)(in Text Numeral
, BASE n
);
T toNumeral10(T, BASE : char)(in Text Numeral
, BASE c
);
Text sort();
Text reverse();
const string toString();
死んでしまえ。
- History:
- 1.00β14:
空の場合に若干変更
string toString();
const string str();
UTF-8文字列取得。
- History:
- 1.090:
[S] 名前変更(text8 -> str)
1.00β19:
新規作成。
alias text8;
alias text16;
const dstring text32();
const const(char*) toStringz();
const Text opCat(in Text Value
);
Text opCatAssign(in Text Value
);
Text opCall(T)(in T arg
);
文字からTextを生成。
- Examples:
Text t;
t = Text('a');
assert(t == Text("a"));
t = Text('あ');
assert(t == Text("あ"));
Text opCall(T)(in T* arg
);
C形式文字列ポインタからText生成。
- Examples:
Text t;
t = Text(x"313233003435360037383900".ptr);
assert(t.text == "123");
t = Text(x"313233003435360037383900"w.ptr);
assert(t.text == "123");
t = Text(x"313233003435360037383900"d.ptr);
assert(t.text == "123");
Text opCall(T)(in T arg
);
クラスからText生成。
TはITextを継承していること。
Text opCall(T)(ref const T arg
);
構造体からText生成。
TはtoTextを持っていること。
Text opCall(T : Text)(ref const T arg
);
TextからText生成。
Text.dup()を内部で呼び出し。
Text opCall(T)(in T arg
);
引数からText生成。
- Params:
-
- arg
- inなのでObject.toStringはできない。
Text opCall(String, T...)(in String SrcFormat
, T Args
);
書式からText生成。
- Note:
-
std.format.doFormat参照。
const tchar opIndex(size_t n
);
tchar opIndexAssign(tchar value
, size_t n
);
Text opSlice();
const Text opSlice(in size_t start
, in size_t end
);
[n..m]
- History:
- 1.00β17:
[B] 事前条件がDの仕様と違っていたのを修正。
const hash_t toHash();
const bool opEquals(ref const Text arg
);
const int opCmp(ref const Text arg
);
const int cmp(in Text text
);
const int icmp(in Text text
);
文字列比較。
大文字小文字を区別しない。
- History:
- 1.100:
[S] 名前変更(cmpi -> icmp)。
1.00β11:
新規作成。
const Text chomp(in Text Delimiter
= (Text).init);
文字列からDelimiter削除。
- Params:
-
- Text Delimiter
- 取り去る文字列。
Text.initならCR,LF,CRLF、
- Note:
-
まんまstd.string.chomp。
- History:
- 1.100:
[P] 引数追加。
const Text stripl();
先頭空白文字削除。
- History:
- 1.063:
[B] 全部ホワイトスペースでアウト。
1.010:
[S] 属性変更。
const Text stripr();
末尾空白文字削除。
- History:
- 1.063:
[B] 全部ホワイトスペースでアウト。
1.010:
[S] 属性変更。
const Text strip();
両端空白文字削除。
- History:
- 1.010:
[S] 属性変更。
enum CASE_SENSITIVE;
enum START;
const size_t count(in tchar c
);
文字列カウント。
- Examples:
Text t;
t = Text("abc;d;e;;f;g");
assert(t.count(';') == 5);
t = Text("abcdefg");
assert(t.count(';') == 0);
t=Text("");
assert(t.count(';') == 0);
t=Text(";");
assert(t.count(';') == 1);
const size_t count(in Text Word
);
文字列カウント。
- Examples:
Text t;
t=Text("123aa456aa789");
assert(t.count(Text("aa")) == 2);
t=Text("123aa456aa789aa");
assert(t.count(Text("aa")) == 3);
t=Text("aaaaaaaa");
assert(t.count(Text("aa")) == 4);
t=Text("aaaaaaaaa");
assert(t.count(Text("aa")) == 4);
t=Text("");
assert(t.count(Text("aa")) == 0);
- History:
- 1.100:
[B] 保持している文字列長が0でRange violation。
1.00β14:
新規作成。
deprecated const int find(in tchar c
);
- Note:
-
多すぎる。
std.string.indexOf, std.string.lastIndexOfにあわせるべき。
- Deprecated:
- Text.indexOfを使用すべき。
deprecated const int ifind(in tchar c
);
ditto
- Deprecated:
- Text.indexOfを使用すべき。
deprecated const int rfind(in tchar c
);
ditto
- Deprecated:
- Text.indexOfを使用すべき。
deprecated const int irfind(in tchar c
);
ditto
- Deprecated:
- Text.indexOfを使用すべき。
deprecated const int find(in Text Word
);
ditto
- Deprecated:
- Text.indexOfを使用すべき。
deprecated const int ifind(in Text Word
);
ditto
- Deprecated:
- Text.indexOfを使用すべき。
deprecated const int rfind(in Text Word
);
ditto
- Deprecated:
- Text.indexOfを使用すべき。
deprecated const int irfind(in Text Word
);
ditto
- Deprecated:
- Text.indexOfを使用すべき。
const int indexOf(tchar c
, CASE_SENSITIVE CaseSensitive
= (CASE_SENSITIVE).YES, START Start
= (START).HEAD);
文字検索。
- Params:
-
- tchar c
- 検索する文字。
- CASE_SENSITIVE CaseSensitive
- 大文字小文字の区別。
- START Start
- 検索位置。
- Returns:
- 見つかった場合はそのインデックス、
見つからなかった場合は-1を返す。
- Examples:
Text t;
t = Text("123456789abcdABCD");
assert(t.indexOf('1', CASE_SENSITIVE.YES, START.HEAD) == 0);
assert(t.indexOf('9', CASE_SENSITIVE.YES, START.HEAD) == 8);
assert(t.indexOf('a', CASE_SENSITIVE.YES, START.HEAD) == 9);
assert(t.indexOf('A', CASE_SENSITIVE.YES, START.HEAD) == 13);
assert(t.indexOf('1', CASE_SENSITIVE.NO, START.HEAD) == 0);
assert(t.indexOf('9', CASE_SENSITIVE.NO, START.HEAD) == 8);
assert(t.indexOf('a', CASE_SENSITIVE.NO, START.HEAD) == 9);
assert(t.indexOf('A', CASE_SENSITIVE.NO, START.HEAD) == 9);
assert(t.indexOf('D', CASE_SENSITIVE.YES, START.TAIL) == 16);
assert(t.indexOf('d', CASE_SENSITIVE.NO, START.TAIL) == 16);
assert(t.indexOf('1', CASE_SENSITIVE.NO, START.TAIL) == 0);
const int indexOf(in Text Word
, CASE_SENSITIVE CaseSensitive
= (CASE_SENSITIVE).YES, START Start
= (START).HEAD);
文字検索。
- Params:
-
- Text Word
- 検索する文字列。
- CASE_SENSITIVE CaseSensitive
- 大文字小文字の区別。
- START Start
- 検索位置。
- Returns:
- 見つかった場合はそのインデックス、
見つからなかった場合は-1を返す。
- Examples:
Text t;
t = Text("123456789abcdABCD");
assert(t.indexOf(Text("1"), CASE_SENSITIVE.YES, START.HEAD) == 0);
assert(t.indexOf(Text("abcd"), CASE_SENSITIVE.YES, START.HEAD) == 9);
assert(t.indexOf(Text("1"), CASE_SENSITIVE.NO, START.HEAD) == 0);
assert(t.indexOf(Text("12"), CASE_SENSITIVE.NO, START.HEAD) == 0);
assert(t.indexOf(Text("ABCD"), CASE_SENSITIVE.NO, START.HEAD) == 9);
assert(t.indexOf(Text("123456789abcdABCD"), CASE_SENSITIVE.NO, START.HEAD) == 0);
assert(t.indexOf(Text("123456789abcdABCDE"), CASE_SENSITIVE.NO, START.HEAD) == -1);
assert(t.indexOf(Text("12"), CASE_SENSITIVE.YES, START.TAIL) == 0);
assert(t.indexOf(Text("23"), CASE_SENSITIVE.YES, START.TAIL) == 1);
assert(t.indexOf(Text("abcd"), CASE_SENSITIVE.YES, START.TAIL) == 9);
assert(t.indexOf(Text("ABCD"), CASE_SENSITIVE.NO, START.TAIL) == 13);
assert(t.indexOf(Text("abcd"), CASE_SENSITIVE.NO, START.TAIL) == 13);
const Text[] split(in tchar c
);
文字列分割。
- Examples:
Text t;
Text[] list;
t = Text("123 456 789");
list = t.split(' ');
assert(list.length == 3);
assert(list[0].text == "123");
assert(list[1].text == "456");
assert(list[2].text == "789");
t = Text("123,456,789,");
list = t.split(',');
assert(list.length == 4);
assert(list[0].text == "123");
assert(list[1].text == "456");
assert(list[2].text == "789");
assert(list[3].text == "");
t = Text("");
list = t.split(',');
assert(!list.length);
t = Text("123456789");
list = t.split(',');
assert(!list.length);
t = Text("あ@い@う@え@お");
list = t.split('@');
assert(list.length == 5);
- History:
- 1.00β14:
分割が変だったのを修正。
const Text[] split(in Text Word
);
文字列分割。
- Examples:
Text t;
Text[] list;
t = Text("123..456..789");
list = t.split(Text(".."));
assert(list.length == 3);
assert(list[0].text == "123");
assert(list[1].text == "456");
assert(list[2].text == "789");
t = Text("123....456..789");
list = t.split(Text(".."));
assert(list.length ==4);
assert(list[0].text == "123");
assert(list[1].text == "");
assert(list[2].text == "456");
assert(list[3].text == "789");
t = Text("");
list = t.split(Text(".."));
assert(!list.length);
t = Text("テキスト文字列text文字列てきすと");
list = t.split(Text("文字列"));
assert(list.length == 3);
assert(list[0].text == "テキスト");
assert(list[1].text == "text");
assert(list[2].text == "てきすと");
t = Text("abcdefg");
list = t.split(Text(".."));
assert(!list.length);
- History:
- 1.100:
[S] 属性変更。
[B] 保持している文字列長が0でRange violation。
[B] 一致しない場合に戻り値がある。
1.00β14:
新規作成。
const Text[] splitlines();
改行分割。
- Note:
-
std.string.splitlines。
Text replaceRaw(in Text SrcWord
, in Text NewWord
);
const Text replace(in Text SrcWord
, in Text NewWord
);
Text insertRaw(in Text Word
, size_t Index
);
const Text insert(in Text Word
, size_t Index
);
static Text repeat(in Text Src
, size_t Repeat
);
文字列を繰り返す。
- History:
- 1.100:
[P] Repeatが一回の場合にSrcを返すのではなくSrcのコピーを返す用に変更。
1.00β14:
新規作成。
static Text repeat(tchar c
, size_t Repeat
);
const Text repeat(size_t Repeat
);
Text quot(T)(in T left
, in T right
);
- History:
- 1.061:
[S] 属性変更。
Text quot(T)(in T arg
);
- History:
- 1.061:
[S] 属性変更。
const bool isNumeric(bool Separator
= true);
文字列は数値か。
- Params:
-
- bool Separator
- セパレータを無視するか。
- Note:
-
std.string.isNumeric。
const Text filter(in wchar[] Characters
);
const Text filter(tchar Character
, in wchar[] Characters
...);
フィルタ。
フィルタに引っ掛かる文字を省く。
- Params:
-
- wchar[] Characters
- フィルタとする文字。
- Returns:
- Charactersを取り除いたText。
const bool startsWith(in Text Word
);
先頭文字列比較。
文字列の先頭が指定した文字列で始まっているかを調べる。
- Params:
-
- Text Word
- 比較したい文字列。
const bool endsWith(in Text Word
);
末尾文字列比較。
文字列の末尾が指定した文字列で終わっているか調べる。
- Params:
-
- Text Word
- 比較したい文字列。