Added 'length' to area.
[UnsignedByte.git] / src / DAL / FieldValues.cpp
blob8fc54aac076dc76da8a3be1bb832fa7970835673
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 "FieldValues.h"
22 #include "KeyValue.h"
23 #include "KeyImpl.h"
24 #include "TableImpl.h"
25 #include "FieldValue.h"
26 #include "FieldImpl.h"
27 #include "Parse.h"
28 #include "StringUtilities.h"
30 FieldValues::FieldValues(TableImplPtr table) :
31 m_table(table)
33 Assert(table);
36 FieldValues::~FieldValues()
41 ValuePtr FieldValues::getField(FieldImplPtr field) const
43 Assert(field);
44 ValueMap::const_iterator it = m_fields.find(field.get());
45 Assert(it != m_fields.end());
47 return it->second;
50 TableImplPtr FieldValues::getTable() const
52 return m_table;
55 void FieldValues::addValue(ValuePtr value)
57 Assert(value);
59 TableImplPtr table = value->getTable();
60 bool isReachableTable = false;
62 if(table == m_table)
63 isReachableTable = true;
65 for(TableImplVector::const_iterator it = m_joinedTables.begin(); it != m_joinedTables.end(); it++)
67 TableImplPtr joinedTable = *it;
68 if(table == joinedTable)
69 isReachableTable = true;
72 Assert(isReachableTable);
74 m_fields[value->getField().get()] = value;
77 void FieldValues::addJoinedTable(TableImplPtr joinedTable)
79 Assert(joinedTable);
81 m_joinedTables.push_back(joinedTable);
84 size_t FieldValues::size() const
86 return m_fields.size();
89 ValuePtr FieldValues::first() const
91 Assert(m_fields.size() > 0);
93 return m_fields.begin()->second;
96 ValueMap::const_iterator FieldValues::begin() const
98 return m_fields.begin();
101 ValueMap::const_iterator FieldValues::end() const
103 return m_fields.end();
106 ValueMap::const_iterator FieldValues::find(FieldImplPtr field) const
108 Assert(field);
110 return m_fields.find(field.get());