diff options
Diffstat (limited to 'libpqpp')
-rw-r--r-- | libpqpp/selectcommand.cpp | 43 | ||||
-rw-r--r-- | libpqpp/selectcommand.h | 7 |
2 files changed, 2 insertions, 48 deletions
diff --git a/libpqpp/selectcommand.cpp b/libpqpp/selectcommand.cpp index 9854216..359cdfd 100644 --- a/libpqpp/selectcommand.cpp +++ b/libpqpp/selectcommand.cpp @@ -26,9 +26,6 @@ PQ::SelectCommand::~SelectCommand() PQclear(execRes); } } - for (unsigned int f = 0; f < fields.size(); f += 1) { - delete fields[f]; - } } void @@ -63,11 +60,8 @@ PQ::SelectCommand::execute() PGRES_COMMAND_OK); fetchTuples(); unsigned int nFields = PQnfields(execRes); - fields.resize(nFields); for (unsigned int f = 0; f < nFields; f += 1) { - Column * c = new Column(this, f); - fields[f] = c; - fieldsName[c->name] = c; + columns.insert(DB::ColumnPtr(new Column(this, f))); } executed = true; } @@ -103,38 +97,3 @@ PQ::SelectCommand::fetch() } } -const DB::Column& -PQ::SelectCommand::operator[](unsigned int n) const -{ - if (n < fields.size()) { - return *fields[n]; - } - throw Error(); -} - -const DB::Column& -PQ::SelectCommand::operator[](const Glib::ustring & n) const -{ - std::map<Glib::ustring, Column *>::const_iterator i = fieldsName.find(n); - if (i != fieldsName.end()) { - return *i->second; - } - throw Error(); -} - -unsigned int -PQ::SelectCommand::getOrdinal(const Glib::ustring & n) const -{ - std::map<Glib::ustring, Column *>::const_iterator i = fieldsName.find(n); - if (i != fieldsName.end()) { - return i->second->colNo; - } - throw Error(); -} - -unsigned int -PQ::SelectCommand::columnCount() const -{ - return fields.size(); -} - diff --git a/libpqpp/selectcommand.h b/libpqpp/selectcommand.h index f4774d7..daa2707 100644 --- a/libpqpp/selectcommand.h +++ b/libpqpp/selectcommand.h @@ -16,16 +16,11 @@ namespace PQ { bool fetch(); void execute(); - const DB::Column& operator[](unsigned int) const; - const DB::Column& operator[](const Glib::ustring&) const; - unsigned int columnCount() const; - unsigned int getOrdinal(const Glib::ustring&) const; + private: void fetchTuples(); mutable bool executed; mutable bool txOpened; - std::vector<Column *> fields; - std::map<Glib::ustring, Column *> fieldsName; int nTuples, tuple; PGresult * execRes; |