50 lines
1.3 KiB
C++
50 lines
1.3 KiB
C++
#ifndef QUERY_COLUMN_HPP
|
|
#define QUERY_COLUMN_HPP
|
|
|
|
#include "matador/sql/sql_functions.hpp"
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
namespace matador::query {
|
|
|
|
class table;
|
|
|
|
// ReSharper disable CppNonExplicitConvertingConstructor
|
|
class column {
|
|
public:
|
|
column(const char *name, const std::string& as = ""); // NOLINT(*-explicit-constructor)
|
|
column(std::string name, std::string as = ""); // NOLINT(*-explicit-constructor)
|
|
column(sql::sql_function_t func, std::string name);
|
|
// 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& name() const;
|
|
[[nodiscard]] const std::string& alias() const;
|
|
|
|
[[nodiscard]] bool is_function() const;
|
|
[[nodiscard]] sql::sql_function_t function() const;
|
|
[[nodiscard]] bool has_alias() const;
|
|
|
|
[[nodiscard]] std::shared_ptr<class table> table() const;
|
|
void table(const std::shared_ptr<query::table>& t);
|
|
|
|
operator const std::string&() const;
|
|
|
|
private:
|
|
std::shared_ptr<query::table> table_;
|
|
std::string name_;
|
|
std::string alias_;
|
|
|
|
sql::sql_function_t function_{sql::sql_function_t::None};
|
|
};
|
|
|
|
column operator ""_col(const char *name, size_t len);
|
|
|
|
}
|
|
#endif //QUERY_COLUMN_HPP
|