summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdbpp/selectcommand.cpp22
-rw-r--r--libdbpp/selectcommand.h7
2 files changed, 20 insertions, 9 deletions
diff --git a/libdbpp/selectcommand.cpp b/libdbpp/selectcommand.cpp
index 6cb8759..f6b1d33 100644
--- a/libdbpp/selectcommand.cpp
+++ b/libdbpp/selectcommand.cpp
@@ -1,5 +1,7 @@
#include "selectcommand.h"
#include "error.h"
+#include <boost/multi_index_container.hpp>
+#include <boost/multi_index/ordered_index.hpp>
namespace DB {
class ColumnIndexOutOfRange : public Error {
@@ -17,19 +19,21 @@ namespace DB {
};
DB::SelectCommand::SelectCommand(const std::string & sql) :
- DB::Command(sql)
+ DB::Command(sql),
+ columns(new Columns)
{
}
DB::SelectCommand::~SelectCommand()
{
+ delete columns;
}
const DB::Column&
DB::SelectCommand::operator[](unsigned int n) const
{
- if (n < columns.size()) {
- return **columns.get<0>().find(n);
+ if (n < columns->size()) {
+ return **columns->get<0>().find(n);
}
throw ColumnIndexOutOfRange(n);
}
@@ -38,8 +42,8 @@ const DB::Column&
DB::SelectCommand::operator[](const Glib::ustring & n) const
{
typedef Columns::nth_index<1>::type CbyName;
- CbyName::iterator i = columns.get<1>().find(n);
- if (i != columns.get<1>().end()) {
+ CbyName::iterator i = columns->get<1>().find(n);
+ if (i != columns->get<1>().end()) {
return **i;
}
throw ColumnDoesNotExist(n);
@@ -54,6 +58,12 @@ DB::SelectCommand::getOrdinal(const Glib::ustring & n) const
unsigned int
DB::SelectCommand::columnCount() const
{
- return columns.size();
+ return columns->size();
+}
+
+void
+DB::SelectCommand::insertColumn(ColumnPtr col)
+{
+ columns->insert(col);
}
diff --git a/libdbpp/selectcommand.h b/libdbpp/selectcommand.h
index a5788ea..8ebaf9c 100644
--- a/libdbpp/selectcommand.h
+++ b/libdbpp/selectcommand.h
@@ -3,9 +3,9 @@
#include "command.h"
#include "column.h"
-#include <boost/multi_index_container.hpp>
+#include <boost/multi_index_container_fwd.hpp>
#include <boost/multi_index/indexed_by.hpp>
-#include <boost/multi_index/ordered_index.hpp>
+#include <boost/multi_index/ordered_index_fwd.hpp>
#include <boost/multi_index/member.hpp>
#include <visibility.h>
@@ -21,6 +21,7 @@ namespace DB {
const Column & operator[](const Glib::ustring &) const;
unsigned int columnCount() const;
unsigned int getOrdinal(const Glib::ustring &) const;
+ void insertColumn(ColumnPtr);
typedef boost::multi_index_container<ColumnPtr, boost::multi_index::indexed_by<
boost::multi_index::ordered_unique<boost::multi_index::member<DB::Column, const unsigned int, &DB::Column::colNo>>,
@@ -28,7 +29,7 @@ namespace DB {
>> Columns;
protected:
- Columns columns;
+ Columns * columns;
};
}