Important Update:
- ApplicationCore: - Rename ConfigParser -> JSONparser - Make JSONparser a public parameter - DataTreeCore: - Bug fix: Insufficient memory allocation on SetValue if Len = -1
This commit is contained in:
@@ -40,7 +40,7 @@ CApplication::CApplication( EDebugLevel pLogLevel )
|
|||||||
|
|
||||||
// Create Configuration
|
// Create Configuration
|
||||||
DataTree = new CDataTree();
|
DataTree = new CDataTree();
|
||||||
ConfigParser = new CJSONparse( DataTree );
|
JSONparser = new CJSONparse( DataTree );
|
||||||
|
|
||||||
// Selector
|
// Selector
|
||||||
Selector = NULL;
|
Selector = NULL;
|
||||||
@@ -73,7 +73,7 @@ CApplication::~CApplication()
|
|||||||
if (Selector) delete Selector;
|
if (Selector) delete Selector;
|
||||||
if (Log) delete Log;
|
if (Log) delete Log;
|
||||||
if (DataTree) delete DataTree;
|
if (DataTree) delete DataTree;
|
||||||
if (ConfigParser) delete ConfigParser;
|
if (JSONparser) delete JSONparser;
|
||||||
|
|
||||||
// Free Process Name
|
// Free Process Name
|
||||||
if (ProcessName) free( ProcessName );
|
if (ProcessName) free( ProcessName );
|
||||||
@@ -119,13 +119,13 @@ bool CApplication::LoadConfig( int argc, char *argv[], const char * pConfigPath
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load Application List
|
// Load Application List
|
||||||
if (ConfigParser->ReadFromFile( pConfigPath, ConfigFile )) {
|
if (JSONparser->ReadFromFile( pConfigPath, ConfigFile )) {
|
||||||
if (Log) Log->Message( dlLow, dlLow, "%s: Config file loaded (%s)", ProcessName, ConfigFile );
|
if (Log) Log->Message( dlLow, dlLow, "%s: Config file loaded (%s)", ProcessName, ConfigFile );
|
||||||
} else {
|
} else {
|
||||||
if (Log) Log->Message( dlLow, dlLow, "%s: Fail to load config file (%s)- %s", ProcessName, ConfigFile, ConfigParser->GetError() );
|
if (Log) Log->Message( dlLow, dlLow, "%s: Fail to load config file (%s)- %s", ProcessName, ConfigFile, JSONparser->GetError() );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//ConfigParser->WriteToScreen( pConfigPath, 2 );
|
//JSONparser->WriteToScreen( pConfigPath, 2 );
|
||||||
|
|
||||||
// Loaded successfully
|
// Loaded successfully
|
||||||
return true;
|
return true;
|
||||||
@@ -136,9 +136,9 @@ bool CApplication::SaveConfig()
|
|||||||
{
|
{
|
||||||
// Save updated configuration
|
// Save updated configuration
|
||||||
if (ConfigFile && *ConfigFile)
|
if (ConfigFile && *ConfigFile)
|
||||||
ConfigParser->WriteToFile( "config", ConfigFile );
|
JSONparser->WriteToFile( "config", ConfigFile );
|
||||||
if (AddressFile && *AddressFile )
|
if (AddressFile && *AddressFile )
|
||||||
ConfigParser->WriteToFile( "address", AddressFile );
|
JSONparser->WriteToFile( "address", AddressFile );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
@@ -192,12 +192,12 @@ bool CApplication::LoadConfigData()
|
|||||||
// Load Address List
|
// Load Address List
|
||||||
if ((AddressFile = (char*)DataTree->GetStr( ConfigMember, "AddressList/Path", NULL )))
|
if ((AddressFile = (char*)DataTree->GetStr( ConfigMember, "AddressList/Path", NULL )))
|
||||||
{
|
{
|
||||||
if (ConfigParser->ReadFromFile( "address", AddressFile )) {
|
if (JSONparser->ReadFromFile( "address", AddressFile )) {
|
||||||
if (Log) Log->Message( dlLow, dlLow, "%s: Address file loaded (%s)", ProcessName, AddressFile );
|
if (Log) Log->Message( dlLow, dlLow, "%s: Address file loaded (%s)", ProcessName, AddressFile );
|
||||||
} else {
|
} else {
|
||||||
if (Log) Log->Message( dlLow, dlLow, "%s: Fail to load Address file (%s) - %s", ProcessName, AddressFile, ConfigParser->GetError() );
|
if (Log) Log->Message( dlLow, dlLow, "%s: Fail to load Address file (%s) - %s", ProcessName, AddressFile, JSONparser->GetError() );
|
||||||
}
|
}
|
||||||
//ConfigParser->WriteToScreen( pAddressListPath, 2 );
|
//JSONparser->WriteToScreen( pAddressListPath, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure Selector
|
// Configure Selector
|
||||||
|
|||||||
@@ -47,9 +47,6 @@ protected:
|
|||||||
// List
|
// List
|
||||||
TFunctionItem * FirstFunction;
|
TFunctionItem * FirstFunction;
|
||||||
|
|
||||||
// Configuration
|
|
||||||
CJSONparse * ConfigParser = NULL;
|
|
||||||
|
|
||||||
// Output
|
// Output
|
||||||
EDebugLevel LogLevel;
|
EDebugLevel LogLevel;
|
||||||
int LogOutput;
|
int LogOutput;
|
||||||
@@ -66,6 +63,7 @@ public:
|
|||||||
CDataTree * DataTree;
|
CDataTree * DataTree;
|
||||||
CLogCore * Log;
|
CLogCore * Log;
|
||||||
CSelect * Selector;
|
CSelect * Selector;
|
||||||
|
CJSONparse * JSONparser = NULL;
|
||||||
|
|
||||||
// Life Cycle
|
// Life Cycle
|
||||||
CApplication( EDebugLevel pDebugLevel );
|
CApplication( EDebugLevel pDebugLevel );
|
||||||
|
|||||||
@@ -371,7 +371,7 @@ bool CDataTree::SetValue( TDataMember * Member, EDataType Type, const char * Va
|
|||||||
|
|
||||||
// Check Length
|
// Check Length
|
||||||
if (Len == -1) {
|
if (Len == -1) {
|
||||||
Len = strlen( Value );
|
Len = strlen(Value)+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create copy of value
|
// Create copy of value
|
||||||
|
|||||||
Reference in New Issue
Block a user