Important Update: (incomplete)

- Split CConfigCore into two classes:
  - DataTreeCore.h - Tree data structure and access
  - JSONparseCore.h - JSON parsing functionality
- Renamed TConfigParam struct to TDataMember
- Renamed most of CDataTreeCore methods
This commit is contained in:
Charl Wentzel
2017-03-23 20:53:32 +02:00
parent ad4d8e8b5f
commit b823bd7ea7
7 changed files with 1149 additions and 1073 deletions

80
JSONparseCore.h Normal file
View File

@@ -0,0 +1,80 @@
/*
* JSONparseCore.h
*
* Created on: 5 Mar 2017
* Author: wentzelc
*/
#ifndef REDACORE_JSONPARSECORE_H_
#define REDACORE_JSONPARSECORE_H_
// redA Libraries
#include <BufferCore.h>
#include <DataTreeCore.h>
// Standard C/C++ Libraries
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
//---------------------------------------------------------------------------
class CJSONparse
{
private:
CDataTree * DataTree;
// File operation
int InputHandle;
int OutputHandle;
CShiftBuffer * Buffer;
// Parsing operation
char * BufEnd;
char * BufPos;
char * LineMark;
int LineNo;
int Level;
// Printing Operation
char Spacer[100];
int SpacerLen;
// Error
bool Error;
char ErrorText[100];
// File Buffer operation
bool CreateBuffer( int pBufLen );
bool FillBuffer();
void FreeBuffer();
// Parsing functions
inline void SkipWhiteSpace() {
while (isspace(*BufPos)) {
if (*BufPos == '\n') {
LineMark = BufPos;
LineNo++;
}
BufPos++;
}
}
bool ParseObject( TDataMember * Object );
bool ParseString( char ** Value, int * pLen = NULL, EDataType * pType = NULL );
bool ParsePrimitive( char ** Value, int * pLen = NULL, EDataType * pType = NULL );
bool SaveObject( TDataMember * Object, const int Indent );
public:
CJSONparse( CDataTree * pDataTree );
~CJSONparse();
bool LoadFile( const char * FilePath, int pBufLen = 500 );
bool SaveFile( const char * FilePath, const int ValueTab = 20 );
const char * GetError() { return ((Error)? ErrorText : "Success"); };
};
#endif /* REDACORE_JSONPARSECORE_H_ */