mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:07:44 +00:00
LibSQL: Implement binary operators for Value objects
The behaviour of the various operators is supposed to mimic that of the same operators in PostgreSQL; the '+' operator for example will successfully add '98' (string) and 2 (integer), but not 'foo' and 2. Also removed some redundant const& parameter declarations for intrinsic types (ints and doubles etc). Passing those by const& doesn't make a lot of sense.
This commit is contained in:
parent
3618ca2420
commit
73fc023652
2 changed files with 161 additions and 6 deletions
|
@ -56,6 +56,7 @@ public:
|
|||
explicit Value(String const&);
|
||||
explicit Value(char const*);
|
||||
explicit Value(int);
|
||||
explicit Value(u32);
|
||||
explicit Value(double);
|
||||
explicit Value(bool);
|
||||
|
||||
|
@ -84,9 +85,10 @@ public:
|
|||
|
||||
void assign(Value const& other_value);
|
||||
void assign(String const& string_value);
|
||||
void assign(int const& int_value);
|
||||
void assign(double const& double_value);
|
||||
void assign(bool const& bool_value);
|
||||
void assign(int int_value);
|
||||
void assign(u32 unsigned_int_value);
|
||||
void assign(double double_value);
|
||||
void assign(bool bool_value);
|
||||
void assign(Vector<Value> const& values);
|
||||
|
||||
Value& operator=(Value const& other);
|
||||
|
@ -116,6 +118,16 @@ public:
|
|||
bool operator>(Value const&) const;
|
||||
bool operator>=(Value const&) const;
|
||||
|
||||
Value add(Value const&) const;
|
||||
Value subtract(Value const&) const;
|
||||
Value multiply(Value const&) const;
|
||||
Value divide(Value const&) const;
|
||||
Value modulo(Value const&) const;
|
||||
Value shift_left(Value const&) const;
|
||||
Value shift_right(Value const&) const;
|
||||
Value bitwise_or(Value const&) const;
|
||||
Value bitwise_and(Value const&) const;
|
||||
|
||||
[[nodiscard]] TupleElementDescriptor descriptor() const
|
||||
{
|
||||
return { "", type(), Order::Ascending };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue