1#ifndef SQL_JSON_PATH_INCLUDED
2#define SQL_JSON_PATH_INCLUDED
118 :
m_index(from_end ? (index < array_length ? array_length - index - 1 : 0)
119 :
std::min(index, array_length)),
372 for (
const auto ptr :
m_path_legs) ptr->~Json_path_leg();
397 other.m_path_legs.clear();
402 if (&other !=
this) {
424 for (
const auto ptr :
m_path_legs) ptr->~Json_path_leg();
483bool 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:97
size_t m_index
The array index.
Definition: json_path.h:103
size_t position() const
Get the position in the array pointed to by this array index.
Definition: json_path.h:140
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:117
bool m_within_bounds
True if the array index is within the bounds of the array.
Definition: json_path.h:106
bool within_bounds() const
Is the array index within the bounds of the array?
Definition: json_path.h:128
A lightweight path expression.
Definition: json_path.h:450
bool append(const Json_path_leg *leg)
Add a path leg to the end of this cloned path.
Definition: json_path.h:458
void clear()
Resets this to an empty path with no legs.
Definition: json_path.h:463
Json_path_clone(PSI_memory_key key)
Definition: json_path.h:452
One path leg in a JSON path expression.
Definition: json_path.h:149
size_t m_first_array_index
The index of an array cell, or the start of an array range.
Definition: json_path.h:154
size_t m_last_array_index
The end (inclusive) of an array range.
Definition: json_path.h:160
Json_path_leg(enum_json_path_leg_type leg_type)
Construct a wildcard or ellipsis path leg.
Definition: json_path.h:175
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:260
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:163
std::string m_member_name
The member name of a member path leg.
Definition: json_path.h:166
enum_json_path_leg_type m_leg_type
The type of this path leg.
Definition: json_path.h:151
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:157
Json_path_leg(const char *member_name, size_t length)
Construct an object member path leg.
Definition: json_path.h:224
Json_path_leg(size_t index)
Construct an array cell path leg.
Definition: json_path.h:187
Json_path_leg(const std::string &member_name)
Construct an object member path leg.
Definition: json_path.h:228
Json_path_leg(size_t index, bool from_end)
Construct an array cell path leg.
Definition: json_path.h:195
enum_json_path_leg_type get_type() const
Get the type of the path leg.
Definition: json_path.h:232
const std::string & get_member_name() const
Get the member name of a jpl_member path leg.
Definition: json_path.h:235
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:210
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:272
A JSON path expression.
Definition: json_path.h:356
Json_path(Json_path &&other)
Move constructor.
Definition: json_path.h:376
~Json_path()
Definition: json_path.h:371
Json_path(PSI_memory_key key)
Definition: json_path.cc:167
bool append(const Json_path_leg &leg)
Add a path leg to the end of this path.
Definition: json_path.h:414
void clear()
Resets this to an empty path with no legs.
Definition: json_path.h:422
bool to_string(String *buf) const
Turn into a human-readable string.
Definition: json_path.cc:170
PSI_memory_key m_psi_key
Key used to instrument memory usage.
Definition: json_path.h:366
Json_path & operator=(Json_path &&other)
Move assignment.
Definition: json_path.h:401
bool can_match_many() const
Return true if the path can match more than one value in a JSON document.
Definition: json_path.cc:180
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:362
A path expression which can be used to seek to a position inside a JSON value.
Definition: json_path.h:301
Json_path_iterator end() const
Get an iterator pointing just past the last path leg.
Definition: json_path.h:316
Json_seekable_path(PSI_memory_key key)
Definition: json_path.cc:164
size_t leg_count() const
Return the number of legs in this searchable path.
Definition: json_path.h:310
const Json_path_leg * last_leg() const
Get a pointer to the last path leg.
Definition: json_path.h:319
Json_path_iterator begin() const
Get an iterator pointing to the first path leg.
Definition: json_path.h:313
Json_path_leg_pointers m_path_legs
An array of pointers to the legs of the JSON path.
Definition: json_path.h:304
bool push_back(const Element_type &element)
Copies an element into the back of the array.
Definition: prealloced_array.h:317
void clear()
Removes (and destroys) all elements.
Definition: prealloced_array.h:600
size_t size() const
Definition: prealloced_array.h:226
iterator begin()
begin : Returns a pointer to the first element in the array.
Definition: prealloced_array.h:253
Element_type & back()
Definition: prealloced_array.h:243
iterator end()
Definition: prealloced_array.h:254
const const Json_path_leg * * const_iterator
Definition: prealloced_array.h:116
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:166
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:48
std::function< void()> JsonDocumentDepthHandler
Definition: json_error_handler.h:31
enum_json_path_leg_type
The type of a Json_path_leg.
Definition: json_path.h:52
@ jpl_array_range
A path leg that represents a range in a JSON array (such as [2 to 7]).
Definition: json_path.h:69
@ 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:83
@ jpl_ellipsis
A path leg that represents the ellipsis (**), which matches any JSON value and recursively all the JS...
Definition: json_path.h:90
@ jpl_member
A path leg that represents a JSON object member (such as .name).
Definition: json_path.h:57
@ jpl_array_cell
A path leg that represents a JSON array cell (such as [10]).
Definition: json_path.h:63
@ jpl_member_wildcard
A path leg that represents the member wildcard.
Definition: json_path.h:77
bool parse_path(size_t path_length, const char *path_expression, Json_path *path, size_t *bad_index, const JsonDocumentDepthHandler &depth_handler)
Initialize a Json_path from a path expression.
Definition: json_path.cc:257
Json_path_leg_pointers::const_iterator Json_path_iterator
Definition: json_path.h:295
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
Some integer typedefs for easier portability.
Common header for many mysys elements.
static char * path
Definition: mysqldump.cc:133
Definition: buf0block_hint.cc:29
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:75
Definition: varlen_sort.h:183
required string key
Definition: replication_asynchronous_connection_failover.proto:59
A structure that represents an array range.
Definition: json_path.h:281
size_t m_end
End of the range, exclusive.
Definition: json_path.h:283
size_t m_begin
Beginning of the range, inclusive.
Definition: json_path.h:282
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:82
void ClearForReuse()
Similar to Clear(), but anticipates that the block will be reused for further allocations.
Definition: my_alloc.cc:186