#if !defined parse_usenet_h #define parse_usenet_h #include #include #include template void ReadGroupsList(std::string &file, Ptree &pt) { std::basic_ifstream listFile(file.c_str()); std::basic_string key; std::basic_string data; size_t sItr; if (!listFile) { throw ("can not open file"); } while (!listFile.eof()) { std::getline(listFile, data); sItr = data.find(" "); key = data.substr(0, sItr); data.erase(0, sItr+1); pt.push_back(std::make_pair(key.c_str(), data.c_str())); } } template void WriteGroupsList(std::string &file, Ptree &pt) { typedef typename Ptree::char_type tch; std::basic_ofstream listFile(file.c_str()); if (!listFile) { throw ("can not open file"); } for (typename Ptree::iterator it = pt.begin(), end = pt.end(); it != end; ++it) { listFile << it->first; listFile << tch(' '); listFile << it->second.template get_own >(); listFile << tch('\n'); } } #endif