@ -5,7 +5,7 @@
*/
/*
* Copyright ( c ) 2006 - 200 8 , Tomasz Sowa
* Copyright ( c ) 2006 - 200 9 , Tomasz Sowa
* All rights reserved .
*
* Redistribution and use in source and binary forms , with or without
@ -638,6 +638,68 @@ void ProgramResources::CheckCoordinates()
void ProgramResources : : AddVariablesFunctions ( IniParser : : Section & temp_variables ,
IniParser : : Section & temp_functions ,
bool if_not_exist )
{
IniParser : : Section : : iterator ic ;
// we're adding variables
if ( ! if_not_exist )
variables . Clear ( ) ;
for ( ic = temp_variables . begin ( ) ; ic ! = temp_variables . end ( ) ; + + ic )
if ( ! if_not_exist | | ! variables . IsDefined ( ic - > first ) )
variables . Add ( ic - > first , ic - > second ) ;
// we're adding functions
if ( ! if_not_exist )
functions . Clear ( ) ;
for ( ic = temp_functions . begin ( ) ; ic ! = temp_functions . end ( ) ; + + ic )
{
const char * name ;
int param ;
if ( ! if_not_exist | | ! functions . IsDefined ( ic - > first ) )
if ( SplitFunction ( ic - > second , & name , & param ) )
functions . Add ( ic - > first , name , param ) ;
}
}
IniParser : : Error ProgramResources : : ReadVariablesFunctionsFromFile ( )
{
IniParser iparser ;
IniParser : : Section temp_variables , temp_functions ;
std : : string ini_value [ 20 ] ;
iparser . ConvertValueToSmallLetters ( false ) ;
iparser . SectionCaseSensitive ( false ) ;
// we have variables and functions case-sensitive
iparser . PatternCaseSensitive ( true ) ;
iparser . Associate ( " variables " , & temp_variables ) ;
iparser . Associate ( " functions " , & temp_functions ) ;
bad_line = - 1 ;
IniParser : : Error err = iparser . ReadFromFile ( configuration_file . c_str ( ) ) ;
if ( err = = IniParser : : err_cant_open_file )
return err ;
AddVariablesFunctions ( temp_variables , temp_functions , true ) ;
if ( err ! = IniParser : : err_ok )
bad_line = iparser . GetBadLine ( ) ;
return err ;
}
IniParser : : Error ProgramResources : : ReadFromFile ( )
@ -680,21 +742,7 @@ std::string ini_value[20];
if ( err = = IniParser : : err_cant_open_file )
return err ;
// we're adding variables
variables . Clear ( ) ;
for ( ic = temp_variables . begin ( ) ; ic ! = temp_variables . end ( ) ; + + ic )
variables . Add ( ic - > first , ic - > second ) ;
// we're adding functions
functions . Clear ( ) ;
for ( ic = temp_functions . begin ( ) ; ic ! = temp_functions . end ( ) ; + + ic )
{
const char * name ;
int param ;
if ( SplitFunction ( ic - > second , & name , & param ) )
functions . Add ( ic - > first , name , param ) ;
}
AddVariablesFunctions ( temp_variables , temp_functions , false ) ;
// we're setting various values
always_on_top = bool ( atoi ( ini_value [ 0 ] . c_str ( ) ) ) ;