英語版
このページの英語版を見る

rt.aApply

このコードは、foreachループのUTF文字列のデコードを処理する。
Authors:
Walter Bright

ソース rt/aApply.d

alias dg_t = int delegate(void* c);
変換されたループ本体に対応するデリゲート型
パラメータは、現在のcharwchar またはdchar
Returns:
break
int _aApplycd1(scope const(char)[] aa, dg_t dg);

int _aApplywd1(scope const(wchar)[] aa, dg_t dg);

int _aApplycw1(scope const(char)[] aa, dg_t dg);

int _aApplywc1(scope const(wchar)[] aa, dg_t dg);

int _aApplydc1(scope const(dchar)[] aa, dg_t dg);

int _aApplydw1(scope const(dchar)[] aa, dg_t dg);
UTFエンコーディングを変更しながら文字列をループする
charwchardchar の間に6つの変換の組み合わせがある、 そして、それぞれ2つずつある。
命名規則は以下の通りである:
aApply{c,d,w}{c,d,w}{1,2}
最初の文字は入力文字列エンコーディングに対応し、2番目の文字はターゲット文字型に対応する。
  • c =char
  • w =wchar
  • d =dchar
1 、文字を生成する。2 、ループ・インデックスも生成する。
Examples:
void main()
{
    string str;
    wtring wstr;
    dstring dstr;

    foreach (dchar c; str) {}
    // _aApplycd1

    foreach (wchar c; dstr) {}
    // _aApplydw1

    foreach (i, wchar c; str) {}
    // _aApplycw2

    foreach (wchar w; wstr) {}
    // 無変換
}
Parameters:
const(char)[] aa 入力文字列
dg_t dg foreach本体は、以下のようなデリゲートに変換される。opApply
Returns:
ループがbreak
alias dg2_t = int delegate(void* i, void* c);
変換されたループ本体に対応するDelegate型を通してループを抜けたとき、0でない。
パラメータは、size_t ループインデックスへのポインタと、現在のcharwchar またはdchar
Returns:
break 、ゼロでない。
int _aApplycd2(scope const(char)[] aa, dg2_t dg);

int _aApplywd2(scope const(wchar)[] aa, dg2_t dg);

int _aApplycw2(scope const(char)[] aa, dg2_t dg);

int _aApplywc2(scope const(wchar)[] aa, dg2_t dg);

int _aApplydc2(scope const(dchar)[] aa, dg2_t dg);

int _aApplydw2(scope const(dchar)[] aa, dg2_t dg);
ループ・インデックスを含むaApplyXXXのバリエーション。