1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
vector<Point2D> p2dvector;
void readData()
{
cout<< "Please enter filename : ";
cin >> inputFile;
fstream fileStream;
fileStream.open(inputFile.c_str(),fstream::in);
int records = 0;
while( fileStream.good() )
{
string line = "";
while (getline (fileStream, line))
{
stringstream ss (line);
getline (ss, className, ',');
if (className == "Point2D")
{
int x, y;
getline (ss, p2dX, '[');
getline (ss, p2dX, ',');
getline (ss, p2dY, ' ');
getline (ss, p2dY, ']');
istringstream (p2dX) >> x;
istringstream (p2dY) >> y;
Point2D p2d (x, y);
p2dvector.push_back(p2d);
sort(p2dvector.begin(), p2dvector.end());
p2dvector.erase(unique(p2dvector.begin(), p2dvector.end()), p2dvector.end());
}
}
}
}
|