added field class

This commit is contained in:
2024-03-10 11:51:07 +01:00
parent 2b552c4383
commit dd94ed1020
4 changed files with 153 additions and 18 deletions
+35 -6
View File
@@ -2,6 +2,28 @@
namespace matador::sql {
field::field(std::string name)
: name_(std::move(name)), value_(nullptr), type_(field_traits<nullptr_t>::type())
{}
field::field(field &&x) noexcept
: name_(std::move(x.name_)), value_(std::move(x.value_)), type_(x.type_)
{
x.value_ = nullptr;
x.type_ = field_type::Null;
}
field &field::operator=(field &&x) noexcept
{
name_ = std::move(x.name_);
value_ = std::move(x.value_);
type_ = x.type_;
x.value_ = nullptr;
x.type_ = field_type::Null;
return *this;
}
const std::string &field::name() const
{
return name_;
@@ -9,36 +31,43 @@ const std::string &field::name() const
std::ostream &operator<<(std::ostream &out, const field &col)
{
out << col.str();
return out;
}
std::string field::str() const
{
return as<std::string>().value();
}
bool field::is_integer() const
{
return false;
return type_ == field_type::Integer;
}
bool field::is_floating_point() const
{
return false;
return type_ == field_type::FloatingPoint;
}
bool field::is_bool() const
{
return false;
return type_ == field_type::Boolean;
}
bool field::is_string() const
{
return false;
return type_ == field_type::String;
}
bool field::is_blob() const
{
return false;
return type_ == field_type::Blob;
}
bool field::is_null() const
{
return false;
return type_ == field_type::Null;
}
}