MySQL 9.1.0
Source Code Documentation
Json_path_leg Class Referencefinal

One path leg in a JSON path expression. More...

#include <json_path.h>

Classes

struct  Array_range
 A structure that represents an array range. More...
 

Public Member Functions

 Json_path_leg (enum_json_path_leg_type leg_type)
 Construct a wildcard or ellipsis path leg. More...
 
 Json_path_leg (size_t index)
 Construct an array cell path leg. More...
 
 Json_path_leg (size_t index, bool from_end)
 Construct an array cell path leg. More...
 
 Json_path_leg (size_t idx1, bool idx1_from_end, size_t idx2, bool idx2_from_end)
 Construct an array range path leg. More...
 
 Json_path_leg (std::string_view member_name)
 Construct an object member path leg. More...
 
enum_json_path_leg_type get_type () const
 Get the type of the path leg. More...
 
const std::string & get_member_name () const
 Get the member name of a jpl_member path leg. More...
 
bool to_string (String *buf) const
 Turn into a human-readable string. More...
 
bool is_autowrap () const
 Is this path leg an auto-wrapping array accessor? More...
 
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 index. More...
 
Json_array_index last_array_index (size_t array_length) const
 Get the last array cell pointed to by an array range. More...
 
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. More...
 

Private Attributes

enum_json_path_leg_type m_leg_type
 The type of this path leg. More...
 
size_t m_first_array_index = 0
 The index of an array cell, or the start of an array range. More...
 
bool m_first_array_index_from_end = false
 Is m_first_array_index relative to the end of the array? More...
 
size_t m_last_array_index = 0
 The end (inclusive) of an array range. More...
 
bool m_last_array_index_from_end = false
 Is m_last_array_index relative to the end of the array? More...
 
std::string m_member_name
 The member name of a member path leg. More...
 

Detailed Description

One path leg in a JSON path expression.

A path leg describes either a key/value pair in an object or a 0-based index into an array.

Constructor & Destructor Documentation

◆ Json_path_leg() [1/5]

Json_path_leg::Json_path_leg ( enum_json_path_leg_type  leg_type)
inlineexplicit

Construct a wildcard or ellipsis path leg.

Parameters
leg_typethe type of wildcard (jpl_ellipsis, jpl_member_wildcard or jpl_array_cell_wildcard)

◆ Json_path_leg() [2/5]

Json_path_leg::Json_path_leg ( size_t  index)
inlineexplicit

Construct an array cell path leg.

Parameters
indexthe 0-based index in the array, relative to the beginning of the array

◆ Json_path_leg() [3/5]

Json_path_leg::Json_path_leg ( size_t  index,
bool  from_end 
)
inline

Construct an array cell path leg.

Parameters
indexthe 0-based index in the array
from_endtrue if index is relative to the end of the array

◆ Json_path_leg() [4/5]

Json_path_leg::Json_path_leg ( size_t  idx1,
bool  idx1_from_end,
size_t  idx2,
bool  idx2_from_end 
)
inline

Construct an array range path leg.

Parameters
idx1the start index of the range, inclusive
idx1_from_endtrue if the start index is relative to the end of the array
idx2the last index of the range, inclusive
idx2_from_endtrue if the last index is relative to the end of the array

◆ Json_path_leg() [5/5]

Json_path_leg::Json_path_leg ( std::string_view  member_name)
inlineexplicit

Construct an object member path leg.

Parameters
member_namethe name of the object member

Member Function Documentation

◆ first_array_index()

Json_array_index Json_path_leg::first_array_index ( size_t  array_length) const
inline

Get the first array cell pointed to by an array range, or the array cell pointed to by an array cell index.

Parameters
array_lengththe length of the array

◆ get_array_range()

Json_path_leg::Array_range Json_path_leg::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.

Parameters
array_lengththe length of the array

◆ get_member_name()

const std::string & Json_path_leg::get_member_name ( ) const
inline

Get the member name of a jpl_member path leg.

◆ get_type()

enum_json_path_leg_type Json_path_leg::get_type ( ) const
inline

Get the type of the path leg.

◆ is_autowrap()

bool Json_path_leg::is_autowrap ( ) const

Is this path leg an auto-wrapping array accessor?

An auto-wrapping array accessor is an array accessor that matches non-arrays by auto-wrapping them in a single-element array before doing the matching.

This function returns true for any jpl_array_cell or jpl_array_range path leg that would match the element contained in a single-element array, and which therefore would also match non-arrays that have been auto-wrapped in single-element arrays.

◆ last_array_index()

Json_array_index Json_path_leg::last_array_index ( size_t  array_length) const
inline

Get the last array cell pointed to by an array range.

The range includes this cell.

Parameters
array_lengththe length of the array

◆ to_string()

bool Json_path_leg::to_string ( String buf) const

Turn into a human-readable string.

Member Data Documentation

◆ m_first_array_index

size_t Json_path_leg::m_first_array_index = 0
private

The index of an array cell, or the start of an array range.

◆ m_first_array_index_from_end

bool Json_path_leg::m_first_array_index_from_end = false
private

Is m_first_array_index relative to the end of the array?

◆ m_last_array_index

size_t Json_path_leg::m_last_array_index = 0
private

The end (inclusive) of an array range.

◆ m_last_array_index_from_end

bool Json_path_leg::m_last_array_index_from_end = false
private

Is m_last_array_index relative to the end of the array?

◆ m_leg_type

enum_json_path_leg_type Json_path_leg::m_leg_type
private

The type of this path leg.

◆ m_member_name

std::string Json_path_leg::m_member_name
private

The member name of a member path leg.


The documentation for this class was generated from the following files: