| 1821 | | * Get the value of a `!!null` SCALAR node. |
|---|
| 1822 | | * |
|---|
| 1823 | | * Use this function to ensure that the given node is a scalar, the node tag is |
|---|
| 1824 | | * equal to `tag:yaml.org,2002:null` and the node value is a valid null value. |
|---|
| 1825 | | * Given that the `!!null` tag admits only one valid value, the value is not |
|---|
| 1826 | | * returned. |
|---|
| 1827 | | * |
|---|
| 1828 | | * Arguments: |
|---|
| 1829 | | * |
|---|
| 1830 | | * - `document`: a document object. |
|---|
| 1831 | | * |
|---|
| 1832 | | * - `node_id`: the node id; could be negative. |
|---|
| 1833 | | * |
|---|
| 1834 | | * Returns: `1` if the node is a valid `!!null` scalar, `0` otherwise. |
|---|
| 1835 | | */ |
|---|
| 1836 | | |
|---|
| 1837 | | YAML_DECLARE(int) |
|---|
| 1838 | | yaml_document_get_null_node(yaml_document_t *document, int node_id); |
|---|
| 1839 | | |
|---|
| 1840 | | /* |
|---|
| 1841 | | * Get the value of a `!!bool` SCALAR node. |
|---|
| 1842 | | * |
|---|
| 1843 | | * Use this function to ensure that the given node is a scalar, the node tag is |
|---|
| 1844 | | * `tag:yaml.org,2002:bool` and the node value is a valid boolean value. The |
|---|
| 1845 | | * function returns the true value as `1` and the false value as `0`. |
|---|
| 1846 | | * |
|---|
| 1847 | | * Arguments: |
|---|
| 1848 | | * |
|---|
| 1849 | | * - `document`: a document object. |
|---|
| 1850 | | * |
|---|
| 1851 | | * - `node_id`: the node id; could be negative. |
|---|
| 1852 | | * |
|---|
| 1853 | | * - `value`: a pointer to save the node value or `NULL`. |
|---|
| 1854 | | * |
|---|
| 1855 | | * Returns: `1` if the node is a valid `!!bool` scalar, `0` otherwise. If the |
|---|
| 1856 | | * function succeeds and `value` is not `NULL`, the node value is saved to |
|---|
| 1857 | | * `value`. |
|---|
| 1858 | | */ |
|---|
| 1859 | | |
|---|
| 1860 | | YAML_DECLARE(int) |
|---|
| 1861 | | yaml_document_get_bool_node(yaml_document_t *document, int node_id, |
|---|
| 1862 | | int *value); |
|---|
| 1863 | | |
|---|
| 1864 | | /* |
|---|
| 1865 | | * Get the value of a `!!str` SCALAR node. |
|---|
| 1866 | | * |
|---|
| 1867 | | * Use this function to ensure that the given node is a scalar, the node tag is |
|---|
| 1868 | | * `tag:yaml.org,2002:str` and the node value is a string that does not contain |
|---|
| 1869 | | * the NUL character. In this case, the function returns the node value. The |
|---|
| 1870 | | * produced value is valid until the document object is cleared or deleted. |
|---|
| 1871 | | * |
|---|
| 1872 | | * Arguments: |
|---|
| 1873 | | * |
|---|
| 1874 | | * - `document`: a document object. |
|---|
| 1875 | | * |
|---|
| 1876 | | * - `node_id`: the node id; could be negative. |
|---|
| 1877 | | * |
|---|
| 1878 | | * - `value`: a pointer to save the node value or `NULL`. |
|---|
| 1879 | | * |
|---|
| 1880 | | * Returns: `1` if the node is a valid `!!str` scalar, `0` otherwise. If the |
|---|
| 1881 | | * function succeeds and `value` is not `NULL`, the node value is saved to |
|---|
| 1882 | | * `value`. |
|---|
| 1883 | | */ |
|---|
| 1884 | | |
|---|
| 1885 | | YAML_DECLARE(int) |
|---|
| 1886 | | yaml_document_get_str_node(yaml_document_t *document, int node_id, |
|---|
| 1887 | | char **value); |
|---|
| 1888 | | |
|---|
| 1889 | | /* |
|---|
| 1890 | | * Get the value of an `!!int` SCALAR node. |
|---|
| 1891 | | * |
|---|
| 1892 | | * Use this function to ensure that the given node is a scalar, the node tag is |
|---|
| 1893 | | * `tag:yaml.org,2002:int` and the node value is a valid integer. In this |
|---|
| 1894 | | * case, the function parses the node value and returns an integer number. The |
|---|
| 1895 | | * function recognizes decimal, hexdecimal and octal numbers including negative |
|---|
| 1896 | | * numbers. |
|---|
| 1897 | | * |
|---|
| 1898 | | * Arguments: |
|---|
| 1899 | | * |
|---|
| 1900 | | * - `document`: a document object. |
|---|
| 1901 | | * |
|---|
| 1902 | | * - `node_id`: the node id; could be negative. |
|---|
| 1903 | | * |
|---|
| 1904 | | * - `value`: a pointer to save the node value or `NULL`. |
|---|
| 1905 | | * |
|---|
| 1906 | | * Returns: `1` if the node is a valid `!!int` scalar, `0` otherwise. If the |
|---|
| 1907 | | * function succeeds and `value` is not `NULL`, the node value is saved to |
|---|
| 1908 | | * `value`. |
|---|
| 1909 | | */ |
|---|
| 1910 | | |
|---|
| 1911 | | YAML_DECLARE(int) |
|---|
| 1912 | | yaml_document_get_int_node(yaml_document_t *document, int node_id, |
|---|
| 1913 | | int *value); |
|---|
| 1914 | | |
|---|
| 1915 | | /* |
|---|
| 1916 | | * Get the value of a `!!float` SCALAR node. |
|---|
| 1917 | | * |
|---|
| 1918 | | * Use this function to ensure that the given node is a scalar, the node tag is |
|---|
| 1919 | | * `tag:yaml.org,2002:float` and the node value is a valid float value. In |
|---|
| 1920 | | * this case, the function parses the node value and returns a float number. |
|---|
| 1921 | | * The function recognizes float values in exponential and fixed notation as |
|---|
| 1922 | | * well as special values `.nan`, `.inf` and `-.inf`. |
|---|
| 1923 | | * |
|---|
| 1924 | | * Arguments: |
|---|
| 1925 | | * |
|---|
| 1926 | | * - `document`: a document object. |
|---|
| 1927 | | * |
|---|
| 1928 | | * - `node_id`: the node id; could be negative. |
|---|
| 1929 | | * |
|---|
| 1930 | | * - `value`: a pointer to save the node value or `NULL`. |
|---|
| 1931 | | * |
|---|
| 1932 | | * Returns: `1` if the node is a valid `!!float` scalar, `0` otherwise. If the |
|---|
| 1933 | | * function succeeds and `value` is not `NULL`, the node value is saved to |
|---|
| 1934 | | * `value`. |
|---|
| 1935 | | */ |
|---|
| 1936 | | |
|---|
| 1937 | | YAML_DECLARE(int) |
|---|
| 1938 | | yaml_document_get_float_node(yaml_document_t *document, int node_id, |
|---|
| 1939 | | double *value); |
|---|
| 1940 | | |
|---|
| 1941 | | /* |
|---|
| 1942 | | * Get the value of a `!!seq` SEQUENCE node. |
|---|
| 1943 | | * |
|---|
| 1944 | | * Use this function to ensure that the given node is a sequence and the node |
|---|
| 1945 | | * tag is `tag:yaml.org,2002:seq`. In this case, the function returns the list |
|---|
| 1946 | | * of nodes that belong to the sequence. The produced list is valid until the |
|---|
| 1947 | | * document object is modified. |
|---|
| 1948 | | * |
|---|
| 1949 | | * Arguments: |
|---|
| 1950 | | * |
|---|
| 1951 | | * - `document`: a document object. |
|---|
| 1952 | | * |
|---|
| 1953 | | * - `node_id`: the node id; could be negative. |
|---|
| 1954 | | * |
|---|
| 1955 | | * - `items`: a pointer to save the list of sequence items or `NULL`. |
|---|
| 1956 | | * |
|---|
| 1957 | | * - `length`: a pointer to save the length of the sequence or `NULL`. |
|---|
| 1958 | | * `length` must be equal to `NULL` if and only if `items` is also `NULL`. |
|---|
| 1959 | | * |
|---|
| 1960 | | * Returns: `1` if the node is a valid `!!seq` sequence, `0` otherwise. If the |
|---|
| 1961 | | * function succeeds and `items` is not `NULL`, the list of sequence items is |
|---|
| 1962 | | * saved to `items` and the sequence length is saved to `length`. |
|---|
| 1963 | | */ |
|---|
| 1964 | | |
|---|
| 1965 | | YAML_DECLARE(int) |
|---|
| 1966 | | yaml_document_get_seq_node(yaml_document_t *document, int node_id, |
|---|
| 1967 | | yaml_node_item_t **items, size_t *length); |
|---|
| 1968 | | |
|---|
| 1969 | | /* |
|---|
| 1970 | | * Get the value of a `!!map` MAPPING node. |
|---|
| 1971 | | * |
|---|
| 1972 | | * Use this function to ensure that the given node is a mapping and the node |
|---|
| 1973 | | * tag is `tag:yaml.org,2002:map`. In this case, the function returns the list |
|---|
| 1974 | | * of node pairs (key, value) that belong to the sequence. The produced list |
|---|
| 1975 | | * is valid until the document is modified. |
|---|
| 1976 | | * |
|---|
| 1977 | | * Arguments: |
|---|
| 1978 | | * |
|---|
| 1979 | | * - `document`: a document object. |
|---|
| 1980 | | * |
|---|
| 1981 | | * - `node_id`: the node id; could be negative. |
|---|
| 1982 | | * |
|---|
| 1983 | | * - `pairs`: a pointer to save the list of mapping pairs or `NULL`. |
|---|
| 1984 | | * |
|---|
| 1985 | | * - `length`: a pointer to save the length of the mapping or `NULL`. |
|---|
| 1986 | | * `length` must be equal to `NULL` if and only if `pairs` is also `NULL`. |
|---|
| 1987 | | * |
|---|
| 1988 | | * Returns: `1` if the node is a valid `!!map` mapping, `0` otherwise. If the |
|---|
| 1989 | | * function succeeds and `pairs` is not `NULL`, the list of mapping pairs is |
|---|
| 1990 | | * saved to `pairs` and the mapping length is saved to `length`. |
|---|
| 1991 | | */ |
|---|
| 1992 | | |
|---|
| 1993 | | YAML_DECLARE(int) |
|---|
| 1994 | | yaml_document_get_map_node(yaml_document_t *document, int node_id, |
|---|
| 1995 | | yaml_node_pair_t **pairs, size_t *length); |
|---|
| 1996 | | |
|---|
| 1997 | | /* |
|---|
| 1998 | | * Add a `!!null` SCALAR node to the document. |
|---|
| 1999 | | * |
|---|
| 2000 | | * This function is a shorthand for the call: |
|---|
| 2001 | | * |
|---|
| 2002 | | * yaml_document_add_scalar(document, node_id, NULL, |
|---|
| 2003 | | * YAML_NULL_TAG, "null", -1, YAML_ANY_SCALAR_STYLE) |
|---|
| 2004 | | * |
|---|
| 2005 | | * Arguments: |
|---|
| 2006 | | * |
|---|
| 2007 | | * - `document`: a document object. |
|---|
| 2008 | | * |
|---|
| 2009 | | * - `node_id`: a pointer to save the id of the generated node or `NULL`. |
|---|
| 2010 | | * |
|---|
| 2011 | | * Returns: `1` on success, `0` on error. The function may fail if it cannot |
|---|
| 2012 | | * allocate memory for new buffers. If the function succeeds, the id of the |
|---|
| 2013 | | * added node is returned via the pointer `node_id` if it is not set to `NULL`. |
|---|
| 2014 | | */ |
|---|
| 2015 | | |
|---|
| 2016 | | YAML_DECLARE(int) |
|---|
| 2017 | | yaml_document_add_null_node(yaml_document_t *document, int *node_id); |
|---|
| 2018 | | |
|---|
| 2019 | | /* |
|---|
| 2020 | | * Add a `!!bool` SCALAR node to the document. |
|---|
| 2021 | | * |
|---|
| 2022 | | * This function is a shorthand for the call: |
|---|
| 2023 | | * |
|---|
| 2024 | | * yaml_document_add_scalar(document, node_id, NULL, |
|---|
| 2025 | | * YAML_BOOL_TAG, (value ? "true" : "false"), -1, |
|---|
| 2026 | | * YAML_ANY_SCALAR_STYLE) |
|---|
| 2027 | | * |
|---|
| 2028 | | * Arguments: |
|---|
| 2029 | | * |
|---|
| 2030 | | * - `document`: a document object. |
|---|
| 2031 | | * |
|---|
| 2032 | | * - `node_id`: a pointer to save the id of the generated node or `NULL`. |
|---|
| 2033 | | * |
|---|
| 2034 | | * - `value`: a boolean value; any non-zero value is true, `0` is false. |
|---|
| 2035 | | * |
|---|
| 2036 | | * Returns: `1` on success, `0` on error. The function may fail if it cannot |
|---|
| 2037 | | * allocate memory for new buffers. If the function succeeds, the id of the |
|---|
| 2038 | | * added node is returned via the pointer `node_id` if it is not set to `NULL`. |
|---|
| 2039 | | */ |
|---|
| 2040 | | |
|---|
| 2041 | | YAML_DECLARE(int) |
|---|
| 2042 | | yaml_document_add_bool_node(yaml_document_t *document, int *node_id, |
|---|
| 2043 | | int value); |
|---|
| 2044 | | |
|---|
| 2045 | | /* |
|---|
| 2046 | | * Add a `!!str` SCALAR node to the document. |
|---|
| 2047 | | * |
|---|
| 2048 | | * This function is a shorthand for the call: |
|---|
| 2049 | | * |
|---|
| 2050 | | * yaml_document_add_scalar(document, node_id, NULL, |
|---|
| 2051 | | * YAML_STR_TAG, (const yaml_char_t *) value, -1, |
|---|
| 2052 | | * YAML_ANY_SCALAR_STYLE) |
|---|
| 2053 | | * |
|---|
| 2054 | | * Arguments: |
|---|
| 2055 | | * |
|---|
| 2056 | | * - `document`: a document object. |
|---|
| 2057 | | * |
|---|
| 2058 | | * - `node_id`: a pointer to save the id of the generated node or `NULL`. |
|---|
| 2059 | | * |
|---|
| 2060 | | * - `value`: a NUL-terminated UTF-8 string. The function does not check if |
|---|
| 2061 | | * `value` is a valid UTF-8 string, but if it is not so, the emitter will |
|---|
| 2062 | | * fail to emit the node. |
|---|
| 2063 | | * |
|---|
| 2064 | | * Returns: `1` on success, `0` on error. The function may fail if it cannot |
|---|
| 2065 | | * allocate memory for new buffers. If the function succeeds, the id of the |
|---|
| 2066 | | * added node is returned via the pointer `node_id` if it is not set to `NULL`. |
|---|
| 2067 | | */ |
|---|
| 2068 | | |
|---|
| 2069 | | YAML_DECLARE(int) |
|---|
| 2070 | | yaml_document_add_str_node(yaml_document_t *document, int *node_id, |
|---|
| 2071 | | const char *value); |
|---|
| 2072 | | |
|---|
| 2073 | | /* |
|---|
| 2074 | | * Add an `!!int` SCALAR node to the document. |
|---|
| 2075 | | * |
|---|
| 2076 | | * This function is a shorthand for the call: |
|---|
| 2077 | | * |
|---|
| 2078 | | * yaml_document_add_scalar(document, node_id, NULL, |
|---|
| 2079 | | * YAML_INT_TAG, <string representation of the value>, -1, |
|---|
| 2080 | | * YAML_ANY_SCALAR_STYLE) |
|---|
| 2081 | | * |
|---|
| 2082 | | * Arguments: |
|---|
| 2083 | | * |
|---|
| 2084 | | * - `document`: a document object. |
|---|
| 2085 | | * |
|---|
| 2086 | | * - `node_id`: a pointer to save the id of the generated node or `NULL`. |
|---|
| 2087 | | * |
|---|
| 2088 | | * - `value`: an integer value. |
|---|
| 2089 | | * |
|---|
| 2090 | | * Returns: `1` on success, `0` on error. The function may fail if it cannot |
|---|
| 2091 | | * allocate memory for new buffers. If the function succeeds, the id of the |
|---|
| 2092 | | * added node is returned via the pointer `node_id` if it is not set to `NULL`. |
|---|
| 2093 | | */ |
|---|
| 2094 | | |
|---|
| 2095 | | YAML_DECLARE(int) |
|---|
| 2096 | | yaml_document_add_int_node(yaml_document_t *document, int *node_id, |
|---|
| 2097 | | int value); |
|---|
| 2098 | | |
|---|
| 2099 | | /* |
|---|
| 2100 | | * Add a `!!float` SCALAR node to the document. |
|---|
| 2101 | | * |
|---|
| 2102 | | * This function is a shorthand for the call: |
|---|
| 2103 | | * |
|---|
| 2104 | | * yaml_document_add_scalar(document, node_id, NULL, |
|---|
| 2105 | | * YAML_FLOAT_TAG, <string representation of the value>, -1, |
|---|
| 2106 | | * YAML_ANY_SCALAR_STYLE) |
|---|
| 2107 | | * |
|---|
| 2108 | | * Arguments: |
|---|
| 2109 | | * |
|---|
| 2110 | | * - `document`: a document object. |
|---|
| 2111 | | * |
|---|
| 2112 | | * - `node_id`: a pointer to save the id of the generated node or `NULL`. |
|---|
| 2113 | | * |
|---|
| 2114 | | * - `value`: a float value. |
|---|
| 2115 | | * |
|---|
| 2116 | | * Returns: `1` on success, `0` on error. The function may fail if it cannot |
|---|
| 2117 | | * allocate memory for new buffers. If the function succeeds, the id of the |
|---|
| 2118 | | * added node is returned via the pointer `node_id` if it is not set to `NULL`. |
|---|
| 2119 | | */ |
|---|
| 2120 | | |
|---|
| 2121 | | YAML_DECLARE(int) |
|---|
| 2122 | | yaml_document_add_float_node(yaml_document_t *document, int *node_id, |
|---|
| 2123 | | double value); |
|---|
| 2124 | | |
|---|
| 2125 | | /* |
|---|
| 2126 | | * Add a `!!seq` SEQUENCE node to the document. |
|---|
| 2127 | | * |
|---|
| 2128 | | * This function is a shorthand for the call: |
|---|
| 2129 | | * |
|---|
| 2130 | | * yaml_document_add_sequence(document, node_id, NULL, |
|---|
| 2131 | | * YAML_SEQ_TAG, YAML_ANY_SEQUENCE_STYLE) |
|---|
| 2132 | | * |
|---|
| 2133 | | * Arguments: |
|---|
| 2134 | | * |
|---|
| 2135 | | * - `document`: a document object. |
|---|
| 2136 | | * |
|---|
| 2137 | | * - `node_id`: a pointer to save the id of the generated node or `NULL`. |
|---|
| 2138 | | * |
|---|
| 2139 | | * Returns: `1` on success, `0` on error. The function may fail if it cannot |
|---|
| 2140 | | * allocate memory for new buffers. If the function succeeds, the id of the |
|---|
| 2141 | | * added node is returned via the pointer `node_id` if it is not set to `NULL`. |
|---|
| 2142 | | */ |
|---|
| 2143 | | |
|---|
| 2144 | | YAML_DECLARE(int) |
|---|
| 2145 | | yaml_document_add_seq_node(yaml_document_t *document, int *node_id); |
|---|
| 2146 | | |
|---|
| 2147 | | /* |
|---|
| 2148 | | * Add a `!!map` MAPPING node to the document. |
|---|
| 2149 | | * |
|---|
| 2150 | | * This function is a shorthand for the call: |
|---|
| 2151 | | * |
|---|
| 2152 | | * yaml_document_add_mapping(document, node_id, NULL, |
|---|
| 2153 | | * YAML_MAP_TAG, YAML_ANY_MAPPING_STYLE) |
|---|
| 2154 | | * |
|---|
| 2155 | | * Arguments: |
|---|
| 2156 | | * |
|---|
| 2157 | | * - `document`: a document object. |
|---|
| 2158 | | * |
|---|
| 2159 | | * - `node_id`: a pointer to save the id of the generated node or `NULL`. |
|---|
| 2160 | | * |
|---|
| 2161 | | * Returns: `1` on success, `0` on error. The function may fail if it cannot |
|---|
| 2162 | | * allocate memory for new buffers. If the function succeeds, the id of the |
|---|
| 2163 | | * added node is returned via the pointer `node_id` if it is not set to `NULL`. |
|---|
| 2164 | | */ |
|---|
| 2165 | | |
|---|
| 2166 | | YAML_DECLARE(int) |
|---|
| 2167 | | yaml_document_add_map_node(yaml_document_t *document, int *node_id); |
|---|
| 2168 | | |
|---|
| 2169 | | /* |
|---|
| 2225 | | /****************************************************************************** |
|---|
| | 1902 | /* |
|---|
| | 1903 | * Get the value of a `!!null` SCALAR node. |
|---|
| | 1904 | * |
|---|
| | 1905 | * Use this function to ensure that the given node is a scalar, the node tag is |
|---|
| | 1906 | * equal to `tag:yaml.org,2002:null` and the node value is a valid null value. |
|---|
| | 1907 | * Given that the `!!null` tag admits only one valid value, the value is not |
|---|
| | 1908 | * returned. |
|---|
| | 1909 | * |
|---|
| | 1910 | * Arguments: |
|---|
| | 1911 | * |
|---|
| | 1912 | * - `document`: a document object. |
|---|
| | 1913 | * |
|---|
| | 1914 | * - `node_id`: the node id; could be negative. |
|---|
| | 1915 | * |
|---|
| | 1916 | * Returns: `1` if the node is a valid `!!null` scalar, `0` otherwise. |
|---|
| | 1917 | */ |
|---|
| | 1918 | |
|---|
| | 1919 | YAML_DECLARE(int) |
|---|
| | 1920 | yaml_document_get_null_node(yaml_document_t *document, int node_id); |
|---|
| | 1921 | |
|---|
| | 1922 | /* |
|---|
| | 1923 | * Get the value of a `!!bool` SCALAR node. |
|---|
| | 1924 | * |
|---|
| | 1925 | * Use this function to ensure that the given node is a scalar, the node tag is |
|---|
| | 1926 | * `tag:yaml.org,2002:bool` and the node value is a valid boolean value. The |
|---|
| | 1927 | * function returns the true value as `1` and the false value as `0`. |
|---|
| | 1928 | * |
|---|
| | 1929 | * Arguments: |
|---|
| | 1930 | * |
|---|
| | 1931 | * - `document`: a document object. |
|---|
| | 1932 | * |
|---|
| | 1933 | * - `node_id`: the node id; could be negative. |
|---|
| | 1934 | * |
|---|
| | 1935 | * - `value`: a pointer to save the node value or `NULL`. |
|---|
| | 1936 | * |
|---|
| | 1937 | * Returns: `1` if the node is a valid `!!bool` scalar, `0` otherwise. If the |
|---|
| | 1938 | * function succeeds and `value` is not `NULL`, the node value is saved to |
|---|
| | 1939 | * `value`. |
|---|
| | 1940 | */ |
|---|
| | 1941 | |
|---|
| | 1942 | YAML_DECLARE(int) |
|---|
| | 1943 | yaml_document_get_bool_node(yaml_document_t *document, int node_id, |
|---|
| | 1944 | int *value); |
|---|
| | 1945 | |
|---|
| | 1946 | /* |
|---|
| | 1947 | * Get the value of a `!!str` SCALAR node. |
|---|
| | 1948 | * |
|---|
| | 1949 | * Use this function to ensure that the given node is a scalar, the node tag is |
|---|
| | 1950 | * `tag:yaml.org,2002:str` and the node value is a string that does not contain |
|---|
| | 1951 | * the NUL character. In this case, the function returns the node value. The |
|---|
| | 1952 | * produced value is valid until the document object is cleared or deleted. |
|---|
| | 1953 | * |
|---|
| | 1954 | * Arguments: |
|---|
| | 1955 | * |
|---|
| | 1956 | * - `document`: a document object. |
|---|
| | 1957 | * |
|---|
| | 1958 | * - `node_id`: the node id; could be negative. |
|---|
| | 1959 | * |
|---|
| | 1960 | * - `value`: a pointer to save the node value or `NULL`. |
|---|
| | 1961 | * |
|---|
| | 1962 | * Returns: `1` if the node is a valid `!!str` scalar, `0` otherwise. If the |
|---|
| | 1963 | * function succeeds and `value` is not `NULL`, the node value is saved to |
|---|
| | 1964 | * `value`. |
|---|
| | 1965 | */ |
|---|
| | 1966 | |
|---|
| | 1967 | YAML_DECLARE(int) |
|---|
| | 1968 | yaml_document_get_str_node(yaml_document_t *document, int node_id, |
|---|
| | 1969 | char **value); |
|---|
| | 1970 | |
|---|
| | 1971 | /* |
|---|
| | 1972 | * Get the value of an `!!int` SCALAR node. |
|---|
| | 1973 | * |
|---|
| | 1974 | * Use this function to ensure that the given node is a scalar, the node tag is |
|---|
| | 1975 | * `tag:yaml.org,2002:int` and the node value is a valid integer. In this |
|---|
| | 1976 | * case, the function parses the node value and returns an integer number. The |
|---|
| | 1977 | * function recognizes decimal, hexdecimal and octal numbers including negative |
|---|
| | 1978 | * numbers. The function uses `strtol()` for string-to-integer conversion. |
|---|
| | 1979 | * |
|---|
| | 1980 | * Arguments: |
|---|
| | 1981 | * |
|---|
| | 1982 | * - `document`: a document object. |
|---|
| | 1983 | * |
|---|
| | 1984 | * - `node_id`: the node id; could be negative. |
|---|
| | 1985 | * |
|---|
| | 1986 | * - `value`: a pointer to save the node value or `NULL`. |
|---|
| | 1987 | * |
|---|
| | 1988 | * Returns: `1` if the node is a valid `!!int` scalar, `0` otherwise. If the |
|---|
| | 1989 | * function succeeds and `value` is not `NULL`, the node value is saved to |
|---|
| | 1990 | * `value`. |
|---|
| | 1991 | */ |
|---|
| | 1992 | |
|---|
| | 1993 | YAML_DECLARE(int) |
|---|
| | 1994 | yaml_document_get_int_node(yaml_document_t *document, int node_id, |
|---|
| | 1995 | long *value); |
|---|
| | 1996 | |
|---|
| | 1997 | /* |
|---|
| | 1998 | * Get the value of a `!!float` SCALAR node. |
|---|
| | 1999 | * |
|---|
| | 2000 | * Use this function to ensure that the given node is a scalar, the node tag is |
|---|
| | 2001 | * `tag:yaml.org,2002:float` and the node value is a valid float value. In |
|---|
| | 2002 | * this case, the function parses the node value and returns a float number. |
|---|
| | 2003 | * The function recognizes float values in exponential and fixed notation as |
|---|
| | 2004 | * well as special values `.nan`, `.inf` and `-.inf`. The function uses |
|---|
| | 2005 | * `strtod()` for string-to-float conversion. The `.nan`, `.inf` and `-.inf` |
|---|
| | 2006 | * values are generated as `0.0/0.0`, `1.0/0.0` and `-1.0/0.0` respectively. |
|---|
| | 2007 | * |
|---|
| | 2008 | * Arguments: |
|---|
| | 2009 | * |
|---|
| | 2010 | * - `document`: a document object. |
|---|
| | 2011 | * |
|---|
| | 2012 | * - `node_id`: the node id; could be negative. |
|---|
| | 2013 | * |
|---|
| | 2014 | * - `value`: a pointer to save the node value or `NULL`. |
|---|
| | 2015 | * |
|---|
| | 2016 | * Returns: `1` if the node is a valid `!!float` scalar, `0` otherwise. If the |
|---|
| | 2017 | * function succeeds and `value` is not `NULL`, the node value is saved to |
|---|
| | 2018 | * `value`. |
|---|
| | 2019 | */ |
|---|
| | 2020 | |
|---|
| | 2021 | YAML_DECLARE(int) |
|---|
| | 2022 | yaml_document_get_float_node(yaml_document_t *document, int node_id, |
|---|
| | 2023 | double *value); |
|---|
| | 2024 | |
|---|
| | 2025 | /* |
|---|
| | 2026 | * Get the value of a `!!seq` SEQUENCE node. |
|---|
| | 2027 | * |
|---|
| | 2028 | * Use this function to ensure that the given node is a sequence and the node |
|---|
| | 2029 | * tag is `tag:yaml.org,2002:seq`. In this case, the function returns the list |
|---|
| | 2030 | * of nodes that belong to the sequence. The produced list is valid until the |
|---|
| | 2031 | * document object is modified. |
|---|
| | 2032 | * |
|---|
| | 2033 | * Arguments: |
|---|
| | 2034 | * |
|---|
| | 2035 | * - `document`: a document object. |
|---|
| | 2036 | * |
|---|
| | 2037 | * - `node_id`: the node id; could be negative. |
|---|
| | 2038 | * |
|---|
| | 2039 | * - `items`: a pointer to save the list of sequence items or `NULL`. |
|---|
| | 2040 | * |
|---|
| | 2041 | * - `length`: a pointer to save the length of the sequence or `NULL`. |
|---|
| | 2042 | * `length` must be equal to `NULL` if and only if `items` is also `NULL`. |
|---|
| | 2043 | * |
|---|
| | 2044 | * Returns: `1` if the node is a valid `!!seq` sequence, `0` otherwise. If the |
|---|
| | 2045 | * function succeeds and `items` is not `NULL`, the list of sequence items is |
|---|
| | 2046 | * saved to `items` and the sequence length is saved to `length`. |
|---|
| | 2047 | */ |
|---|
| | 2048 | |
|---|
| | 2049 | YAML_DECLARE(int) |
|---|
| | 2050 | yaml_document_get_seq_node(yaml_document_t *document, int node_id, |
|---|
| | 2051 | yaml_node_item_t **items, size_t *length); |
|---|
| | 2052 | |
|---|
| | 2053 | /* |
|---|
| | 2054 | * Get the value of a `!!map` MAPPING node. |
|---|
| | 2055 | * |
|---|
| | 2056 | * Use this function to ensure that the given node is a mapping and the node |
|---|
| | 2057 | * tag is `tag:yaml.org,2002:map`. In this case, the function returns the list |
|---|
| | 2058 | * of node pairs (key, value) that belong to the sequence. The produced list |
|---|
| | 2059 | * is valid until the document is modified. |
|---|
| | 2060 | * |
|---|
| | 2061 | * Arguments: |
|---|
| | 2062 | * |
|---|
| | 2063 | * - `document`: a document object. |
|---|
| | 2064 | * |
|---|
| | 2065 | * - `node_id`: the node id; could be negative. |
|---|
| | 2066 | * |
|---|
| | 2067 | * - `pairs`: a pointer to save the list of mapping pairs or `NULL`. |
|---|
| | 2068 | * |
|---|
| | 2069 | * - `length`: a pointer to save the length of the mapping or `NULL`. |
|---|
| | 2070 | * `length` must be equal to `NULL` if and only if `pairs` is also `NULL`. |
|---|
| | 2071 | * |
|---|
| | 2072 | * Returns: `1` if the node is a valid `!!map` mapping, `0` otherwise. If the |
|---|
| | 2073 | * function succeeds and `pairs` is not `NULL`, the list of mapping pairs is |
|---|
| | 2074 | * saved to `pairs` and the mapping length is saved to `length`. |
|---|
| | 2075 | */ |
|---|
| | 2076 | |
|---|
| | 2077 | YAML_DECLARE(int) |
|---|
| | 2078 | yaml_document_get_map_node(yaml_document_t *document, int node_id, |
|---|
| | 2079 | yaml_node_pair_t **pairs, size_t *length); |
|---|
| | 2080 | |
|---|
| | 2081 | /* |
|---|
| | 2082 | * Add a `!!null` SCALAR node to the document. |
|---|
| | 2083 | * |
|---|
| | 2084 | * This function is a shorthand for the call: |
|---|
| | 2085 | * |
|---|
| | 2086 | * yaml_document_add_scalar(document, node_id, NULL, |
|---|
| | 2087 | * YAML_NULL_TAG, "null", -1, YAML_ANY_SCALAR_STYLE) |
|---|
| | 2088 | * |
|---|
| | 2089 | * Arguments: |
|---|
| | 2090 | * |
|---|
| | 2091 | * - `document`: a document object. |
|---|
| | 2092 | * |
|---|
| | 2093 | * - `node_id`: a pointer to save the id of the generated node or `NULL`. |
|---|
| | 2094 | * |
|---|
| | 2095 | * Returns: `1` on success, `0` on error. The function may fail if it cannot |
|---|
| | 2096 | * allocate memory for new buffers. If the function succeeds, the id of the |
|---|
| | 2097 | * added node is returned via the pointer `node_id` if it is not set to `NULL`. |
|---|
| | 2098 | */ |
|---|
| | 2099 | |
|---|
| | 2100 | YAML_DECLARE(int) |
|---|
| | 2101 | yaml_document_add_null_node(yaml_document_t *document, int *node_id); |
|---|
| | 2102 | |
|---|
| | 2103 | /* |
|---|
| | 2104 | * Add a `!!bool` SCALAR node to the document. |
|---|
| | 2105 | * |
|---|
| | 2106 | * This function is a shorthand for the call: |
|---|
| | 2107 | * |
|---|
| | 2108 | * yaml_document_add_scalar(document, node_id, NULL, |
|---|
| | 2109 | * YAML_BOOL_TAG, (value ? "true" : "false"), -1, |
|---|
| | 2110 | * YAML_ANY_SCALAR_STYLE) |
|---|
| | 2111 | * |
|---|
| | 2112 | * Arguments: |
|---|
| | 2113 | * |
|---|
| | 2114 | * - `document`: a document object. |
|---|
| | 2115 | * |
|---|
| | 2116 | * - `node_id`: a pointer to save the id of the generated node or `NULL`. |
|---|
| | 2117 | * |
|---|
| | 2118 | * - `value`: a boolean value; any non-zero value is true, `0` is false. |
|---|
| | 2119 | * |
|---|
| | 2120 | * Returns: `1` on success, `0` on error. The function may fail if it cannot |
|---|
| | 2121 | * allocate memory for new buffers. If the function succeeds, the id of the |
|---|
| | 2122 | * added node is returned via the pointer `node_id` if it is not set to `NULL`. |
|---|
| | 2123 | */ |
|---|
| | 2124 | |
|---|
| | 2125 | YAML_DECLARE(int) |
|---|
| | 2126 | yaml_document_add_bool_node(yaml_document_t *document, int *node_id, |
|---|
| | 2127 | int value); |
|---|
| | 2128 | |
|---|
| | 2129 | /* |
|---|
| | 2130 | * Add a `!!str` SCALAR node to the document. |
|---|
| | 2131 | * |
|---|
| | 2132 | * This function is a shorthand for the call: |
|---|
| | 2133 | * |
|---|
| | 2134 | * yaml_document_add_scalar(document, node_id, NULL, |
|---|
| | 2135 | * YAML_STR_TAG, (const yaml_char_t *) value, -1, |
|---|
| | 2136 | * YAML_ANY_SCALAR_STYLE) |
|---|
| | 2137 | * |
|---|
| | 2138 | * Arguments: |
|---|
| | 2139 | * |
|---|
| | 2140 | * - `document`: a document object. |
|---|
| | 2141 | * |
|---|
| | 2142 | * - `node_id`: a pointer to save the id of the generated node or `NULL`. |
|---|
| | 2143 | * |
|---|
| | 2144 | * - `value`: a NUL-terminated UTF-8 string. The function does not check if |
|---|
| | 2145 | * `value` is a valid UTF-8 string, but if it is not so, the emitter will |
|---|
| | 2146 | * fail to emit the node. |
|---|
| | 2147 | * |
|---|
| | 2148 | * Returns: `1` on success, `0` on error. The function may fail if it cannot |
|---|
| | 2149 | * allocate memory for new buffers. If the function succeeds, the id of the |
|---|
| | 2150 | * added node is returned via the pointer `node_id` if it is not set to `NULL`. |
|---|
| | 2151 | */ |
|---|
| | 2152 | |
|---|
| | 2153 | YAML_DECLARE(int) |
|---|
| | 2154 | yaml_document_add_str_node(yaml_document_t *document, int *node_id, |
|---|
| | 2155 | const char *value); |
|---|
| | 2156 | |
|---|
| | 2157 | /* |
|---|
| | 2158 | * Add an `!!int` SCALAR node to the document. |
|---|
| | 2159 | * |
|---|
| | 2160 | * This function is a shorthand for the call: |
|---|
| | 2161 | * |
|---|
| | 2162 | * yaml_document_add_scalar(document, node_id, NULL, |
|---|
| | 2163 | * YAML_INT_TAG, <string representation of the value>, -1, |
|---|
| | 2164 | * YAML_ANY_SCALAR_STYLE) |
|---|
| | 2165 | * |
|---|
| | 2166 | * Arguments: |
|---|
| | 2167 | * |
|---|
| | 2168 | * - `document`: a document object. |
|---|
| | 2169 | * |
|---|
| | 2170 | * - `node_id`: a pointer to save the id of the generated node or `NULL`. |
|---|
| | 2171 | * |
|---|
| | 2172 | * - `value`: an integer value. |
|---|
| | 2173 | * |
|---|
| | 2174 | * Returns: `1` on success, `0` on error. The function may fail if it cannot |
|---|
| | 2175 | * allocate memory for new buffers. If the function succeeds, the id of the |
|---|
| | 2176 | * added node is returned via the pointer `node_id` if it is not set to `NULL`. |
|---|
| | 2177 | */ |
|---|
| | 2178 | |
|---|
| | 2179 | YAML_DECLARE(int) |
|---|
| | 2180 | yaml_document_add_int_node(yaml_document_t *document, int *node_id, |
|---|
| | 2181 | long value); |
|---|
| | 2182 | |
|---|
| | 2183 | /* |
|---|
| | 2184 | * Add a `!!float` SCALAR node to the document. |
|---|
| | 2185 | * |
|---|
| | 2186 | * This function is a shorthand for the call: |
|---|
| | 2187 | * |
|---|
| | 2188 | * yaml_document_add_scalar(document, node_id, NULL, |
|---|
| | 2189 | * YAML_FLOAT_TAG, <string representation of the value>, -1, |
|---|
| | 2190 | * YAML_ANY_SCALAR_STYLE) |
|---|
| | 2191 | * |
|---|
| | 2192 | * Arguments: |
|---|
| | 2193 | * |
|---|
| | 2194 | * - `document`: a document object. |
|---|
| | 2195 | * |
|---|
| | 2196 | * - `node_id`: a pointer to save the id of the generated node or `NULL`. |
|---|
| | 2197 | * |
|---|
| | 2198 | * - `value`: a float value. |
|---|
| | 2199 | * |
|---|
| | 2200 | * Returns: `1` on success, `0` on error. The function may fail if it cannot |
|---|
| | 2201 | * allocate memory for new buffers. If the function succeeds, the id of the |
|---|
| | 2202 | * added node is returned via the pointer `node_id` if it is not set to `NULL`. |
|---|
| | 2203 | */ |
|---|
| | 2204 | |
|---|
| | 2205 | YAML_DECLARE(int) |
|---|
| | 2206 | yaml_document_add_float_node(yaml_document_t *document, int *node_id, |
|---|
| | 2207 | double value); |
|---|
| | 2208 | |
|---|
| | 2209 | /* |
|---|
| | 2210 | * Add a `!!seq` SEQUENCE node to the document. |
|---|
| | 2211 | * |
|---|
| | 2212 | * This function is a shorthand for the call: |
|---|
| | 2213 | * |
|---|
| | 2214 | * yaml_document_add_sequence(document, node_id, NULL, |
|---|
| | 2215 | * YAML_SEQ_TAG, YAML_ANY_SEQUENCE_STYLE) |
|---|
| | 2216 | * |
|---|
| | 2217 | * Arguments: |
|---|
| | 2218 | * |
|---|
| | 2219 | * - `document`: a document object. |
|---|
| | 2220 | * |
|---|
| | 2221 | * - `node_id`: a pointer to save the id of the generated node or `NULL`. |
|---|
| | 2222 | * |
|---|
| | 2223 | * Returns: `1` on success, `0` on error. The function may fail if it cannot |
|---|
| | 2224 | * allocate memory for new buffers. If the function succeeds, the id of the |
|---|
| | 2225 | * added node is returned via the pointer `node_id` if it is not set to `NULL`. |
|---|
| | 2226 | */ |
|---|
| | 2227 | |
|---|
| | 2228 | YAML_DECLARE(int) |
|---|
| | 2229 | yaml_document_add_seq_node(yaml_document_t *document, int *node_id); |
|---|
| | 2230 | |
|---|
| | 2231 | /* |
|---|
| | 2232 | * Add a `!!map` MAPPING node to the document. |
|---|
| | 2233 | * |
|---|
| | 2234 | * This function is a shorthand for the call: |
|---|
| | 2235 | * |
|---|
| | 2236 | * yaml_document_add_mapping(document, node_id, NULL, |
|---|
| | 2237 | * YAML_MAP_TAG, YAML_ANY_MAPPING_STYLE) |
|---|
| | 2238 | * |
|---|
| | 2239 | * Arguments: |
|---|
| | 2240 | * |
|---|
| | 2241 | * - `document`: a document object. |
|---|
| | 2242 | * |
|---|
| | 2243 | * - `node_id`: a pointer to save the id of the generated node or `NULL`. |
|---|
| | 2244 | * |
|---|
| | 2245 | * Returns: `1` on success, `0` on error. The function may fail if it cannot |
|---|
| | 2246 | * allocate memory for new buffers. If the function succeeds, the id of the |
|---|
| | 2247 | * added node is returned via the pointer `node_id` if it is not set to `NULL`. |
|---|
| | 2248 | */ |
|---|
| | 2249 | |
|---|
| | 2250 | YAML_DECLARE(int) |
|---|
| | 2251 | yaml_document_add_map_node(yaml_document_t *document, int *node_id); |
|---|
| | 2252 | |
|---|
| | 2253 | /***************************************************************************** |
|---|