You.i Engine
CYIRapidJSONUtility Class Reference

Detailed Description

A front-end utility class aimed to simplify the use of RapidJSON tools.

#include <utility/YiRapidJSONUtility.h>

Public Member Functions

virtual ~CYIRapidJSONUtility ()
 

Static Public Member Functions

static std::unique_ptr< yi::rapidjson::Document > CreateDocumentFromString (const CYIString &rJsonString, CYIParsingError &rParsingError)
 
static std::unique_ptr< yi::rapidjson::Document > CreateDocumentFromFile (const CYIString &rFilePath, CYIParsingError &rParsingError)
 
static CYIString CreateStringFromDocument (const yi::rapidjson::Document &rDocument)
 
static bool GetBooleanField (const yi::rapidjson::Value *pValue, const char *pFieldName, bool *pFieldData, CYIParsingError &rParsingError)
 
static bool GetIntegerField (const yi::rapidjson::Value *pValue, const char *pFieldName, int32_t *pFieldData, CYIParsingError &rParsingError)
 
static bool GetLongField (const yi::rapidjson::Value *pValue, const char *pFieldName, int64_t *pFieldData, CYIParsingError &rParsingError)
 
static bool GetUnsignedLongField (const yi::rapidjson::Value *pValue, const char *pFieldName, uint64_t *pFieldData, CYIParsingError &rParsingError)
 
static bool GetStringField (const yi::rapidjson::Value *pValue, const char *pFieldName, CYIString &rFieldData, CYIParsingError &rParsingError)
 
static bool GetFloatField (const yi::rapidjson::Value *pValue, const char *pFieldName, float *pFieldData, CYIParsingError &rParsingError)
 
static bool GetDateField (const yi::rapidjson::Value *pValue, const char *pFieldName, CYIDateTime &rFieldData, CYIParsingError &rParsingError)
 
static bool IsNullField (const yi::rapidjson::Value *pValue, const char *pFieldName, bool *pbFieldIsNull, CYIParsingError &rParsingError)
 
static bool AddBooleanField (yi::rapidjson::Document *pDocument, const CYIString &rFieldName, bool bValue)
 
static bool AddIntegerField (yi::rapidjson::Document *pDocument, const CYIString &rFieldName, int32_t nValue)
 
static bool AddLongField (yi::rapidjson::Document *pDocument, const CYIString &rFieldName, int64_t nValue)
 
static bool AddUnsignedLongField (yi::rapidjson::Document *pDocument, const CYIString &rField, uint64_t uValue)
 
static bool AddFloatField (yi::rapidjson::Document *pDocument, const CYIString &rFieldName, float fValue)
 
static bool AddObjectField (yi::rapidjson::Document *pDocument, const CYIString &rFieldName, yi::rapidjson::Value &rValue)
 
static bool AddStringField (yi::rapidjson::Document *pDocument, const CYIString &rFieldName, const CYIString &rValue)
 

Constructor & Destructor Documentation

virtual CYIRapidJSONUtility::~CYIRapidJSONUtility ( )
virtual

Member Function Documentation

static bool CYIRapidJSONUtility::AddBooleanField ( yi::rapidjson::Document *  pDocument,
const CYIString rFieldName,
bool  bValue 
)
static

Adds a new boolean field, bValue, to the RapidJSON pDocument for the given rFieldName.

static bool CYIRapidJSONUtility::AddFloatField ( yi::rapidjson::Document *  pDocument,
const CYIString rFieldName,
float  fValue 
)
static

Adds a new float field, fValue, to the RapidJSON pDocument for the given rFieldName.

static bool CYIRapidJSONUtility::AddIntegerField ( yi::rapidjson::Document *  pDocument,
const CYIString rFieldName,
int32_t  nValue 
)
static

Adds a new integer field, nValue, to the RapidJSON pDocument for the given rFieldName.

static bool CYIRapidJSONUtility::AddLongField ( yi::rapidjson::Document *  pDocument,
const CYIString rFieldName,
int64_t  nValue 
)
static

Adds a new long field, nValue, to the RapidJSON pDocument for the given rFieldName.

static bool CYIRapidJSONUtility::AddObjectField ( yi::rapidjson::Document *  pDocument,
const CYIString rFieldName,
yi::rapidjson::Value &  rValue 
)
static

Adds a new RapidJSon object field, rValue, to the RapidJSON pDocument for the given rFieldName.

static bool CYIRapidJSONUtility::AddStringField ( yi::rapidjson::Document *  pDocument,
const CYIString rFieldName,
const CYIString rValue 
)
static

Adds a new CYIString field, rValue, to the RapidJSON pDocument for the given rFieldName.

static bool CYIRapidJSONUtility::AddUnsignedLongField ( yi::rapidjson::Document *  pDocument,
const CYIString rField,
uint64_t  uValue 
)
static

Adds a new unsigned long field, nValue, to the RapidJSON pDocument for the given rFieldName.

static std::unique_ptr<yi::rapidjson::Document> CYIRapidJSONUtility::CreateDocumentFromFile ( const CYIString rFilePath,
CYIParsingError rParsingError 
)
static

