![]() |
Gray C++ Libraries
0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
|
#include <cJSONReader.h>
Public Member Functions | |
cJSONReader (const char *pszVal, StrLen_t nStrLenMax=StrT::k_LEN_MAX, StrLen_t iTabSize=cStrConst::k_TabSize) | |
cJSONReader (const cMemBlock &b, StrLen_t iTabSize=cStrConst::k_TabSize) | |
~cJSONReader () | |
HRESULT | ReturnError (HRESULT hRes) const |
HRESULT | ReadVisitor (cJSONReadVisitor &rVisit) |
HRESULT | ReadVar (OUT cVariant &rVar) |
![]() | |
cTextReader (const char *pszStart, StrLen_t nLenMax=StrT::k_LEN_MAX, StrLen_t nTabSize=cStrConst::k_TabSize) | |
StrLen_t | get_LenMax () const noexcept |
StrLen_t | get_LenRemaining () const noexcept |
bool | isValidIndex () const noexcept |
bool | isValidPos () const noexcept |
const char * | get_CursorPtr () const noexcept |
char | get_CursorChar () const noexcept |
void | IncToks (StrLen_t nLen=1) |
void | IncTab (StrLen_t nLenChar=1) |
StrLen_t | IncLineCR (StrLen_t nLenChar=1) |
bool | isEOF () const |
void | SetStartPtr (const char *pszStart, StrLen_t nLenMax=StrT::k_LEN_MAX) |
![]() | |
cTextPos (STREAM_POS_t lOffset=(STREAM_POS_t) k_ITERATE_BAD, ITERATE_t iLineNum=k_ITERATE_BAD, StrLen_t iColNum=k_StrLen_UNK) noexcept | |
void | InitTop () noexcept |
bool | isTopLine () const noexcept |
bool | isValidPos () const noexcept |
STREAM_POS_t | get_Offset () const noexcept |
ITERATE_t | get_LineNum () const noexcept |
< Get 0 based line. More... | |
ITERATE_t | get_Line1 () const noexcept |
< Get 1 based line. More... | |
StrLen_t | get_Column1 () const noexcept |
< Get 1 based column. More... | |
void | IncOffset (StrLen_t nLenOffsetSrc) noexcept |
void | IncOffset (StrLen_t nLenOffsetSrc, StrLen_t nLenCol) noexcept |
void | IncChar (StrLen_t nLenChar=1) noexcept |
void | IncLine (StrLen_t nLenChar=1) noexcept |
StrLen_t | GetStr2 (OUT char *pszOut, StrLen_t nLenOut) const |
![]() | |
UNITTEST_FRIEND (cJSON) | |
Static Public Member Functions | |
static HRESULT GRAYCALL | ReadVar (cStreamInput &stmIn, OUT cVariant &rVar) |
![]() | |
static bool GRAYCALL | IsJSON (const char *pszStr, StrLen_t iLenMax=StrT::k_LEN_MAX) |
static cVariant GRAYCALL | Parse (const char *pszVal) |
static cJSONString GRAYCALL | Encode (const cVariant &v) |
Public Attributes | |
int | m_iDepth |
Indent depth of reader. More... | |
![]() | |
const StrLen_t | m_iTabSize |
for proper tracking of the column number on errors. and m_CursorPos. 0 = not used/don't care. More... | |
Protected Member Functions | |
bool | ReadWhitespace () |
HRESULT | ReadString (char *pszOut, StrLen_t nSizeMax) |
HRESULT | ReadString (cJSONReadVisitor &rVisit) |
HRESULT | ReadArray (cJSONReadVisitor &rVisit) |
HRESULT | ReadMapElementName (OUT ATOMCHAR_t *pszName) |
HRESULT | ReadMap (cJSONReadVisitor &rVisit) |
Additional Inherited Members | |
![]() | |
enum | TYPE_TYPE { TYPE_Null , TYPE_Bool , TYPE_Double , TYPE_String } |
![]() | |
static const cTextPos | k_Invalid |
Set to invalid values. More... | |
static const cTextPos | k_Zero |
Top of file. More... | |
![]() | |
static const char | k_null [5] = "null" |
"null" is valid syntax. More... | |
static const char | k_true [5] = "true" |
"true" More... | |
static const char | k_false [6] = "false" |
"false" More... | |
static const int | k_DEPTH_MAX = 50 |
Arbitrary max depth of read recursion. More... | |
![]() | |
const char * | m_pszStart |
starting read position in the data parsing stream/buffer. cTextPos cursor = m_pszStart + m_lOffset. More... | |
StrLen_t | m_nLenMax |
don't advance cTextPos::m_lOffset past this. More... | |
![]() | |
STREAM_POS_t | m_lOffset |
byte offset into the file. 0 based More... | |
ITERATE_t | m_iLineNum |
0 based row/line, for debug purposes if there is an error. More... | |
StrLen_t | m_iColNum |
0 based column number. if used. # of characters, not bytes. UTF can have multi bytes per char. More... | |
Walk/read the JSON formatted Stream/string/file and store as cVariant using cVariantMap. Deal with decoding escape sequences. Use cJSON::Parse to use this.
GrayLib::cJSONReader::cJSONReader | ( | const char * | pszVal, |
StrLen_t | nStrLenMax = StrT::k_LEN_MAX , |
||
StrLen_t | iTabSize = cStrConst::k_TabSize |
||
) |
GrayLib::cJSONReader::cJSONReader | ( | const cMemBlock & | b, |
StrLen_t | iTabSize = cStrConst::k_TabSize |
||
) |
GrayLib::cJSONReader::~cJSONReader | ( | ) |
|
protected |
start of array. read until closing ]
|
protected |
start of map/object. read until closing }
|
protected |
Read the "TagName": header for an element. StrT::k_LEN_MAX_KEY e.g. "0123123.123" is a valid JSON name.
given the start of quoted string, decode string until closing "quote"
|
protected |
start of quoted string. decode string until closing "
|
static |
Read into memory then parse and store result in cVariant.
Store result in cVariant using cJSONReadVisitor
HRESULT GrayLib::cJSONReader::ReadVisitor | ( | cJSONReadVisitor & | rVisit | ) |
Read a JSON block from memory buffer. Store result in cVariant
|
protected |
skip whitespace.
Something went wrong. In unit test this may be intentional. breakpoint?
int GrayLib::cJSONReader::m_iDepth |
Indent depth of reader.