Movatterモバイル変換


[0]ホーム

URL:


D Logo
Menu
Search

Library Reference

version 2.112.0

overview

Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.Requires a signed-in GitHub account. This works well for small changes.If you'd like to make larger changes you may want to consider usinga local clone.

rt.aApply

This code handles decoding UTF strings for foreach loops.
License:
Boost License 1.0.
Authors:
Walter Bright

Sourcert/aApply.d

aliasdg_t = int delegate(void* c);
Delegate type corresponding to transformed loop body
The parameter is a pointer to the currentchar,wchar ordchar
Returns:
non-zero when abreak statement is hit
int_aApplycd1(scope const(char)[]aa, dg_tdg);

int_aApplywd1(scope const(wchar)[]aa, dg_tdg);

int_aApplycw1(scope const(char)[]aa, dg_tdg);

int_aApplywc1(scope const(wchar)[]aa, dg_tdg);

int_aApplydc1(scope const(dchar)[]aa, dg_tdg);

int_aApplydw1(scope const(dchar)[]aa, dg_tdg);
Loop over a string while changing the UTF encoding
There are 6 combinations of conversions betweenchar,wchar, anddchar,and 2 of each of those.
The naming convention is as follows:
aApply{c,d,w}{c,d,w}{1,2}
The first letter corresponds to the input string encoding, and the second letter corresponds to the target character type.
  • c =char
  • w =wchar
  • d =dchar
The1 variant only produces the character, the2 variant also produces a loop index.
Examples:
void main(){    string str;    wtring wstr;    dstring dstr;foreach (dchar c; str) {}// _aApplycd1foreach (wchar c; dstr) {}// _aApplydw1foreach (i,wchar c; str) {}// _aApplycw2foreach (wchar w; wstr) {}// no conversion}
Parameters:
const(char)[]aainput string
dg_tdgforeach body transformed into a delegate, similar toopApply
Returns:
non-zero when the loop was exited through abreak
aliasdg2_t = int delegate(void* i, void* c);
Delegate type corresponding to transformed loop body
Parameters are pointers to asize_t loop index, and the currentchar,wchar ordchar.
Returns:
non-zero when abreak statement is hit
int_aApplycd2(scope const(char)[]aa, dg2_tdg);

int_aApplywd2(scope const(wchar)[]aa, dg2_tdg);

int_aApplycw2(scope const(char)[]aa, dg2_tdg);

int_aApplywc2(scope const(wchar)[]aa, dg2_tdg);

int_aApplydc2(scope const(dchar)[]aa, dg2_tdg);

int_aApplydw2(scope const(dchar)[]aa, dg2_tdg);
Variants of aApplyXXX that include a loop index.
Copyright © 1999-2026 by theD Language Foundation | Page generated byDdoc on Sat Feb 21 00:06:41 2026

[8]ページ先頭

©2009-2026 Movatter.jp