i have a txt file that has millions of lines, each line has 3 floats, i read it using the following code :
ifstream file(path)
float x,y,z;
while(!file.eof())
file >> x >> y >> z;
and i works perfectly.
Now i want to try doing the same thing using Boost mapped files, so i do the following
string filename = "C:\\myfile.txt";
file_mapping mapping(filename.c_str(), read_only);
mapped_region mapped_rgn(mapping, read_only);
char* const mmaped_data = static_cast<char*>(mapped_rgn.get_address());
streamsize const mmap_size = mapped_rgn.get_size();
istringstream s;
s.rdbuf()->pubsetbuf(mmaped_data, mmap_size);
while(!s.eof())
mystream >> x >> y >> z;
It compiles without any problem, but unfortunatly the X,Y,Z doesn't get the actual float numbers but just rubbish, and after one iteration the While is ended.
I probably doing something terribly wrong
How can i use and parse the data inside the memory mapped file ? i searched all over the internet and especially stack overflow and couldn't find any example.
I'm using windows 7 64 bit.