libodsstream
Library for mass spectrometry
Loading...
Searching...
No Matches
OdsCell Class Reference

#include <odscell.h>

Public Member Functions

 OdsCell ()
 
virtual ~OdsCell ()
 
const QString & toString () const
 
const QString & getOfficeValueType () const
 
const QDateTime & getDateTimeValue () const
 
const QString & getStringValue () const
 
bool getBooleanValue () const
 
double getDoubleValue () const
 
bool isBoolean () const
 
bool isDate () const
 
bool isDouble () const
 
bool isString () const
 
bool isEmpty () const
 

Protected Member Functions

void setOfficeValueType (const QString &type)
 
void setDateValue (const QDateTime &date)
 
void setValueString (const QString &value)
 
void setValueDouble (double value_num)
 
void setValueBoolean (bool value_bool)
 
void setValueOfUndefinedType (const QString &value)
 

Protected Attributes

QString _string_value
 
QString _office_value_type
 
QDateTime _date_value
 
double _double_value
 
bool _bool_value
 
bool _is_empty
 

Private Attributes

friend QXmlStreamReaderContentXml
 
friend TsvReader
 

Detailed Description

Definition at line 28 of file odscell.h.

Constructor & Destructor Documentation

◆ OdsCell()

OdsCell::OdsCell ( )

Definition at line 24 of file odscell.cpp.

25{
26}

◆ ~OdsCell()

OdsCell::~OdsCell ( )
virtual

Definition at line 28 of file odscell.cpp.

29{
30}

Member Function Documentation

◆ getBooleanValue()

bool OdsCell::getBooleanValue ( ) const

Definition at line 136 of file odscell.cpp.

137{
138 if(isBoolean())
139 {
140 return _bool_value;
141 }
142 else
143 {
144 throw OdsException(
145 QObject::tr("this cell is not a boolean :\n").append(toString()));
146 }
147};
bool _bool_value
Definition odscell.h:61
const QString & toString() const
Definition odscell.cpp:83
bool isBoolean() const
Definition odscell.cpp:181

References _bool_value, isBoolean(), and toString().

◆ getDateTimeValue()

const QDateTime & OdsCell::getDateTimeValue ( ) const

Definition at line 97 of file odscell.cpp.

98{
99 if(isDate())
100 {
101 return _date_value;
102 }
103 else
104 {
105 throw OdsException(
106 QObject::tr("this cell is not a date :\n").append(toString()));
107 }
108};
QDateTime _date_value
Definition odscell.h:59
bool isDate() const
Definition odscell.cpp:154

References _date_value, isDate(), and toString().

Referenced by OdsDocReader::setInsideCell().

◆ getDoubleValue()

double OdsCell::getDoubleValue ( ) const

Definition at line 123 of file odscell.cpp.

124{
125 if(isDouble())
126 {
127 return _double_value;
128 }
129 else
130 {
131 throw OdsException(
132 QObject::tr("this cell is not a double :\n").append(toString()));
133 }
134};
bool isDouble() const
Definition odscell.cpp:161
double _double_value
Definition odscell.h:60

References _double_value, isDouble(), and toString().

Referenced by OdsDocReader::setInsideCell().

◆ getOfficeValueType()

const QString & OdsCell::getOfficeValueType ( ) const

Definition at line 91 of file odscell.cpp.

92{
93 return _office_value_type;
94};
QString _office_value_type
Definition odscell.h:58

References _office_value_type.

Referenced by QXmlStreamReaderContentXml::readTableLine(), and OdsDocReader::setInsideCell().

◆ getStringValue()

const QString & OdsCell::getStringValue ( ) const

Definition at line 110 of file odscell.cpp.

111{
112 if(isString())
113 {
114 return _string_value;
115 }
116 else
117 {
118 throw OdsException(
119 QObject::tr("this cell is not a string :\n").append(toString()));
120 }
121};
bool isString() const
Definition odscell.cpp:168
QString _string_value
Definition odscell.h:57

References _string_value, isString(), and toString().

Referenced by OdsDocReader::setInsideCell().

◆ isBoolean()

bool OdsCell::isBoolean ( ) const

Definition at line 181 of file odscell.cpp.

182{
183 if(_office_value_type == "boolean")
184 return true;
185 return false;
186};

References _office_value_type.

Referenced by getBooleanValue(), and isString().

◆ isDate()

bool OdsCell::isDate ( ) const

Definition at line 154 of file odscell.cpp.

155{
156 if(_office_value_type == "date")
157 return true;
158 return false;
159};

References _office_value_type.

Referenced by getDateTimeValue(), isString(), and OdsDocReader::setInsideCell().

◆ isDouble()

bool OdsCell::isDouble ( ) const

Definition at line 161 of file odscell.cpp.

162{
163 if(_office_value_type == "float")
164 return true;
165 return false;
166};

References _office_value_type.

Referenced by getDoubleValue(), isString(), and OdsDocReader::setInsideCell().

◆ isEmpty()

bool OdsCell::isEmpty ( ) const

Definition at line 149 of file odscell.cpp.

150{
151 return _is_empty;
152};
bool _is_empty
Definition odscell.h:62

References _is_empty.

Referenced by isString().

◆ isString()

bool OdsCell::isString ( ) const

Definition at line 168 of file odscell.cpp.

169{
170 if(isDate())
171 return false;
172 if(isDouble())
173 return false;
174 if(isBoolean())
175 return false;
176 if(isEmpty())
177 return false;
178 return true;
179};
bool isEmpty() const
Definition odscell.cpp:149

References isBoolean(), isDate(), isDouble(), and isEmpty().

