Concord - C Discord API library
A Discord API wrapper library written in C
|
#include <stddef.h>
#include <stdio.h>
Go to the source code of this file.
Data Structures | |
struct | jsonb |
Handle for building a JSON string. More... | |
Macros | |
#define | JSONB_API extern |
#define | JSONB_MAX_DEPTH 128 |
#define | TRACE(prev, next) next |
#define | DECORATOR(a) |
#define | STACK_HEAD(b, state) *(b)->top = (state) |
#define | STACK_PUSH(b, state) TRACE(*(b)->top, *++(b)->top = (state)) |
#define | STACK_POP(b) TRACE(*(b)->top, DECORATOR(*)--(b)->top) |
#define | BUFFER_COPY_CHAR(b, c, _pos, buf, bufsize) |
#define | BUFFER_COPY(b, value, len, _pos, buf, bufsize) |
Typedefs | |
typedef enum jsonbcode | jsonbcode |
json-builder return codes More... | |
typedef struct jsonb | jsonb |
Handle for building a JSON string. More... | |
Enumerations | |
enum | jsonbcode { JSONB_OK = 0 , JSONB_END , JSONB_ERROR_NOMEM = -1 , JSONB_ERROR_INPUT = -2 , JSONB_ERROR_STACK = -3 } |
json-builder return codes More... | |
enum | jsonbstate { JSONB_INIT = 0 , JSONB_ARRAY_OR_OBJECT_OR_VALUE = JSONB_INIT , JSONB_OBJECT_KEY_OR_CLOSE , JSONB_OBJECT_VALUE , JSONB_OBJECT_NEXT_KEY_OR_CLOSE , JSONB_ARRAY_VALUE_OR_CLOSE , JSONB_ARRAY_NEXT_VALUE_OR_CLOSE , JSONB_ERROR , JSONB_DONE } |
json-builder serializing state More... | |
Functions | |
void | jsonb_init (jsonb *builder) |
Initialize a jsonb handle. More... | |
jsonbcode | jsonb_object (jsonb *builder, char buf[], size_t bufsize) |
Push an object to the builder. More... | |
jsonbcode | jsonb_object_pop (jsonb *builder, char buf[], size_t bufsize) |
Pop an object from the builder. More... | |
jsonbcode | jsonb_key (jsonb *builder, char buf[], size_t bufsize, const char key[], size_t len) |
Push a key to the builder. More... | |
jsonbcode | jsonb_array (jsonb *builder, char buf[], size_t bufsize) |
Push an array to the builder. More... | |
jsonbcode | jsonb_array_pop (jsonb *builder, char buf[], size_t bufsize) |
Pop an array from the builder. More... | |
jsonbcode | jsonb_token (jsonb *builder, char buf[], size_t bufsize, const char token[], size_t len) |
Push a raw JSON token to the builder. More... | |
jsonbcode | jsonb_bool (jsonb *builder, char buf[], size_t bufsize, int boolean) |
Push a boolean token to the builder. More... | |
jsonbcode | jsonb_null (jsonb *builder, char buf[], size_t bufsize) |
Push a null token to the builder. More... | |
jsonbcode | jsonb_string (jsonb *builder, char buf[], size_t bufsize, const char str[], size_t len) |
Push a string token to the builder. More... | |
jsonbcode | jsonb_number (jsonb *builder, char buf[], size_t bufsize, double number) |
Push a number token to the builder. More... | |
#define JSONB_API extern |
#define JSONB_MAX_DEPTH 128 |
Maximum JSON nesting depth, if default value is unwanted then it should be defined before json-build.h is included:
#define JSONB_MAX_DEPTH 256 #include "json-build.h"
#define TRACE | ( | prev, | |
next | |||
) | next |
#define DECORATOR | ( | a | ) |
#define STACK_HEAD | ( | b, | |
state | |||
) | *(b)->top = (state) |
#define STACK_PUSH | ( | b, | |
state | |||
) | TRACE(*(b)->top, *++(b)->top = (state)) |
#define BUFFER_COPY_CHAR | ( | b, | |
c, | |||
_pos, | |||
buf, | |||
bufsize | |||
) |
#define BUFFER_COPY | ( | b, | |
value, | |||
len, | |||
_pos, | |||
buf, | |||
bufsize | |||
) |
enum jsonbcode |
json-builder return codes
enum jsonbstate |
void jsonb_init | ( | jsonb * | builder | ) |
Initialize a jsonb handle.
builder | the handle to be initialized |
Push an object to the builder.
builder | the builder initialized with jsonb_init() |
buf | the JSON buffer |
bufsize | the JSON buffer size |
Pop an object from the builder.
builder | the builder initialized with jsonb_init() |
buf | the JSON buffer |
bufsize | the JSON buffer size |
Push a key to the builder.
builder | the builder initialized with jsonb_init() |
buf | the JSON buffer |
bufsize | the JSON buffer size |
key | the key to be inserted |
len | the key length |
Push an array to the builder.
builder | the builder initialized with jsonb_init() |
buf | the JSON buffer |
bufsize | the JSON buffer size |
Pop an array from the builder.
builder | the builder initialized with jsonb_init() |
buf | the JSON buffer |
bufsize | the JSON buffer size |
jsonbcode jsonb_token | ( | jsonb * | builder, |
char | buf[], | ||
size_t | bufsize, | ||
const char | token[], | ||
size_t | len | ||
) |
Push a raw JSON token to the builder.
builder | the builder initialized with jsonb_init() |
buf | the JSON buffer |
bufsize | the JSON buffer size |
token | the token to be inserted |
len | the token length |
Push a boolean token to the builder.
builder | the builder initialized with jsonb_init() |
buf | the JSON buffer |
bufsize | the JSON buffer size |
boolean | the boolean to be inserted |
Push a null token to the builder.
builder | the builder initialized with jsonb_init() |
buf | the JSON buffer |
bufsize | the JSON buffer size |
jsonbcode jsonb_string | ( | jsonb * | builder, |
char | buf[], | ||
size_t | bufsize, | ||
const char | str[], | ||
size_t | len | ||
) |
Push a string token to the builder.
builder | the builder initialized with jsonb_init() |
buf | the JSON buffer |
bufsize | the JSON buffer size |
str | the string to be inserted |
len | the string length |
Push a number token to the builder.
builder | the builder initialized with jsonb_init() |
buf | the JSON buffer |
bufsize | the JSON buffer size |
number | the number to be inserted |