1 /***************************************************************************
2 * Copyright (C) 2008 by Sverre Rabbelier *
3 * sverre@rabbelier.nl *
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. *
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. *
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 ***************************************************************************/
24 * This file contains the FieldValue class.
32 * This class contains the value of one cell in a table.
34 * A value belongs to a specific field.
35 * Values are strongly typed, this is asserted at runtime.
40 /** Constructs a Value object with no value (e.g., a NULL cell). */
41 FieldValue(FieldImplPtr field
);
43 /** Constructs a Value object with a string value (e.g., a Text cell). */
44 FieldValue(FieldImplPtr field
, cstring value
);
46 /** Constructs a Value object with a value_type valueu (e.g. an Integer cell). */
47 FieldValue(FieldImplPtr field
, value_type value
);
49 /** Value destructor, a noop. */
50 virtual ~FieldValue();
52 /** Returns what field this Value belongs to. */
53 FieldImplPtr
getField() const;
55 /** Returns the table of the field this Value belongs to. */
56 TableImplPtr
getTable() const;
58 /** Returns the name of the field this value belongs to. */
59 cstring
getName() const;
61 /** Returns the string value of this Value, only valid if this value belongs to a Text cell. */
62 const std::string
& getStringValue() const;
64 /** Returns the integer value of this Value, only valid if this value does not belong to a Text cell. */
65 value_type
getIntegerValue() const;
67 /** Returns the boolean value of this Value, oly valid if this value does not belong to a Text cell. */
68 bool getBoolValue() const;
70 /** Returns wether this Value is 'dirty', e.g., if it has been changed without being saved. */
73 /** Whether this field is a key field. */
74 virtual bool isKey() const { return false; }
77 /** Sets the text value of this Value, only valid if this value belongs to a Text cell. */
78 void setTextValue(const std::string
& value
);
80 /** Sets the integer value of this Value, only valid if this value does not belong to a Text cell. */
81 void setIntegerValue(value_type value
);
83 /** Sets the integer valueu of this Value to 0 or 1, only valid if this value does not belong to a Text cell. */
84 void setBoolValue(bool value
);
86 /** Sets this Value's dirtyness, e.g., if it has been changed without being saved. */
87 void setDirty(bool dirty
);
90 FieldImplPtr m_field
; /**< Member containing the field this value belongs to. */
91 std::string m_textvalue
; /**< Member containing the field's text value. */
92 value_type m_integervalue
; /**< Member containing the field's integer value. */
93 bool m_dirty
; /**< Wether the field is dirty or not. */