35 #ifndef _DATABASE_VIRTUAL_MACHINE_VALUE_TYPLE_SET_HPP_INCLUDED
36 #define _DATABASE_VIRTUAL_MACHINE_VALUE_TYPLE_SET_HPP_INCLUDED
41 #include <boost/shared_ptr.hpp>
42 #include <boost/algorithm/string.hpp>
113 throw std::runtime_error(
"value tuple set column index out of range");
142 if (i == 0 || i >
m_colnames.size())
throw std::runtime_error(
"column index out of range");
152 if (boost::algorithm::iequals( name,
m_colnames.at(ii)))
157 throw std::runtime_error(
"unknown value set column name");
161 void push(
const std::vector<types::VariantConst>& c)
163 if (c.size() !=
m_colnames.size())
throw std::runtime_error(
"pushed result with non matching number of columns");
164 for (std::vector<types::VariantConst>::const_iterator ci=c.begin(), ce=c.end(); ci != ce; ++ci)
166 m_ar.push_back( *ci);
171 void push(
const std::vector<types::Variant>& c)
173 if (c.size() !=
m_colnames.size())
throw std::runtime_error(
"pushed result with non matching number of columns");
174 for (std::vector<types::Variant>::const_iterator ci=c.begin(), ce=c.end(); ci != ce; ++ci)
176 m_ar.push_back( *ci);
197 if (
size() == 0)
throw std::runtime_error(
"constraint 'set non empty' failed");
203 if (
size() > 1)
throw std::runtime_error(
"constraint 'set unique' failed");
209 if (ts.
m_colnames.size() !=
m_colnames.size())
throw std::runtime_error(
"joining incompatible lists");
215 std::vector<types::Variant>
m_ar;
bool operator==(const const_iterator &o) const
Definition: valueTupleSet.hpp:99
ValueTupleSet()
Default constructor.
Definition: valueTupleSet.hpp:54
bool empty() const
Evaluate if the tuple set is empty.
Definition: valueTupleSet.hpp:189
void push(const std::vector< types::Variant > &c)
Add one tuple to the set (checking its size)
Definition: valueTupleSet.hpp:171
const const_iterator * operator->() const
Definition: valueTupleSet.hpp:108
Iterator on this set of value tuples.
Definition: valueTupleSet.hpp:66
boost::shared_ptr< ValueTupleSet > ValueTupleSetR
Definition: valueTupleSet.hpp:218
std::vector< types::Variant > m_ar
Definition: valueTupleSet.hpp:215
const_iterator(const ValueTupleSet *ref_, std::size_t idx_=0)
Definition: valueTupleSet.hpp:75
const_iterator end() const
Get the end tuple set iterator.
Definition: valueTupleSet.hpp:129
std::size_t index() const
Definition: valueTupleSet.hpp:94
Forward declaration.
Definition: variant.hpp:65
const_iterator operator++(int)
Definition: valueTupleSet.hpp:87
Set of tuples (database results, transaction input, etc.)
Definition: valueTupleSet.hpp:50
void checkConstraintNonEmpty() const
Check the NONEMPTY constaint on this tuple set.
Definition: valueTupleSet.hpp:195
std::size_t columnIndex(const std::string &name) const
Get the index of a column by name numbered starting with 1.
Definition: valueTupleSet.hpp:147
void push(const std::vector< types::VariantConst > &c)
Add one tuple to the set (checking its size)
Definition: valueTupleSet.hpp:161
std::vector< std::string > m_colnames
Definition: valueTupleSet.hpp:214
void append(const ValueTupleSet &ts)
Append a tuple set (checking number of columns to be equal in both sets)
Definition: valueTupleSet.hpp:207
const ValueTupleSet * m_ref
Definition: valueTupleSet.hpp:120
const types::Variant & column(std::size_t i) const
Definition: valueTupleSet.hpp:109
friend class const_iterator
Definition: valueTupleSet.hpp:62
const_iterator & operator++()
Definition: valueTupleSet.hpp:79
std::size_t nofColumns() const
Get the number of columns.
Definition: valueTupleSet.hpp:135
ValueTupleSet(const ValueTupleSet &o)
Copy constructor.
Definition: valueTupleSet.hpp:59
ValueTupleSet(const std::vector< std::string > &colnames_)
Constructor.
Definition: valueTupleSet.hpp:56
const std::string & columnName(std::size_t i) const
Get the name of a column numbered starting with 1.
Definition: valueTupleSet.hpp:140
const_iterator()
Definition: valueTupleSet.hpp:69
const_iterator(const const_iterator &o)
Definition: valueTupleSet.hpp:77
std::size_t size() const
Get the number of tuples in the tuple set.
Definition: valueTupleSet.hpp:182
const_iterator begin() const
Get the start tuple set iterator.
Definition: valueTupleSet.hpp:124
void checkConstraintUnique() const
Check the UNIQUE constaint on this tuple set.
Definition: valueTupleSet.hpp:201
std::size_t m_idx
Definition: valueTupleSet.hpp:119
bool operator!=(const const_iterator &o) const
Definition: valueTupleSet.hpp:103