Goose Management Model ODdox
1.02
|
Go to the documentation of this file.
25 #define _CRT_SECURE_NO_DEPRECATE
33 #include "../BatchALMaSS/ALMaSS_Setup.h"
37 #if !(defined __UNIX) & !(defined __BORLANDC__)
39 #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
75 if ( NULL ==
g_cfg ) {
138 g_msg->
Warn(
"CfgFloat::set Value out of range: ", a_newval);
160 const char* a_defval )
184 string l_key = a_key;
186 if (
CfgI.find( l_key ) !=
CfgI.end() ) {
191 unsigned int i = (int)
CfgVals.size();
204 cf_file.open(a_cfgfile,fstream::in);
205 if ( !cf_file.is_open() ) {
206 g_msg->
Warn(
WARN_FILE,
"Configurator::ReadSymbols() Unable to open file for reading: ", a_cfgfile );
209 while ( !cf_file.eof()) {
228 while ( *a_line !=
'"' && *a_line !=
'\0' ) {
233 if ( *a_line !=
'"' ) {
236 " String not enclosed in double quotes at "
237 "config line ", lineno );
241 char* endline = ++a_line;
242 bool escaped =
false, found =
false;
244 while ( *endline !=
'\0' ) {
245 if ( *endline ==
'\\' ) {
249 if ( *endline ==
'"' &&
256 if ( *endline ==
'"' && !escaped ) {
269 "No ending double quote after string at "
270 "config line ", lineno );
276 if ( sscanf( endline,
"%*s" ) == 1 ) {
278 if ( sscanf( endline,
"%*[#]" ) != 1 ) {
282 "Illegal comment at "
283 "config line ", lineno );
296 while ( *a_rest_of_line !=
'\0' && *a_rest_of_line !=
'#' ) {
297 if ( *a_rest_of_line ==
'"' ) {
316 if ( sscanf( a_line,
"%[#]", l_id ) == 1 ) {
321 if ( sscanf( a_line,
"%s", l_id) == EOF ) {
327 int l_conv = sscanf( a_line,
"%[A-Z_] (%[a-z]) %s", l_id, l_type, l_sep );
333 "Syntax error at config line ",
338 if ( strcmp( l_sep,
"=" ) != 0 ) {
342 "Missing '=' assignment operator at config line ",
347 if (
CfgI.find( l_id ) ==
CfgI.end() ) {
353 if ( strlen( l_type ) == 6 &&
354 strncmp( l_type,
"string", 6 ) == 0 ) {
364 l_conv = sscanf( a_line,
"%*[A-Z_] (%*[a-z]) %*s %s %s",
367 if ( l_conv == 2 && l_comm[0] !=
'#' ) {
371 "Syntax error at end of config line ",
376 if ( strlen( l_type ) == 5 &&
377 strncmp( l_type,
"float", 5 ) == 0 ) {
382 if ( strlen( l_type ) == 4 &&
383 strncmp( l_type,
"bool", 4 ) == 0 ) {
388 if ( strlen( l_type ) == 3 &&
389 strncmp( l_type,
"int", 3 ) == 0 ) {
396 "Unknown type specifier at config line ",
406 "Type for identifier ",
407 CfgVals[ a_i ]->getkey().c_str() );
446 string l_key = a_key;
448 if ( sscanf( a_val,
"%d", &l_val ) != 1 ) {
451 "Not an integer data value at config line",
457 unsigned int i =
CfgI[ l_key ];
459 "Attempting to set public config variable in line",
469 "Non-integer identifier specified at config line",
475 dynamic_cast<CfgInt*>(
CfgVals[ i ])->set( l_val );
482 string l_key = a_key;
485 if ( strcmp ( a_val,
"false" ) == 0 ) {
487 }
else if ( strcmp ( a_val,
"true" ) == 0 ) {
492 "Not a boolean data value at config line",
498 unsigned int i =
CfgI[ l_key ];
500 "Attempting to set public config variable in line",
510 "Non-boolean identifier specified at config line",
516 dynamic_cast<CfgBool*>(
CfgVals[ i ])->set( l_val );
526 string l_key = a_key;
528 if ( sscanf( a_val,
"%f", &f) != 1 ) {
531 "Not a floating point data value at config line",
538 unsigned int i =
CfgI[ l_key ];
540 "Attempting to set public config variable in line",
550 "Non-floating point identifier specified at config line",
556 dynamic_cast<CfgFloat*>(
CfgVals[ i ])->set( l_val );
564 string l_key = a_key;
567 unsigned int i =
CfgI[ l_key ];
569 "Attempting to set public config variable in line",
579 "Non-string identifier specified at config line",
585 dynamic_cast<CfgStr*>(
CfgVals[ i ])->set( a_val );
615 l_dumpfile=fopen( a_dumpfile,
"w" );
618 "Unable to open file for writing:",
623 typedef map<string,unsigned int>::const_iterator MI;
625 for ( MI ii =
CfgI.begin(); ii !=
CfgI.end(); ii++ ) {
626 unsigned int i = ii->second;
629 if (
CfgVals[ i ]->getlevel() > a_level ) {
635 string rubbish=
CfgVals[ i ]->getkey();
636 l_id=rubbish.c_str();
638 sscanf( l_id,
"%[A-Z]", l_nprefix );
639 if ( strcmp( l_oprefix, l_nprefix ) != 0 ) {
640 fprintf( l_dumpfile,
"\n" );
641 strcpy( l_oprefix, l_nprefix );
644 fprintf( l_dumpfile,
"%s (%s) = ",
649 switch(
CfgVals[ i ]->gettype() ) {
653 fprintf( l_dumpfile,
"%d", l_p->
value() );
659 fprintf( l_dumpfile,
"%f", l_p->
value() );
665 if ( l_p->
value() ) {
666 fprintf( l_dumpfile,
"true" );
668 fprintf( l_dumpfile,
"false" );
675 fprintf( l_dumpfile,
"\"%s\"", l_p->
value() );
681 sprintf( l_errno,
"%d",
CfgVals[ i ]->gettype() );
683 "Unknown symbol type read:",
688 fprintf( l_dumpfile,
" # %s\n",
map< string, unsigned int > CfgI
CfgStr(const char *a_key, CfgSecureLevel a_level, const char *a_defval)
CfgFloat(const char *a_key, CfgSecureLevel a_level, double a_defval)
void WarnAddInfo(MapErrorState a_level, std::string a_add1, std::string a_add2)
String configurator entry class.
bool SetCfgGatekeeper(const char *a_method, const char *a_key, CfgSecureLevel a_level)
CfgBool(const char *a_key, CfgSecureLevel a_level, bool a_defval)
static CfgBool l_cfg_public_exit_on_set("CFG_PUBLIC_EXIT_ON_SET", CFG_CUSTOM, true)
A class to provide standard parameter entry facilities.
void ShowIdType(unsigned int a_i)
virtual void set(double a_newval)
static const char * CfgTypeStrings[]
CfgBase(const char *a_key, CfgSecureLevel a_level)
class Configurator * g_cfg
bool ReadSymbols(const char *a_cfgfile)
void DumpPublicSymbols(const char *a_dumpfile, CfgSecureLevel a_level)
Bool configurator entry class.
void SetCfgBool(char *a_key, char *a_val)
static const char * CfgSecureStrings[]
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
bool Register(CfgBase *a_cfgval, const char *a_key)
#define CFG_MAX_LINE_LENGTH
void SetCfgStr(char *a_key, char *a_val)
void FloatToDouble(double &, float)
CfgInt(const char *a_key, CfgSecureLevel a_level, int a_defval)
bool LastDoubleQuote(char *a_rest_of_line)
Integer configurator entry class.
static CfgBool l_cfg_public_warn_on_set("CFG_PUBLIC_WARN_ON_SET", CFG_CUSTOM, true)
char * ExtractString(char *a_line)
MapErrorMsg * g_msg
This pointer provides access the to the internal ALMaSS error message system.
Base class for a configurator entry.
Double configurator entry class.
void SetCfgInt(char *a_key, char *a_val)
void DumpSymbols(const char *a_dumpfile, CfgSecureLevel a_level)
vector< CfgBase * > CfgVals
void ParseCfgLine(char *a_line)
void SetCfgFloat(char *a_key, char *a_val)
void DumpAllSymbolsAndExit(const char *a_dumpfile)
virtual void set(int a_newval)