Creates a new RapidJSON Document object containing the parsed data from the file at the given rFilePath. Parsing errors will be returned in rParsingError.

Warning
The developer is responsible for cleaning up the returned document.
static std::unique_ptr<yi::rapidjson::Document> CYIRapidJSONUtility::CreateDocumentFromString ( const CYIString rJsonString,
CYIParsingError rParsingError 
)
static

Creates a new RapidJSON Document object containing the parsed data from the given rJsonString. Parsing errors will be returned in rParsingError.

Warning
The developer is responsible for cleaning up the returned document.
When assigning the result of this function only assign it to a variable of the type rapidjson::Document and not rapidjson::Value. Otherwise deleting the pointer to the rapidjson::Value will leak memory. Refer to the RapidJSON documentation http://rapidjson.org/classrapidjson_1_1_generic_document.html
static CYIString CYIRapidJSONUtility::CreateStringFromDocument ( const yi::rapidjson::Document &  rDocument)
static

Returns a CYIString representation of the RapidJSON Document.

static bool CYIRapidJSONUtility::GetBooleanField ( const yi::rapidjson::Value *  pValue,
const char *  pFieldName,
bool *  pFieldData,
CYIParsingError rParsingError 
)
static

Retrieves pFieldData as a boolean given a RapidJSON pValue and a pFieldName. In addition to reading Boolean data type, Number values of 1 and 0 and String values of "1", "0", "true" and "false" are all successfully read. pFieldData is only modified if parsing is successful (and function returns true) Returns false on error with rParsingError populated with error information from the last parsing error. Json value 'null' also returns false.

static bool CYIRapidJSONUtility::GetDateField ( const yi::rapidjson::Value *  pValue,
const char *  pFieldName,
CYIDateTime rFieldData,
CYIParsingError rParsingError 
)
static

Retrieves pFieldData as a CYIDateTime given a RapidJSON pValue and a pFieldName. pFieldData is only modified if parsing is successful (and function returns true) Returns false on error with rParsingError populated with error information from the last parsing error. Json value 'null' also returns false.

Note
This function works with dates in the ISO 8601 format as well as epoch time in seconds.
static bool CYIRapidJSONUtility::GetFloatField ( const yi::rapidjson::Value *  pValue,
const char *  pFieldName,
float *  pFieldData,
CYIParsingError rParsingError 
)
static

Retrieves pFieldData as a float given a RapidJSON pValue and a pFieldName. In addition to reading Number data type, also reads String values containing a numeric value. pFieldData is only modified if parsing is successful (and function returns true) Returns false on error with rParsingError populated with error information from the last parsing error. Json value 'null' also returns false.

static bool CYIRapidJSONUtility::GetIntegerField ( const yi::rapidjson::Value *  pValue,
const char *  pFieldName,
int32_t *  pFieldData,
CYIParsingError rParsingError 
)
static

Retrieves pFieldData as an integer given a RapidJSON pValue and a pFieldName. In addition to reading Number data type, also reads String values containing a numeric value. pFieldData is only modified if parsing is successful (and function returns true) Returns false on error with rParsingError populated with error information from the last parsing error. Json value 'null' also returns false.

static bool CYIRapidJSONUtility::GetLongField ( const yi::rapidjson::Value *  pValue,
const char *  pFieldName,
int64_t *  pFieldData,
CYIParsingError rParsingError 
)
static

Retrieves pFieldData as a long given a RapidJSON pValue and a pFieldName. In addition to reading Number data type, also reads String values containing a numeric value. pFieldData is only modified if parsing is successful (and function returns true) Returns false on error with rParsingError populated with error information from the last parsing error. Json value 'null' also returns false.

static bool CYIRapidJSONUtility::GetStringField ( const yi::rapidjson::Value *  pValue,
const char *  pFieldName,
CYIString rFieldData,
CYIParsingError rParsingError 
)
static

Retrieves pFieldData as a CYIString given a RapidJSON pValue and a pFieldName. pFieldData is only modified if parsing is successful (and function returns true) Returns false on error with rParsingError populated with error information from the last parsing error. Json value 'null' also returns false.

static bool CYIRapidJSONUtility::GetUnsignedLongField ( const yi::rapidjson::Value *  pValue,
const char *  pFieldName,
uint64_t *  pFieldData,
CYIParsingError rParsingError 
)
static

Retrieves pFieldData as an unsigned long given a RapidJSON pValue and a pFieldName. In addition to reading Number data type, also reads String values containing a numeric value. pFieldData is only modified if parsing is successful (and function returns true) Returns false on error with rParsingError populated with error information from the last parsing error. Json value 'null' also returns false.

static bool CYIRapidJSONUtility::IsNullField ( const yi::rapidjson::Value *  pValue,
const char *  pFieldName,
bool *  pbFieldIsNull,
CYIParsingError rParsingError 
)
static

Sets pbFieldIsNull to true if the pFieldName contained within the RapidJSON pValue is null and false otherwise. Returns true when parsing the field succeeded and false otherwise. When false is returned rParsingError will be populated.


The documentation for this class was generated from the following file: