initial matador ng commit
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
#include "matador/utils/value.hpp"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace matador::utils {
|
||||
namespace detail {
|
||||
|
||||
size_t determine_size(const std::string &val)
|
||||
{
|
||||
return val.size();
|
||||
}
|
||||
|
||||
size_t determine_size(const char *val)
|
||||
{
|
||||
return strlen(val);
|
||||
}
|
||||
|
||||
size_t determine_size(const blob &val)
|
||||
{
|
||||
return val.size();
|
||||
}
|
||||
|
||||
}
|
||||
value::value(const basic_type data_type, const size_t size)
|
||||
: size_(size)
|
||||
, type_(data_type)
|
||||
{
|
||||
initialize_by_basic_type(type_, value_);
|
||||
}
|
||||
|
||||
value::value(value &&x) noexcept
|
||||
: value_(std::move(x.value_))
|
||||
, type_(x.type_)
|
||||
{
|
||||
x.value_ = nullptr;
|
||||
x.type_ = basic_type::type_null;
|
||||
}
|
||||
|
||||
value &value::operator=(value &&x) noexcept
|
||||
{
|
||||
value_ = std::move(x.value_);
|
||||
type_ = x.type_;
|
||||
x.value_ = nullptr;
|
||||
x.type_ = basic_type::type_null;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::string value::str() const
|
||||
{
|
||||
return as<std::string>().value_or("");
|
||||
}
|
||||
|
||||
size_t value::size() const
|
||||
{
|
||||
return size_;
|
||||
}
|
||||
|
||||
basic_type value::type() const
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
bool value::is_integer() const
|
||||
{
|
||||
return type_ >= basic_type::type_int8 && type_ <= basic_type::type_uint64;
|
||||
}
|
||||
|
||||
bool value::is_floating_point() const
|
||||
{
|
||||
return type_ == basic_type::type_float || type_ == basic_type::type_double;
|
||||
}
|
||||
|
||||
bool value::is_bool() const
|
||||
{
|
||||
return type_ == basic_type::type_bool;
|
||||
}
|
||||
|
||||
bool value::is_string() const
|
||||
{
|
||||
return type_ == basic_type::type_text;
|
||||
}
|
||||
|
||||
bool value::is_varchar() const
|
||||
{
|
||||
return type_ == basic_type::type_varchar;
|
||||
}
|
||||
|
||||
bool value::is_date() const
|
||||
{
|
||||
return type_ == basic_type::type_date;
|
||||
}
|
||||
|
||||
bool value::is_time() const
|
||||
{
|
||||
return type_ == basic_type::type_time;
|
||||
}
|
||||
|
||||
bool value::is_blob() const
|
||||
{
|
||||
return type_ == basic_type::type_blob;
|
||||
}
|
||||
|
||||
bool value::is_null() const
|
||||
{
|
||||
return type_ == basic_type::type_null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user