Ignore:
Timestamp:
Nov 26, 2010, 4:37:58 PM (13 years ago)
Author:
Frank Seelisch <seelisch@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
Children:
92e2cd1822dc1be6a8ef69173615a30e5bd67d0e
Parents:
9e7d85ecc0703de24759963ee74edd60d4139c09
Message:
coding at Goettingen (cones&fans)

git-svn-id: file:///usr/local/Singular/svn/trunk@13677 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • gfanlib/gfanlib_polymakefile.cpp

    r9e7d85 rc4d065  
    1010#include <assert.h>
    1111#include <sstream>
     12#include <istream>
    1213
    1314using namespace std;
     
    3132}
    3233
    33 static string readUntil(FILE *f, int c)
     34static string readUntil(istream &f, int c)
    3435{
    3536  stringstream ret;
    3637  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  {
    4043      ret<<char(c2);
    41       c2=fgetc(f);
    42     }
     44      //c2=fgetc(f);
     45      c2=f.get();
     46  }
    4347  return ret.str();
    4448}
     
    6771
    6872
    69 void PolymakeFile::open(const char *fileName_)
     73void 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_)
    70110{
    71111  isXml=false;
     
    101141    }
    102142}
    103 
    104 
     143*/
    105144void PolymakeFile::create(const char *fileName_, const char *application_, const char *type_, bool isXml_)
    106145{
     
    244283ZMatrix PolymakeFile::readMatrixProperty(const char *p, int height, int width)
    245284{
    246   ZMatrix ret(height,width);
     285  ZMatrix ret(0,width);
    247286
    248287  assert(hasProperty(p,true));
    249288  list<PolymakeProperty>::iterator prop=findProperty(p);
    250289  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);
    252295    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());
    259314
    260315  return ret;
Note: See TracChangeset for help on using the changeset viewer.