54 lines
1.4 KiB
C++
54 lines
1.4 KiB
C++
#ifndef QUERY_COLUMN_HPP
|
|
#define QUERY_COLUMN_HPP
|
|
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
namespace matador::sql {
|
|
|
|
class table;
|
|
|
|
enum class sql_function_t {
|
|
None,
|
|
Count,
|
|
Avg,
|
|
Sum,
|
|
Min,
|
|
Max
|
|
};
|
|
|
|
class column {
|
|
public:
|
|
column(const char *name, const std::string& as = ""); // NOLINT(*-explicit-constructor)
|
|
explicit column(std::string name, std::string as = "");
|
|
column(sql_function_t func, std::string name); // NOLINT(*-explicit-constructor)
|
|
column(const class table &tab, std::string name, std::string as = "");
|
|
column(const std::shared_ptr<table> &t, std::string name, std::string as = "");
|
|
|
|
[[nodiscard]] bool equals(const column &x) const;
|
|
|
|
column& as(std::string a);
|
|
|
|
[[nodiscard]] const std::string& column_name() const;
|
|
[[nodiscard]] std::string full_name() const;
|
|
[[nodiscard]] const std::string& alias_name() const;
|
|
[[nodiscard]] bool is_function() const;
|
|
[[nodiscard]] sql_function_t function() const;
|
|
[[nodiscard]] bool has_alias() const;
|
|
[[nodiscard]] std::string alias() const;
|
|
[[nodiscard]] std::shared_ptr<sql::table> table() const;
|
|
void table(const std::shared_ptr<sql::table>& t);
|
|
|
|
private:
|
|
std::shared_ptr<sql::table> table_;
|
|
std::string name;
|
|
std::string alias_;
|
|
sql_function_t function_{sql_function_t::None};
|
|
};
|
|
|
|
column operator ""_col(const char *name, size_t len);
|
|
|
|
}
|
|
#endif //QUERY_COLUMN_HPP
|