Webcom C SDK
|
enum | wc_parser_result_t { WC_PARSER_OK = 0, WC_PARSER_CONTINUE, WC_PARSER_ERROR } |
wc_parser_t * | wc_datasync_parser_new () |
wc_parser_result_t | wc_datasync_parse_msg_ex (wc_parser_t *parser, char *buf, size_t len, wc_msg_t *res) |
const char * | wc_datasync_parser_get_error (wc_parser_t *parser) |
int | wc_datasync_parse_msg (char *str, wc_msg_t *res) |
void | wc_datasync_parser_free (wc_parser_t *parser) |
int | wc_datasync_key_cmp (const char *sa, const char *sb) |
enum wc_parser_result_t |
int wc_datasync_key_cmp | ( | const char * | sa, |
const char * | sb | ||
) |
Compares two strings using the Webcom key order:
Example: "0" < "1" < "9" < "72" < "521" < "1000" < "aa" < "bb"
sa | first string |
sb | second string |
int wc_datasync_parse_msg | ( | char * | str, |
wc_msg_t * | res | ||
) |
Parses a null-terminated webcom message string.
This function parses a null-terminated string containing a webcom message (JSON document) and populates the wc_msg_t object given as parameter.
str | the message string to parse | |
[out] | res | the wc_msg_t object to populate |
wc_parser_result_t wc_datasync_parse_msg_ex | ( | wc_parser_t * | parser, |
char * | buf, | ||
size_t | len, | ||
wc_msg_t * | res | ||
) |
Parses a JSON text buffer to populate a wc_msg_t object.
If you have only partial buffers, you can call this function several times with the following buffers and the same parser object. It will return WC_PARSER_CONTINUE until the end of the JSON document has been parsed.
parser | the parser created by wc_parser_new() | |
buf | the JSON text buffer to parse | |
len | the buffer length | |
[out] | res | the wc_msg_t object to populate |
void wc_datasync_parser_free | ( | wc_parser_t * | parser | ) |
Frees a wc_parser_t object previously allocated by wc_parser_new()
parser | the wc_parser_t object to free |
const char* wc_datasync_parser_get_error | ( | wc_parser_t * | parser | ) |
Returns a string describing a parsing error.
wc_parser_t* wc_datasync_parser_new | ( | ) |
Creates a new wc_parser_t object.