/* Method to fetch (as boolean) the first value of a given * variable list. * * In this context, a variable list is the same as a variable but * it is composed of several parts (words), separated by spaces. * * @param variableList Variable list name. * @param section Section the variable list belongs to. * * \warning This method will MODIFY the original content of * 'variableList'. */ bool ConfDataReader::fetchListValueAsBoolean( string variableList, string section, bool defaultVal ) throw(ConfigurationException) { try { // Let's make sure that section and variable names are uppercase section = StringUtils::upperCase(section); variableList = StringUtils::upperCase(variableList); // Get first value in 'variableList' and make it uppercase string result( fetchListValue(variableList,section) ); result = StringUtils::upperCase(result); // Test if it is "TRUE" or "FALSE" if( result == "TRUE" ) { return true; } else { if( (result == "FALSE") || (result == "") ) // If list is empty returns false { return defaultVal; } else { // Throw an exception if value is neither TRUE nor FALSE ConfigurationException e( "Variable list '" + variableList + "' in configuration file '" + filename + "' have a value that is neither TRUE " + "nor FALSE."); GPSTK_THROW(e); } // End of 'if( result == "FALSE" )' } // End of 'if( result == "TRUE" )' } // End of 'try' block catch (ConfigurationException& e) { GPSTK_RETHROW(e); } } // End of method 'ConfDataReader::fetchListValueAsBoolean()'
/** Method to fetch (as integer) the first value of a given * variable list. * * In this context, a variable list is the same as a variable but * it is composed of several parts (words), separated by spaces. * * @param variableList Variable list name. * @param section Section the variable list belongs to. * * \warning This method will MODIFY the original content of * 'variableList'. */ virtual int fetchListValueAsInt( std::string variableList, std::string section = "DEFAULT", int defaultVal = 0 ) throw(ConfigurationException) { return StringUtils::asInt( fetchListValue(variableList,section,StringUtils::asString(defaultVal))); };
/** Method to fetch (as double) the first value of a given * variable list. * * In this context, a variable list is the same as a variable but * it is composed of several parts (words), separated by spaces. * * @param variableList Variable list name. * @param section Section the variable list belongs to. * * \warning This method will MODIFY the original content of * 'variableList'. */ virtual double fetchListValueAsDouble( std::string variableList, std::string section = "DEFAULT", double defaultVal = 0.0 ) throw(ConfigurationException) { return StringUtils::asDouble( fetchListValue(variableList,section,StringUtils::asString(defaultVal))); };