38 lines
665 B
C++
38 lines
665 B
C++
#ifndef QUERY_FIELD_HPP
|
|
#define QUERY_FIELD_HPP
|
|
|
|
#include "matador/sql/any_type.hpp"
|
|
#include "matador/sql/any_type_to_visitor.hpp"
|
|
|
|
#include <string>
|
|
|
|
namespace matador::sql {
|
|
|
|
class field
|
|
{
|
|
public:
|
|
|
|
[[nodiscard]] const std::string& name() const;
|
|
|
|
template<class Type>
|
|
Type as() const
|
|
{
|
|
const Type* ptr= std::get_if<Type>(&value_);
|
|
if (ptr) {
|
|
return *ptr;
|
|
}
|
|
any_type_to_visitor<Type> visitor;
|
|
std::visit(visitor, const_cast<any_type&>(value_));
|
|
return visitor.result;
|
|
}
|
|
|
|
friend std::ostream& operator<<(std::ostream &out, const field &col);
|
|
|
|
private:
|
|
std::string name_;
|
|
any_type value_;
|
|
};
|
|
|
|
}
|
|
#endif //QUERY_FIELD_HPP
|