added connection impl class
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
#include "matador/sql/record.hpp"
|
||||
|
||||
namespace matador::sql {
|
||||
|
||||
record::record(std::initializer_list<column> columns)
|
||||
: columns_(columns) {
|
||||
size_t index{0};
|
||||
for(auto &col : columns_) {
|
||||
columns_by_name_.emplace(col.name(), column_index_pair {std::ref(col), index++});
|
||||
}
|
||||
}
|
||||
|
||||
const column &record::at(const std::string &name) const
|
||||
{
|
||||
return columns_by_name_.at(name).first;
|
||||
}
|
||||
|
||||
const column &record::at(size_t index)
|
||||
{
|
||||
return columns_.at(index);
|
||||
}
|
||||
|
||||
record::iterator record::find(const std::string &column_name)
|
||||
{
|
||||
auto it = columns_by_name_.find(column_name);
|
||||
return it != columns_by_name_.end() ? columns_.begin() + it->second.second : columns_.end();
|
||||
}
|
||||
|
||||
record::const_iterator record::find(const std::string &column_name) const {
|
||||
auto it = columns_by_name_.find(column_name);
|
||||
return it != columns_by_name_.end() ? columns_.begin() + it->second.second : columns_.end();
|
||||
}
|
||||
|
||||
void record::append(column col)
|
||||
{
|
||||
auto &ref = columns_.emplace_back(std::move(col));
|
||||
columns_by_name_.emplace(ref.name(), column_index_pair{std::ref(ref), columns_.size()-1});
|
||||
}
|
||||
|
||||
record::iterator record::begin()
|
||||
{
|
||||
return columns_.begin();
|
||||
}
|
||||
|
||||
record::const_iterator record::begin() const
|
||||
{
|
||||
return columns_.begin();
|
||||
}
|
||||
|
||||
record::const_iterator record::cbegin() const
|
||||
{
|
||||
return columns_.cbegin();
|
||||
}
|
||||
|
||||
record::iterator record::end()
|
||||
{
|
||||
return columns_.end();
|
||||
}
|
||||
|
||||
record::const_iterator record::end() const
|
||||
{
|
||||
return columns_.end();
|
||||
}
|
||||
|
||||
record::const_iterator record::cend() const
|
||||
{
|
||||
return columns_.cend();
|
||||
}
|
||||
|
||||
size_t record::size() const
|
||||
{
|
||||
return columns_.size();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user