cudl

A data language as simple as JSON but as readable as YAML or TOML.
git clone https://shtanton.xyz/git/cudl.git
Log | Files | Refs | README

cudl.h (1202B)


      1 #ifndef cudl_h_INCLUDED
      2 #define cudl_h_INCLUDED
      3 
      4 #include <stdio.h>
      5 #include <stddef.h>
      6 
      7 struct cudl_array_value {
      8 	struct cudl_value *values;
      9 	size_t length;
     10 };
     11 
     12 struct cudl_map_value {
     13 	struct cudl_map_field *fields;
     14 	size_t length;
     15 };
     16 
     17 struct cudl_value {
     18 	union {
     19 		char *string;
     20 		double number;
     21 		int boolean;
     22 		struct cudl_array_value array;
     23 		struct cudl_map_value map;
     24 	} data;
     25 	int tag;
     26 };
     27 
     28 struct cudl_map_field {
     29 	char *key;
     30 	struct cudl_value value;
     31 };
     32 
     33 enum {
     34 	CUDL_TAG_NULL,
     35 	CUDL_TAG_BOOL,
     36 	CUDL_TAG_NUMBER,
     37 	CUDL_TAG_ARRAY,
     38 	CUDL_TAG_MAP,
     39 	CUDL_TAG_STRING,
     40 };
     41 
     42 enum {
     43 	CUDL_OK = 0,
     44 	CUDL_ERR_OUT_OF_MEMORY,
     45 	CUDL_ERR_READING,
     46 	CUDL_ERR_EXPECTED_VALUE,
     47 	CUDL_ERR_EXPECTED_BOOL_OR_NULL,
     48 	CUDL_ERR_EXPECTED_ESCAPE_SEQUENCE,
     49 	CUDL_ERR_EXPECTED_MAP_KEY,
     50 	CUDL_ERR_EXPECTED_COLON,
     51 	CUDL_ERR_UNMATCHED_BRACK,
     52 	CUDL_ERR_UNMATCHED_BRACE,
     53 	CUDL_ERR_UNMATCHED_QUOTE,
     54 	CUDL_ERR_UNRECOGNISED_VALUE,
     55 	CUDL_ERR_UNRECOGNISED_UNICODE,
     56 };
     57 
     58 extern int cudl_err;
     59 
     60 void cudl_debug(struct cudl_value value);
     61 void cudl_deinit_value(struct cudl_value value);
     62 void cudl_parse_from_file(FILE *file, struct cudl_value *value);
     63 size_t cudl_parse(char *input, struct cudl_value *value);
     64 
     65 #endif // cudl_h_INCLUDED