2024-10-25 02:04:11 -07:00
|
|
|
// This file was generated automatially by gencpp's unreal.cpp (See: https://github.com/Ed94/gencpp)
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifdef __clang__
|
2024-10-27 18:44:34 -07:00
|
|
|
# pragma clang diagnostic push
|
|
|
|
# pragma clang diagnostic ignored "-Wunused-const-variable"
|
|
|
|
# pragma clang diagnostic ignored "-Wunused-but-set-variable"
|
|
|
|
# pragma clang diagnostic ignored "-Wswitch"
|
|
|
|
# pragma clang diagnostic ignored "-Wunused-variable"
|
|
|
|
# pragma clang diagnostic ignored "-Wunknown-pragmas"
|
|
|
|
# pragma clang diagnostic ignored "-Wvarargs"
|
|
|
|
# pragma clang diagnostic ignored "-Wunused-function"
|
2024-12-15 11:14:02 -08:00
|
|
|
# pragma clang diagnostic ignored "-Wbraced-scalar-init"
|
|
|
|
# pragma clang diagnostic ignored "-W#pragma-messages"
|
|
|
|
# pragma clang diagnostic ignored "-Wstatic-in-inline"
|
2024-10-21 19:39:40 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
2024-10-27 18:44:34 -07:00
|
|
|
# pragma GCC diagnostic push
|
|
|
|
# pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
|
|
|
# pragma GCC diagnostic ignored "-Wcomment"
|
|
|
|
# pragma GCC diagnostic ignored "-Wswitch"
|
|
|
|
# pragma GCC diagnostic ignored "-Wunused-variable"
|
2024-10-21 19:39:40 -07:00
|
|
|
#endif
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
#include "gen.hpp"
|
|
|
|
|
2024-10-21 19:39:40 -07:00
|
|
|
GEN_NS_BEGIN
|
|
|
|
|
|
|
|
#pragma region ADT
|
|
|
|
|
|
|
|
enum ADT_Type : u32
|
|
|
|
{
|
|
|
|
EADT_TYPE_UNINITIALISED, /* node was not initialised, this is a programming error! */
|
|
|
|
EADT_TYPE_ARRAY,
|
|
|
|
EADT_TYPE_OBJECT,
|
|
|
|
EADT_TYPE_STRING,
|
|
|
|
EADT_TYPE_MULTISTRING,
|
|
|
|
EADT_TYPE_INTEGER,
|
|
|
|
EADT_TYPE_REAL,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ADT_Props : u32
|
|
|
|
{
|
|
|
|
EADT_PROPS_NONE,
|
|
|
|
EADT_PROPS_NAN,
|
|
|
|
EADT_PROPS_NAN_NEG,
|
|
|
|
EADT_PROPS_INFINITY,
|
|
|
|
EADT_PROPS_INFINITY_NEG,
|
|
|
|
EADT_PROPS_FALSE,
|
|
|
|
EADT_PROPS_TRUE,
|
|
|
|
EADT_PROPS_NULL,
|
|
|
|
EADT_PROPS_IS_EXP,
|
|
|
|
EADT_PROPS_IS_HEX,
|
|
|
|
|
|
|
|
// Used internally so that people can fill in real numbers they plan to write.
|
|
|
|
EADT_PROPS_IS_PARSED_REAL,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ADT_NamingStyle : u32
|
|
|
|
{
|
|
|
|
EADT_NAME_STYLE_DOUBLE_QUOTE,
|
|
|
|
EADT_NAME_STYLE_SINGLE_QUOTE,
|
|
|
|
EADT_NAME_STYLE_NO_QUOTES,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ADT_AssignStyle : u32
|
|
|
|
{
|
|
|
|
EADT_ASSIGN_STYLE_COLON,
|
|
|
|
EADT_ASSIGN_STYLE_EQUALS,
|
|
|
|
EADT_ASSIGN_STYLE_LINE,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ADT_DelimStyle : u32
|
|
|
|
{
|
|
|
|
EADT_DELIM_STYLE_COMMA,
|
|
|
|
EADT_DELIM_STYLE_LINE,
|
|
|
|
EADT_DELIM_STYLE_NEWLINE,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ADT_Error : u32
|
|
|
|
{
|
|
|
|
EADT_ERROR_NONE,
|
|
|
|
EADT_ERROR_INTERNAL,
|
|
|
|
EADT_ERROR_ALREADY_CONVERTED,
|
|
|
|
EADT_ERROR_INVALID_TYPE,
|
|
|
|
EADT_ERROR_OUT_OF_MEMORY,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ADT_Node
|
|
|
|
{
|
|
|
|
char const* name;
|
|
|
|
struct ADT_Node* parent;
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
ADT_Type type : 4;
|
2024-10-27 18:44:34 -07:00
|
|
|
u8 props : 4;
|
2024-10-21 19:39:40 -07:00
|
|
|
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
|
|
|
u8 cfg_mode : 1;
|
|
|
|
u8 name_style : 2;
|
|
|
|
u8 assign_style : 2;
|
|
|
|
u8 delim_style : 2;
|
|
|
|
u8 delim_line_width : 4;
|
|
|
|
u8 assign_line_width : 4;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* adt data */
|
|
|
|
union
|
|
|
|
{
|
|
|
|
char const* string;
|
2024-12-15 11:14:02 -08:00
|
|
|
Array(ADT_Node) nodes; ///< zpl_array
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
f64 real;
|
|
|
|
s64 integer;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
|
|
|
/* number analysis */
|
|
|
|
s32 base;
|
|
|
|
s32 base2;
|
|
|
|
u8 base2_offset : 4;
|
|
|
|
s8 exp : 4;
|
|
|
|
u8 neg_zero : 1;
|
|
|
|
u8 lead_digit : 1;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ADT NODE LIMITS
|
2024-10-27 18:44:34 -07:00
|
|
|
* delimiter and assignment segment width is limited to 128 whitespace symbols each.
|
|
|
|
* real number limits decimal position to 128 places.
|
|
|
|
* real number exponent is limited to 64 digits.
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Initialise an ADT object or array
|
|
|
|
*
|
|
|
|
* @param node
|
|
|
|
* @param backing Memory allocator used for descendants
|
|
|
|
* @param name Node's name
|
|
|
|
* @param is_array
|
|
|
|
* @return error code
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
u8 adt_make_branch( ADT_Node* node, AllocatorInfo backing, char const* name, b32 is_array );
|
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Destroy an ADT branch and its descendants
|
|
|
|
*
|
|
|
|
* @param node
|
|
|
|
* @return error code
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
u8 adt_destroy_branch( ADT_Node* node );
|
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Initialise an ADT leaf
|
|
|
|
*
|
|
|
|
* @param node
|
|
|
|
* @param name Node's name
|
|
|
|
* @param type Node's type (use zpl_adt_make_branch for container nodes)
|
|
|
|
* @return error code
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
u8 adt_make_leaf( ADT_Node* node, char const* name, ADT_Type type );
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Fetch a node using provided URI string.
|
|
|
|
*
|
|
|
|
* This method uses a basic syntax to fetch a node from the ADT. The following features are available
|
|
|
|
* to retrieve the data:
|
|
|
|
*
|
|
|
|
* - "a/b/c" navigates through objects "a" and "b" to get to "c"
|
|
|
|
* - "arr/[foo=123]/bar" iterates over "arr" to find any object with param "foo" that matches the value "123", then gets its field called "bar"
|
|
|
|
* - "arr/3" retrieves the 4th element in "arr"
|
|
|
|
* - "arr/[apple]" retrieves the first element of value "apple" in "arr"
|
|
|
|
*
|
|
|
|
* @param node ADT node
|
|
|
|
* @param uri Locator string as described above
|
|
|
|
* @return zpl_adt_node*
|
|
|
|
*
|
|
|
|
* @see code/apps/examples/json_get.c
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
ADT_Node* adt_query( ADT_Node* node, char const* uri );
|
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Find a field node within an object by the given name.
|
|
|
|
*
|
|
|
|
* @param node
|
|
|
|
* @param name
|
|
|
|
* @param deep_search Perform search recursively
|
|
|
|
* @return zpl_adt_node * node
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
ADT_Node* adt_find( ADT_Node* node, char const* name, b32 deep_search );
|
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Allocate an unitialised node within a container at a specified index.
|
|
|
|
*
|
|
|
|
* @param parent
|
|
|
|
* @param index
|
|
|
|
* @return zpl_adt_node * node
|
|
|
|
*/
|
|
|
|
ADT_Node* adt_alloc_at( ADT_Node* parent, ssize index );
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Allocate an unitialised node within a container.
|
|
|
|
*
|
|
|
|
* @param parent
|
|
|
|
* @return zpl_adt_node * node
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
ADT_Node* adt_alloc( ADT_Node* parent );
|
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Move an existing node to a new container at a specified index.
|
|
|
|
*
|
|
|
|
* @param node
|
|
|
|
* @param new_parent
|
|
|
|
* @param index
|
|
|
|
* @return zpl_adt_node * node
|
|
|
|
*/
|
|
|
|
ADT_Node* adt_move_node_at( ADT_Node* node, ADT_Node* new_parent, ssize index );
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Move an existing node to a new container.
|
|
|
|
*
|
|
|
|
* @param node
|
|
|
|
* @param new_parent
|
|
|
|
* @return zpl_adt_node * node
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
ADT_Node* adt_move_node( ADT_Node* node, ADT_Node* new_parent );
|
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Swap two nodes.
|
|
|
|
*
|
|
|
|
* @param node
|
|
|
|
* @param other_node
|
|
|
|
* @return
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
void adt_swap_nodes( ADT_Node* node, ADT_Node* other_node );
|
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Remove node from container.
|
|
|
|
*
|
|
|
|
* @param node
|
|
|
|
* @return
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
void adt_remove_node( ADT_Node* node );
|
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Initialise a node as an object
|
|
|
|
*
|
|
|
|
* @param obj
|
|
|
|
* @param name
|
|
|
|
* @param backing
|
|
|
|
* @return
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
b8 adt_set_obj( ADT_Node* obj, char const* name, AllocatorInfo backing );
|
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Initialise a node as an array
|
|
|
|
*
|
|
|
|
* @param obj
|
|
|
|
* @param name
|
|
|
|
* @param backing
|
|
|
|
* @return
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
b8 adt_set_arr( ADT_Node* obj, char const* name, AllocatorInfo backing );
|
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Initialise a node as a string
|
|
|
|
*
|
|
|
|
* @param obj
|
|
|
|
* @param name
|
|
|
|
* @param value
|
|
|
|
* @return
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
b8 adt_set_str( ADT_Node* obj, char const* name, char const* value );
|
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Initialise a node as a float
|
|
|
|
*
|
|
|
|
* @param obj
|
|
|
|
* @param name
|
|
|
|
* @param value
|
|
|
|
* @return
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
b8 adt_set_flt( ADT_Node* obj, char const* name, f64 value );
|
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Initialise a node as a signed integer
|
|
|
|
*
|
|
|
|
* @param obj
|
|
|
|
* @param name
|
|
|
|
* @param value
|
|
|
|
* @return
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
b8 adt_set_int( ADT_Node* obj, char const* name, s64 value );
|
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Append a new node to a container as an object
|
|
|
|
*
|
|
|
|
* @param parent
|
|
|
|
* @param name
|
|
|
|
* @return*
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
ADT_Node* adt_append_obj( ADT_Node* parent, char const* name );
|
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Append a new node to a container as an array
|
|
|
|
*
|
|
|
|
* @param parent
|
|
|
|
* @param name
|
|
|
|
* @return*
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
ADT_Node* adt_append_arr( ADT_Node* parent, char const* name );
|
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Append a new node to a container as a string
|
|
|
|
*
|
|
|
|
* @param parent
|
|
|
|
* @param name
|
|
|
|
* @param value
|
|
|
|
* @return*
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
ADT_Node* adt_append_str( ADT_Node* parent, char const* name, char const* value );
|
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Append a new node to a container as a float
|
|
|
|
*
|
|
|
|
* @param parent
|
|
|
|
* @param name
|
|
|
|
* @param value
|
|
|
|
* @return*
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
ADT_Node* adt_append_flt( ADT_Node* parent, char const* name, f64 value );
|
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Append a new node to a container as a signed integer
|
|
|
|
*
|
|
|
|
* @param parent
|
|
|
|
* @param name
|
|
|
|
* @param value
|
|
|
|
* @return*
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
ADT_Node* adt_append_int( ADT_Node* parent, char const* name, s64 value );
|
|
|
|
|
|
|
|
/* parser helpers */
|
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Parses a text and stores the result into an unitialised node.
|
|
|
|
*
|
|
|
|
* @param node
|
|
|
|
* @param base
|
|
|
|
* @return*
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
char* adt_parse_number( ADT_Node* node, char* base );
|
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Parses a text and stores the result into an unitialised node.
|
|
|
|
* This function expects the entire input to be a number.
|
|
|
|
*
|
|
|
|
* @param node
|
|
|
|
* @param base
|
|
|
|
* @return*
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
char* adt_parse_number_strict( ADT_Node* node, char* base_str );
|
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Parses and converts an existing string node into a number.
|
|
|
|
*
|
|
|
|
* @param node
|
|
|
|
* @return
|
|
|
|
*/
|
2024-12-15 11:14:02 -08:00
|
|
|
ADT_Error adt_c_str_to_number( ADT_Node* node );
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Parses and converts an existing string node into a number.
|
|
|
|
* This function expects the entire input to be a number.
|
|
|
|
*
|
|
|
|
* @param node
|
|
|
|
* @return
|
|
|
|
*/
|
2024-12-15 11:14:02 -08:00
|
|
|
ADT_Error adt_c_str_to_number_strict( ADT_Node* node );
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Prints a number into a file stream.
|
|
|
|
*
|
|
|
|
* The provided file handle can also be a memory mapped stream.
|
|
|
|
*
|
|
|
|
* @see zpl_file_stream_new
|
|
|
|
* @param file
|
|
|
|
* @param node
|
|
|
|
* @return
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
ADT_Error adt_print_number( FileInfo* file, ADT_Node* node );
|
|
|
|
|
|
|
|
/**
|
2024-10-27 18:44:34 -07:00
|
|
|
* @brief Prints a string into a file stream.
|
|
|
|
*
|
|
|
|
* The provided file handle can also be a memory mapped stream.
|
|
|
|
*
|
|
|
|
* @see zpl_file_stream_new
|
|
|
|
* @param file
|
|
|
|
* @param node
|
|
|
|
* @param escaped_chars
|
|
|
|
* @param escape_symbol
|
|
|
|
* @return
|
|
|
|
*/
|
2024-10-21 19:39:40 -07:00
|
|
|
ADT_Error adt_print_string( FileInfo* file, ADT_Node* node, char const* escaped_chars, char const* escape_symbol );
|
|
|
|
|
|
|
|
#pragma endregion ADT
|
|
|
|
|
|
|
|
#pragma region CSV
|
|
|
|
|
|
|
|
enum CSV_Error : u32
|
|
|
|
{
|
|
|
|
ECSV_Error__NONE,
|
|
|
|
ECSV_Error__INTERNAL,
|
|
|
|
ECSV_Error__UNEXPECTED_END_OF_INPUT,
|
|
|
|
ECSV_Error__MISMATCHED_ROWS,
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef ADT_Node CSV_Object;
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
u8 csv_parse( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header );
|
|
|
|
u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header, char delim );
|
|
|
|
void csv_free( CSV_Object* obj );
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
void csv_write( FileInfo* file, CSV_Object* obj );
|
2024-12-15 11:14:02 -08:00
|
|
|
StrBuilder csv_write_string( AllocatorInfo a, CSV_Object* obj );
|
2024-10-27 18:44:34 -07:00
|
|
|
void csv_write_delimiter( FileInfo* file, CSV_Object* obj, char delim );
|
2024-12-15 11:14:02 -08:00
|
|
|
StrBuilder csv_write_strbuilder_delimiter( AllocatorInfo a, CSV_Object* obj, char delim );
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
/* inline */
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
inline
|
|
|
|
u8 csv_parse( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return csv_parse_delimiter( root, text, allocator, has_header, ',' );
|
|
|
|
}
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
inline
|
|
|
|
void csv_write( FileInfo* file, CSV_Object* obj )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
csv_write_delimiter( file, obj, ',' );
|
|
|
|
}
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
inline
|
2024-12-15 11:14:02 -08:00
|
|
|
StrBuilder csv_write_string( AllocatorInfo a, CSV_Object* obj )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
2024-12-15 11:14:02 -08:00
|
|
|
return csv_write_strbuilder_delimiter( a, obj, ',' );
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma endregion CSV
|
|
|
|
|
2024-12-15 11:14:02 -08:00
|
|
|
#pragma region Scanner
|
|
|
|
|
2024-10-21 19:39:40 -07:00
|
|
|
// This is a simple file reader that reads the entire file into memory.
|
|
|
|
// It has an extra option to skip the first few lines for undesired includes.
|
|
|
|
// This is done so that includes can be kept in dependency and component files so that intellisense works.
|
2024-12-15 11:14:02 -08:00
|
|
|
Code scan_file( char const* path );
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-12-15 11:14:02 -08:00
|
|
|
CodeBody parse_file( const char* path );
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-12-15 11:14:02 -08:00
|
|
|
// The follow is basic support for light csv parsing (use it as an example)
|
|
|
|
// Make something robust if its more serious.
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-12-15 11:14:02 -08:00
|
|
|
typedef struct CSV_Column CSV_Column;
|
|
|
|
struct CSV_Column {
|
|
|
|
CSV_Object ADT;
|
|
|
|
Array(ADT_Node) Content;
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
|
2024-12-15 11:14:02 -08:00
|
|
|
typedef struct CSV_Columns2 CSV_Columns2;
|
|
|
|
struct CSV_Columns2 {
|
|
|
|
CSV_Object ADT;
|
|
|
|
Array(ADT_Node) Col_1;
|
|
|
|
Array(ADT_Node) Col_2;
|
|
|
|
};
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-12-15 11:14:02 -08:00
|
|
|
CSV_Column parse_csv_one_column(AllocatorInfo allocator, char const* path);
|
|
|
|
CSV_Columns2 parse_csv_two_columns(AllocatorInfo allocator, char const* path);
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-12-15 11:14:02 -08:00
|
|
|
#pragma endregion Scanner
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
GEN_NS_END
|
|
|
|
|
|
|
|
#ifdef __clang__
|
2024-10-27 18:44:34 -07:00
|
|
|
# pragma clang diagnostic pop
|
2024-10-21 19:39:40 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
2024-10-27 18:44:34 -07:00
|
|
|
# pragma GCC diagnostic pop
|
2024-10-21 19:39:40 -07:00
|
|
|
#endif
|