39 lines
1.3 KiB
C++
39 lines
1.3 KiB
C++
#include "matador/query/generator.hpp"
|
|
|
|
namespace matador::query::generator {
|
|
column_generator::column_generator( const std::string& table_name, const column_generator_options options)
|
|
: options_(options) {
|
|
table_stack_.push(table_name.empty() ? std::make_shared<table>() : std::make_shared<table>(table_name));
|
|
}
|
|
|
|
column_generator::column_generator(const object::repository& repo, const std::string& table_name, const column_generator_options options)
|
|
: repo_(std::cref(repo))
|
|
, options_(options) {
|
|
table_stack_.push(table_name.empty() ? std::make_shared<table>() : std::make_shared<table>(table_name));
|
|
}
|
|
|
|
void column_generator::on_revision( const char* id, uint64_t& ) {
|
|
push(id);
|
|
}
|
|
|
|
void column_generator::push( const std::string& column_name ) {
|
|
if (is_column_generator_option_set(options_, column_generator_options::GenerateAlias)) {
|
|
char str[4];
|
|
snprintf(str, 4, "c%02d", ++column_index);
|
|
result_.emplace_back(table_stack_.top(), column_name, str);
|
|
} else {
|
|
result_.emplace_back(table_stack_.top(), column_name);
|
|
}
|
|
}
|
|
|
|
void placeholder_generator::on_revision(const char* /*id*/, uint64_t&) {
|
|
result_.emplace_back(utils::_);
|
|
}
|
|
|
|
column_value_generator::column_value_generator(column_value_generator_options options)
|
|
: options_(options) {}
|
|
|
|
void column_value_generator::on_revision(const char* id, uint64_t& x) {
|
|
push_back(id, x);
|
|
}
|
|
} |