65 lines
1.2 KiB
C++
65 lines
1.2 KiB
C++
#include "matador/query/table.hpp"
|
|
|
|
namespace matador::query {
|
|
|
|
table::table(const char* name)
|
|
: table(std::string(name))
|
|
{}
|
|
|
|
table::table(std::string name)
|
|
: name_(std::move(name))
|
|
{}
|
|
|
|
table::table(std::string name, std::string as)
|
|
: name_(std::move(name))
|
|
, alias_(std::move(as))
|
|
{}
|
|
|
|
table::table( std::string name, std::string as, const std::vector<query::column>& columns )
|
|
: name_(std::move(name))
|
|
, alias_(std::move(as))
|
|
, columns_(columns) {}
|
|
|
|
bool table::operator==( const table& x ) const {
|
|
return name_ == x.name_;
|
|
}
|
|
|
|
table & table::as(const std::string &a) {
|
|
alias_ = a;
|
|
return *this;
|
|
}
|
|
|
|
table table::as(const std::string &a) const {
|
|
return { name_, a, columns_ };
|
|
}
|
|
|
|
bool table::has_alias() const {
|
|
return !alias_.empty();
|
|
}
|
|
|
|
const std::string& table::name() const {
|
|
return name_;
|
|
}
|
|
|
|
const std::string& table::alias() const {
|
|
return alias_;
|
|
}
|
|
|
|
const std::vector<column>& table::columns() const {
|
|
return columns_;
|
|
}
|
|
|
|
column table::column( const std::string& name ) const {
|
|
return {*this, name};
|
|
}
|
|
|
|
table::operator const std::vector<query::column>&() const {
|
|
return columns_;
|
|
}
|
|
|
|
table operator ""_tab(const char *name, size_t len) {
|
|
return {{name, len}};
|
|
}
|
|
|
|
}
|