mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
parsebuffer: type and macros
This commit is contained in:
parent
06a2326e3b
commit
0f98214e71
16
cJSON.c
16
cJSON.c
@ -185,6 +185,22 @@ static unsigned char get_decimal_point(void)
|
||||
return (unsigned char) lconv->decimal_point[0];
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const unsigned char *content;
|
||||
size_t length;
|
||||
size_t offset;
|
||||
} parse_buffer;
|
||||
|
||||
/* check if the given size is left to read in a given parse buffer (starting with 1) */
|
||||
#define can_read(buffer, size) ((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length))
|
||||
#define cannot_read(buffer, size) (!can_read(buffer, size))
|
||||
/* check if the buffer can be accessed at the given index (starting with 0) */
|
||||
#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
|
||||
#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
|
||||
/* get a pointer to the buffer at the position */
|
||||
#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
|
||||
|
||||
/* Parse the input text to generate a number, and populate the result into item. */
|
||||
static const unsigned char *parse_number(cJSON * const item, const unsigned char * const input)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user