COPASI API  4.16.103
Public Member Functions | Private Attributes | Friends | List of all members
CTableCell Class Reference

#include <CTableCell.h>

Collaboration diagram for CTableCell:
Collaboration graph
[legend]

Public Member Functions

 CTableCell (const char &separator= '\t')
 
 CTableCell (const CTableCell &src)
 
const std::string & getName () const
 
const char & getSeparator () const
 
const C_FLOAT64getValue () const
 
const bool & isEmpty () const
 
const bool & isValue () const
 
bool setSeparator (const char &separator)
 
 ~CTableCell ()
 

Private Attributes

bool mIsEmpty
 
bool mIsValue
 
std::string mName
 
char mSeparator
 
C_FLOAT64 mValue
 

Friends

std::istream & operator>> (std::istream &is, CTableCell &cell)
 

Detailed Description

Definition at line 29 of file CTableCell.h.

Constructor & Destructor Documentation

CTableCell::CTableCell ( const char &  separator = '\t')

Default constructor

Parameters
constchar & separator (default: '')

Definition at line 27 of file CTableCell.cpp.

27  :
28  mSeparator(separator),
29  mName(""),
30  mValue(std::numeric_limits<C_FLOAT64>::quiet_NaN()),
31  mIsValue(false),
32  mIsEmpty(true)
33 {}
bool mIsEmpty
Definition: CTableCell.h:106
std::string mName
Definition: CTableCell.h:100
char mSeparator
Definition: CTableCell.h:98
bool mIsValue
Definition: CTableCell.h:104
C_FLOAT64 mValue
Definition: CTableCell.h:102
CTableCell::CTableCell ( const CTableCell src)

Copy constructor

Parameters
constCTableCell & src

Definition at line 35 of file CTableCell.cpp.

35  :
37  mName(src.mName),
38  mValue(src.mValue),
39  mIsValue(src.mIsValue),
40  mIsEmpty(src.mIsEmpty)
41 {}
bool mIsEmpty
Definition: CTableCell.h:106
std::string mName
Definition: CTableCell.h:100
char mSeparator
Definition: CTableCell.h:98
bool mIsValue
Definition: CTableCell.h:104
C_FLOAT64 mValue
Definition: CTableCell.h:102
CTableCell::~CTableCell ( )

Destructor

Definition at line 43 of file CTableCell.cpp.

43 {}

Member Function Documentation

const std::string & CTableCell::getName ( ) const

Retrieve the name.

Returns
const std::string & name

Definition at line 57 of file CTableCell.cpp.

References mName.

57 {return mName;}
std::string mName
Definition: CTableCell.h:100
const char & CTableCell::getSeparator ( ) const

Retreive the separator

Returns
const char & separator

Definition at line 51 of file CTableCell.cpp.

References mSeparator.

51 {return mSeparator;}
char mSeparator
Definition: CTableCell.h:98
const C_FLOAT64 & CTableCell::getValue ( ) const

Retrieve the value.

Returns
const C_FLOAT64 & value

Definition at line 59 of file CTableCell.cpp.

References mValue.

59 {return mValue;}
C_FLOAT64 mValue
Definition: CTableCell.h:102
const bool & CTableCell::isEmpty ( ) const

Check whether a cell contains any data. A cell is considered empty when it only contains whitespace charaters.

Definition at line 55 of file CTableCell.cpp.

References mIsEmpty.

55 {return mIsEmpty;}
bool mIsEmpty
Definition: CTableCell.h:106
const bool & CTableCell::isValue ( ) const

Check whether the cell contains a numeric value

Returns
bool isValue

Definition at line 53 of file CTableCell.cpp.

References mIsValue.

53 {return mIsValue;}
bool mIsValue
Definition: CTableCell.h:104
bool CTableCell::setSeparator ( const char &  separator)

Set the separator

Parameters
constchar & separator
Returns
bool success

Definition at line 45 of file CTableCell.cpp.

References mSeparator.

46 {
47  mSeparator = separator;
48  return true;
49 }
char mSeparator
Definition: CTableCell.h:98

Friends And Related Function Documentation

std::istream& operator>> ( std::istream &  is,
CTableCell cell 
)
friend

Formated stream input operator

Parameters
CTableCell& cell
Returns
std::istream &

Definition at line 61 of file CTableCell.cpp.

62 {
63  static char buffer[256];
64 
65  cell.mName = "";
66 
67  do
68  {
69  is.clear();
70  is.getline(buffer, 256, cell.mSeparator);
71  cell.mName += buffer;
72  }
73  while (strlen(buffer) == 255 && !is.eof());
74 
75  /* Trim leading and trailing whitespaces from the string */
76  std::string::size_type begin = cell.mName.find_first_not_of("\x20\x09\x0d\x0a");
77 
78  if (begin == std::string::npos)
79  {
80  cell.mName = "";
81  cell.mIsValue = false;
82  cell.mValue = std::numeric_limits<C_FLOAT64>::quiet_NaN();
83  cell.mIsEmpty = true;
84 
85  return is;
86  }
87 
88  std::string::size_type end = cell.mName.find_last_not_of("\x20\x09\x0d\x0a");
89 
90  if (end == std::string::npos)
91  cell.mName = cell.mName.substr(begin);
92  else
93  cell.mName = cell.mName.substr(begin, end - begin + 1);
94 
95  cell.mIsEmpty = false;
96 
97  /* Try to convert the string into a number */
98  const char * Tail = NULL;
99  cell.mValue = strToDouble(cell.mName.c_str(), & Tail);
100 
101  if (Tail != NULL && *Tail == 0x0)
102  {
103  cell.mIsValue = true;
104  }
105  else if (cell.mName == "INF")
106  {
107  cell.mIsValue = true;
108  cell.mValue = std::numeric_limits<C_FLOAT64>::infinity();
109  }
110  else if (cell.mName == "-INF")
111  {
112  cell.mIsValue = true;
113  cell.mValue = - std::numeric_limits<C_FLOAT64>::infinity();
114  }
115  else
116  {
117  cell.mIsValue = false;
118  cell.mValue = std::numeric_limits<C_FLOAT64>::quiet_NaN();
119  }
120 
121  return is;
122 }
bool mIsEmpty
Definition: CTableCell.h:106
std::string mName
Definition: CTableCell.h:100
char mSeparator
Definition: CTableCell.h:98
bool mIsValue
Definition: CTableCell.h:104
C_FLOAT64 mValue
Definition: CTableCell.h:102
double strToDouble(const char *str, char const **pTail)
Definition: utility.cpp:325

Member Data Documentation

bool CTableCell::mIsEmpty
private

Definition at line 106 of file CTableCell.h.

Referenced by isEmpty(), and operator>>().

bool CTableCell::mIsValue
private

Definition at line 104 of file CTableCell.h.

Referenced by isValue(), and operator>>().

std::string CTableCell::mName
private

Definition at line 100 of file CTableCell.h.

Referenced by getName(), and operator>>().

char CTableCell::mSeparator
private

Definition at line 98 of file CTableCell.h.

Referenced by getSeparator(), operator>>(), and setSeparator().

C_FLOAT64 CTableCell::mValue
private

Definition at line 102 of file CTableCell.h.

Referenced by getValue(), and operator>>().


The documentation for this class was generated from the following files: