| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
5.2 Input functions
Including <cln/io.h> defines flexible input functions:
cl_N read_complex (std::istream& stream, const cl_read_flags& flags)cl_R read_real (std::istream& stream, const cl_read_flags& flags)cl_F read_float (std::istream& stream, const cl_read_flags& flags)cl_RA read_rational (std::istream& stream, const cl_read_flags& flags)cl_I read_integer (std::istream& stream, const cl_read_flags& flags)Reads a number from
stream. Theflagsare parameters which affect the input syntax. Whitespace before the number is silently skipped.cl_N read_complex (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse)cl_R read_real (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse)cl_F read_float (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse)cl_RA read_rational (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse)cl_I read_integer (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse)Reads a number from a string in memory. The
flagsare parameters which affect the input syntax. The string starts atstringand ends atstring_limit(exclusive limit).string_limitmay also beNULL, denoting the entire string, i.e. equivalent tostring_limit = string + strlen(string). Ifend_of_parseisNULL, the string in memory must contain exactly one number and nothing more, else an exception will be thrown. Ifend_of_parseis notNULL,*end_of_parsewill be assigned a pointer past the last parsed character (i.e.string_limitif nothing came after the number). Whitespace is not allowed.
The structure cl_read_flags contains the following fields:
cl_read_syntax_t syntaxThe possible results of the read operation. Possible values are
syntax_number,syntax_real,syntax_rational,syntax_integer,syntax_float,syntax_sfloat,syntax_ffloat,syntax_dfloat,syntax_lfloat.cl_read_lsyntax_t lsyntaxSpecifies the language-dependent syntax variant for the read operation. Possible values are
lsyntax_standardaccept standard algebraic notation only, no complex numbers,
lsyntax_algebraicaccept the algebraic notation
x+yifor complex numbers,lsyntax_commonlispaccept the
#b,#o,#xsyntaxes for binary, octal, hexadecimal numbers,#baseRfor rational numbers in a given base,#c(realpart imagpart)for complex numbers,lsyntax_allaccept all of these extensions.
unsigned int rational_baseThe base in which rational numbers are read.
float_format_t float_flags.default_float_formatThe float format used when reading floats with exponent marker ‘e’.
float_format_t float_flags.default_lfloat_formatThe float format used when reading floats with exponent marker ‘l’.
bool float_flags.mantissa_dependent_float_formatWhen this flag is true, floats specified with more digits than corresponding to the exponent marker they contain, but without _nnn suffix, will get a precision corresponding to their number of significant digits.
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on August 27, 2013 using texi2html 5.0.
