[74a91c9] | 1 | /* |
---|
| 2 | * gfanlib_polymakefile.h |
---|
| 3 | * |
---|
| 4 | * Created on: Nov 17, 2010 |
---|
| 5 | * Author: anders |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #ifndef GFANLIB_POLYMAKEFILE_H_INCLUDED |
---|
| 9 | #define GFANLIB_POLYMAKEFILE_H_INCLUDED |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | #include <list> |
---|
| 13 | #include <vector> |
---|
| 14 | #include <string> |
---|
| 15 | #include <iostream> |
---|
| 16 | |
---|
| 17 | #include "gfanlib_matrix.h" |
---|
| 18 | |
---|
| 19 | namespace gfan |
---|
| 20 | { |
---|
| 21 | class PolymakeProperty |
---|
| 22 | { |
---|
| 23 | public: |
---|
| 24 | std::string value; |
---|
| 25 | std::string name; |
---|
| 26 | PolymakeProperty(const std::string &name_, const std::string &value_); |
---|
| 27 | }; |
---|
| 28 | |
---|
| 29 | class PolymakeFile |
---|
| 30 | { |
---|
| 31 | std::string application,type; |
---|
| 32 | std::string fileName; |
---|
| 33 | std::list<PolymakeProperty> properties; |
---|
| 34 | std::list<PolymakeProperty>::iterator findProperty(const char *p); |
---|
| 35 | void writeProperty(const char *p, const std::string &data); |
---|
| 36 | bool isXml; |
---|
| 37 | public: |
---|
| 38 | void open(const char *fileName_); |
---|
| 39 | void create(const char *fileName_, const char *application_, const char *type_, bool isXml_=false); |
---|
| 40 | void writeStream(std::ostream &file); |
---|
| 41 | void close(); |
---|
| 42 | bool hasProperty(const char *p, bool doAssert=false); |
---|
| 43 | |
---|
| 44 | // The following could be part of a subclass to avoid dependencies on gfan |
---|
| 45 | Integer readCardinalProperty(const char *p); |
---|
| 46 | void writeCardinalProperty(const char *p, Integer n); |
---|
| 47 | |
---|
| 48 | bool readBooleanProperty(const char *p); |
---|
| 49 | void writeBooleanProperty(const char *p, bool n); |
---|
| 50 | |
---|
| 51 | ZMatrix readMatrixProperty(const char *p, int height, int width); |
---|
| 52 | void writeMatrixProperty(const char *p, const ZMatrix &m, bool indexed=false, const std::vector<std::string> *comments=0); |
---|
| 53 | |
---|
| 54 | std::vector<std::list<int> > readMatrixIncidenceProperty(const char *p); |
---|
| 55 | void writeIncidenceMatrixProperty(const char *p, const std::vector<std::list<int> > &m); |
---|
| 56 | |
---|
| 57 | ZVector readCardinalVectorProperty(const char *p); |
---|
| 58 | void writeCardinalVectorProperty(const char *p, ZVector const &v); |
---|
| 59 | |
---|
| 60 | void writeStringProperty(const char *p, const std::string &s); |
---|
| 61 | }; |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | #endif |
---|
| 65 | |
---|