/********************************************** Class for parsing ECI file (multicomponent) Written by k-fleak *********************************************/ #include #include #include #include #include #include #include #include #ifndef __PARSEECI_CPP #define __PARSEECI_CPP class ParseECI{ private: std::ifstream input; std::map, double> > eciMap; public: ParseECI(char* filename); ~ParseECI(); std::map, double> > getECI(); }; ParseECI::ParseECI(char* filename){ input.open(filename); std::string line; while(!input.eof()){ std::getline(input,line); std::stringstream str; std::string stmp; str << line; std::istream_iterator iss_iter (str); std::istream_iterator iss_end; if ((*iss_iter).size() < 1){ break; } int clusterIndex = boost::lexical_cast(*iss_iter); std::advance(iss_iter, 1); std::vector basis; double eci; while (iss_iter != iss_end){ stmp = *iss_iter; for (int i = 0; i < stmp.size(); ++i){ basis.push_back(boost::lexical_cast(stmp[i])); } ++iss_iter; eci = boost::lexical_cast(*iss_iter); ++iss_iter; eciMap[clusterIndex][basis] = eci; basis.clear(); } } input.close(); } ParseECI::~ParseECI(){ } std::map, double> > ParseECI::getECI(){ return eciMap; } #endif /* int main(){ ParseECI pe("ECI"); std::map, double> > eci = pe.getECI(); std::map, double> >::iterator it; std::map, double>::iterator it2; it = eci.begin(); while (it != eci.end()){ int cluster = (*it).first; it2 = (*it).second.begin(); std::cout << "cluster: " << cluster << std::endl; while (it2 != (*it).second.end()){ std::vector basis; double ecis; basis = (*it2).first; ecis = (*it2).second; for (int i = 0; i < basis.size(); ++i){ std::cout << basis[i] << " "; } std::cout << " : " << ecis << std::endl; ++it2; } ++it; } }; */