Libecoli 0.11.1
Extensible COmmand LIne library
Loading...
Searching...
No Matches
Integer node

Nodes that match signed or unsigned integers. More...

Functions

struct ec_nodeec_node_int (const char *id, int64_t min, int64_t max, unsigned int base)
int ec_node_int_getval (const struct ec_node *node, const char *str, int64_t *result)
struct ec_nodeec_node_uint (const char *id, uint64_t min, uint64_t max, unsigned int base)
int ec_node_uint_getval (const struct ec_node *node, const char *str, uint64_t *result)

Detailed Description

Nodes that match signed or unsigned integers.

Configuration Schema

schema int {
int64 min {
description "The minimum valid value (included).";
}
int64 max {
description "The maximum valid value (included).";
}
uint64 base {
description "The base to use. If unset or 0, try to guess.";
}
}

Configuration Schema

schema uint {
uint64 min {
description "The minimum valid value (included).";
}
uint64 max {
description "The maximum valid value (included).";
}
uint64 base {
description "The base to use. If unset or 0, try to guess.";
}
}

Function Documentation

◆ ec_node_int()

struct ec_node * ec_node_int ( const char * id,
int64_t min,
int64_t max,
unsigned int base )

Create a signed integer node.

Parameters
idThe node identifier.
minThe minimum valid value (included).
maxThe maximum valid value (included).
baseThe base to use for parsing. If 0, try to guess from prefix.
Returns
The node, or NULL on error (errno is set).
Examples
readline/main.c, and simple-editline/main.c.

◆ ec_node_int_getval()

int ec_node_int_getval ( const struct ec_node * node,
const char * str,
int64_t * result )

Get the value of a parsed signed integer.

Parameters
nodeThe integer node.
strThe string to parse.
resultPointer where the result will be stored on success.
Returns
0 on success, -1 on error (errno is set).

◆ ec_node_uint()

struct ec_node * ec_node_uint ( const char * id,
uint64_t min,
uint64_t max,
unsigned int base )

Create an unsigned integer node.

Parameters
idThe node identifier.
minThe minimum valid value (included).
maxThe maximum valid value (included).
baseThe base to use for parsing. If 0, try to guess from prefix.
Returns
The node, or NULL on error (errno is set).

◆ ec_node_uint_getval()

int ec_node_uint_getval ( const struct ec_node * node,
const char * str,
uint64_t * result )

Get the value of a parsed unsigned integer.

Parameters
nodeThe unsigned integer node.
strThe string to parse.
resultPointer where the result will be stored on success.
Returns
0 on success, -1 on error (errno is set).