COPASI API  4.16.103
CReadConfig.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 /**
16  * CReadConfig class. A more elaborate class description.
17  * New Class based on pmutils read functionality
18  *
19  * (C) Stefan Hoops 2001
20  */
21 
22 #ifndef COPASI_CReadConfig
23 #define COPASI_CReadConfig
24 
25 #include <iostream>
26 #include <sstream>
27 
28 #include <string>
29 
30 // available operations mode for the configurations buffer
31 // #define CReadConfig_SEARCH 0x01
32 // #define CReadConfig_LOOP 0x02
33 
35 {
36  // data
37 
38 public:
39  enum Mode
40  {
41  NEXT = 0,
45  };
46 
47 private:
48  /**
49  * Default constructor.
50  * This creates a configuration buffer for input assigning a filename.
51  * It is currently useless.
52  */
53  CReadConfig();
54 
55  /**
56  * Initializes the input buffer for reading.
57  * @return mFail
58  * @see mFail
59  */
61 
62  /**
63  * Look ahead to find the next variable name
64  */
65  std::string lookAhead();
66 
67  /**
68  * A pointer to the input buffer
69  */
70  std::istream * mpBuffer;
71 
72  /**
73  * Current line number in the configuration file
74  */
76 
77  /**
78  * Mode = CReadConfig::SEARCH
79  */
81 
82  /**
83  * Failure status:
84  * 0 = no error
85  * !0 = error
86  */
88 
89  /*
90  * The Version of the configuration file.
91  */
92  std::string mVersion;
93 
94  /**
95  * Name of the configuration file.
96  */
97  std::string mFilename;
98 
99  /**
100  * A buffer for reading the file.
101  */
102  std::stringstream mFileBuffer;
103 
104 public:
105  /**
106  * Specified constructor.
107  * This opens the configuration file using the filename specified
108  * as the argument.
109  * @param name name of the configuration file.
110  */
111  CReadConfig(const std::string& name);
112 
113  /**
114  * Specified constructor.
115  * This opens the configuration file using the filename specified
116  * as the argument.
117  * @param std::istream & in
118  */
119  CReadConfig(std::istream & in);
120 
121  /**
122  * Destructor.
123  * The destructor calls the method free().
124  */
125  ~CReadConfig();
126 
127  /**
128  * Retrieves the version string of the configbuffer
129  */
130  std::string getVersion();
131 
132  /**
133  * Load various system wide default values
134  */
135  void getDefaults();
136 
137  /**
138  * Returns the failure status.
139  * @return mFail
140  * @see mFail
141  */
142  C_INT32 fail();
143 
144  /**
145  * Retrieves a variable from the input file.
146  * @param name name of the variable to be retrieved.
147  * @param type type of the variable to be retrieved.
148  * @param *pout pointer to the location where the retrieved variable
149  * is stored.
150  * @return mFail
151  * @see mFail
152  */
153  C_INT32 getVariable(const std::string& name,
154  const std::string& type,
155  void * pout,
157 
158  /**
159  * Retrieves a variable from the input file.
160  * @param name name of the variable to be retrieved.
161  * @param type type of the variable to be retrieved.
162  * @param *pout1 pointer to the location where the first part of the
163  * retrieved variable is stored.
164  * @param *pout2 pointer to the location where the second part of the
165  * retrieved variable is stored.
166  * @return mFail
167  * @see mFail
168  */
169  C_INT32 getVariable(const std::string& name,
170  const std::string& type,
171  void * pout1,
172  void * pout2,
174 
175  /**
176  * Rewind the buffer
177  */
178  void rewind();
179 };
180 
181 #endif // COPASI_CReadConfig
std::string lookAhead()
C_INT32 initFileBuffer()
std::string mFilename
Definition: CReadConfig.h:97
std::string getVersion()
Definition: CReadConfig.cpp:76
CReadConfig::Mode mMode
Definition: CReadConfig.h:80
#define C_INT32
Definition: copasi.h:90
C_INT32 fail()
Definition: CReadConfig.cpp:71
C_INT32 mFail
Definition: CReadConfig.h:87
C_INT32 mLineNumber
Definition: CReadConfig.h:75
std::string mVersion
Definition: CReadConfig.h:92
std::stringstream mFileBuffer
Definition: CReadConfig.h:102
C_INT32 getVariable(const std::string &name, const std::string &type, void *pout, CReadConfig::Mode mode=CReadConfig::NEXT)
Definition: CReadConfig.cpp:81
void getDefaults()
Definition: CReadConfig.cpp:78
std::istream * mpBuffer
Definition: CReadConfig.h:70