Add json_pointer::parent_pointer (cf. std::filesystem::path::parent_path)

This commit is contained in:
garethsb-sony 2019-02-25 09:10:45 +00:00 committed by gbsylveg
parent 164e0e54d9
commit 08de9eeaca
2 changed files with 30 additions and 0 deletions

View File

@ -122,6 +122,21 @@ class json_pointer
return json_pointer(lhs) /= array_index; return json_pointer(lhs) /= array_index;
} }
/*!
@brief create a new JSON pointer that is the parent of this JSON pointer
*/
json_pointer parent_pointer() const
{
if (empty())
{
return *this;
}
json_pointer res = *this;
res.pop_back();
return res;
}
/*! /*!
@param[in] s reference token to be converted into an array index @param[in] s reference token to be converted into an array index

View File

@ -11932,6 +11932,21 @@ class json_pointer
return json_pointer(lhs) /= array_index; return json_pointer(lhs) /= array_index;
} }
/*!
@brief create a new JSON pointer that is the parent of this JSON pointer
*/
json_pointer parent_pointer() const
{
if (empty())
{
return *this;
}
json_pointer res = *this;
res.pop_back();
return res;
}
/*! /*!
@param[in] s reference token to be converted into an array index @param[in] s reference token to be converted into an array index