/** * Create a new cal file based on the old file * @param oldfile :: The old cal file path * @param newfile :: The new cal file path */ void MaskDetectorsIf::createNewCalFile(const std::string &oldfile, const std::string &newfile) { std::ifstream oldf(oldfile.c_str()); if (!oldf.is_open()) { g_log.error() << "Unable to open grouping file " << oldfile << '\n'; throw Exception::FileError("Error reading .cal file", oldfile); } std::ofstream newf(newfile.c_str()); if (!newf.is_open()) { g_log.error() << "Unable to open grouping file " << newfile << '\n'; throw Exception::FileError("Error reading .cal file", newfile); } std::string str; while (getline(oldf, str)) { // Comment or empty lines get copied into the new cal file if (str.empty() || str[0] == '#') { newf << str << '\n'; continue; } std::istringstream istr(str); int n, udet, sel, group; double offset; istr >> n >> udet >> offset >> sel >> group; auto it = umap.find(udet); bool selection; if (it == umap.end()) selection = sel != 0; else selection = (*it).second; newf << std::fixed << std::setw(9) << n << std::fixed << std::setw(15) << udet << std::fixed << std::setprecision(7) << std::setw(15) << offset << std::fixed << std::setw(8) << selection << std::fixed << std::setw(8) << group << '\n'; } oldf.close(); newf.close(); }
static std::vector<FastInterval> buildIndex(std::string const & filename, uint64_t const steps = 1) { std::string const indexfilename = getIndexFileName(filename,steps); if ( ::libmaus2::util::GetFileSize::fileExists ( indexfilename ) ) { libmaus2::aio::InputStreamInstance istr(indexfilename); std::vector < FastInterval > intervals = ::libmaus2::fastx::FastInterval::deserialiseVector(istr); return intervals; } else { reader_type reader(filename); std::vector<FastInterval> intervals = reader.enumerateOffsets(steps); libmaus2::aio::OutputStreamInstance ostr(indexfilename); FastInterval::serialiseVector(ostr,intervals); ostr.flush(); return intervals; } }
/* * Check for DAWG in first 4 to identify as special binary format, * otherwise assume ASCII, one word per line */ void DawgLexicon::addWordsFromFile(const std::string& filename) { char firstFour[4], expected[] = "DAWG"; std::ifstream istr(filename.c_str()); if (istr.fail()) { error("DawgLexicon::addWordsFromFile: Couldn't open lexicon file " + filename); } istr.read(firstFour, 4); if (strncmp(firstFour, expected, 4) == 0) { if (otherWords.size() != 0) { error("DawgLexicon::addWordsFromFile: Binary files require an empty lexicon"); } readBinaryFile(filename); } else { // plain text file istr.seekg(0); std::string line; while (getline(istr, line)) { add(line); } istr.close(); } }
void function() const { const char xmldata[] = "<?xml version=\"1.0\"?>\n" "<def>\n" " <function name=\"foo\">\n" " <noreturn>false</noreturn>\n" " </function>\n" "</def>"; tinyxml2::XMLDocument doc; doc.Parse(xmldata, sizeof(xmldata)); TokenList tokenList(nullptr); std::istringstream istr("foo();"); tokenList.createTokens(istr); tokenList.front()->next()->astOperand1(tokenList.front()); Library library; library.load(doc); ASSERT(library.use.empty()); ASSERT(library.leakignore.empty()); ASSERT(library.argumentChecks.empty()); ASSERT(library.isnotnoreturn(tokenList.front())); }
void check(const char code[], bool inconclusive=false) { // Clear the error buffer.. errout.str(""); Settings settings; settings.inconclusive = inconclusive; // Tokenize.. Tokenizer tokenizer(&settings, this); std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); CheckAutoVariables checkAutoVariables(&tokenizer, &settings, this); checkAutoVariables.returnReference(); tokenizer.simplifyTokenList(); // Check auto variables checkAutoVariables.autoVariables(); checkAutoVariables.returnPointerToLocalArray(); checkAutoVariables.returncstr(); }
void indexer(string genome, int seed_len, int threads) { IndexProperties ip; GenomeCleaner g(genome); g.clean(); vector<string> chromosomes = g.get_chromosomes(); vector<t_value> offsets = g.get_offsets(); for (int i = 1; i <= chromosomes.size(); i++) { ip.put_property(CHROMOSOME_PREFIX + pad(i, PAD_WIDTH) , chromosomes[i - 1]); ip.put_property(CHROMOSOME_OFFSET + pad(i, PAD_WIDTH) , istr(offsets[i - 1])); } GenomeIndexWriter giw(seed_len, threads); for (int i = 1; i <= chromosomes.size(); ++i) { giw.write_index(GENOME_PATH + CHROMOSOME_PREFIX + pad(i, PAD_WIDTH)); } giw.close_index(); ip.put_property(SEED_LEN_PROP, to_string(seed_len)); ip.put_property(NUM_CHROMO_PROP, to_string(chromosomes.size())); ip.write_file(); }
void CRegionalMetaModel::ReadTrainingData( const string& strDataFile, int nInputs, int nOutputs, vector< vector<REAL> >& vcInputs, vector< vector<REAL> >& vcOutputs ) { ifstream ifg( strDataFile.c_str() ); char buf[_MAX_LINE]; while( true ){ ifg.getline( buf, ELEMENTS(buf) ); if( ifg.fail() || ifg.eof() )break; istrstream istr(buf); vector<REAL> vci(nInputs); for( int i=0; i<nInputs; i++ )istr>>vci[i]; vector<REAL> vco(nOutputs); for( i=0; i<nOutputs; i++ )istr>>vco[i]; vcInputs.push_back( vector<REAL>() ); vcInputs.back().swap( vci ); vcOutputs.push_back( vector<REAL>() ); vcOutputs.back().swap( vco ); } }
void ossimQtViewDialogController::transferFromDialog() { ossimKeywordlist kwl; kwl.add(ossimKeywordNames::TYPE_KW, ossimString(theViewDialog->theProjectionComboBox->currentText().ascii()), true); QString currentText = theViewDialog->theDatumComboBox->currentText().ascii(); ossimString code = currentText.ascii(); std::vector<ossimString> arrayList = code.explode(":"); kwl.add(ossimKeywordNames::DATUM_KW, arrayList[0], true); kwl.add(ossimKeywordNames::METERS_PER_PIXEL_X_KW, ossimString(theViewDialog->theGsdInput->text().ascii()).toDouble(), true); kwl.add(ossimKeywordNames::METERS_PER_PIXEL_Y_KW, ossimString(theViewDialog->theGsdInput->text().ascii()).toDouble(), true); ossimString origin = theViewDialog->theOriginInput->text().ascii(); if(origin != "") { istringstream istr(origin.c_str()); double lat=0.0, lon=0.0; istr>>lat >>lon; kwl.add(ossimKeywordNames::ORIGIN_LATITUDE_KW, lat, true); kwl.add(ossimKeywordNames::CENTRAL_MERIDIAN_KW, lon, true); }
void function_arg_minsize() const { const char xmldata[] = "<?xml version=\"1.0\"?>\n" "<def>\n" " <function name=\"foo\">\n" " <arg nr=\"1\"><minsize type=\"strlen\" arg=\"2\"/></arg>\n" " <arg nr=\"2\"><minsize type=\"argvalue\" arg=\"3\"/></arg>\n" " <arg nr=\"3\"/>\n" " </function>\n" "</def>"; Library library; readLibrary(library, xmldata); TokenList tokenList(nullptr); std::istringstream istr("foo(a,b,c);"); tokenList.createTokens(istr); tokenList.front()->next()->astOperand1(tokenList.front()); // arg1: type=strlen arg2 const std::list<Library::ArgumentChecks::MinSize> *minsizes = library.argminsizes(tokenList.front(),1); ASSERT_EQUALS(true, minsizes != nullptr); ASSERT_EQUALS(1U, minsizes ? minsizes->size() : 1U); if (minsizes && minsizes->size() == 1U) { const Library::ArgumentChecks::MinSize &m = minsizes->front(); ASSERT_EQUALS(Library::ArgumentChecks::MinSize::STRLEN, m.type); ASSERT_EQUALS(2, m.arg); } // arg2: type=argvalue arg3 minsizes = library.argminsizes(tokenList.front(), 2); ASSERT_EQUALS(true, minsizes != nullptr); ASSERT_EQUALS(1U, minsizes ? minsizes->size() : 1U); if (minsizes && minsizes->size() == 1U) { const Library::ArgumentChecks::MinSize &m = minsizes->front(); ASSERT_EQUALS(Library::ArgumentChecks::MinSize::ARGVALUE, m.type); ASSERT_EQUALS(3, m.arg); } }
static void initTranslation() { std::istringstream istr(g_directmap); std::string line; while (std::getline(istr, line)) { if (line.empty() || line[0] == '#') continue; std::vector<std::string> segs = string_explode(line, ';'); if (segs.size() < 2) continue; if (segs[0].compare(0, 3, "32!") == 0) { #ifdef __x86_64__ continue; #else segs[0] = segs[0].substr(3); #endif } if (segs[0].compare(0, 3, "64!") == 0) { #ifdef __i386__ continue; #else segs[0] = segs[0].substr(3); #endif } // std::cout << segs[0] << " -> " << segs[1] << std::endl; g_nameMap[segs[0]] = segs[1]; } Darling::registerDlsymHook(NameTranslator); }
int kmlocalmain(::libmaus::util::ArgInfo const & arginfo) { try { // ::libmaus::fastx::FqWeightQuantiser::statsRun(arginfo,arginfo.restargs,std::cerr); std::string scont = ::libmaus::fastx::CompactFastQBlockGenerator::encodeCompactFastQContainer(arginfo.restargs,0,3); std::istringstream textistr(scont); ::libmaus::fastx::CompactFastQContainer CFQC(textistr); ::libmaus::fastx::CompactFastQContainer::pattern_type cpat; for ( uint64_t i = 0; i < CFQC.size(); ++i ) { CFQC.getPattern(cpat,i); std::cout << cpat; } #if 1 std::ostringstream ostr; ::libmaus::fastx::CompactFastQBlockGenerator::encodeCompactFastQFile(arginfo.restargs,0,256,6/* qbits */,ostr); std::istringstream istr(ostr.str()); // CompactFastQSingleBlockReader<std::istream> CFQSBR(istr); ::libmaus::fastx::CompactFastQMultiBlockReader<std::istream> CFQMBR(istr); ::libmaus::fastx::CompactFastQMultiBlockReader<std::istream>::pattern_type pattern; while ( CFQMBR.getNextPatternUnlocked(pattern) ) { std::cout << pattern; } #endif // ::libmaus::fastx::FqWeightQuantiser::rephredFastq(arginfo.restargs,arginfo); return EXIT_SUCCESS; } catch(std::exception const & ex) { std::cerr << ex.what() << std::endl; return EXIT_FAILURE; } }
int main(int argc, char *argv[]) { std::string server("127.0.0.1"); std::string port("8335"); std::string password(""); std::string address(""); int threadcount=1; ParseParameters(argc,argv); if(mapArgs.count("-server")>0) { server=mapArgs["-server"]; } if(mapArgs.count("-port")>0) { port=mapArgs["-port"]; } if(mapArgs.count("-password")>0) { password=mapArgs["-password"]; } if(mapArgs.count("-address")>0) { address=mapArgs["-address"]; uint160 h160; if(AddressToHash160(address.c_str(),h160)==false) { std::cout << "Address is invalid" << std::endl; address=""; } } if(mapArgs.count("-threads")>0) { std::istringstream istr(mapArgs["-threads"]); istr >> threadcount; }
extern int handle_mail_command(t_connection * c, char const * text) { if (!prefs_get_mail_support()) { message_send_text(c,message_type_error,c,"This server has NO mail support."); return -1; } std::istringstream istr(text); std::string token; /* stkip "/mail" */ istr >> token; /* get the mail function */ token.clear(); istr >> token; switch (identify_mail_function(token.c_str())) { case MAIL_FUNC_SEND: mail_func_send(c, istr); break; case MAIL_FUNC_READ: mail_func_read(c, istr); break; case MAIL_FUNC_DELETE: mail_func_delete(c, istr); break; case MAIL_FUNC_HELP: message_send_text(c, message_type_info, c, "The mail command supports the following patterns."); mail_usage(c); break; default: message_send_text(c, message_type_error, c, "The command its incorrect. Use one of the following patterns."); mail_usage(c); } return 0; }
// virtual void LLTranslate::TranslationReceiver::completedRaw( U32 http_status, const std::string& reason, const LLChannelDescriptors& channels, const LLIOPipe::buffer_ptr_t& buffer) { LLBufferStream istr(channels, buffer.get()); std::stringstream strstrm; strstrm << istr.rdbuf(); const std::string body = strstrm.str(); std::string translation, detected_lang, err_msg; int status = http_status; LL_DEBUGS("Translate") << "HTTP status: " << status << " " << reason << LL_ENDL; LL_DEBUGS("Translate") << "Response body: " << body << LL_ENDL; if (mHandler.parseResponse(status, body, translation, detected_lang, err_msg)) { // Fix up the response LLStringUtil::replaceString(translation, "<", "<"); LLStringUtil::replaceString(translation, ">",">"); LLStringUtil::replaceString(translation, ""","\""); LLStringUtil::replaceString(translation, "'","'"); LLStringUtil::replaceString(translation, "&","&"); LLStringUtil::replaceString(translation, "'","'"); handleResponse(translation, detected_lang); } else { if (err_msg.empty()) { err_msg = LLTrans::getString("TranslationResponseParseError"); } llwarns << "Translation request failed: " << err_msg << llendl; handleFailure(status, err_msg); } }
int wmain(int argc, wchar_t *argv[]) { std::vector<double> coords; std::vector<std::string> connectivities; for (int i = 1; i <= 10; i++) { std::ifstream fileIn(::getHorseFilePath(i)); std::string line; std::ostringstream connectivity; while (std::getline(fileIn, line)) { if (line[0] == '#') //comment continue; std::string token; std::istringstream istr(line); istr >> token; if (token == "v") { double x, y, z; istr >> x >> y >> z; coords.push_back(x); coords.push_back(y); coords.push_back(z); } else if (token == "f") { connectivity << line << "\n"; } }
void check(const char code[]) { // Tokenize.. Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); tokenizer.simplifyTokenList(); // Assign variable ids tokenizer.setVarId(); // Fill function list tokenizer.fillFunctionList(); // Clear the error buffer.. errout.str(""); // Check auto variables Settings settings; CheckAutoVariables checkAutoVariables(&tokenizer, &settings, this); checkAutoVariables.autoVariables(); checkAutoVariables.returnPointerToLocalArray(); }
static tree_t pick_arch(const loc_t *loc, ident_t name, lib_t *new_lib, const elab_ctx_t *ctx) { // When an explicit architecture name is not given select the most // recently analysed architecture of this entity lib_t lib = elab_find_lib(name, ctx); tree_t arch = lib_get_check_stale(lib, name); if ((arch == NULL) || (tree_kind(arch) != T_ARCH)) { arch = NULL; lib_search_params_t params = { lib, name, &arch }; lib_walk_index(lib, find_arch, ¶ms); if (arch == NULL) fatal_at(loc, "no suitable architecture for %s", istr(name)); } if (new_lib != NULL) *new_lib = lib; return arch; }
// Metoda deserializująca JSON z łańcucha znaków // lub pliku jeśli podano ścieżkę do pliku z rozszerzeniem ".json" Json Json::deserialize(std::string str) { static const std::string ext = ".json"; bool isPath = false; if (str.size() > ext.size()) isPath = str.substr(str.size() - ext.size()) == ext; if (isPath) { std::ifstream file(str); if (file.good()) str = std::string(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>()); else throw std::runtime_error(("Couldn't open file: " + str).c_str()); } PropertyTree tree; std::istringstream istr(str); ReadJson(tree, istr); return ToJsonObject(tree); }
void SeeDif::getSelectedName(int curSelected,char*bName, char*fName,char*cName,char*lName) { char* bStr=seadifBrowser->String(curSelected); int mode; int out; outModeBS->GetValue(mode); outSelBS->GetValue(out); if(mode==2) /* Long output Mode */ { istrstream istr(bStr); if(out >= 1) istr >> bName; if(out >= 2) istr >> fName; if(out >= 3) istr >> cName; if(out >= 4) istr >> lName; }
void cover_report(tree_t top, const int32_t *stmts) { stmt_tag_i = ident_new("stmt_tag"); tree_visit(top, cover_report_stmts_fn, (void *)stmts); ident_t name = ident_strip(tree_ident(top), ident_new(".elab")); char dir[256]; snprintf(dir, sizeof(dir), "%s.cover", istr(name)); lib_t work = lib_work(); lib_mkdir(work, dir); for (cover_file_t *f = files; f != NULL; f = f->next) cover_report_file(f, dir); cover_index(name, dir); char output[PATH_MAX]; lib_realpath(work, dir, output, sizeof(output)); notef("coverage report generated in %s/", output); }
ImpWTLF (::libmaus2::huffman::RLDecoder & decoder, uint64_t const b, ::libmaus2::util::TempFileNameGenerator & rtmpgen) : n(decoder.getN()) { if ( n ) { ::libmaus2::wavelet::ImpExternalWaveletGenerator IEWG(b,rtmpgen); for ( uint64_t i = 0; i < n; ++i ) IEWG.putSymbol(decoder.decode()); std::string const tmpfilename = rtmpgen.getFileName(); IEWG.createFinalStream(tmpfilename); std::ifstream istr(tmpfilename.c_str(),std::ios::binary); wt_ptr_type tW(new wt_type(istr)); W = UNIQUE_PTR_MOVE(tW); istr.close(); remove ( tmpfilename.c_str() ); D = ::libmaus2::autoarray::AutoArray < uint64_t >((1ull<<W->getB())+1); for ( uint64_t i = 0; i < (1ull<<W->getB()); ++i ) D [ i ] = W->rank(i,n-1); D.prefixSums(); } }
void testIndFile(std::string const fn, uint64_t const maxsize = std::numeric_limits<uint64_t>::max(), uint64_t const roffset = 0) { { uint64_t const offset = std::min(roffset,::libmaus2::util::GetFileSize::getFileSize(fn)); uint64_t const n = std::min(::libmaus2::util::GetFileSize::getFileSize(fn)-offset,maxsize); std::cerr << "Running for file " << fn << " size " << n << " offset " << offset << std::endl; ::libmaus2::autoarray::AutoArray<char> A(n+1); std::ifstream istr(fn.c_str(),std::ios::binary); assert ( istr.is_open() ); istr.seekg(offset,std::ios::beg); assert ( istr ); istr.read( A.get(), n ); assert ( istr ); assert ( istr.gcount() == static_cast<int64_t>(n) ); A[n] = 0; std::string const s ( A.begin(), A.end() ); bool const ok = testInducedBWTHash(s,true); if ( ! ok ) std::cerr << fn << " failed!" << std::endl; else std::cerr << fn << " ok." << std::endl; } }
LLIOPipe::EStatus LLPipeStringExtractor::process_impl( const LLChannelDescriptors& channels, buffer_ptr_t& buffer, bool& eos, LLSD& context, LLPumpIO* pump) { if(!eos) return STATUS_BREAK; if(!pump || !buffer) return STATUS_PRECONDITION_NOT_MET; LLBufferStream istr(channels, buffer.get()); std::ostringstream ostr; while (istr.good()) { char buf[1024]; /* Flawfinder: ignore */ istr.read(buf, sizeof(buf)); /* Flawfinder: ignore */ ostr.write(buf, istr.gcount()); } mString = ostr.str(); mDone = true; return STATUS_DONE; }
static ::libmaus2::autoarray::AutoArray<data_type> readFile(std::string const & filename) { // number of bytes uint64_t const n8 = ::libmaus2::util::GetFileSize::getFileSize(filename); if ( n8 % sizeof(data_type) ) { libmaus2::exception::LibMausException se; se.getStream() << "GetFileSize::readFile(): size of file " << n8 << " is not a multiple of the data type size " << sizeof(data_type) << std::endl; se.finish(); throw se; } // number of entities uint64_t const n = n8/sizeof(data_type); // allocate array ::libmaus2::autoarray::AutoArray<data_type> A(n,false); // open file libmaus2::aio::InputStreamInstance istr(filename); istr.read ( reinterpret_cast<char *>(A.get()), n8 ); return A; }
/*! \exception throws xmlpp::xmlerror on filename or file access error */ void XMLDocument::load_file(string f) { string infile; if(f.size()<1) { if(filename_.size()<1) { // we do not have a valid filename to use throw xmlerror(xml_filename_invalid); } else { infile=filename_; } } else { infile=f; } ifstream istr(infile.c_str()); if(istr.is_open()) { load(istr, contextptr); filename_=infile; } else { // file access error throw xmlerror(xml_file_access, infile); } }
::libmaus2::autoarray::AutoArray < ::libmaus2::autoarray::AutoArray < uint64_t > > getBlockSizes() const { ::libmaus2::autoarray::AutoArray < ::libmaus2::autoarray::AutoArray < uint64_t > > blocksizes(index.size()); for ( uint64_t fileptr = 0; fileptr < index.size(); ++fileptr ) { blocksizes[fileptr] = ::libmaus2::autoarray::AutoArray<uint64_t>(index[fileptr].size(),false); libmaus2::aio::InputStreamInstance istr(filenames[fileptr]); for ( uint64_t blockptr = 0; blockptr < index[fileptr].size(); ++blockptr ) { istr.clear(); istr.seekg(index[fileptr][blockptr].pos,std::ios::beg); sbis_type::raw_input_ptr_type ript(new sbis_type::raw_input_type(istr)); sbis_type SBIS(ript,1024); uint64_t const blocksize = ::libmaus2::bitio::readElias2(SBIS); blocksizes[fileptr][blockptr] = blocksize; } } return blocksizes; }
void JSSPageReader::parseAttributes() { static const int eof = std::char_traits<char>::eof(); std::string basename; std::istringstream istr(_attrs); int ch = istr.get(); while (ch != eof && Poco::Ascii::isSpace(ch)) ch = istr.get(); while (ch != eof && Poco::Ascii::isAlphaNumeric(ch)) { basename += (char) ch; ch = istr.get(); } while (ch != eof && Poco::Ascii::isSpace(ch)) ch = istr.get(); while (ch != eof) { std::string name(basename + "."); std::string value; while (ch != eof && Poco::Ascii::isAlphaNumeric(ch)) { name += (char) ch; ch = istr.get(); } while (ch != eof && Poco::Ascii::isSpace(ch)) ch = istr.get(); if (ch != '=') throw Poco::SyntaxException("Bad attribute syntax: '=' expected", where()); ch = istr.get(); while (ch != eof && Poco::Ascii::isSpace(ch)) ch = istr.get(); if (ch == '"') { ch = istr.get(); while (ch != eof && ch != '"') { value += (char) ch; ch = istr.get(); } if (ch != '"') throw Poco::SyntaxException("Bad attribute syntax: '\"' expected", where()); } else if (ch == '\'') { ch = istr.get(); while (ch != eof && ch != '\'') { value += (char) ch; ch = istr.get(); } if (ch != '\'') throw Poco::SyntaxException("Bad attribute syntax: ''' expected", where()); } else throw Poco::SyntaxException("Bad attribute syntax: '\"' or ''' expected", where()); ch = istr.get(); handleAttribute(name, value); while (ch != eof && Poco::Ascii::isSpace(ch)) ch = istr.get(); } }
//Constructor(Default) msl::socket::socket(const std::string& address):std::ostream(reinterpret_cast<std::streambuf*>(NULL)),_socket(SOCKET_ERROR),_hosting(false),_time_out(200) { //Parsing Variables unsigned char ip[4]={0,0,0,0}; unsigned short port=0; std::istringstream istr(address,std::ios_base::in); //Find 4 IP Octets and a Port (5 Things Total) for(unsigned int ii=0;ii<5;++ii) { //Temporary Variables char remove_delimeter; unsigned int temp; //Bad Read if(!(istr>>temp)) throw std::runtime_error("socket::socket - address is invalid!"); //IP Octet if(ii<4) ip[ii]=temp; //Port else port=temp; //Remove Delimeters (.'s and :'s) istr>>remove_delimeter; //Check For Bad Delimeters if((ii<3&&remove_delimeter!='.')||(ii>2&&remove_delimeter!=':')) throw std::runtime_error("socket::socket - delimeter is invalid!"); } //Set Address _address=msl::ipv4(ip,port); }
//Load Configuration Function Definition bool load_configuration() { //Try to Load File if(msl::file_exists(configuration_filename)&&msl::file_to_string(configuration_filename,configuration_data)) { //Create a Parser std::istringstream istr(configuration_data,std::ios_base::in); //Create Vectors to Hold Parsed Variables and Values std::vector<std::string> variables; std::vector<std::string> values; //Temporary String Variable std::string temp=""; //Parse Configuration Data while(true) { //Parse Variable if(istr>>temp) { //Add Variable to Vector variables.push_back(temp); //Parse Value if(istr>>temp) values.push_back(temp); //Error Parsing Value, Break else break; } //Error Parsing Variable, Break else { break;
void Util::UnpackUrl(const string& url,string& path,map<string,string>& parameters) { URI uri(url); path.assign(uri.getPath()); string query = uri.getRawQuery(); istringstream istr(query); static const int eof = std::char_traits<char>::eof(); int ch = istr.get(); while (ch != eof) { string name; string value; while (ch != eof && ch != '=' && ch != '&') { if (ch == '+') ch = ' '; name += (char) ch; ch = istr.get(); } if (ch == '=') { ch = istr.get(); while (ch != eof && ch != '&') { if (ch == '+') ch = ' '; value += (char) ch; ch = istr.get(); } } string decodedName; string decodedValue; URI::decode(name, decodedName); URI::decode(value, decodedValue); parameters[decodedName] = decodedValue; if (ch == '&') ch = istr.get(); } }