1#ifndef SQL_JSON_PATH_INCLUDED
2#define SQL_JSON_PATH_INCLUDED
119 :
m_index(from_end ? (index < array_length ? array_length - index - 1 : 0)
120 :
std::min(index, array_length)),
373 for (
const auto ptr :
m_path_legs) ptr->~Json_path_leg();
398 other.m_path_legs.clear();
403 if (&other !=
this) {
425 for (
const auto ptr :
m_path_legs) ptr->~Json_path_leg();
484bool 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:98
size_t m_index
The array index.
Definition: json_path.h:104
size_t position() const
Get the position in the array pointed to by this array index.
Definition: json_path.h:141
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:118
bool m_within_bounds
True if the array index is within the bounds of the array.
Definition: json_path.h:107
bool within_bounds() const
Is the array index within the bounds of the array?
Definition: json_path.h:129
A lightweight path expression.
Definition: json_path.h:451
bool append(const Json_path_leg *leg)
Add a path leg to the end of this cloned path.
Definition: json_path.h:459
void clear()
Resets this to an empty path with no legs.
Definition: json_path.h:464
Json_path_clone(PSI_memory_key key)
Definition: json_path.h:453
One path leg in a JSON path expression.
Definition: json_path.h:150
size_t m_first_array_index
The index of an array cell, or the start of an array range.
Definition: json_path.h:155
size_t m_last_array_index
The end (inclusive) of an array range.
Definition: json_path.h:161
Json_path_leg(enum_json_path_leg_type leg_type)
Construct a wildcard or ellipsis path leg.
Definition: json_path.h:176
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:261
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:149
bool m_last_array_index_from_end
Is m_last_array_index relative to the end of the array?
Definition: json_path.h:164
std::string m_member_name
The member name of a member path leg.
Definition: json_path.h:167
enum_json_path_leg_type m_leg_type
The type of this path leg.
Definition: json_path.h:152
bool is_autowrap() const
Is this path leg an auto-wrapping array accessor?
Definition: json_path.cc:126
bool m_first_array_index_from_end
Is m_first_array_index relative to the end of the array?
Definition: json_path.h:158
Json_path_leg(const char *member_name, size_t length)
Construct an object member path leg.
Definition: json_path.h:225
Json_path_leg(size_t index)
Construct an array cell path leg.
Definition: json_path.h:188
Json_path_leg(const std::string &member_name)
Construct an object member path leg.
Definition: json_path.h:229
Json_path_leg(size_t index, bool from_end)
Construct an array cell path leg.
Definition: json_path.h:196
enum_json_path_leg_type get_type() const
Get the type of the path leg.
Definition: json_path.h:233
const std::string & get_member_name() const
Get the member name of a jpl_member path leg.
Definition: json_path.h:236
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:211
bool to_string(String *buf) const
Turn into a human-readable string.
Definition: json_path.cc:91
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:273
A JSON path expression.
Definition: json_path.h:357
Json_path(Json_path &&other)
Move constructor.
Definition: json_path.h:377
~Json_path()
Definition: json_path.h:372
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:415
void clear()
Resets this to an empty path with no legs.
Definition: json_path.h:423
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:367
Json_path & operator=(Json_path &&other)
Move assignment.
Definition: json_path.h:402
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:363
A path expression which can be used to seek to a position inside a JSON value.
Definition: json_path.h:302
Json_path_iterator end() const
Get an iterator pointing just past the last path leg.
Definition: json_path.h:317
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:311
const Json_path_leg * last_leg() const
Get a pointer to the last path leg.
Definition: json_path.h:320
Json_path_iterator begin() const
Get an iterator pointing to the first path leg.
Definition: json_path.h:314
Json_path_leg_pointers m_path_legs
An array of pointers to the legs of the JSON path.
Definition: json_path.h:305
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:168
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:49
std::function< void()> JsonDocumentDepthHandler
Definition: json_error_handler.h:32
enum_json_path_leg_type
The type of a Json_path_leg.
Definition: json_path.h:53
@ jpl_array_range
A path leg that represents a range in a JSON array (such as [2 to 7]).
Definition: json_path.h:70
@ 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:84
@ jpl_ellipsis
A path leg that represents the ellipsis (**), which matches any JSON value and recursively all the JS...
Definition: json_path.h:91
@ jpl_member
A path leg that represents a JSON object member (such as .name).
Definition: json_path.h:58
@ jpl_array_cell
A path leg that represents a JSON array cell (such as [10]).
Definition: json_path.h:64
@ jpl_member_wildcard
A path leg that represents the member wildcard.
Definition: json_path.h:78
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:258
Json_path_leg_pointers::const_iterator Json_path_iterator
Definition: json_path.h:296
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:137
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
required string key
Definition: replication_asynchronous_connection_failover.proto:60
A structure that represents an array range.
Definition: json_path.h:282
size_t m_end
End of the range, exclusive.
Definition: json_path.h:284
size_t m_begin
Beginning of the range, inclusive.
Definition: json_path.h:283
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:189