Simpleson
Macros | Functions | Variables
json.cpp File Reference

Simpleson source file. More...

#include "json.h"
#include <string.h>
#include <assert.h>

Macros

#define EMPTY_STRING(str)   (*str == '\0')
 Checks for an empty string. More...
 
#define SKIP_WHITE_SPACE(str)   { const char *next = json::parsing::tlws(str); str = next; }
 Moves a pointer to the first character that is not white space. More...
 
#define END_CHARACTER_ENCOUNTERED(obj, index)   (obj.is_array() ? *index == ']' : *index == '}')
 Determines if the end character of serialized JSON is encountered. More...
 
#define IS_DIGIT(input)   (input >= '0' && input <= '9')
 Determines if the supplied character is a digit. More...
 

Functions

bool is_control_character (const char input)
 
bool is_hex_digit (const char input)
 

Variables

const char * INT_FORMAT = "%i"
 Format used for integer to string conversion.
 
const char * UINT_FORMAT = "%u"
 Format used for unsigned integer to string conversion.
 
const char * LONG_FORMAT = "%li"
 Format used for long integer to string conversion.
 
const char * ULONG_FORMAT = "%lu"
 Format used for unsigned long integer to string conversion.
 
const char * CHAR_FORMAT = "%c"
 Format used for character to string conversion.
 
const char * FLOAT_FORMAT = "%f"
 Format used for floating-point number to string conversion.
 
const char * DOUBLE_FORMAT = "%lf"
 Format used for double floating-opint number to string conversion.
 

Detailed Description

Simpleson source file.

Macro Definition Documentation

◆ EMPTY_STRING

#define EMPTY_STRING (   str)    (*str == '\0')

Checks for an empty string.

Parameters
strThe string to check
Returns
True if the string is empty, false if the string is not empty
Warning
The string must be null-terminated for this macro to work

◆ END_CHARACTER_ENCOUNTERED

#define END_CHARACTER_ENCOUNTERED (   obj,
  index 
)    (obj.is_array() ? *index == ']' : *index == '}')

Determines if the end character of serialized JSON is encountered.

Parameters
objThe JSON object or array that is being written to
indexThe pointer to the character to be checked

◆ IS_DIGIT

#define IS_DIGIT (   input)    (input >= '0' && input <= '9')

Determines if the supplied character is a digit.

Parameters
inputThe character to be tested

◆ SKIP_WHITE_SPACE

#define SKIP_WHITE_SPACE (   str)    { const char *next = json::parsing::tlws(str); str = next; }

Moves a pointer to the first character that is not white space.

Parameters
strThe pointer to move