Referenced by getStringValue(), and OdsDocReader::setInsideCell().

◆ setDateValue()

void OdsCell::setDateValue ( const QDateTime &  date)
protected

Definition at line 56 of file odscell.cpp.

57{
58 // qDebug() << "setDateValue date.fromString " <<
59 // date.toString(Qt::ISODate);
60 _date_value = date;
61 _string_value = date.toString();
62};

References _date_value, and _string_value.

Referenced by QXmlStreamReaderContentXml::readTableLine().

◆ setOfficeValueType()

void OdsCell::setOfficeValueType ( const QString &  type)
protected

Definition at line 33 of file odscell.cpp.

34{
35 // float
36 // percentage
37 // currency
38 // date
39 // time
40 // boolean
41 // string
42 if(type.isEmpty())
43 {
44 _is_empty = true;
45 qDebug() << "empty cell";
47 }
48 else
49 {
50 _is_empty = false;
51 _office_value_type = type;
52 }
53 _string_value = "";
54};

References _is_empty, _office_value_type, and _string_value.

Referenced by TsvReader::readCsvRow(), and QXmlStreamReaderContentXml::readTableLine().

◆ setValueBoolean()

void OdsCell::setValueBoolean ( bool  value_bool)
protected

Definition at line 76 of file odscell.cpp.

77{
78 _bool_value = value_bool;
79 _string_value.setNum(value_bool);
80};

References _bool_value, and _string_value.

Referenced by QXmlStreamReaderContentXml::readTableLine().

◆ setValueDouble()

void OdsCell::setValueDouble ( double  value_num)
protected

Definition at line 70 of file odscell.cpp.

71{
72 _double_value = value_num;
73 _string_value.setNum(value_num);
74};

References _double_value, and _string_value.

Referenced by QXmlStreamReaderContentXml::readTableLine().

◆ setValueOfUndefinedType()

void OdsCell::setValueOfUndefinedType ( const QString &  value)
protected

Definition at line 190 of file odscell.cpp.

191{
192 qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
193 << value;
194 _office_value_type = "string";
195 _string_value = value;
196
197 // float
198 // percentage
199 // currency
200 // date
201 // time
202 // boolean
203 // string
204
205 bool ok;
206 _double_value = _string_value.toDouble(&ok);
207 if(ok)
208 {
209 _office_value_type = "float";
210 return;
211 }
212 else
213 {
214 // test for french decimal separator
215 _double_value = QString(_string_value).replace(",", ".").toDouble(&ok);
216 if(ok)
217 {
218 _office_value_type = "float";
219 _string_value = QString(_string_value).replace(",", ".");
220 return;
221 }
222 }
223 if((_string_value == "T") || (_string_value == "TRUE") ||
224 (_string_value == "VRAI"))
225 {
226 _bool_value = true;
227 _office_value_type = "boolean";
228 return;
229 }
230 if((_string_value == "F") || (_string_value == "FALSE") ||
231 (_string_value == "FAUX"))
232 {
233 _bool_value = false;
234 _office_value_type = "boolean";
235 return;
236 }
237 QDateTime date = QDateTime::fromString(_string_value, "yyyy-MM-ddThh:mm:ss");
238 if(date.isValid())
239 {
240 _date_value = date;
241 _office_value_type = "date";
242 return;
243 }
244 date = QDateTime::fromString(_string_value, "yyyy-MM-dd");
245 if(date.isValid())
246 {
247 _date_value = date;
248 _office_value_type = "date";
249 return;
250 }
251 if(!_string_value.isEmpty())
252 {
253 _is_empty = false;
254 }
255};

References _bool_value, _date_value, _double_value, _is_empty, _office_value_type, and _string_value.

Referenced by TsvReader::readCsvRow().

◆ setValueString()

void OdsCell::setValueString ( const QString &  value)
protected

Definition at line 65 of file odscell.cpp.

66{
67 _string_value = value;
68};

References _string_value.

Referenced by TsvReader::readCsvRow().

◆ toString()

const QString & OdsCell::toString ( ) const

Definition at line 83 of file odscell.cpp.

84{
85 // if (isDate()) return QString (_date_value.toString());
86 // if (isDouble()) return QString(""+_double_value);
87 return _string_value;
88};

References _string_value.

Referenced by getBooleanValue(), getDateTimeValue(), getDoubleValue(), getStringValue(), and OdsDocReader::setInsideCell().

Member Data Documentation

◆ _bool_value

bool OdsCell::_bool_value
protected

Definition at line 61 of file odscell.h.

Referenced by getBooleanValue(), setValueBoolean(), and setValueOfUndefinedType().

◆ _date_value

QDateTime OdsCell::_date_value
protected

Definition at line 59 of file odscell.h.

Referenced by getDateTimeValue(), setDateValue(), and setValueOfUndefinedType().

◆ _double_value

double OdsCell::_double_value
protected

Definition at line 60 of file odscell.h.

Referenced by getDoubleValue(), setValueDouble(), and setValueOfUndefinedType().

◆ _is_empty

bool OdsCell::_is_empty
protected

Definition at line 62 of file odscell.h.

Referenced by isEmpty(), setOfficeValueType(), and setValueOfUndefinedType().

◆ _office_value_type

QString OdsCell::_office_value_type
protected

◆ _string_value

◆ QXmlStreamReaderContentXml

friend OdsCell::QXmlStreamReaderContentXml
private

Definition at line 30 of file odscell.h.

◆ TsvReader

friend OdsCell::TsvReader
private

Definition at line 31 of file odscell.h.


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