Read a complex file to pair <string,pair<map<string,string> string> > C++ <p>So we basically want to read a text file consisting of some different segments to our program:</p> <p>the structure in the program is a cache with: pair data> ></p> <p>the structure in the file is (were key is used as both a key and a delimiter between segments) </p> <pre><code>key headerKey : headerValue headerKey : headerValue ...................... headerKey : headerValue key data data ... data key </code></pre> <p>We have been trying to read this using the following, but it doesnt read the date format (RFC1123). we only get the dates in headerValues as "08 Gmt" or similar "XX gmt". What is wrong in our reading algorithm, below is that <strong>we are using : as a delimiter</strong> but it appears in the date format in different meaning, i.e. segmenting the time:</p> <pre><code> try{ // Create stream ifstream ifs(this-&gt;cacheFile.c_str(), ios::binary); // Read file to cache if stream is good if(ifs.good()){ while (! ifs.eof() ){ map&lt;string,string&gt; headerPairs; string tmp; string key; string data; getline(ifs, tmp); while(tmp.empty()){ getline(ifs, tmp); cout &lt;&lt; "Empty line..." &lt;&lt; "\n"; if(ifs.eof()){ cout &lt;&lt; "End of File.."&lt;&lt; "\n"; break; } } //After empty lines get "Key" key = tmp; getline(ifs, tmp); //Get segment of header pairs while(tmp != key){ StringTokenizer headerPair(tmp, ":", StringTokenizer::TOK_TRIM); //StringTokenizer::Iterator it = headerPair.begin(); std::cout &lt;&lt; *(headerPair.begin()) &lt;&lt;": " &lt;&lt; *(headerPair.end()-1)&lt;&lt; std::endl; string headerKey = *(headerPair.begin()); string headerValue = *(headerPair.end()-1); headerPairs.insert(make_pair(headerKey, headerValue)); getline(ifs, tmp); } cout &lt;&lt; "Added " &lt;&lt; headerPairs.size() &lt;&lt; " header pairs from cache" &lt;&lt; "\n"; //tmp equals Key while(tmp!=key){ getline(ifs, tmp); cout &lt;&lt; "Searching for header-&gt;data delimiter" &lt;&lt; "\n"; } cout &lt;&lt; "Found header-&gt;data delimiter" &lt;&lt; "\n"; //Get segment of data! getline(ifs, tmp); while(tmp != key){ data+=tmp; getline(ifs, tmp); } cout &lt;&lt; "DATA: " &lt;&lt; data &lt;&lt; "\n"; cout &lt;&lt; "Ending delimiter:" &lt;&lt; tmp &lt;&lt; "\n"; this-&gt;add(key,make_pair(headerPairs, data)); cout &lt;&lt; "Added: " &lt;&lt; key &lt;&lt; " to memory-cache" &lt;&lt; endl; } ifs.close(); } } catch (Exception &amp;ex){ cerr &lt;&lt; ex.displayText() &lt;&lt; endl; } </code></pre> <p>Please suggest a better way of getting the date string:</p> <pre><code> DateTime now : Mon, 29 Apr 2013 08:15:57 GMT DateRetrieved from file: 57 GMT </code></pre> <p>In short: The problem is that we are using a : as a delimiter for the headers, i would like suggestions for another delimiter sign that is failsafe, i.e. it wont be found in the HTTP 1.0 or 1.1 Headers.</p>