- A
boolifdoCountis set toNo.doCount - A
tuplecontaining abooland asize_tifdoCountis set toYes.doCount
parse
fn
auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source source) if (is(immutable Target == immutable bool) &&
isInputRange!Source &&
isSomeChar!(ElementType!Source))The
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
A ConvException if the range does not represent a
bool.Note
All character input range conversions using to are forwarded
to parse and do not require lvalues.
fn
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
A ConvException If an overflow occurred during conversion or
if no character of the input was meaningfully converted.
fn
auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source source, uint radix) if (isIntegral!Target && !is(Target == enum) &&
isSomeChar!(ElementType!Source))ditto
fn
auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source s) if (is(Target == enum) && isSomeString!Source && !is(Source == enum))- Parses an
enumtype from a string representing an enum member name.Parameters
fn
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
fn
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
A ConvException if the range is empty.
fn
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
fn
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
A ConvException if the range doesn't represent
null.fn
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
'Parameters
fn
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
fn
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
'Parameters