Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00027 #include <H3D/INIFile.h>
00028 #include <fstream>
00029
00030 using namespace std;
00031 using namespace H3D;
00032
00033 #define GET4(ENV,GROUP,VAR,DEFAULT) \
00034 ( getenv(ENV) ? \
00035 string(getenv(ENV)) : \
00036 ( ini_file.hasOption(GROUP,VAR) ? \
00037 ini_file.get( GROUP, VAR ) : \
00038 DEFAULT ) )
00039
00040 #define GET_ENV_INI_DEFAULT(ENV,PATH,GROUP,VAR,DEFAULT) \
00041 ( getenv(ENV) ? \
00042 string(getenv(ENV)) : \
00043 ( ini_file.hasOption(GROUP,VAR) ? \
00044 PATH + ini_file.get( GROUP, VAR ) : \
00045 DEFAULT ) )
00046
00047 inline string GET_ENV_INI_DEFAULT_FILE( INIFile &ini_file,
00048 const string &ENV,
00049 const string &DISPLAY_PATH,
00050 const string &COMMON_PATH,
00051 const string &GROUP,
00052 const string &VAR ) {
00053 char *env = getenv(ENV.c_str());
00054 if( env ) return env;
00055
00056 if( ini_file.hasOption(GROUP,VAR) ) {
00057 string option = ini_file.get( GROUP, VAR );
00058 string full_path = string(DISPLAY_PATH) + option;
00059 ifstream inp( full_path.c_str() );
00060 inp.close();
00061 string r = full_path;
00062 if(!inp.fail()) return full_path;
00063 inp.clear();
00064
00065 full_path = (COMMON_PATH + option);
00066 inp.open( full_path.c_str() );
00067 inp.close();
00068 if(!inp.fail()) return full_path;
00069 }
00070 return "";
00071 }
00072
00073 #define GET_INT(GROUP,VAR,DEFAULT) \
00074 ( ini_file.hasOption(GROUP,VAR) ? \
00075 atoi(ini_file.get( GROUP, VAR ).c_str()) : \
00076 DEFAULT )
00077
00078 #define GET_BOOL(GROUP,VAR,DEFAULT) \
00079 ( ini_file.hasOption(GROUP,VAR) ? \
00080 ini_file.getBoolean( GROUP, VAR ) : \
00081 DEFAULT )