Used a more uniform of logging and added a commandline parser.
[UnsignedByte.git] / src / DAL / FieldValue.cpp
blob578980861b7a53aabb565e72c12b3eb0f73ff218
1 /***************************************************************************
2 * Copyright (C) 2008 by Sverre Rabbelier *
3 * sverre@rabbelier.nl *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "FieldValue.h"
22 #include "FieldImpl.h"
23 #include "TableImpl.h"
24 #include "KeyImpl.h"
26 FieldValue::FieldValue(FieldImplPtr field) :
27 m_field(field),
28 m_textvalue(""),
29 m_integervalue(0) ,
30 m_dirty(false)
32 Assert(field);
35 FieldValue::FieldValue(FieldImplPtr field, cstring value) :
36 m_field(field),
37 m_textvalue(value),
38 m_integervalue(0),
39 m_dirty(true)
41 Assert(field);
44 FieldValue::FieldValue(FieldImplPtr field, value_type value) :
45 m_field(field),
46 m_textvalue(""),
47 m_integervalue(value),
48 m_dirty(true)
50 Assert(field);
53 FieldValue::~FieldValue()
58 FieldImplPtr FieldValue::getField() const
60 return m_field;
63 TableImplPtr FieldValue::getTable() const
65 return m_field->getTable();
68 cstring FieldValue::getName() const
70 return m_field->getName();
73 const std::string& FieldValue::getStringValue() const
75 Assert(m_field->isText());
76 return m_textvalue;
79 value_type FieldValue::getIntegerValue() const
81 Assert(!m_field->isText());
82 return m_integervalue;
85 bool FieldValue::getBoolValue() const
87 Assert(!m_field->isText());
88 return m_integervalue == 1 ? true : false;
91 bool FieldValue::isDirty() const
93 return m_dirty;
96 void FieldValue::setTextValue(const std::string& value)
98 Assert(m_field->isText());
99 m_textvalue = value;
102 void FieldValue::setIntegerValue(value_type value)
104 Assert(!m_field->isText());
105 m_integervalue = value;
108 void FieldValue::setBoolValue(bool value)
110 Assert(!m_field->isText());
111 m_integervalue = (value ? 1 : 0);
114 void FieldValue::setDirty(bool dirty)
116 m_dirty = dirty;