Skip to content

Commit

Permalink
tidy code
Browse files Browse the repository at this point in the history
  • Loading branch information
danielaparker committed Dec 29, 2024
1 parent 14f308c commit efdb8d6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 74 deletions.
38 changes: 9 additions & 29 deletions include/jsoncons_ext/jmespath/jmespath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ namespace jmespath {
int64_t step_;

slice()
: start_(), stop_(), step_(1)
: step_(1)
{
}

Expand All @@ -668,35 +668,15 @@ namespace jmespath {
{
}

slice(const slice& other)
: start_(other.start_), stop_(other.stop_), step_(other.step_)
{
}
slice(const slice& other) = default;

slice& operator=(const slice& rhs)
{
if (this != &rhs)
{
if (rhs.start_)
{
start_ = rhs.start_;
}
else
{
start_.reset();
}
if (rhs.stop_)
{
stop_ = rhs.stop_;
}
else
{
stop_.reset();
}
step_ = rhs.step_;
}
return *this;
}
slice(slice&& other) = default;

slice& operator=(const slice& other) = default;

slice& operator=(slice&& other) = default;

~slice() = default;

int64_t get_start(std::size_t size) const
{
Expand Down
2 changes: 2 additions & 0 deletions include/jsoncons_ext/jsonpath/json_location.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,9 @@ namespace jsonpath {
break;
case '\r':
if ((p_+1 < end_input_) && (*(p_+1) == '\n'))
{
++p_;
}
++line_;
column_ = 1;
++p_;
Expand Down
58 changes: 13 additions & 45 deletions include/jsoncons_ext/jsonpath/jsonpath_selector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace detail {
int64_t step_;

slice()
: start_(), stop_(), step_(1)
: step_(1)
{
}

Expand All @@ -39,35 +39,15 @@ namespace detail {
{
}

slice(const slice& other)
: start_(other.start_), stop_(other.stop_), step_(other.step_)
{
}
slice(const slice& other) = default;

slice& operator=(const slice& rhs)
{
if (this != &rhs)
{
if (rhs.start_)
{
start_ = rhs.start_;
}
else
{
start_.reset();
}
if (rhs.stop_)
{
stop_ = rhs.stop_;
}
else
{
stop_.reset();
}
step_ = rhs.step_;
}
return *this;
}
slice(slice&& other) = default;

slice& operator=(const slice& other) = default;

slice& operator=(slice&& other) = default;

~slice() = default;

int64_t get_start(std::size_t size) const
{
Expand Down Expand Up @@ -96,10 +76,7 @@ namespace detail {
auto len = *stop_ >= 0 ? *stop_ : (static_cast<int64_t>(size) + *stop_);
return len <= static_cast<int64_t>(size) ? len : static_cast<int64_t>(size);
}
else
{
return step_ >= 0 ? static_cast<int64_t>(size) : -1;
}
return step_ >= 0 ? static_cast<int64_t>(size) : -1;
}

int64_t step() const
Expand Down Expand Up @@ -148,10 +125,7 @@ namespace detail {
{
return *context.create_path_node(&last, index);
}
else
{
return last;
}
return last;
}

static const path_node_type& generate(eval_context<Json,JsonReference>& context,
Expand All @@ -164,10 +138,7 @@ namespace detail {
{
return *context.create_path_node(&last, identifier);
}
else
{
return last;
}
return last;
}
};

Expand Down Expand Up @@ -238,10 +209,7 @@ namespace detail {
{
return current;
}
else
{
return tail_->evaluate(context, root, last, current, options, ec);
}
return tail_->evaluate(context, root, last, current, options, ec);
}

std::string to_string(int level = 0) const override
Expand Down

0 comments on commit efdb8d6

Please sign in to comment.