1#ifndef SQL_JSON_PATH_INCLUDED
2#define SQL_JSON_PATH_INCLUDED
117 :
m_index(from_end ? (index < array_length ? array_length - index - 1 : 0)
118 :
std::min(index, array_length)),
366 for (
const auto ptr :
m_path_legs) ptr->~Json_path_leg();
391 other.m_path_legs.clear();
396 if (&other !=
this) {
418 for (
const auto ptr :
m_path_legs) ptr->~Json_path_leg();
475bool parse_path(
size_t path_length,
const char *path_expression,
A class that represents the index of an element in a JSON array.
Definition: json_path.h:96
size_t m_index
The array index.
Definition: json_path.h:102
size_t position() const
Get the position in the array pointed to by this array index.
Definition: json_path.h:139
Json_array_index(size_t index, bool from_end, size_t array_length)
Construct a new Json_array_index object representing the specified position in an array of the given ...
Definition: json_path.h:116
bool m_within_bounds
True if the array index is within the bounds of the array.
Definition: json_path.h:105
bool within_bounds() const
Is the array index within the bounds of the array?
Definition: json_path.h:127
A lightweight path expression.
Definition: json_path.h:444
bool append(const Json_path_leg *leg)
Add a path leg to the end of this cloned path.
Definition: json_path.h:452
void clear()
Resets this to an empty path with no legs.
Definition: json_path.h:457
Json_path_clone(PSI_memory_key key)
Definition: json_path.h:446
One path leg in a JSON path expression.
Definition: json_path.h:148
size_t m_first_array_index
The index of an array cell, or the start of an array range.
Definition: json_path.h:153
size_t m_last_array_index
The end (inclusive) of an array range.
Definition: json_path.h:159
Json_path_leg(enum_json_path_leg_type leg_type)
Construct a wildcard or ellipsis path leg.
Definition: json_path.h:174
Json_array_index first_array_index(size_t array_length) const
Get the first array cell pointed to by an array range, or the array cell pointed to by an array cell ...
Definition: json_path.h:254
Array_range get_array_range(size_t array_length) const
Get the array range pointed to by a path leg of type jpl_array_range or jpl_array_cell_wildcard.
Definition: json_path.cc:148
bool m_last_array_index_from_end
Is m_last_array_index relative to the end of the array?
Definition: json_path.h:162
std::string m_member_name
The member name of a member path leg.
Definition: json_path.h:165
enum_json_path_leg_type m_leg_type
The type of this path leg.
Definition: json_path.h:150
bool is_autowrap() const
Is this path leg an auto-wrapping array accessor?
Definition: json_path.cc:125
bool m_first_array_index_from_end
Is m_first_array_index relative to the end of the array?
Definition: json_path.h:156
Json_path_leg(std::string_view member_name)
Construct an object member path leg.
Definition: json_path.h:222
Json_path_leg(size_t index)
Construct an array cell path leg.
Definition: json_path.h:186
Json_path_leg(size_t index, bool from_end)
Construct an array cell path leg.
Definition: json_path.h:194
enum_json_path_leg_type get_type() const
Get the type of the path leg.
Definition: json_path.h:226
const std::string & get_member_name() const
Get the member name of a jpl_member path leg.
Definition: json_path.h:229
Json_path_leg(size_t idx1, bool idx1_from_end, size_t idx2, bool idx2_from_end)
Construct an array range path leg.
Definition: json_path.h:209
bool to_string(String *buf) const
Turn into a human-readable string.
Definition: json_path.cc:90
Json_array_index last_array_index(size_t array_length) const
Get the last array cell pointed to by an array range.
Definition: json_path.h:266
A JSON path expression.
Definition: json_path.h:350
Json_path(Json_path &&other)
Move constructor.
Definition: json_path.h:370
~Json_path()
Definition: json_path.h:365
Json_path(PSI_memory_key key)
Definition: json_path.cc:168
bool append(const Json_path_leg &leg)
Add a path leg to the end of this path.
Definition: json_path.h:408
void clear()
Resets this to an empty path with no legs.
Definition: json_path.h:416
bool to_string(String *buf) const
Turn into a human-readable string.
Definition: json_path.cc:171
PSI_memory_key m_psi_key
Key used to instrument memory usage.
Definition: json_path.h:360
Json_path & operator=(Json_path &&other)
Move assignment.
Definition: json_path.h:395
bool can_match_many() const
Return true if the path can match more than one value in a JSON document.
Definition: json_path.cc:181
MEM_ROOT m_mem_root
A MEM_ROOT in which the Json_path_leg objects pointed to by Json_seekable_path::m_path_legs are alloc...
Definition: json_path.h:356
A path expression which can be used to seek to a position inside a JSON value.
Definition: json_path.h:295
Json_path_iterator end() const
Get an iterator pointing just past the last path leg.
Definition: json_path.h:310
Json_seekable_path(PSI_memory_key key)
Definition: json_path.cc:165
size_t leg_count() const
Return the number of legs in this searchable path.
Definition: json_path.h:304
const Json_path_leg * last_leg() const
Get a pointer to the last path leg.
Definition: json_path.h:313
Json_path_iterator begin() const
Get an iterator pointing to the first path leg.
Definition: json_path.h:307
Json_path_leg_pointers m_path_legs
An array of pointers to the legs of the JSON path.
Definition: json_path.h:298
Abstraction for accessing JSON values irrespective of whether they are (started out as) binary JSON v...
Definition: json_dom.h:1150
bool push_back(const Element_type &element)
Copies an element into the back of the array.
Definition: prealloced_array.h:327
void clear()
Removes (and destroys) all elements.
Definition: prealloced_array.h:610
size_t size() const
Definition: prealloced_array.h:227
iterator begin()
begin : Returns a pointer to the first element in the array.
Definition: prealloced_array.h:254
Element_type & back()
Definition: prealloced_array.h:244
iterator end()
Definition: prealloced_array.h:255
const const Json_path_leg * * const_iterator
Definition: prealloced_array.h:117
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:167
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:49
bool clone_without_autowrapping(const Json_path *source_path, Json_path_clone *target_path, Json_wrapper *doc, PSI_memory_key key)
Clone a source path to a target path, stripping out legs which are made redundant by the auto-wrappin...
Definition: json_path.cc:775
enum_json_path_leg_type
The type of a Json_path_leg.
Definition: json_path.h:51
@ jpl_array_range
A path leg that represents a range in a JSON array (such as [2 to 7]).
Definition: json_path.h:68
@ jpl_array_cell_wildcard
A path leg that represents the array wildcard ([*]), which matches all the elements of a JSON array.
Definition: json_path.h:82
@ jpl_ellipsis
A path leg that represents the ellipsis (**), which matches any JSON value and recursively all the JS...
Definition: json_path.h:89
@ jpl_member
A path leg that represents a JSON object member (such as .name).
Definition: json_path.h:56
@ jpl_array_cell
A path leg that represents a JSON array cell (such as [10]).
Definition: json_path.h:62
@ jpl_member_wildcard
A path leg that represents the member wildcard.
Definition: json_path.h:76
Json_path_leg_pointers::const_iterator Json_path_iterator
Definition: json_path.h:289
bool parse_path(size_t path_length, const char *path_expression, Json_path *path, size_t *bad_index)
Initialize a Json_path from a path expression.
Definition: json_path.cc:258
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
static char * path
Definition: mysqldump.cc:149
Definition: buf0block_hint.cc:30
Definition: gcs_xcom_synode.h:64
Performance schema instrumentation interface.
required string key
Definition: replication_asynchronous_connection_failover.proto:60
A structure that represents an array range.
Definition: json_path.h:275
size_t m_end
End of the range, exclusive.
Definition: json_path.h:277
size_t m_begin
Beginning of the range, inclusive.
Definition: json_path.h:276
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
void ClearForReuse()
Similar to Clear(), but anticipates that the block will be reused for further allocations.
Definition: my_alloc.cc:190