CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
jsmn.cpp File Reference

Third-party (vendored): jsmn JSON tokenizer implementation (see include/jsmn.h). More...

#include "jsmn.h"
Include dependency graph for jsmn.cpp:

Go to the source code of this file.

Functions

static jsmntok_tjsmn_alloc_token (jsmn_parser *parser, jsmntok_t *tokens, size_t num_tokens)
 Allocates a fresh unused token from the token pull.
static void jsmn_fill_token (jsmntok_t *token, jsmntype_t type, int start, int end)
 Fills token type and boundaries.
static int jsmn_parse_primitive (jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, size_t num_tokens)
 Fills next available token with JSON primitive.
static int jsmn_parse_string (jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, size_t num_tokens)
 Filsl next token with JSON string.
int jsmn_parse (jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, unsigned int num_tokens)
 Parse JSON string and fill tokens.
void jsmn_init (jsmn_parser *parser)
 Creates a new parser based over a given buffer with an array of tokens available.
int GetJSONTokenLevel (jsmntok_t *tokens, int startToken)
int GetJSONToken (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, int parent, jsmntype_t type)
const char * GetJSONValue (jsmntok_t *tokens, int tokenCount, const char *json, int token, int &valLength)
std::string GetJSONValueString (jsmntok_t *tokens, int tokenCount, const char *json, int token)
int64 GetJSONValueInt64 (jsmntok_t *tokens, int tokenCount, const char *json, int token)
uint64 GetJSONValueUint64 (jsmntok_t *tokens, int tokenCount, const char *json, int token)
float64 GetJSONValueFloat64 (jsmntok_t *tokens, int tokenCount, const char *json, int token)
const char * GetJSONValue (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, jsmntype_t type, int &valLength, int level, int instance)
const char * GetJSONChildValue (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, int parent, jsmntype_t type, int &valLength)
std::string GetJSONValueString (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, jsmntype_t type, int level, int instance)
int64 GetJSONValueInt64 (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, jsmntype_t type, int level, int instance)
uint64 GetJSONValueUint64 (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, jsmntype_t type, int level, int instance)
float64 GetJSONValueFloat64 (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, jsmntype_t type, int level, int instance)
std::string GetJSONChildValueString (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, int parent, jsmntype_t type)
int64 GetJSONChildValueInt64 (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, int parent, jsmntype_t type)
uint64 GetJSONChildValueUint64 (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, int parent, jsmntype_t type)
float64 GetJSONChildValueFloat64 (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, int parent, jsmntype_t type)
std::vector< int > GetJSONArrayIndexes (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, jsmntype_t type, int level, int instance)
std::vector< int > GetJSONChildArrayIndexes (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, int parent, jsmntype_t type)
std::vector< int > GetJSONChildArrayIndexes (jsmntok_t *tokens, int tokenCount, const char *json, int parent, jsmntype_t type)
std::string AddToJSONRoot (const char *json, const char *subJSON)

Detailed Description

Third-party (vendored): jsmn JSON tokenizer implementation (see include/jsmn.h).

Not part of the CMSDK documentation remediation.

Definition in file jsmn.cpp.

Function Documentation

◆ AddToJSONRoot()

std::string AddToJSONRoot ( const char * json,
const char * subJSON )

◆ GetJSONArrayIndexes()

std::vector< int > GetJSONArrayIndexes ( jsmntok_t * tokens,
int tokenCount,
const char * json,
const char * key,
jsmntype_t type,
int level,
int instance )

◆ GetJSONChildArrayIndexes() [1/2]

std::vector< int > GetJSONChildArrayIndexes ( jsmntok_t * tokens,
int tokenCount,
const char * json,
const char * key,
int parent,
jsmntype_t type )

Definition at line 492 of file jsmn.cpp.

References JSMN_UNDEFINED.

◆ GetJSONChildArrayIndexes() [2/2]

std::vector< int > GetJSONChildArrayIndexes ( jsmntok_t * tokens,
int tokenCount,
const char * json,
int parent,
jsmntype_t type )

Definition at line 519 of file jsmn.cpp.

References JSMN_UNDEFINED.

◆ GetJSONChildValue()

const char * GetJSONChildValue ( jsmntok_t * tokens,
int tokenCount,
const char * json,
const char * key,
int parent,
jsmntype_t type,
int & valLength )

Definition at line 398 of file jsmn.cpp.

References jsmntok_t::end, JSMN_UNDEFINED, and jsmntok_t::start.

Referenced by GetJSONChildValueString().

◆ GetJSONChildValueFloat64()

float64 GetJSONChildValueFloat64 ( jsmntok_t * tokens,
int tokenCount,
const char * json,
const char * key,
int parent,
jsmntype_t type )

Definition at line 457 of file jsmn.cpp.

References cmlabs::utils::Ascii2Float64(), and GetJSONChildValueString().

◆ GetJSONChildValueInt64()

int64 GetJSONChildValueInt64 ( jsmntok_t * tokens,
int tokenCount,
const char * json,
const char * key,
int parent,
jsmntype_t type )

Definition at line 449 of file jsmn.cpp.

References cmlabs::utils::Ascii2Int64(), and GetJSONChildValueString().

◆ GetJSONChildValueString()

std::string GetJSONChildValueString ( jsmntok_t * tokens,
int tokenCount,
const char * json,
const char * key,
int parent,
jsmntype_t type )

◆ GetJSONChildValueUint64()

uint64 GetJSONChildValueUint64 ( jsmntok_t * tokens,
int tokenCount,
const char * json,
const char * key,
int parent,
jsmntype_t type )

◆ GetJSONToken()

int GetJSONToken ( jsmntok_t * tokens,
int tokenCount,
const char * json,
const char * key,
int parent,
jsmntype_t type )

Definition at line 328 of file jsmn.cpp.

References JSMN_UNDEFINED.

◆ GetJSONTokenLevel()

int GetJSONTokenLevel ( jsmntok_t * tokens,
int startToken )

Definition at line 317 of file jsmn.cpp.

References jsmntok_t::parent.

Referenced by GetJSONArrayIndexes(), and GetJSONValue().

◆ GetJSONValue() [1/2]

const char * GetJSONValue ( jsmntok_t * tokens,
int tokenCount,
const char * json,
const char * key,
jsmntype_t type,
int & valLength,
int level,
int instance )

Definition at line 375 of file jsmn.cpp.

References jsmntok_t::end, GetJSONTokenLevel(), JSMN_UNDEFINED, and jsmntok_t::start.

◆ GetJSONValue() [2/2]

◆ GetJSONValueFloat64() [1/2]

float64 GetJSONValueFloat64 ( jsmntok_t * tokens,
int tokenCount,
const char * json,
const char * key,
jsmntype_t type,
int level,
int instance )

Definition at line 436 of file jsmn.cpp.

References cmlabs::utils::Ascii2Float64(), and GetJSONValueString().

◆ GetJSONValueFloat64() [2/2]

float64 GetJSONValueFloat64 ( jsmntok_t * tokens,
int tokenCount,
const char * json,
int token )

Definition at line 370 of file jsmn.cpp.

References cmlabs::utils::Ascii2Float64(), and GetJSONValueString().

◆ GetJSONValueInt64() [1/2]

int64 GetJSONValueInt64 ( jsmntok_t * tokens,
int tokenCount,
const char * json,
const char * key,
jsmntype_t type,
int level,
int instance )

Definition at line 428 of file jsmn.cpp.

References cmlabs::utils::Ascii2Int64(), and GetJSONValueString().

◆ GetJSONValueInt64() [2/2]

int64 GetJSONValueInt64 ( jsmntok_t * tokens,
int tokenCount,
const char * json,
int token )

Definition at line 362 of file jsmn.cpp.

References cmlabs::utils::Ascii2Int64(), and GetJSONValueString().

◆ GetJSONValueString() [1/2]

std::string GetJSONValueString ( jsmntok_t * tokens,
int tokenCount,
const char * json,
const char * key,
jsmntype_t type,
int level,
int instance )

Definition at line 420 of file jsmn.cpp.

References GetJSONValue().

◆ GetJSONValueString() [2/2]

std::string GetJSONValueString ( jsmntok_t * tokens,
int tokenCount,
const char * json,
int token )

◆ GetJSONValueUint64() [1/2]

uint64 GetJSONValueUint64 ( jsmntok_t * tokens,
int tokenCount,
const char * json,
const char * key,
jsmntype_t type,
int level,
int instance )

Definition at line 432 of file jsmn.cpp.

References cmlabs::utils::Ascii2Uint64(), and GetJSONValueString().

◆ GetJSONValueUint64() [2/2]

uint64 GetJSONValueUint64 ( jsmntok_t * tokens,
int tokenCount,
const char * json,
int token )

Definition at line 366 of file jsmn.cpp.

References cmlabs::utils::Ascii2Uint64(), and GetJSONValueString().

◆ jsmn_alloc_token()

jsmntok_t * jsmn_alloc_token ( jsmn_parser * parser,
jsmntok_t * tokens,
size_t num_tokens )
static

Allocates a fresh unused token from the token pull.

Definition at line 11 of file jsmn.cpp.

References jsmntok_t::end, jsmntok_t::parent, jsmntok_t::size, jsmntok_t::start, and jsmn_parser::toknext.

Referenced by jsmn_parse(), jsmn_parse_primitive(), and jsmn_parse_string().

◆ jsmn_fill_token()

void jsmn_fill_token ( jsmntok_t * token,
jsmntype_t type,
int start,
int end )
static

Fills token type and boundaries.

Definition at line 29 of file jsmn.cpp.

References jsmntok_t::end, jsmntok_t::size, jsmntok_t::start, and jsmntok_t::type.

Referenced by jsmn_parse_primitive(), and jsmn_parse_string().

◆ jsmn_init()

void jsmn_init ( jsmn_parser * parser)

◆ jsmn_parse()

◆ jsmn_parse_primitive()

int jsmn_parse_primitive ( jsmn_parser * parser,
const char * js,
size_t len,
jsmntok_t * tokens,
size_t num_tokens )
static

Fills next available token with JSON primitive.

Definition at line 40 of file jsmn.cpp.

References jsmn_alloc_token(), JSMN_ERROR_INVAL, JSMN_ERROR_NOMEM, JSMN_ERROR_PART, jsmn_fill_token(), JSMN_PRIMITIVE, jsmntok_t::parent, jsmn_parser::pos, and jsmn_parser::toksuper.

Referenced by jsmn_parse().

◆ jsmn_parse_string()

int jsmn_parse_string ( jsmn_parser * parser,
const char * js,
size_t len,
jsmntok_t * tokens,
size_t num_tokens )
static

Filsl next token with JSON string.

Definition at line 89 of file jsmn.cpp.

References jsmn_alloc_token(), JSMN_ERROR_INVAL, JSMN_ERROR_NOMEM, JSMN_ERROR_PART, jsmn_fill_token(), JSMN_STRING, jsmntok_t::parent, jsmn_parser::pos, and jsmn_parser::toksuper.

Referenced by jsmn_parse().