Function yaml_document_append_mapping_pair

Synopsis

#include <include/yaml.h>

int yaml_document_append_mapping_pair(yaml_document_t *document, int mapping, int key, int value)

Description

Add a pair of a key and a value to a MAPPING node.

Parameters:

[ in,out ] document - A document object.

[ in ] mapping - The mapping node id.

[ in ] key - The key node id.

[ in ] value - The value node id.

Return
1 if the function succeeded, 0 on error.
Append a pair of a key and a value to a mapping node.

Source

Lines 1362-1391 in src/api.c. Line 960 in include/yaml.h.

YAML_DECLARE(int)
yaml_document_append_mapping_pair(yaml_document_t *document,
        int mapping, int key, int value)
{
    struct {
        yaml_error_type_t error;
    } context;

    yaml_node_pair_t pair;

    assert(document);       /* Non-NULL document is required. */
    assert(mapping > 0
            && document->nodes.start + mapping <= document->nodes.top);
                            /* Valid mapping id is required. */
    assert(document->nodes.start[mapping-1].type == YAML_MAPPING_NODE);
                            /* A mapping node is required. */
    assert(key > 0 && document->nodes.start + key <= document->nodes.top);
                            /* Valid key id is required. */
    assert(value > 0 && document->nodes.start + value <= document->nodes.top);
                            /* Valid value id is required. */

    pair.key = key;
    pair.value = value;

    if (!PUSH(&context,
                document->nodes.start[mapping-1].data.mapping.pairs, pair))
        return 0;

    return 1;
}





Add Discussion as Guest

Log in to DocsForge