bool parseError(stringstream& ss, string errMessage, int offset = 0) { ss.clear(); int colNo = (int) ss.tellg(); if (colNo <= 0) colNo = 1; colNo += offset; cerr // << ss.str() << endl << setw(colNo) << right << "^" << endl << "Parse error: col #" << colNo << ", " << errMessage << endl; return false; }
void CIF::Parse(stringstream &in) { bool vv=false;//very verbose ? char lastc=' '; string block="";// Current block data while(!in.eof()) { stringstream mess; mess<<"CIF: Parsing:"<<in.tellg(); (*fpObjCrystInformUser)(mess.str()); while(!isgraph(in.peek()) && !in.eof()) in.get(lastc); if(in.eof()) break; if(vv) cout<<endl; if(in.peek()=='#') {//Comment string tmp; getline(in,tmp); if(block=="") mvComment.push_back(tmp); else mvData[block].mvComment.push_back(tmp); lastc='\r'; if(vv)cout<<"Comment:"<<tmp<<endl; continue; } if(in.peek()=='_') {//Tag string tag,value; in>>tag; // Convert all dots to underscores to cover much of DDL2 with this DDL1 parser. for (string::size_type pos = tag.find('.'); pos != string::npos; pos = tag.find('.', ++ pos)) tag.replace(pos, 1, 1, '_'); value=CIFReadValue(in,lastc); if(value==string("?")) continue;//useless mvData[block].mvItem[ci_string(tag.c_str())]=value; if(vv)cout<<"New Tag:"<<tag<<" ("<<value.size()<<"):"<<value<<endl; continue; } if((in.peek()=='d') || (in.peek()=='D')) {// Data string tmp; in>>tmp; block=tmp.substr(5); if(vv) cout<<endl<<endl<<"NEW BLOCK DATA: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ->"<<block<<endl<<endl<<endl; mvData[block]=CIFData(); continue; }
void seco(void){ cout << "position: "<<inFile.tellg()<<endl; cout << inFile.str()<<endl; }
int main(int argc, char* argv[]) { prim(); cout << "MinFile.str: "<<inFile.str(); cout << "Mposition: "<<inFile.tellg()<<endl; seco(); }
void prim(void){ // outFile << "output this" << endl; inFile << "output this" << endl; cout << "inFile.str: "<<inFile.str(); cout << "position: "<<inFile.tellg()<<endl; }