LLSD LLControlVariable::getComparableValue(const LLSD& value) { // *FIX:MEP - The following is needed to make the LLSD::ImplString // work with boolean controls... LLSD storable_value; if(TYPE_BOOLEAN == type() && value.isString()) { BOOL temp; if(LLStringUtil::convertToBOOL(value.asString(), temp)) { storable_value = (bool)temp; } else { storable_value = false; } } else if (TYPE_LLSD == type() && value.isString()) { LLPointer<LLSDNotationParser> parser = new LLSDNotationParser; LLSD result; std::stringstream value_stream(value.asString()); if (parser->parse(value_stream, result, LLSDSerialize::SIZE_UNLIMITED) != LLSDParser::PARSE_FAILURE) { storable_value = result; } else { storable_value = value; } } else { storable_value = value; } return storable_value; }
bool CommandLineOptions::readOptions(int argc, const char **argv) { for (int i=0; i < argc; ++i) { m_arguments.push_back(argv[i]); } for (int i=1; i < argc; ++i) { const string & argument = m_arguments[i]; string option_name; if (argument.size() > 1 && argument[0] == '-') { if (argument.size() > 2 && argument[1] == '-') { option_name = argument.substr(2); } else { string short_name = argument.substr(1); std::map<std::string, std::string>::iterator it; it = m_long_names.find(short_name); if (it != m_long_names.end()) { option_name = it->second; } else { cerr << "Invalid option: " << argument << endl; return false; } } } if (option_name.empty()) { m_remaining.push_back(argument); continue; } std::map<std::string, Option*>::iterator option_it; option_it = m_options.find(option_name); if (option_it == m_options.end()) { cerr << "Invalid option: " << argument << endl; return false; } Option *option = option_it->second; { OptionT<bool> *bool_option = option_cast<bool>(option); if (bool_option) { bool_option->is_set = true; continue; } } if (i == argc-1) { std::cerr << "Missing value for option: " << argument << endl; return false; } ++i; std::istringstream value_stream( m_arguments[i] ); if (!option->parse_value( value_stream )) { std::cerr << "Invalid value for option: " << argument << ' ' << value_stream.str() << endl; return false; } } return true; }