Libecoli  0.11.3
Extensible COmmand LIne library
Macros | Functions
Subset node

A node that matches any subset of its children in any order. More...

Macros

#define EC_NODE_SUBSET(args...)   __ec_node_subset(args, EC_VA_END)
 

Functions

struct ec_nodeec_node_subset (const char *id)
 
struct ec_nodeec_node_subset_min (const char *id, unsigned int min)
 
int ec_node_subset_add (struct ec_node *node, struct ec_node *child)
 
int ec_node_subset_set_min (struct ec_node *node, unsigned int min)
 
unsigned int ec_node_subset_get_min (const struct ec_node *node)
 

Detailed Description

A node that matches any subset of its children in any order.

Configuration Schema

No configuration schema.

Macro Definition Documentation

◆ EC_NODE_SUBSET

#define EC_NODE_SUBSET (   args...)    __ec_node_subset(args, EC_VA_END)

Create a subset node from a list of child nodes.

A subset node matches any permutation of a subset of its children. All child nodes passed as arguments are consumed and will be freed when the subset node is freed, or immediately on error.

Example:

EC_NODE_SUBSET("mysubset", child1, child2, child3)
#define EC_NODE_SUBSET(args...)
Definition: node_subset.h:30

Definition at line 30 of file node_subset.h.

Function Documentation

◆ ec_node_subset()

struct ec_node* ec_node_subset ( const char *  id)

Create an empty subset node.

Use ec_node_subset_add() to add children.

Parameters
idThe node identifier.
Returns
The node, or NULL on error (errno is set).

◆ ec_node_subset_min()

struct ec_node* ec_node_subset_min ( const char *  id,
unsigned int  min 
)

Create an empty subset node with a minimum number of children that must match.

Use ec_node_subset_add() to add children.

Parameters
idThe node identifier.
minThe minimum number of children that must match.
Returns
The node, or NULL on error (errno is set).

◆ ec_node_subset_add()

int ec_node_subset_add ( struct ec_node node,
struct ec_node child 
)

Add a child to a subset node.

Parameters
nodeThe subset node.
childThe child node to add. It is consumed and will be freed when the parent is freed, or immediately on error.
Returns
0 on success, -1 on error (errno is set).

◆ ec_node_subset_set_min()

int ec_node_subset_set_min ( struct ec_node node,
unsigned int  min 
)

Set the minimum number of children that must match.

By default, a subset node accepts zero matching children. Use this function to require a minimum number of children to match for the parse to succeed.

Parameters
nodeThe subset node.
minThe minimum number of children that must match.
Returns
0 on success, -1 on error (errno is set).

◆ ec_node_subset_get_min()

unsigned int ec_node_subset_get_min ( const struct ec_node node)

Get the minimum number of children that must match.

Parameters
nodeThe subset node.
Returns
The minimum number, or 0 if the node is not a subset.