manpagez: man pages & more
info cln
Home | html | info | man
[ << ] [ < ] [ 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. The flags are 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 flags are parameters which affect the input syntax. The string starts at string and ends at string_limit (exclusive limit). string_limit may also be NULL, denoting the entire string, i.e. equivalent to string_limit = string + strlen(string). If end_of_parse is NULL, the string in memory must contain exactly one number and nothing more, else an exception will be thrown. If end_of_parse is not NULL, *end_of_parse will be assigned a pointer past the last parsed character (i.e. string_limit if nothing came after the number). Whitespace is not allowed.

The structure cl_read_flags contains the following fields:

cl_read_syntax_t syntax

The 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 lsyntax

Specifies the language-dependent syntax variant for the read operation. Possible values are

lsyntax_standard

accept standard algebraic notation only, no complex numbers,

lsyntax_algebraic

accept the algebraic notation x+yi for complex numbers,

lsyntax_commonlisp

accept the #b, #o, #x syntaxes for binary, octal, hexadecimal numbers, #baseR for rational numbers in a given base, #c(realpart imagpart) for complex numbers,

lsyntax_all

accept all of these extensions.

unsigned int rational_base

The base in which rational numbers are read.

float_format_t float_flags.default_float_format

The float format used when reading floats with exponent marker ‘e’.

float_format_t float_flags.default_lfloat_format

The float format used when reading floats with exponent marker ‘l’.

bool float_flags.mantissa_dependent_float_format

When 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.

© manpagez.com 2000-2017
Individual documents may contain additional copyright information.