Skip to content

Commit

Permalink
Revert jmespath change
Browse files Browse the repository at this point in the history
  • Loading branch information
danielaparker committed Dec 9, 2024
1 parent dbff968 commit 1347fd3
Showing 1 changed file with 83 additions and 81 deletions.
164 changes: 83 additions & 81 deletions include/jsoncons_ext/jmespath/jmespath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,87 +23,6 @@
namespace jsoncons {
namespace jmespath {

enum class parameter_kind{value, expression};

class parameter
{
parameter_kind type_;

union
{
expression_base* expression_;
pointer value_;
};

public:

parameter(const parameter& other) noexcept
: type_(other.type_)
{
switch (type_)
{
case parameter_kind::expression:
expression_ = other.expression_;
break;
case parameter_kind::value:
value_ = other.value_;
break;
default:
break;
}
}

parameter(reference value) noexcept
: type_(parameter_kind::value), value_(std::addressof(value))
{
}

parameter(expression_base* expression) noexcept
: type_(parameter_kind::expression), expression_(expression)
{
}

parameter& operator=(const parameter& other)
{
if (&other != this)
{
type_ = other.type_;
switch (type_)
{
case parameter_kind::expression:
expression_ = other.expression_;
break;
case parameter_kind::value:
value_ = other.value_;
break;
default:
break;
}
}
return *this;
}

bool is_value() const
{
return type_ == parameter_kind::value;
}

bool is_expression() const
{
return type_ == parameter_kind::expression;
}

const Json& value() const
{
return *value_;
}

const expression_base& expression() const
{
return *expression_;
}
};

enum class operator_kind
{
default_op, // Identifier, CurrentNode, Index, MultiSelectList, MultiSelectHash, FunctionExpression
Expand Down Expand Up @@ -683,6 +602,89 @@ namespace jmespath {
}
};

// parameter

enum class parameter_kind{value, expression};

class parameter
{
parameter_kind type_;

union
{
expression_base* expression_;
pointer value_;
};

public:

parameter(const parameter& other) noexcept
: type_(other.type_)
{
switch (type_)
{
case parameter_kind::expression:
expression_ = other.expression_;
break;
case parameter_kind::value:
value_ = other.value_;
break;
default:
break;
}
}

parameter(reference value) noexcept
: type_(parameter_kind::value), value_(std::addressof(value))
{
}

parameter(expression_base* expression) noexcept
: type_(parameter_kind::expression), expression_(expression)
{
}

parameter& operator=(const parameter& other)
{
if (&other != this)
{
type_ = other.type_;
switch (type_)
{
case parameter_kind::expression:
expression_ = other.expression_;
break;
case parameter_kind::value:
value_ = other.value_;
break;
default:
break;
}
}
return *this;
}

bool is_value() const
{
return type_ == parameter_kind::value;
}

bool is_expression() const
{
return type_ == parameter_kind::expression;
}

const Json& value() const
{
return *value_;
}

const expression_base& expression() const
{
return *expression_;
}
};

// function_base
class function_base
{
Expand Down

0 comments on commit 1347fd3

Please sign in to comment.