void Manifest::addKeyValuePair(const uint8_t* key, size_t keySize, const uint8_t* value, size_t valueSize) { std::string keyS(reinterpret_cast<const char*>(key), keySize); std::string valueS(reinterpret_cast<const char*>(value), valueSize); addKeyValuePair(keyS, valueS); }
void RuntimeEnvironment::processCommandLine( int argc, char *argv[] ) { if (!pathInitialized) init(); // Declare the supported options. boost::program_options::options_description desc("Simox runtime options"); desc.add_options() ("help", "Simox command line parser: Set options with '--key value'\n") ("data-path", boost::program_options::value< std::vector< std::string > >()->composing(), "Set data path. Multiple data paths are allowed.") ; for (size_t i=0;i<processKeys.size();i++) desc.add_options() (processKeys[i].c_str(), boost::program_options::value< std::vector< std::string > >(), processKeys[i].c_str()) ; boost::program_options::parsed_options parsed = boost::program_options::command_line_parser(argc, argv).options(desc).allow_unregistered().run(); boost::program_options::variables_map vm; //boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm); boost::program_options::store(parsed,vm); boost::program_options::notify(vm); // process data-path entries if (vm.count("data-path")) { //VR_INFO << "Data paths are: " << endl; std::vector< std::string > dp = vm["data-path"].as< std::vector< std::string > >(); for (size_t i=0;i<dp.size();i++) { addDataPath(dp[i]); //VR_INFO << dp[i] << "\n"; } } // process generic keys for (size_t i=0;i<processKeys.size();i++) { if (vm.count(processKeys[i].c_str())) { std::vector< std::string > dp = vm[processKeys[i].c_str()].as< std::vector< std::string > >(); if (dp.size()>1) VR_WARNING << "More than one parameter for key " << processKeys[i] << ". taking the first one..." << endl; if (dp.size()>0) addKeyValuePair(processKeys[i],dp[0]); // take the first one... } } // collect unrecognized arguments std::vector<std::string> options = boost::program_options::collect_unrecognized(parsed.options, boost::program_options::include_positional); for (size_t i=0;i<options.size();i++) { unrecognizedOptions.push_back(options[i]); } }
// // addKeyValuePair -- const char * version // void XHTMLR::addKeyValuePair(const char *key,const char *value){ std::string k(key); std::string v(value); addKeyValuePair(k,v); }
void Manifest::decode() { Block content = getContent(); content.parse(); // Manifest ::= CONTENT-TLV TLV-LENGTH // Catalogue? // Name* // KeyValuePair* for ( Block::element_const_iterator val = content.elements_begin(); val != content.elements_end(); ++val) { if (val->type() == tlv::ManifestCatalogue) { val->parse(); for ( Block::element_const_iterator catalogueNameElem = val->elements_begin(); catalogueNameElem != val->elements_end(); ++catalogueNameElem) { if (catalogueNameElem->type() == tlv::Name) { Name name(*catalogueNameElem); m_catalogueNames.push_back(name); } } } else if (val->type() == tlv::KeyValuePair) { std::string str((char*)val->value(), val->value_size()); size_t index = str.find_first_of('='); if (index == std::string::npos || index == 0 || (index == str.size() - 1)) continue; std::string key = str.substr(0, index); std::string value = str.substr(index + 1, str.size() - index - 1); addKeyValuePair(key, value); } } }