COPASI API  4.16.103
CTableCell.h
Go to the documentation of this file.
1 /* Begin CVS Header
2  $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/utilities/CTableCell.h,v $
3  $Revision: 1.9 $
4  $Name: $
5  $Author: shoops $
6  $Date: 2011/03/07 19:34:55 $
7  End CVS Header */
8 
9 // Copyright (C) 2011 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
16 // and The University of Manchester.
17 // All rights reserved.
18 
19 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
20 // Properties, Inc. and EML Research, gGmbH.
21 // All rights reserved.
22 
23 #ifndef COPASI_CTableCell
24 #define COPASI_CTableCell
25 
26 #include <iostream>
27 #include <vector>
28 
30 {
31  // Operations
32 public:
33  /**
34  * Default constructor
35  * @param const char & separator (default: '\t')
36  */
37  CTableCell(const char & separator = '\t');
38 
39  /**
40  * Copy constructor
41  * @param const CTableCell & src
42  */
43  CTableCell(const CTableCell & src);
44 
45  /**
46  * Destructor
47  */
48  ~CTableCell();
49 
50  /**
51  * Set the separator
52  * @param const char & separator
53  * @return bool success
54  */
55  bool setSeparator(const char & separator);
56 
57  /**
58  * Retreive the separator
59  * @return const char & separator
60  */
61  const char & getSeparator() const;
62 
63  /**
64  * Check whether the cell contains a numeric value
65  * @return bool isValue
66  */
67  const bool & isValue() const;
68 
69  /**
70  * Retrieve the name.
71  * @return const std::string & name
72  */
73  const std::string & getName() const;
74 
75  /**
76  * Retrieve the value.
77  * @return const C_FLOAT64 & value
78  */
79  const C_FLOAT64 & getValue() const;
80 
81  /**
82  * Check whether a cell contains any data.
83  * A cell is considered empty when it only contains
84  * whitespace charaters.
85  */
86  const bool & isEmpty() const;
87 
88  /**
89  * Formated stream input operator
90  * @param CTableCell & cell
91  * @return std::istream &
92  */
93  friend
94  std::istream & operator >> (std::istream &is, CTableCell & cell);
95 
96  // Attributes
97 private:
98  char mSeparator;
99 
100  std::string mName;
101 
103 
104  bool mIsValue;
105 
106  bool mIsEmpty;
107 };
108 
110 {
111  // Operations
112 public:
113  /**
114  * Default constructor
115  * @param const unisgned C_INT32 & size (default: 0)
116  * @param const char & separator (default: '\t')
117  */
118  CTableRow(const size_t & size = 0,
119  const char & separator = '\t');
120 
121  /**
122  * Copy constructor
123  * @param const CTableRow & src
124  */
125  CTableRow(const CTableRow & src);
126 
127  /**
128  * Destructor
129  */
130  ~CTableRow();
131 
132  /**
133  * Retrieve the cells.
134  * @return const std::vector< CTableCell > & cells
135  */
136  const std::vector< CTableCell > & getCells() const;
137 
138  /**
139  * Resize
140  * @param const size_t & size
141  * @return bool success
142  */
143  bool resize(const size_t & size);
144 
145  /**
146  * Retrieve the size of the row
147  * @return const size_t size
148  */
149  size_t size() const;
150 
151  /**
152  * Retrieve the index of the last non empty cell
153  * in the last read operation.
154  * @const size_t & lastFilledCell
155  */
156  const size_t & getLastFilledCell() const;
157 
158  /**
159  * Try to guess the number of columns
160  * in the current line
161  * @param std::istream &is
162  * @param const bool & rewind
163  * @return size_t numColumns
164  */
165  size_t guessColumnNumber(std::istream &is,
166  const bool & rewind);
167 
168  /**
169  * Check whether row contains any cells with data
170  * A row is considered empty when it all cells are empty.
171  */
172  const bool & isEmpty() const;
173 
174  /**
175  * Formated stream input operator
176  * @param CTableRow & cell
177  * @return std::istream &
178  */
179  friend
180  std::istream & operator >> (std::istream &is, CTableRow & cell);
181 
182 private:
183  /**
184  * Fill the row with data from the inpute stream until End_Of_Line
185  * is encountered and advance the stream accordingly.
186  * @param std::istream & is
187  * @return std::istream & is
188  */
189  std::istream & readLine(std::istream & is);
190 
191  // Attributes
192 private:
193  std::vector< CTableCell > mCells;
194 
196 
197  bool mIsEmpty;
198 
200 };
201 
202 #endif // COPASI_CTableCell
char mSeparator
Definition: CTableCell.h:195
CTableCell(const char &separator= '\t')
Definition: CTableCell.cpp:27
bool mIsEmpty
Definition: CTableCell.h:106
const bool & isEmpty() const
Definition: CTableCell.cpp:182
CTableRow(const size_t &size=0, const char &separator= '\t')
Definition: CTableCell.cpp:124
const std::string & getName() const
Definition: CTableCell.cpp:57
const std::vector< CTableCell > & getCells() const
Definition: CTableCell.cpp:141
std::string mName
Definition: CTableCell.h:100
const size_t & getLastFilledCell() const
Definition: CTableCell.cpp:160
std::istream & readLine(std::istream &is)
Definition: CTableCell.cpp:184
const C_FLOAT64 & getValue() const
Definition: CTableCell.cpp:59
friend std::istream & operator>>(std::istream &is, CTableCell &cell)
Definition: CTableCell.cpp:61
std::vector< CTableCell > mCells
Definition: CTableCell.h:193
bool mIsEmpty
Definition: CTableCell.h:197
const char & getSeparator() const
Definition: CTableCell.cpp:51
char mSeparator
Definition: CTableCell.h:98
size_t size() const
Definition: CTableCell.cpp:157
bool mIsValue
Definition: CTableCell.h:104
C_FLOAT64 mValue
Definition: CTableCell.h:102
const bool & isEmpty() const
Definition: CTableCell.cpp:55
#define C_FLOAT64
Definition: copasi.h:92
friend std::istream & operator>>(std::istream &is, CTableRow &cell)
Definition: CTableCell.cpp:253
size_t guessColumnNumber(std::istream &is, const bool &rewind)
Definition: CTableCell.cpp:163
size_t mLastFilledCell
Definition: CTableCell.h:199
bool setSeparator(const char &separator)
Definition: CTableCell.cpp:45
bool resize(const size_t &size)
Definition: CTableCell.cpp:144
const bool & isValue() const
Definition: CTableCell.cpp:53