Code compacting of JSON & DataTree:
- Remove excessive {}
DataTree:
- Use "p" prefix in funtion parameters to avoid object parameter overlap
This commit is contained in:
@@ -38,10 +38,10 @@ class CDataMember
|
||||
CDataMember * NextPeer;
|
||||
|
||||
// Manage Members
|
||||
CDataMember * CreateChild( const char * Name, const int Len = -1 );
|
||||
CDataMember * CreateChild( const char * pName, const int pLen = -1 );
|
||||
|
||||
// Set Member value
|
||||
bool SetValue( EJsonDataType Type, const char * Value = NULL, int Len = -1 );
|
||||
bool SetValue( EJsonDataType pType, const char * pValue = NULL, int pLen = -1 );
|
||||
bool SetValuePtr( EJsonDataType pType, const char * pValue, int pLen = -1 );
|
||||
|
||||
public:
|
||||
@@ -50,16 +50,15 @@ public:
|
||||
~CDataMember();
|
||||
|
||||
const char * GetName() { return Name; };
|
||||
EJsonDataType GetType() { return Type; };
|
||||
const int GetLen() { return Len; };
|
||||
|
||||
const char * GetChName( const char * Path );
|
||||
const int GetChLen( const char * Path );
|
||||
EJsonDataType GetChType( const char * Path );
|
||||
const int GetChLen( const char * Path );
|
||||
|
||||
/* Check Type */
|
||||
|
||||
EJsonDataType GetType() { return Type; };
|
||||
EJsonDataType GetChType( const char * Path );
|
||||
|
||||
inline bool isNull() { return (Type == jtNull); };
|
||||
inline bool isBool() { return (Type == jtBool); };
|
||||
inline bool isInt() { return (Type == jtInt); };
|
||||
@@ -73,9 +72,9 @@ public:
|
||||
inline CDataMember * GetFirstChild() { return GetChFirstChild( NULL, false ); };
|
||||
inline CDataMember * GetElement( const int Index ) { return GetChElement( NULL, Index, false ); };
|
||||
|
||||
CDataMember * GetChild( const char * Path, bool Create = false );
|
||||
CDataMember * GetChild( const char * Path, bool Create = false );
|
||||
CDataMember * GetChFirstChild( const char * Path, bool Create = false );
|
||||
CDataMember * GetChElement( const char * Path, const int Index, bool Create = false );
|
||||
CDataMember * GetChElement( const char * Path, const int Index, bool Create = false );
|
||||
|
||||
inline CDataMember * GetParent() { return Parent; };
|
||||
inline CDataMember * GetPrevPeer() { return PrevPeer; };
|
||||
@@ -83,37 +82,37 @@ public:
|
||||
|
||||
/* Read Values */
|
||||
|
||||
inline const char * GetStr( const char * Default = NULL ) { return GetChStr( NULL, Default, false ); };
|
||||
inline const char * GetStr( int &Len, const char * Default = NULL ) { return GetChStr( NULL, Len, Default, false ); };
|
||||
inline const bool GetBool( bool Default = false ) { return GetChBool( NULL, Default, false ); };
|
||||
inline const long GetInt( long Default = 0, const char * Mask = NULL ) { return GetChInt( NULL, Default, false, Mask ); };
|
||||
inline const char * GetStr( const char * Default = NULL ) { return GetChStr( NULL, Default, false ); };
|
||||
inline const char * GetStr( int &pLen, const char * Default = NULL ) { return GetChStr( NULL, pLen, Default, false ); };
|
||||
inline const bool GetBool( bool Default = false ) { return GetChBool( NULL, Default, false ); };
|
||||
inline const long GetInt( long Default = 0, const char * Mask = NULL ) { return GetChInt( NULL, Default, false, Mask ); };
|
||||
inline const double GetFloat( double Default = 0.0, const char * Mask = NULL ) { return GetChFloat( NULL, Default, false, Mask ); };
|
||||
|
||||
const char * GetChStr( const char * Path, const char * Default = NULL, bool Create = false );
|
||||
const char * GetChStr( const char * Path, int &Len, const char * Default = NULL, bool Create = false );
|
||||
const char * GetChStr( const char * Path, int &pLen, const char * Default = NULL, bool Create = false );
|
||||
const bool GetChBool( const char * Path, bool Default = false, bool Create = false );
|
||||
const long GetChInt( const char * Path, long Default = 0, bool Create = false, const char * Mask = NULL );
|
||||
const double GetChFloat( const char * Path, double Default = 0.0, bool Create = false, const char * Mask = NULL );
|
||||
|
||||
/* Modify Values */
|
||||
|
||||
inline bool SetNull() { return SetChNull( NULL ); };
|
||||
inline bool SetNull() { return SetChNull( NULL ); };
|
||||
inline bool SetObject() { return SetChObject( NULL ); };
|
||||
inline bool SetArray() { return SetChArray( NULL ); };
|
||||
inline bool SetArray() { return SetChArray( NULL ); };
|
||||
|
||||
inline bool SetBool( const bool Value ) { return SetChBool( NULL, Value ); };
|
||||
inline bool SetInt( const long Value, const char * Mask = NULL ) { return SetChInt( NULL, Value, Mask ); };
|
||||
inline bool SetFloat( const double Value, const char * Mask = NULL ) { return SetChFloat( NULL, Value, Mask ); };
|
||||
inline bool SetStr( const char * Value = NULL, const int Len = -1 ) { return SetChStr( NULL, Value, Len ); };
|
||||
inline bool SetBool( const bool pValue ) { return SetChBool( NULL, pValue ); };
|
||||
inline bool SetInt( const long pValue, const char * Mask = NULL ) { return SetChInt( NULL, pValue, Mask ); };
|
||||
inline bool SetFloat( const double pValue, const char * Mask = NULL ) { return SetChFloat( NULL, pValue, Mask ); };
|
||||
inline bool SetStr( const char * pValue = NULL, const int pLen = -1 ) { return SetChStr( NULL, pValue, pLen ); };
|
||||
|
||||
bool SetChStr( const char * Path, const char * Value = NULL, const int Len = -1 ); // Use Len param if Value contains NULL values
|
||||
bool SetChStr( const char * Path, const char * pValue = NULL, const int pLen = -1 ); // Use Len param if Value contains NULL values
|
||||
bool SetChObject( const char * Path );
|
||||
bool SetChArray( const char * Path );
|
||||
|
||||
bool SetChNull( const char * Path );
|
||||
bool SetChBool( const char * Path, const bool Value );
|
||||
bool SetChInt( const char * Path, const long Value, const char * Mask = NULL );
|
||||
bool SetChFloat( const char * Path, const double Value, const char * Mask = NULL );
|
||||
bool SetChNull( const char * Path );
|
||||
bool SetChBool( const char * Path, const bool pValue );
|
||||
bool SetChInt( const char * Path, const long pValue, const char * Mask = NULL );
|
||||
bool SetChFloat( const char * Path, const double pValue, const char * Mask = NULL );
|
||||
|
||||
/* Clear / Remove values */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user