Author:
cramur
Description: boost::tokenizer usage
Language: C++
/*
* === FUNCTION =====================================================
* Name: fillPointSetFromFile
* Description: fills points from file
* ====================================================================
*/
void fillPoinSetFromFile(char* filename)
{
std::ifstream fInput(filename);
std::string tmpData;
point tmpPoint;
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
boost::char_separator<char> sep(";\t ");
while(fInput.eof() == false)
{
std::getline(fInput,tmpData);
if(tmpData.empty())
break;
tokenizer tok(tmpData, sep);
tokenizer::iterator t = tok.begin();
tmpPoint.x = boost::lexical_cast<fract>(*t);
t++;
tmpPoint.y = boost::lexical_cast<fract>(*t);
points.push_back(tmpPoint);
}
fInput.close();
}
|
Recent pastes:
prostoHz (Java)
ndubinkin (XML)
Riateche (Plain Text)
Slapotam (Perl)
ksurent (Perl)
John_Wein (Java)
John_Wein (HTML)
Riateche (HTML)
Riateche (JavaScript)
Riateche (JavaScript)
Lisenish (C++)
Lisenish (C++)
cramur (C++)
|