Yimmo YAML ============== warning:: This module is a hack! .. c:type:: ymo_yaml_type_t YMO Yaml node type. .. code-block:: c :caption: Definition typedef enum { YMO_YAML_ERROR, YMO_YAML_OBJECT, YMO_YAML_SCALAR, YMO_YAML_SEQUENCE, } ymo_yaml_type_t; .. c:type:: ymo_yaml_doc_t Opaque type reprsenting a yaml doc. .. code-block:: c :caption: Definition typedef struct ymo_yaml_doc ymo_yaml_doc_t; .. c:type:: ymo_yaml_node_t Opaque type reprsenting a yaml node. .. code-block:: c :caption: Definition typedef struct ymo_yaml_node ymo_yaml_node_t; Doc Functions ------------- .. c:function:: ymo_yaml_doc_t* ymo_yaml_load_file(const char* f_path) Load a yaml document from the given file path. TODO: Probably, it'd be nice to be able to load from FILE* or memory too. :param f_path: the file to load the yaml from :returns: pointer to yaml doc; else return ``null`` and set ``errno`` .. c:function:: const char* ymo_yaml_doc_filepath(const ymo_yaml_doc_t* doc) Get the file path for a loaded yaml doc. .. c:function:: ymo_yaml_node_t* ymo_yaml_doc_root(const ymo_yaml_doc_t* doc) Get the root node for a YAML document. .. c:function:: void ymo_yaml_doc_print_json_hack(FILE* out_file, const ymo_yaml_doc_t* doc) Added for debug. Probably, don't use this. It's going away (or else going to be significantly refactored. .. c:function:: void ymo_yaml_doc_free(ymo_yaml_doc_t* doc) Free a yaml doc. Node Functions -------------- TODO: scalar, sequence, and type conversion stuff ala ymo_env. --------------------------------------------------------------- .. c:function:: ymo_yaml_type_t ymo_yaml_node_type(const ymo_yaml_node_t* node) Given a yaml item, return its type. .. c:function:: const ymo_yaml_node_t* ymo_yaml_item_next(const ymo_yaml_node_t* list, const ymo_yaml_node_t* current) Iterate over items in a list or keys in a mapping, one by one. Invoked the first time with current = NULL; .. c:function:: const ymo_yaml_node_t* ymo_yaml_doc_get(ymo_yaml_doc_t* doc, ...); Given a set of keys, return the value of the first yaml node that matches. .. c:function:: const ymo_yaml_node_t* ymo_yaml_doc_vget(ymo_yaml_doc_t* doc, va_list args) Given a set of keys, return the value of the first yaml node that matches. .. c:function:: const ymo_yaml_node_t* ymo_yaml_object_get(const ymo_yaml_node_t* node, const char* key) Given a yaml object, return the value for the given key as a yaml node. .. c:function:: const ymo_yaml_node_t* ymo_yaml_node_child(const ymo_yaml_node_t* key) Given a yaml node representing a mapping key, return the value node. .. c:function:: const char* ymo_yaml_node_as_str(const ymo_yaml_node_t* node) Given a yaml object, return the value as a string. .. c:function:: int ymo_yaml_node_as_long(const ymo_yaml_node_t* node, long* value) Given a yaml object, return the value as a long. .. c:function:: int ymo_yaml_node_as_float(const ymo_yaml_node_t* node, float* value) Given a yaml object, return the value as a float.