#ifndef HSV_H
#define HSV_H
#include <stddef.h>
#define HSV_SOH '\x01'
#define HSV_STX '\x02'
#define HSV_ETX '\x03'
#define HSV_EOT '\x04'
#define HSV_SO '\x0e'
#define HSV_SI '\x0f'
#define HSV_DLE '\x10'
#define HSV_FS '\x1c'
#define HSV_GS '\x1d'
#define HSV_RS '\x1e'
#define HSV_US '\x1f'
typedef enum {
HSV_TYPE_STRING,
HSV_TYPE_ARRAY,
HSV_TYPE_OBJECT
} hsv_type_t;
typedef struct hsv_value hsv_value_t;
typedef struct hsv_pair hsv_pair_t;
typedef struct hsv_document hsv_document_t;
struct hsv_pair {
char *key;
hsv_value_t *value;
};
struct hsv_value {
hsv_type_t type;
union {
char *string;
struct {
hsv_value_t **items;
size_t count;
} array;
struct {
hsv_pair_t *pairs;
size_t count;
} object;
} data;
};
struct hsv_document {
hsv_value_t *header;
hsv_value_t **records;
size_t record_count;
};
hsv_document_t *hsv_parse(const char *text);
void hsv_free_document(hsv_document_t *doc);
void hsv_free_value(hsv_value_t *value);
const char *hsv_get_string(hsv_value_t *obj, const char *key);
hsv_value_t *hsv_get(hsv_value_t *obj, const char *key);
#endif