FWIW
Code:
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
#include <iterator>
#include <algorithm>
using namespace std;
struct MESH
{
string name;
short flag, index;
};
void load(const char *filename, vector<MESH> &meshes)
{
ifstream file(filename);
string line;
short count;
if ( file >> line >> count && line == "Meshes:" )
{
short i = 0;
while ( i < count )
{
if ( getline(file, line) )
{
istringstream iss(line);
MESH m;
char quote;
if ( iss >> quote && quote == '"' && getline(iss, m.name, '"') &&
iss >> m.flag >> m.index )
{
meshes.push_back(m);
++i;
}
}
}
}
}
ostream& operator<< (ostream &o, const MESH &m)
{
return o << m.name << ',' << m.flag << ',' << m.index;
}
int main()
{
vector<MESH> meshes;
load("file.txt", meshes);
copy(meshes.begin(), meshes.end(), ostream_iterator<MESH>(cout, "\n"));
return 0;
}
/* file.txt
Meshes: 3
"Testing..." 1 2
"Testing again" 3 4
"Oh, yes -- I'm testing again!" 5 6
"One too many lines" 7 8
*/
/* my output
Testing...,1,2
Testing again,3,4
Oh, yes -- I'm testing again!,5,6
*/