Changeset c4d065 in git for gfanlib/gfanlib_polymakefile.cpp
- Timestamp:
- Nov 26, 2010, 4:37:58 PM (13 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
- Children:
- 92e2cd1822dc1be6a8ef69173615a30e5bd67d0e
- Parents:
- 9e7d85ecc0703de24759963ee74edd60d4139c09
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gfanlib/gfanlib_polymakefile.cpp
r9e7d85 rc4d065 10 10 #include <assert.h> 11 11 #include <sstream> 12 #include <istream> 12 13 13 14 using namespace std; … … 31 32 } 32 33 33 static string readUntil( FILE *f, int c)34 static string readUntil(istream &f, int c) 34 35 { 35 36 stringstream ret; 36 37 int c2; 37 c2=fgetc(f); 38 while(c2!=c && c2!=EOF) 39 { 38 c2=f.get(); 39 // c2=fgetc(f); 40 // while(c2!=c && c2!=EOF) 41 while(c2!=c && !f.eof()) 42 { 40 43 ret<<char(c2); 41 c2=fgetc(f); 42 } 44 //c2=fgetc(f); 45 c2=f.get(); 46 } 43 47 return ret.str(); 44 48 } … … 67 71 68 72 69 void PolymakeFile::open(const char *fileName_) 73 void PolymakeFile::open(std::istream &f) 74 { 75 isXml=false; 76 // fileName=string(fileName_); 77 78 // FILE *f=fopen(fileName.c_str(),"r"); 79 // if(!f)//fprintf(Stderr,"Could not open file:\"%s\"\n",fileName_); 80 // assert(f); 81 82 int c=f.get();//fgetc(f); 83 while(!f.eof()) 84 { 85 if(c=='_') 86 { 87 readUntil(f,'\n'); 88 } 89 else if(c!='\n') 90 { 91 f.unget(); 92 // ungetc(c,f); 93 string name=readUntil(f,'\n'); 94 95 // fprintf(Stderr,"Reading:\"%s\"\n",name.c_str()); 96 stringstream value; 97 while(1) 98 { 99 string l=readUntil(f,'\n'); 100 if(l.size()==0)break; 101 value << l <<endl; 102 } 103 properties.push_back(PolymakeProperty(name.c_str(),value.str().c_str())); 104 } 105 c=f.get();//fgetc(f); 106 } 107 } 108 109 /*void PolymakeFile::open(const char *fileName_) 70 110 { 71 111 isXml=false; … … 101 141 } 102 142 } 103 104 143 */ 105 144 void PolymakeFile::create(const char *fileName_, const char *application_, const char *type_, bool isXml_) 106 145 { … … 244 283 ZMatrix PolymakeFile::readMatrixProperty(const char *p, int height, int width) 245 284 { 246 ZMatrix ret( height,width);285 ZMatrix ret(0,width); 247 286 248 287 assert(hasProperty(p,true)); 249 288 list<PolymakeProperty>::iterator prop=findProperty(p); 250 289 stringstream s(prop->value); 251 for(int i=0;i<height;i++) 290 // for(int i=0;i<height;i++) 291 for(int i=0;;i++) 292 { 293 if(i==height)break; 294 ZVector w(width); 252 295 for(int j=0;j<width;j++) 253 { 254 int v; 255 eatComment(s); 256 s>>v; 257 ret[i][j]=v; 258 } 296 { 297 int v; 298 eatComment(s); 299 s>>v; 300 if(s.eof())goto done; 301 w[j]=v; 302 } 303 ret.appendRow(w); 304 } 305 done: 306 307 if(height>=0)assert(ret.getHeight()==height); 308 // cerr<<p; 309 // eatComment(s); 310 // int v; 311 // s>>v; 312 // while(!s.eof())std::cerr<<char(s.get()); 313 // assert(s.eof()); 259 314 260 315 return ret;
Note: See TracChangeset
for help on using the changeset viewer.