mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-27 10:07:19 +02:00
Expressions
- Filter processing short-circuits if there is no filter. - Variant code was not only incomplete, but very broken. It should not have been used. It still doesn't handle dates and durations. - Converted all logical and relational Variant operators to return Boolean values. - Stack size is now checked for every operator. - All operators implemented (without any advanced special case handling) except %, ~ and !~. - Added lazy DOM expansion at the last possible moment. - Implemented Expression::create_variant to create appropriate Variant instances based on categorized and inferred type. - Removed Variant math functions. No point. - Debug code left in place for now.
This commit is contained in:
parent
c57f880be7
commit
db17536266
4 changed files with 363 additions and 270 deletions
|
@ -44,17 +44,20 @@ extern Context context;
|
||||||
Expression::Expression (Arguments& arguments)
|
Expression::Expression (Arguments& arguments)
|
||||||
: _args (arguments)
|
: _args (arguments)
|
||||||
{
|
{
|
||||||
_args.dump ("Expression::Expression");
|
if (_args.size ())
|
||||||
|
{
|
||||||
|
_args.dump ("Expression::Expression");
|
||||||
|
|
||||||
expand_sequence ();
|
expand_sequence ();
|
||||||
implicit_and ();
|
implicit_and ();
|
||||||
expand_tag ();
|
expand_tag ();
|
||||||
expand_pattern ();
|
expand_pattern ();
|
||||||
expand_attr ();
|
expand_attr ();
|
||||||
expand_attmod ();
|
expand_attmod ();
|
||||||
expand_word ();
|
expand_word ();
|
||||||
expand_tokens ();
|
expand_tokens ();
|
||||||
postfix ();
|
postfix ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -71,123 +74,204 @@ bool Expression::eval (Task& task)
|
||||||
|
|
||||||
// There are elements in the filter, so the expression must be evaluated
|
// There are elements in the filter, so the expression must be evaluated
|
||||||
// against each task.
|
// against each task.
|
||||||
std::vector <std::pair <Variant, std::string> > value_stack;
|
std::vector <Variant> value_stack;
|
||||||
|
|
||||||
// TODO Build an on-demand regex cache.
|
// TODO Build an on-demand regex cache.
|
||||||
|
|
||||||
std::vector <std::pair <std::string, std::string> >::iterator arg;
|
std::vector <std::pair <std::string, std::string> >::const_iterator arg;
|
||||||
for (arg = _args.begin (); arg != _args.end (); ++arg)
|
for (arg = _args.begin (); arg != _args.end (); ++arg)
|
||||||
{
|
{
|
||||||
if (arg->second == "op")
|
if (arg->second == "op")
|
||||||
{
|
{
|
||||||
|
std::cout << "# operator " << arg->first << "\n";
|
||||||
|
|
||||||
// Handle the unary operator first.
|
// Handle the unary operator first.
|
||||||
if (arg->first == "!")
|
if (arg->first == "!")
|
||||||
{
|
{
|
||||||
|
// Are there sufficient arguments?
|
||||||
if (value_stack.size () < 1)
|
if (value_stack.size () < 1)
|
||||||
throw std::string ("Error: Insufficient operands for '!' operator.");
|
throw std::string ("Error: Insufficient operands for '!' operator.");
|
||||||
|
|
||||||
std::string right_type = value_stack.back ().second;
|
Variant right (value_stack.back ());
|
||||||
Variant right (value_stack.back ().first);
|
if (right.raw_type () == "lvalue")
|
||||||
|
{
|
||||||
|
right = Variant (context.dom.get (right.raw (), task));
|
||||||
|
right.raw (value_stack.back ().raw ());
|
||||||
|
right.raw_type (value_stack.back ().raw_type ());
|
||||||
|
}
|
||||||
value_stack.pop_back ();
|
value_stack.pop_back ();
|
||||||
|
|
||||||
right = ! right;
|
std::cout << "# " << " ! " << right.dump () << "\n";
|
||||||
value_stack.push_back (std::make_pair (right, ""));
|
bool result = !right;
|
||||||
continue; // This only occurs here.
|
right = Variant (result);
|
||||||
|
right.raw_type ("bool");
|
||||||
|
|
||||||
|
std::cout << "# --> " << right.dump () << "\n";
|
||||||
|
value_stack.push_back (right);
|
||||||
|
|
||||||
|
// This only occurs here, because the unary operators are handled, and
|
||||||
|
// now the binary operators will be processed.
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Are there sufficient arguments?
|
||||||
if (value_stack.size () < 2)
|
if (value_stack.size () < 2)
|
||||||
throw std::string ("Error: Insufficient operands for '") + arg->first + "' operator.";
|
throw std::string ("Error: Insufficient operands for '") + arg->first + "' operator.";
|
||||||
|
|
||||||
// Pop the binary operands first.
|
// rvalue (string, rx, int, number, dom ...).
|
||||||
std::string right_type = value_stack.back ().second;
|
Variant right (value_stack.back ());
|
||||||
Variant right (value_stack.back ().first);
|
if (right.raw_type () == "lvalue")
|
||||||
|
{
|
||||||
|
right = Variant (context.dom.get (right.raw (), task));
|
||||||
|
right.raw (value_stack.back ().raw ());
|
||||||
|
right.raw_type (value_stack.back ().raw_type ());
|
||||||
|
}
|
||||||
value_stack.pop_back ();
|
value_stack.pop_back ();
|
||||||
|
|
||||||
std::string left_type = value_stack.back ().second;
|
// lvalue (dom).
|
||||||
Variant left (value_stack.back ().first);
|
Variant left (value_stack.back ());
|
||||||
|
if (left.raw_type () == "lvalue")
|
||||||
|
{
|
||||||
|
left = Variant (context.dom.get (left.raw (), task));
|
||||||
|
left.raw (value_stack.back ().raw ());
|
||||||
|
left.raw_type (value_stack.back ().raw_type ());
|
||||||
|
}
|
||||||
value_stack.pop_back ();
|
value_stack.pop_back ();
|
||||||
|
|
||||||
// Now hte binary operators.
|
// Now the binary operators.
|
||||||
if (arg->first == "and")
|
if (arg->first == "and")
|
||||||
{
|
{
|
||||||
left = left && right;
|
std::cout << "# " << left.dump () << " and " << right.dump () << "\n";
|
||||||
value_stack.push_back (std::make_pair (left, ""));
|
bool result = (left && right);
|
||||||
|
left = Variant (result);
|
||||||
|
left.raw_type ("bool");
|
||||||
|
|
||||||
|
std::cout << "# --> " << left.dump () << "\n";
|
||||||
|
value_stack.push_back (left);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (arg->first == "xor")
|
else if (arg->first == "xor")
|
||||||
{
|
{
|
||||||
left = (left && !right) || (!left && right);
|
std::cout << "# " << left.dump () << " xor " << right.dump () << "\n";
|
||||||
value_stack.push_back (std::make_pair (left, ""));
|
bool left_bool = left.boolean ();
|
||||||
|
bool right_bool = right.boolean ();
|
||||||
|
bool result = (left_bool && !right_bool) || (!left_bool && right_bool);
|
||||||
|
left = Variant (result);
|
||||||
|
left.raw_type ("bool");
|
||||||
|
|
||||||
|
std::cout << "# --> " << left.dump () << "\n";
|
||||||
|
value_stack.push_back (left);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (arg->first == "or")
|
else if (arg->first == "or")
|
||||||
{
|
{
|
||||||
left = left || right;
|
std::cout << "# " << left.dump () << " or " << right.dump () << "\n";
|
||||||
value_stack.push_back (std::make_pair (left, ""));
|
bool result = (left || right);
|
||||||
|
left = Variant (result);
|
||||||
|
left.raw_type ("bool");
|
||||||
|
|
||||||
|
std::cout << "# --> " << left.dump () << "\n";
|
||||||
|
value_stack.push_back (left);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (arg->first == "<=")
|
else if (arg->first == "<=")
|
||||||
{
|
{
|
||||||
left = left <= right;
|
std::cout << "# " << left.dump () << " <= " << right.dump () << "\n";
|
||||||
value_stack.push_back (std::make_pair (left, ""));
|
bool result = (left <= right);
|
||||||
|
left = Variant (result);
|
||||||
|
left.raw_type ("bool");
|
||||||
|
|
||||||
|
std::cout << "# --> " << left.dump () << "\n";
|
||||||
|
value_stack.push_back (left);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (arg->first == ">=")
|
else if (arg->first == ">=")
|
||||||
{
|
{
|
||||||
left = left >= right;
|
std::cout << "# " << left.dump () << " >= " << right.dump () << "\n";
|
||||||
value_stack.push_back (std::make_pair (left, ""));
|
bool result = (left >= right);
|
||||||
|
left = Variant (result);
|
||||||
|
left.raw_type ("bool");
|
||||||
|
|
||||||
|
std::cout << "# --> " << left.dump () << "\n";
|
||||||
|
value_stack.push_back (left);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (arg->first == "!~")
|
else if (arg->first == "!~")
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO Copy "~".
|
||||||
/*
|
|
||||||
if left == "description" then it really means description or annotations or project.
|
|
||||||
if left == "tags" then it just means tags.
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (arg->first == "!=")
|
else if (arg->first == "!=")
|
||||||
{
|
{
|
||||||
left = left != right;
|
std::cout << "# " << left.dump () << " != " << right.dump () << "\n";
|
||||||
value_stack.push_back (std::make_pair (left, ""));
|
bool result = (left != right);
|
||||||
|
left = Variant (result);
|
||||||
|
left.raw_type ("bool");
|
||||||
|
|
||||||
|
std::cout << "# --> " << left.dump () << "\n";
|
||||||
|
value_stack.push_back (left);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (arg->first == "=")
|
else if (arg->first == "=")
|
||||||
{
|
{
|
||||||
context.debug ("eval left=" + left.format ());
|
std::cout << "# " << left.dump () << " = " << right.dump () << "\n";
|
||||||
context.debug ("eval right=" + right.format ());
|
bool result = (left == right);
|
||||||
|
left = Variant (result);
|
||||||
|
left.raw_type ("bool");
|
||||||
|
|
||||||
left = left == right;
|
std::cout << "# --> " << left.dump () << "\n";
|
||||||
value_stack.push_back (std::make_pair (left, ""));
|
value_stack.push_back (left);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (arg->first == ">")
|
else if (arg->first == ">")
|
||||||
{
|
{
|
||||||
left = left > right;
|
std::cout << "# " << left.dump () << " > " << right.dump () << "\n";
|
||||||
value_stack.push_back (std::make_pair (left, ""));
|
bool result = (left > right);
|
||||||
|
left = Variant (result);
|
||||||
|
left.raw_type ("bool");
|
||||||
|
|
||||||
|
std::cout << "# --> " << left.dump () << "\n";
|
||||||
|
value_stack.push_back (left);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (arg->first == "~")
|
else if (arg->first == "~")
|
||||||
{
|
{
|
||||||
// TODO We need to compare right against description, all annotations and project.
|
// Matches against description are really against either description,
|
||||||
// TODO Does that mean we need the original lvalue intact, and not a DOM subst?
|
// annotations or project.
|
||||||
/*
|
if (left.raw () == "description")
|
||||||
if left == "description" then it really means description or annotations or project.
|
{
|
||||||
if left == "tags" then it just means tags.
|
if (right.raw_type () == "rx")
|
||||||
*/
|
{
|
||||||
|
throw std::string ("rx not supported");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Matches against non-description fields are treated as-is.
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (right.raw_type () == "rx")
|
||||||
|
{
|
||||||
|
throw std::string ("rx not supported");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (arg->first == "*")
|
else if (arg->first == "*")
|
||||||
{
|
{
|
||||||
left = left * right;
|
left = left * right;
|
||||||
value_stack.push_back (std::make_pair (left, ""));
|
value_stack.push_back (left);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (arg->first == "/")
|
else if (arg->first == "/")
|
||||||
{
|
{
|
||||||
left = left / right;
|
left = left / right;
|
||||||
value_stack.push_back (std::make_pair (left, ""));
|
value_stack.push_back (left);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (arg->first == "%")
|
else if (arg->first == "%")
|
||||||
|
@ -198,19 +282,24 @@ context.debug ("eval right=" + right.format ());
|
||||||
else if (arg->first == "+")
|
else if (arg->first == "+")
|
||||||
{
|
{
|
||||||
left = left + right;
|
left = left + right;
|
||||||
value_stack.push_back (std::make_pair (left, ""));
|
value_stack.push_back (left);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (arg->first == "-")
|
else if (arg->first == "-")
|
||||||
{
|
{
|
||||||
left = left - right;
|
left = left - right;
|
||||||
value_stack.push_back (std::make_pair (left, ""));
|
value_stack.push_back (left);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (arg->first == "<")
|
else if (arg->first == "<")
|
||||||
{
|
{
|
||||||
left = left < right;
|
std::cout << "# " << left.dump () << " < " << right.dump () << "\n";
|
||||||
value_stack.push_back (std::make_pair (left, ""));
|
bool result = (left < right);
|
||||||
|
left = Variant (result);
|
||||||
|
left.raw_type ("bool");
|
||||||
|
|
||||||
|
std::cout << "# --> " << left.dump () << "\n";
|
||||||
|
value_stack.push_back (left);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -220,28 +309,14 @@ context.debug ("eval right=" + right.format ());
|
||||||
// It's not an operator, it's either and lvalue or some form of rvalue.
|
// It's not an operator, it's either and lvalue or some form of rvalue.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (arg->second == "lvalue")
|
Variant operand;
|
||||||
value_stack.push_back (std::make_pair (Variant (context.dom.get (arg->first, task)), ""));
|
create_variant (operand, arg->first, arg->second);
|
||||||
|
value_stack.push_back (operand);
|
||||||
else if (arg->second == "int")
|
|
||||||
value_stack.push_back (std::make_pair (Variant ((int) strtol (arg->first.c_str (), NULL, 10)), ""));
|
|
||||||
|
|
||||||
else if (arg->second == "number")
|
|
||||||
value_stack.push_back (std::make_pair (Variant (strtod (arg->first.c_str (), NULL)), ""));
|
|
||||||
|
|
||||||
else if (arg->second == "rvalue" ||
|
|
||||||
arg->second == "string" ||
|
|
||||||
arg->second == "rx")
|
|
||||||
value_stack.push_back (std::make_pair (Variant (unquoteText (arg->first)), ""));
|
|
||||||
|
|
||||||
else
|
|
||||||
throw std::string ("Error: Expression::eval unrecognized operand '") + + "'.";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Coerce stack element to boolean.
|
// Coerce stack element to boolean.
|
||||||
Variant result (value_stack.back ().first);
|
Variant result (value_stack.back ());
|
||||||
//context.debug ("eval result=" + result.format ());
|
|
||||||
value_stack.pop_back ();
|
value_stack.pop_back ();
|
||||||
bool pass_fail = result.boolean ();
|
bool pass_fail = result.boolean ();
|
||||||
|
|
||||||
|
@ -252,6 +327,38 @@ context.debug ("eval right=" + right.format ());
|
||||||
return pass_fail;
|
return pass_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void Expression::create_variant (
|
||||||
|
Variant& variant,
|
||||||
|
const std::string& value,
|
||||||
|
const std::string& type)
|
||||||
|
{
|
||||||
|
std::cout << "# operand '" << value << "' as " << type << "\n";
|
||||||
|
|
||||||
|
// DOM references are not resolved until the operator is processed. This
|
||||||
|
// preserves the original name, which helps determine how to apply the
|
||||||
|
// operator.
|
||||||
|
if (type == "lvalue")
|
||||||
|
variant = Variant (value);
|
||||||
|
|
||||||
|
else if (type == "int")
|
||||||
|
variant = Variant ((int) strtol (value.c_str (), NULL, 10));
|
||||||
|
|
||||||
|
else if (type == "number")
|
||||||
|
variant = Variant (strtod (value.c_str (), NULL));
|
||||||
|
|
||||||
|
else if (type == "rvalue" ||
|
||||||
|
type == "string" ||
|
||||||
|
type == "rx")
|
||||||
|
variant = Variant (unquoteText (value));
|
||||||
|
|
||||||
|
else
|
||||||
|
throw std::string ("Unrecognized operand '") + + "'.";
|
||||||
|
|
||||||
|
variant.raw (value);
|
||||||
|
variant.raw_type (type);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Convert: 1,3-5,00000000-0000-0000-0000-000000000000
|
// Convert: 1,3-5,00000000-0000-0000-0000-000000000000
|
||||||
//
|
//
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#include <Arguments.h>
|
#include <Arguments.h>
|
||||||
#include <Task.h>
|
#include <Task.h>
|
||||||
|
#include <Variant.h>
|
||||||
|
|
||||||
class Expression
|
class Expression
|
||||||
{
|
{
|
||||||
|
@ -51,6 +52,7 @@ private:
|
||||||
void expand_tokens ();
|
void expand_tokens ();
|
||||||
void postfix ();
|
void postfix ();
|
||||||
|
|
||||||
|
void create_variant (Variant&, const std::string&, const std::string&);
|
||||||
bool is_new_style ();
|
bool is_new_style ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
321
src/Variant.cpp
321
src/Variant.cpp
|
@ -32,15 +32,19 @@
|
||||||
#include <Variant.h>
|
#include <Variant.h>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Variant::Variant () :
|
Variant::Variant ()
|
||||||
mType (v_unknown)
|
: mType (v_unknown)
|
||||||
|
, mRaw ("")
|
||||||
|
, mRawType ("")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Variant::Variant (const Variant& other)
|
Variant::Variant (const Variant& other)
|
||||||
{
|
{
|
||||||
mType = other.mType;
|
mType = other.mType;
|
||||||
|
mRaw = other.mRaw;
|
||||||
|
mRawType = other.mRawType;
|
||||||
|
|
||||||
// Explicitly copy only the relevant type. This saves memory.
|
// Explicitly copy only the relevant type. This saves memory.
|
||||||
switch (mType)
|
switch (mType)
|
||||||
|
@ -98,188 +102,217 @@ Variant::Variant (const Duration& input)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Variant& Variant::operator&& (const Variant& other)
|
// For copying.
|
||||||
|
Variant& Variant::operator= (const Variant& other)
|
||||||
|
{
|
||||||
|
if (this != &other)
|
||||||
|
{
|
||||||
|
mType = other.mType;
|
||||||
|
mBool = other.mBool;
|
||||||
|
mInteger = other.mInteger;
|
||||||
|
mDouble = other.mDouble;
|
||||||
|
mString = other.mString;
|
||||||
|
mDate = other.mDate;
|
||||||
|
mDuration = other.mDuration;
|
||||||
|
mRaw = other.mRaw;
|
||||||
|
mRawType = other.mRawType;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool Variant::operator&& (Variant& other)
|
||||||
{
|
{
|
||||||
cast (v_boolean);
|
cast (v_boolean);
|
||||||
Variant copy (other);
|
other.cast (v_boolean);
|
||||||
copy.cast (v_boolean);
|
return mBool && other.mBool;
|
||||||
mBool = (mBool && copy.mBool) ? true : false;
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Variant& Variant::operator|| (const Variant& other)
|
bool Variant::operator|| (Variant& other)
|
||||||
{
|
{
|
||||||
cast (v_boolean);
|
cast (v_boolean);
|
||||||
Variant copy (other);
|
other.cast (v_boolean);
|
||||||
copy.cast (v_boolean);
|
return mBool || other.mBool;
|
||||||
mBool = (mBool || copy.mBool) ? true : false;
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Variant& Variant::operator<= (const Variant& other)
|
bool Variant::operator<= (Variant& other)
|
||||||
{
|
{
|
||||||
|
promote (*this, other);
|
||||||
|
bool result;
|
||||||
|
|
||||||
switch (mType)
|
switch (mType)
|
||||||
{
|
{
|
||||||
case v_boolean:
|
case v_boolean:
|
||||||
mBool = false; // TODO Makes no sense.
|
throw std::string ("Cannot perform relative comparison on bool types");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_integer:
|
case v_integer:
|
||||||
mBool = mInteger <= other.mInteger ? true : false;
|
result = mInteger <= other.mInteger ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_double:
|
case v_double:
|
||||||
mBool = mDouble <= other.mDouble ? true : false;
|
result = mDouble <= other.mDouble ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_string:
|
case v_string:
|
||||||
{
|
{
|
||||||
int collating = strcmp (mString.c_str (), other.mString.c_str ());
|
int collating = strcmp (mString.c_str (), other.mString.c_str ());
|
||||||
mBool = collating <= 0 ? true : false;
|
result = collating <= 0 ? true : false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_date:
|
case v_date:
|
||||||
mBool = mDate <= other.mDate ? true : false;
|
result = mDate <= other.mDate ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_duration:
|
case v_duration:
|
||||||
mBool = (time_t)mDuration <= (time_t)other.mDuration ? true : false;
|
result = (time_t)mDuration <= (time_t)other.mDuration ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_unknown:
|
case v_unknown:
|
||||||
|
throw std::string ("Cannot perform relative comparison on unknown types");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
mType = v_boolean;
|
return result;
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Variant& Variant::operator>= (const Variant& other)
|
bool Variant::operator>= (Variant& other)
|
||||||
{
|
{
|
||||||
|
promote (*this, other);
|
||||||
|
bool result;
|
||||||
|
|
||||||
switch (mType)
|
switch (mType)
|
||||||
{
|
{
|
||||||
case v_boolean:
|
case v_boolean:
|
||||||
mBool = false; // TODO Makes no sense.
|
throw std::string ("Cannot perform relative comparison on bool types");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_integer:
|
case v_integer:
|
||||||
mBool = mInteger >= other.mInteger ? true : false;
|
result = mInteger >= other.mInteger ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_double:
|
case v_double:
|
||||||
mBool = mDouble >= other.mDouble ? true : false;
|
result = mDouble >= other.mDouble ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_string:
|
case v_string:
|
||||||
{
|
{
|
||||||
int collating = strcmp (mString.c_str (), other.mString.c_str ());
|
int collating = strcmp (mString.c_str (), other.mString.c_str ());
|
||||||
mBool = collating >= 0 ? true : false;
|
result = collating >= 0 ? true : false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_date:
|
case v_date:
|
||||||
mBool = mDate >= other.mDate ? true : false;
|
result = mDate >= other.mDate ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_duration:
|
case v_duration:
|
||||||
mBool = (time_t)mDuration >= (time_t)other.mDuration ? true : false;
|
result = (time_t)mDuration >= (time_t)other.mDuration ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_unknown:
|
case v_unknown:
|
||||||
|
throw std::string ("Cannot perform relative comparison on unknown types");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
mType = v_boolean;
|
return result;
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Variant& Variant::operator== (const Variant& other)
|
bool Variant::operator== (Variant& other)
|
||||||
{
|
{
|
||||||
|
promote (*this, other);
|
||||||
|
bool result;
|
||||||
|
|
||||||
switch (mType)
|
switch (mType)
|
||||||
{
|
{
|
||||||
case v_boolean:
|
case v_boolean:
|
||||||
mBool = mBool == other.mBool ? true : false;
|
result = mBool == other.mBool ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_integer:
|
case v_integer:
|
||||||
mBool = mInteger == other.mInteger ? true : false;
|
result = mInteger == other.mInteger ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_double:
|
case v_double:
|
||||||
mBool = mDouble == other.mDouble ? true : false;
|
result = mDouble == other.mDouble ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_string:
|
case v_string:
|
||||||
{
|
{
|
||||||
int collating = strcmp (mString.c_str (), other.mString.c_str ());
|
int collating = strcmp (mString.c_str (), other.mString.c_str ());
|
||||||
mBool = collating == 0 ? true : false;
|
result = collating == 0 ? true : false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_date:
|
case v_date:
|
||||||
mBool = mDate == other.mDate ? true : false;
|
result = mDate == other.mDate ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_duration:
|
case v_duration:
|
||||||
mBool = mDuration == other.mDuration ? true : false;
|
result = mDuration == other.mDuration ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_unknown:
|
case v_unknown:
|
||||||
|
throw std::string ("Cannot perform relative comparison on unknown types");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
mType = v_boolean;
|
return result;
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Variant& Variant::operator!= (const Variant& other)
|
bool Variant::operator!= (Variant& other)
|
||||||
{
|
{
|
||||||
|
promote (*this, other);
|
||||||
|
bool result;
|
||||||
|
|
||||||
switch (mType)
|
switch (mType)
|
||||||
{
|
{
|
||||||
case v_boolean:
|
case v_boolean:
|
||||||
mBool = mBool != other.mBool ? true : false;
|
result = mBool != other.mBool ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_integer:
|
case v_integer:
|
||||||
mBool = mInteger != other.mInteger ? true : false;
|
result = mInteger != other.mInteger ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_double:
|
case v_double:
|
||||||
mBool = mDouble != other.mDouble ? true : false;
|
result = mDouble != other.mDouble ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_string:
|
case v_string:
|
||||||
{
|
{
|
||||||
int collating = strcmp (mString.c_str (), other.mString.c_str ());
|
int collating = strcmp (mString.c_str (), other.mString.c_str ());
|
||||||
mBool = collating != 0 ? true : false;
|
result = collating != 0 ? true : false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_date:
|
case v_date:
|
||||||
mBool = mDate != other.mDate ? true : false;
|
result = mDate != other.mDate ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_duration:
|
case v_duration:
|
||||||
mBool = mDuration != other.mDuration ? true : false;
|
result = mDuration != other.mDuration ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_unknown:
|
case v_unknown:
|
||||||
|
throw std::string ("Cannot perform relative comparison on unknown types");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
mType = v_boolean;
|
return result;
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Variant& Variant::operator^ (const Variant& other)
|
Variant& Variant::operator^ (Variant& other)
|
||||||
{
|
{
|
||||||
|
// TODO This is all wrong!
|
||||||
switch (mType)
|
switch (mType)
|
||||||
{
|
{
|
||||||
case v_boolean:
|
case v_boolean:
|
||||||
|
@ -307,6 +340,7 @@ Variant& Variant::operator^ (const Variant& other)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_unknown:
|
case v_unknown:
|
||||||
|
throw std::string ("Cannot perform exponentiation on unknown types");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,16 +348,18 @@ Variant& Variant::operator^ (const Variant& other)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Variant& Variant::operator! ()
|
bool Variant::operator! ()
|
||||||
{
|
{
|
||||||
cast (v_boolean);
|
cast (v_boolean);
|
||||||
mBool = ! mBool;
|
mBool = ! mBool;
|
||||||
return *this;
|
return mBool;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Variant& Variant::operator- (const Variant& other)
|
Variant& Variant::operator- (Variant& other)
|
||||||
{
|
{
|
||||||
|
promote (*this, other);
|
||||||
|
|
||||||
switch (mType)
|
switch (mType)
|
||||||
{
|
{
|
||||||
case v_boolean:
|
case v_boolean:
|
||||||
|
@ -352,6 +388,7 @@ Variant& Variant::operator- (const Variant& other)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_unknown:
|
case v_unknown:
|
||||||
|
throw std::string ("Cannot perform subtraction on unknown types");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,8 +396,10 @@ Variant& Variant::operator- (const Variant& other)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Variant& Variant::operator+ (const Variant& other)
|
Variant& Variant::operator+ (Variant& other)
|
||||||
{
|
{
|
||||||
|
promote (*this, other);
|
||||||
|
|
||||||
switch (mType)
|
switch (mType)
|
||||||
{
|
{
|
||||||
case v_boolean:
|
case v_boolean:
|
||||||
|
@ -390,6 +429,7 @@ Variant& Variant::operator+ (const Variant& other)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_unknown:
|
case v_unknown:
|
||||||
|
throw std::string ("Cannot perform addition on unknown types");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,8 +437,10 @@ Variant& Variant::operator+ (const Variant& other)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Variant& Variant::operator* (const Variant& other)
|
Variant& Variant::operator* (Variant& other)
|
||||||
{
|
{
|
||||||
|
promote (*this, other);
|
||||||
|
|
||||||
switch (mType)
|
switch (mType)
|
||||||
{
|
{
|
||||||
case v_boolean:
|
case v_boolean:
|
||||||
|
@ -426,6 +468,7 @@ Variant& Variant::operator* (const Variant& other)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_unknown:
|
case v_unknown:
|
||||||
|
throw std::string ("Cannot perform multiplication on unknown types");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,8 +476,10 @@ Variant& Variant::operator* (const Variant& other)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Variant& Variant::operator/ (const Variant& other)
|
Variant& Variant::operator/ (Variant& other)
|
||||||
{
|
{
|
||||||
|
promote (*this, other);
|
||||||
|
|
||||||
switch (mType)
|
switch (mType)
|
||||||
{
|
{
|
||||||
case v_boolean:
|
case v_boolean:
|
||||||
|
@ -462,6 +507,7 @@ Variant& Variant::operator/ (const Variant& other)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_unknown:
|
case v_unknown:
|
||||||
|
throw std::string ("Cannot perform division on unknown types");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,8 +515,11 @@ Variant& Variant::operator/ (const Variant& other)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Variant& Variant::operator< (const Variant& other)
|
bool Variant::operator< (Variant& other)
|
||||||
{
|
{
|
||||||
|
promote (*this, other);
|
||||||
|
bool result;
|
||||||
|
|
||||||
switch (mType)
|
switch (mType)
|
||||||
{
|
{
|
||||||
case v_boolean:
|
case v_boolean:
|
||||||
|
@ -478,39 +527,42 @@ Variant& Variant::operator< (const Variant& other)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_integer:
|
case v_integer:
|
||||||
mBool = mInteger < other.mInteger ? true : false;
|
result = mInteger < other.mInteger ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_double:
|
case v_double:
|
||||||
mBool = mDouble < other.mDouble ? true : false;
|
result = mDouble < other.mDouble ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_string:
|
case v_string:
|
||||||
{
|
{
|
||||||
int collating = strcmp (mString.c_str (), other.mString.c_str ());
|
int collating = strcmp (mString.c_str (), other.mString.c_str ());
|
||||||
mBool = collating < 0 ? true : false;
|
result = collating < 0 ? true : false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_date:
|
case v_date:
|
||||||
mBool = mDate < other.mDate ? true : false;
|
result = mDate < other.mDate ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_duration:
|
case v_duration:
|
||||||
mBool = mDuration < other.mDuration ? true : false;
|
result = mDuration < other.mDuration ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_unknown:
|
case v_unknown:
|
||||||
|
throw std::string ("Cannot perform relative comparisons on unknown types");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
mType = v_boolean;
|
return result;
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Variant& Variant::operator> (const Variant& other)
|
bool Variant::operator> (Variant& other)
|
||||||
{
|
{
|
||||||
|
promote (*this, other);
|
||||||
|
bool result;
|
||||||
|
|
||||||
switch (mType)
|
switch (mType)
|
||||||
{
|
{
|
||||||
case v_boolean:
|
case v_boolean:
|
||||||
|
@ -518,129 +570,34 @@ Variant& Variant::operator> (const Variant& other)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_integer:
|
case v_integer:
|
||||||
mBool = mInteger > other.mInteger ? true : false;
|
result = mInteger > other.mInteger ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_double:
|
case v_double:
|
||||||
mBool = mDouble > other.mDouble ? true : false;
|
result = mDouble > other.mDouble ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_string:
|
case v_string:
|
||||||
{
|
{
|
||||||
int collating = strcmp (mString.c_str (), other.mString.c_str ());
|
int collating = strcmp (mString.c_str (), other.mString.c_str ());
|
||||||
mBool = collating > 0 ? true : false;
|
result = collating > 0 ? true : false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_date:
|
case v_date:
|
||||||
mBool = mDate > other.mDate ? true : false;
|
result = mDate > other.mDate ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_duration:
|
case v_duration:
|
||||||
mBool = mDuration > other.mDuration ? true : false;
|
result = mDuration > other.mDuration ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_unknown:
|
case v_unknown:
|
||||||
|
throw std::string ("Cannot perform relative comparisons on unknown types");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
mType = v_boolean;
|
return result;
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void Variant::sqrt ()
|
|
||||||
{
|
|
||||||
cast (v_double);
|
|
||||||
if (mDouble < 0.0)
|
|
||||||
throw std::string ("Cannot take the square root of a negative number.");
|
|
||||||
mDouble = ::sqrt (mDouble);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void Variant::sin ()
|
|
||||||
{
|
|
||||||
cast (v_double);
|
|
||||||
mDouble = ::sin (mDouble);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void Variant::cos ()
|
|
||||||
{
|
|
||||||
cast (v_double);
|
|
||||||
mDouble = ::cos (mDouble);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void Variant::tan ()
|
|
||||||
{
|
|
||||||
cast (v_double);
|
|
||||||
mDouble = ::tan (mDouble);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void Variant::asin ()
|
|
||||||
{
|
|
||||||
cast (v_double);
|
|
||||||
mDouble = ::asin (mDouble);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void Variant::acos ()
|
|
||||||
{
|
|
||||||
cast (v_double);
|
|
||||||
mDouble = ::acos (mDouble);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void Variant::atan ()
|
|
||||||
{
|
|
||||||
cast (v_double);
|
|
||||||
mDouble = ::atan (mDouble);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void Variant::log ()
|
|
||||||
{
|
|
||||||
cast (v_double);
|
|
||||||
mDouble = ::log10 (mDouble);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void Variant::exp ()
|
|
||||||
{
|
|
||||||
cast (v_double);
|
|
||||||
mDouble = ::exp (mDouble);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void Variant::exp10 ()
|
|
||||||
{
|
|
||||||
cast (v_double);
|
|
||||||
mDouble = ::pow (10.0, mDouble);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void Variant::ln ()
|
|
||||||
{
|
|
||||||
cast (v_double);
|
|
||||||
mDouble = ::sqrt (mDouble);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void Variant::sign ()
|
|
||||||
{
|
|
||||||
cast (v_double);
|
|
||||||
if (mDouble == 0.0)
|
|
||||||
throw std::string ("Divide by zero.");
|
|
||||||
mDouble /= fabs (mDouble);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void Variant::abs ()
|
|
||||||
{
|
|
||||||
cast (v_double);
|
|
||||||
mDouble = ::fabs (mDouble);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -820,6 +777,30 @@ Variant::variant_type Variant::type ()
|
||||||
return mType;
|
return mType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void Variant::raw (const std::string& input)
|
||||||
|
{
|
||||||
|
mRaw = input;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
std::string Variant::raw ()
|
||||||
|
{
|
||||||
|
return mRaw;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void Variant::raw_type (const std::string& input)
|
||||||
|
{
|
||||||
|
mRawType = input;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
std::string Variant::raw_type ()
|
||||||
|
{
|
||||||
|
return mRawType;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Variant::promote (Variant& lhs, Variant& rhs)
|
void Variant::promote (Variant& lhs, Variant& rhs)
|
||||||
{
|
{
|
||||||
|
@ -861,3 +842,9 @@ bool Variant::boolean ()
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
std::string Variant::dump ()
|
||||||
|
{
|
||||||
|
return format () + "/" + raw () + "/" + raw_type ();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -55,42 +55,36 @@ public:
|
||||||
Variant (const std::string&);
|
Variant (const std::string&);
|
||||||
Variant (const Date&);
|
Variant (const Date&);
|
||||||
Variant (const Duration&);
|
Variant (const Duration&);
|
||||||
|
Variant& operator= (const Variant&);
|
||||||
|
|
||||||
Variant& operator&& (const Variant& other);
|
bool operator&& (Variant& other);
|
||||||
Variant& operator|| (const Variant& other);
|
bool operator|| (Variant& other);
|
||||||
Variant& operator<= (const Variant& other);
|
|
||||||
Variant& operator>= (const Variant& other);
|
|
||||||
Variant& operator== (const Variant& other);
|
|
||||||
Variant& operator!= (const Variant& other);
|
|
||||||
Variant& operator^ (const Variant& other);
|
|
||||||
Variant& operator! ();
|
|
||||||
Variant& operator- (const Variant& other);
|
|
||||||
Variant& operator+ (const Variant& other);
|
|
||||||
Variant& operator* (const Variant& other);
|
|
||||||
Variant& operator/ (const Variant& other);
|
|
||||||
Variant& operator< (const Variant& other);
|
|
||||||
Variant& operator> (const Variant& other);
|
|
||||||
|
|
||||||
void sqrt ();
|
bool operator<= (Variant& other);
|
||||||
void sin ();
|
bool operator>= (Variant& other);
|
||||||
void cos ();
|
bool operator== (Variant& other);
|
||||||
void tan ();
|
bool operator< (Variant& other);
|
||||||
void asin ();
|
bool operator> (Variant& other);
|
||||||
void acos ();
|
bool operator!= (Variant& other);
|
||||||
void atan ();
|
bool operator! ();
|
||||||
void log ();
|
|
||||||
void exp ();
|
Variant& operator^ (Variant& other);
|
||||||
void exp10 ();
|
Variant& operator- (Variant& other);
|
||||||
void ln ();
|
Variant& operator+ (Variant& other);
|
||||||
void sign ();
|
Variant& operator* (Variant& other);
|
||||||
void abs ();
|
Variant& operator/ (Variant& other);
|
||||||
|
|
||||||
void input (const std::string&);
|
void input (const std::string&);
|
||||||
std::string format ();
|
std::string format ();
|
||||||
void cast (const variant_type);
|
void cast (const variant_type);
|
||||||
variant_type type ();
|
variant_type type ();
|
||||||
|
void raw (const std::string&);
|
||||||
|
std::string raw ();
|
||||||
|
void raw_type (const std::string&);
|
||||||
|
std::string raw_type ();
|
||||||
void promote (Variant&, Variant&);
|
void promote (Variant&, Variant&);
|
||||||
bool boolean ();
|
bool boolean ();
|
||||||
|
std::string dump ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
variant_type mType;
|
variant_type mType;
|
||||||
|
@ -101,6 +95,9 @@ private:
|
||||||
std::string mString;
|
std::string mString;
|
||||||
Date mDate;
|
Date mDate;
|
||||||
Duration mDuration;
|
Duration mDuration;
|
||||||
|
|
||||||
|
std::string mRaw;
|
||||||
|
std::string mRawType;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue