|
-
Jun 15th, 2007, 12:28 PM
#1
Thread Starter
Lively Member
[RESOLVED] Stringstream problems
I am having some problems with stringstreams. I wrote a SMD Model loader and on one of the models, my stringstream fails after extracting after a certain point. It works on another model but on this one it doesn't. And it is NOT the file I'm reading, that was the first thing I checked.
Here is the function where it is failing. Basically before this function, I am reading the lines from the file and putting them in separate vectors since there are multiple textures associated with the mesh. Then processing the lines read for each texture. Each of the lines is being read correctly, being inserted into the vectors and taken out of the vectors. The values on the line are being separated by spaces.
Code:
stringstream *tempStream;
//process the data
for(unsigned int i=0;i<textureList.size();i++){
cout<<"Processing mesh "<<i<<endl;
for(unsigned int j=0;j<meshList[i].size();j++){
tempStream = new stringstream(meshList[i].at(j));
(*tempStream)>>triangles[i][j].parentID; //parentID
(*tempStream)>>triangles[i][j].x>>triangles[i][j].y>>triangles[i][j].z; //position (x,y,z)
(*tempStream)>>triangles[i][j].nX>>triangles[i][j].nY>>triangles[i][j].nZ; //normal
(*tempStream)>>triangles[i][j].u>>triangles[i][j].v; //text coords
(*tempStream)>>triangles[i][j].numLinks; //number of links
//create the link structures
triangles[i][j].linkIDs = new int[triangles[i][j].numLinks];
triangles[i][j].linkWeights = new float[triangles[i][j].numLinks];
cout<<" "<<(*tempStream).tellg()<<" "<<(*tempStream).eof()<<" "<<(*tempStream).bad();
//extract the link IDs and weights
for(int k=0;k<triangles[i][j].numLinks;k++){
(*tempStream)>>triangles[i][j].linkIDs[k];
cout<<" "<<triangles[i][j].linkIDs[k]<<" ";
(*tempStream)>>triangles[i][j].linkWeights[k];
cout<<triangles[i][j].linkWeights[k]<<endl;
}
delete tempStream;
}
}
After reading 121 triangles, it fails at the point of extracting the IDs in the last loop. I went to the line in the file and checked the format, and it was correct. It extracts everything up to the number of links, but then fails on trying to extract the linkID of the bones (the last loop). It does print out the line JUST before the loop, telling where it is in the stream (its set to -1 after the fail), and what flags are set (both of them are set). Also, here is the error message that was thrown:
terminate called after throwing an instance of 'std::ios_base::failure'
what(): basic_ios::clear
Aborted (core dumped)
I've been playing around with this for about 30 minutes and getting really frustrated. Any ideas on why it is failing?
EDIT:
I fixed it.
Last edited by fartman_900; Jun 15th, 2007 at 02:16 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|