- A
boolifdoCountis set toNo.doCount - A
tuplecontaining abooland asize_tifdoCountis set toYes.doCount
parse
auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source source) if (is(immutable Target == immutable bool) &&
isInputRange!Source &&
isSomeChar!(ElementType!Source))parse family of functions works quite like the to
family, except that:
- It only works with character ranges as input.
- It takes the input by reference. This means that rvalues (such
as string literals) are not accepted: use
toinstead. - It advances the input to the position following the conversion.
- It does not throw if it could not convert the entire input.
This overload parses a bool from a character input range.
Parameters
Target | the boolean type to convert to |
source | the lvalue of an input range |
doCount | the flag for deciding to report the number of consumed characters |
Returns
Throws
bool.Note
to parse and do not require lvalues.
auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref scope Source s) if (isIntegral!Target && !is(Target == enum) &&
isSomeChar!(ElementType!Source))Parses an integer from a character input range.
Parameters
Target | the integral type to convert to |
s | the lvalue of an input range |
doCount | the flag for deciding to report the number of consumed characters |
Returns
- A number of type
TargetifdoCountis set toNo.doCount - A
tuplecontaining a number of typeTargetand asize_tifdoCountis set toYes.doCount
Throws
if no character of the input was meaningfully converted.
auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source source, uint radix) if (isIntegral!Target && !is(Target == enum) &&
isSomeChar!(ElementType!Source))ditto
auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source s) if (is(Target == enum) && isSomeString!Source && !is(Source == enum))Parses an enum type from a string representing an enum member name.
Parameters
Target | the enum type to convert to |
s | the lvalue of the range to _parse |
doCount | the flag for deciding to report the number of consumed characters |
Returns
- An
enumof typeTargetifdoCountis set toNo.doCount - A
tuplecontaining anenumof typeTargetand asize_tifdoCountis set toYes.doCount
Throws
auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source source) if (isFloatingPoint!Target && !is(Target == enum) &&
isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum))Parses a floating point number from a character range.
Parameters
Target | a floating point type |
source | the lvalue of the range to _parse |
doCount | the flag for deciding to report the number of consumed characters |
Returns
- A floating point number of type
TargetifdoCountis set toNo.doCount - A
tuplecontaining a floating point number of·typeTargetand asize_tif
doCountis set toYes.doCount
Throws
auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source s) if (staticIndexOf!(immutable Target, immutable dchar, immutable ElementEncodingType!Source) >= 0 &&
isSomeString!Source && !is(Source == enum))Parses one character from a character range.
Parameters
Target | the type to convert to |
s | the lvalue of an input range |
doCount | the flag for deciding to report the number of consumed characters |
Returns
- A character of type
TargetifdoCountis set toNo.doCount - A
tuplecontaining a character of typeTargetand asize_tifdoCountis set toYes.doCount
Throws
auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source s) if (isSomeChar!Target && Target.sizeof >= ElementType!Source.sizeof && !is(Target == enum) &&
!isSomeString!Source && isInputRange!Source && isSomeChar!(ElementType!Source))ditto
auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source s) if (is(immutable Target == immutable typeof(null)) &&
isInputRange!Source &&
isSomeChar!(ElementType!Source))Parses typeof(null) from a character range if the range spells "null". This function is case insensitive.
Parameters
Target | the type to convert to |
s | the lvalue of an input range |
doCount | the flag for deciding to report the number of consumed characters |
Returns
nullifdoCountis set toNo.doCount- A
tuplecontainingnulland asize_tifdoCountis set toYes.doCount
Throws
null.auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source s, dchar lbracket = '[',
dchar rbracket = ']', dchar comma = ',') if (isDynamicArray!Target && !is(Target == enum) &&
isSomeString!Source && !is(Source == enum))Parses an array from a string given the left bracket (default '['), right bracket (default `']'`), and element separator (by default `','`). A trailing separator is allowed.
Parameters
s | The string to parse |
lbracket | the character that starts the array |
rbracket | the character that ends the array |
comma | the character that separates the elements of the array |
doCount | the flag for deciding to report the number of consumed characters |
Returns
- An array of type
TargetifdoCountis set toNo.doCount - A
tuplecontaining an array of typeTargetand asize_tifdoCountis set toYes.doCount
auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source s, dchar lbracket = '[',
dchar rbracket = ']', dchar comma = ',') if (isStaticArray!Target && !is(Target == enum) &&
isExactSomeString!Source)ditto
auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source s, dchar lbracket = '[',
dchar rbracket = ']', dchar keyval = ':', dchar comma = ',') if (isAssociativeArray!Target && !is(Target == enum) &&
isSomeString!Source && !is(Source == enum))Parses an associative array from a string given the left bracket (default '['), right bracket (default `']'`), key-value separator (default ':'), and element seprator (by default `','`).
Parameters
s | the string to parse |
lbracket | the character that starts the associative array |
rbracket | the character that ends the associative array |
keyval | the character that associates the key with the value |
comma | the character that separates the elements of the associative array |
doCount | the flag for deciding to report the number of consumed characters |
Returns
- An associative array of type
TargetifdoCountis set toNo.doCount - A
tuplecontaining an associative array of typeTargetand asize_tif
doCountis set toYes.doCount