1#ifndef SQL_JSON_PATH_INCLUDED
2#define SQL_JSON_PATH_INCLUDED
115 :
m_index(from_end ? (index < array_length ? array_length - index - 1 : 0)
116 :
std::min(index, array_length)),
369 for (
const auto ptr :
m_path_legs) ptr->~Json_path_leg();
394 other.m_path_legs.clear();
399 if (&other !=
this) {
421 for (
const auto ptr :
m_path_legs) ptr->~Json_path_leg();
478bool 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:94
size_t m_index
The array index.
Definition: json_path.h:100
size_t position() const
Get the position in the array pointed to by this array index.
Definition: json_path.h:137
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:114
bool m_within_bounds
True if the array index is within the bounds of the array.
Definition: json_path.h:103
bool within_bounds() const
Is the array index within the bounds of the array?
Definition: json_path.h:125
A lightweight path expression.
Definition: json_path.h:447
bool append(const Json_path_leg *leg)
Add a path leg to the end of this cloned path.
Definition: json_path.h:455
void clear()
Resets this to an empty path with no legs.
Definition: json_path.h:460
Json_path_clone(PSI_memory_key key)
Definition: json_path.h:449
One path leg in a JSON path expression.
Definition: json_path.h:146
size_t m_first_array_index
The index of an array cell, or the start of an array range.
Definition: json_path.h:151
size_t m_last_array_index
The end (inclusive) of an array range.
Definition: json_path.h:157
Json_path_leg(enum_json_path_leg_type leg_type)
Construct a wildcard or ellipsis path leg.
Definition: json_path.h:172
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:257
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:160
std::string m_member_name
The member name of a member path leg.
Definition: json_path.h:163
enum_json_path_leg_type m_leg_type
The type of this path leg.
Definition: json_path.h:148
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:154
Json_path_leg(const char *member_name, size_t length)
Construct an object member path leg.
Definition: json_path.h:221
Json_path_leg(size_t index)
Construct an array cell path leg.
Definition: json_path.h:184
Json_path_leg(const std::string &member_name)
Construct an object member path leg.
Definition: json_path.h:225
Json_path_leg(size_t index, bool from_end)
Construct an array cell path leg.
Definition: json_path.h:192
enum_json_path_leg_type get_type() const
Get the type of the path leg.
Definition: json_path.h:229
const std::string & get_member_name() const
Get the member name of a jpl_member path leg.
Definition: json_path.h:232
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:207
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:269
A JSON path expression.
Definition: json_path.h:353
Json_path(Json_path &&other)
Move constructor.
Definition: json_path.h:373
~Json_path()
Definition: json_path.h:368
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:411
void clear()
Resets this to an empty path with no legs.
Definition: json_path.h:419
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:363
Json_path & operator=(Json_path &&other)
Move assignment.
Definition: json_path.h:398
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:359
A path expression which can be used to seek to a position inside a JSON value.
Definition: json_path.h:298
Json_path_iterator end() const
Get an iterator pointing just past the last path leg.
Definition: json_path.h:313
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:307
const Json_path_leg * last_leg() const
Get a pointer to the last path leg.
Definition: json_path.h:316
Json_path_iterator begin() const
Get an iterator pointing to the first path leg.
Definition: json_path.h:310
Json_path_leg_pointers m_path_legs
An array of pointers to the legs of the JSON path.
Definition: json_path.h:301
bool push_back(const Element_type &element)
Copies an element into the back of the array.
Definition: prealloced_array.h:318
void clear()
Removes (and destroys) all elements.
Definition: prealloced_array.h:601
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
enum_json_path_leg_type
The type of a Json_path_leg.
Definition: json_path.h:49
@ jpl_array_range
A path leg that represents a range in a JSON array (such as [2 to 7]).
Definition: json_path.h:66
@ 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:80
@ jpl_ellipsis
A path leg that represents the ellipsis (**), which matches any JSON value and recursively all the JS...
Definition: json_path.h:87
@ jpl_member
A path leg that represents a JSON object member (such as .name).
Definition: json_path.h:54
@ jpl_array_cell
A path leg that represents a JSON array cell (such as [10]).
Definition: json_path.h:60
@ jpl_member_wildcard
A path leg that represents the member wildcard.
Definition: json_path.h:74
Json_path_leg_pointers::const_iterator Json_path_iterator
Definition: json_path.h:292
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
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
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:278
size_t m_end
End of the range, exclusive.
Definition: json_path.h:280
size_t m_begin
Beginning of the range, inclusive.
Definition: json_path.h:279
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