Update API doc
This commit is contained in:
parent
df95db7882
commit
ecb3222605
54
doc/api
54
doc/api
@ -20,18 +20,21 @@
|
||||
* Control how rjp_to_json outputs
|
||||
*/
|
||||
typedef enum RJP_format_flag{
|
||||
RJP_FORMAT_NONE = 0, //No formatting
|
||||
RJP_FORMAT_PRETTY = 1 //Rexy's preffered formatting
|
||||
RJP_FORMAT_NONE = 0,
|
||||
RJP_FORMAT_KEY_SPACES = 1,
|
||||
RJP_FORMAT_NEWLINES = 2,
|
||||
RJP_FORMAT_TABBED_LINES = RJP_FORMAT_NEWLINES | 4,
|
||||
RJP_FORMAT_COMMA_SPACES = 8,
|
||||
RJP_FORMAT_PRETTY = RJP_FORMAT_KEY_SPACES | RJP_FORMAT_NEWLINES | RJP_FORMAT_TABBED_LINES
|
||||
}RJP_format_flag;
|
||||
|
||||
/*
|
||||
* Control what extensions are allowed in rjp_parse
|
||||
*/
|
||||
typedef enum RJP_parse_flag{
|
||||
RJP_PARSE_NONE = 0, //Standard JSON
|
||||
RJP_PARSE_ALLOW_COMMENTS = 1, //Allow C++/C comments
|
||||
RJP_PARSE_ALLOW_TRAILING_COMMA = 2, //Allow trailing comma in array/object
|
||||
//Enable all extensions
|
||||
RJP_PARSE_NO_EXT = 0,
|
||||
RJP_PARSE_ALLOW_COMMENTS = 1,
|
||||
RJP_PARSE_ALLOW_TRAILING_COMMA = 2,
|
||||
RJP_PARSE_ALL_EXT = RJP_PARSE_ALLOW_COMMENTS | RJP_PARSE_ALLOW_TRAILING_COMMA
|
||||
}RJP_parse_flag;
|
||||
|
||||
@ -91,6 +94,19 @@ typedef struct RJP_parse_callback{
|
||||
void* data;
|
||||
}RJP_parse_callback;
|
||||
|
||||
/*
|
||||
* Retains enough information from a parse run to construct an error message and where the error occurred.
|
||||
@member parsestate: internal use only
|
||||
@member errcode: enumeration of what the error was
|
||||
@member row: what row of the input contained the error
|
||||
@member column: where in the row that the error occurred
|
||||
*/
|
||||
typedef struct RJP_parse_error{
|
||||
void* parsestate;
|
||||
int errcode;
|
||||
int row, column;
|
||||
}RJP_parse_error;
|
||||
|
||||
|
||||
/***************** NON OBJECT OPERATIONS *******************/
|
||||
/*
|
||||
@ -138,13 +154,20 @@ RJP_index rjp_escape_strlen(const char* str);
|
||||
RJP_string rjp_escape(const char* src);
|
||||
|
||||
/***************** GENERIC OPERATIONS *******************/
|
||||
/*
|
||||
* Convert C string of json data into RJP's format using no extensions and without
|
||||
error reporting.
|
||||
@param str: input JSON
|
||||
@returns: pointer to root value or NULL on failure
|
||||
*/
|
||||
RJP_value* rjp_simple_parse(const char* str);
|
||||
/*
|
||||
* Convert C string consisting of json data into RJP's format
|
||||
@param str: input JSON
|
||||
@param flags: RJP_parse_flags OR'd together
|
||||
@returns: pointer to root value or NULL on failure
|
||||
*/
|
||||
RJP_value* rjp_parse(const char* str, int flags);
|
||||
RJP_value* rjp_parse(const char* str, int flags, RJP_parse_error* err);
|
||||
|
||||
/*
|
||||
* Read json data in using a user supplied callback and convert
|
||||
@ -153,7 +176,22 @@ RJP_value* rjp_parse(const char* str, int flags);
|
||||
@param cbacks: RJP_parse_callback with function/data used for reading
|
||||
@returns: pointer to root value or NULL on failure
|
||||
*/
|
||||
RJP_value* rjp_parse_cback(int flags, RJP_parse_callback* cbacks);
|
||||
RJP_value* rjp_parse_cback(int flags, RJP_parse_callback* cbacks, RJP_parse_error* err);
|
||||
|
||||
/*
|
||||
* Allocate a string representing the error stored in RJP_parse_error structure
|
||||
@param err: pointer to error to stringify
|
||||
@returns: rjp_alloc'd pointer to string describing the error.
|
||||
Must be freed with rjp_free
|
||||
*/
|
||||
char* rjp_parse_error_to_string(const RJP_parse_error* err);
|
||||
/*
|
||||
* Cleanup a RJP_parse_error structure when finished
|
||||
Note: DO NOT call if rjp_parse* was successful. Error will contain garbage data and
|
||||
will cause a segfault.
|
||||
@param err: pointer to error which needs cleanup
|
||||
*/
|
||||
void rjp_delete_parse_error(RJP_parse_error* err);
|
||||
|
||||
/*
|
||||
* Convert RJP's representation to rjp_alloc'd JSON string
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user