MySQL 9.1.0
Source Code Documentation
|
Represents a JSON array container, i.e. More...
#include <json_dom.h>
Public Types | |
using | const_iterator = decltype(m_v)::const_iterator |
Constant iterator over the elements in the JSON array. More... | |
Public Member Functions | |
Json_array () | |
enum_json_type | json_type () const override |
bool | append_clone (const Json_dom *value) |
Append a clone of the value to the end of the array. More... | |
bool | append_alias (Json_dom *value) |
Append the value to the end of the array. More... | |
bool | append_alias (Json_dom_ptr value) |
Append the value to the end of the array and take over the ownership of the value. More... | |
bool | consume (Json_array_ptr other) |
Moves all of the elements in the other array to the end of this array. More... | |
bool | insert_clone (size_t index, const Json_dom *value) |
Insert a clone of the value at position index of the array. More... | |
bool | insert_alias (size_t index, Json_dom_ptr value) |
Insert the value at position index of the array. More... | |
bool | remove (size_t index) |
Remove the value at this index. More... | |
size_t | size () const |
The cardinality of the array (number of values). More... | |
uint32 | depth () const override |
Compute the depth of a document. More... | |
Json_dom_ptr | clone () const override |
Make a deep clone. More... | |
Json_dom * | operator[] (size_t index) const |
Get the value at position index. More... | |
void | clear () |
Remove the values in the array. More... | |
const_iterator | begin () const |
Returns a const_iterator that refers to the first element. More... | |
const_iterator | end () const |
Returns a const_iterator that refers past the last element. More... | |
void | replace_dom_in_container (const Json_dom *oldv, Json_dom_ptr newv) override |
Replace oldv contained inside this container array or object) with newv. More... | |
void | sort (const CHARSET_INFO *cs=nullptr) |
Sort the array. More... | |
template<class T > | |
void | sort (const T &comparator) |
Sort the array using a user-defined comparator. More... | |
bool | binary_search (Json_dom *val) |
Check if the given value appears in the array. More... | |
void | remove_duplicates (const CHARSET_INFO *cs) |
Sort array and remove duplicate elements. More... | |
Public Member Functions inherited from Json_dom | |
virtual | ~Json_dom ()=default |
void * | operator new (size_t size, const std::nothrow_t &) noexcept |
Allocate space on the heap for a Json_dom object. More... | |
void | operator delete (void *ptr) noexcept |
Deallocate the space used by a Json_dom object. More... | |
void | operator delete (void *ptr, const std::nothrow_t &) noexcept |
Nothrow delete. More... | |
Json_container * | parent () const |
Get the parent dom to which this dom is attached. More... | |
virtual bool | is_scalar () const |
virtual bool | is_number () const |
Json_path | get_location () const |
Get the path location of this dom, measured from the outermost document it nests inside. More... | |
bool | seek (const Json_seekable_path &path, size_t legs, Json_dom_vector *hits, bool auto_wrap, bool only_need_one) |
Finds all of the json sub-documents which match the path expression. More... | |
Public Attributes | |
friend | Json_dom |
Private Attributes | |
std::vector< Json_dom_ptr, Malloc_allocator< Json_dom_ptr > > | m_v |
Holds the array values. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from Json_dom | |
static Json_dom_ptr | parse (const char *text, size_t length, const JsonParseErrorHandler &error_handler, const JsonErrorHandler &depth_handler) |
Parse Json text to DOM (using rapidjson). More... | |
static Json_dom_ptr | parse (const json_binary::Value &v) |
Construct a DOM object based on a binary JSON value. More... | |
Represents a JSON array container, i.e.
type J_ARRAY here.
using Json_array::const_iterator = decltype(m_v)::const_iterator |
Constant iterator over the elements in the JSON array.
Json_array::Json_array | ( | ) |
|
inline |
Append the value to the end of the array.
Ownership of the value is effectively transferred to the array and the value will be deallocated by the array so only append values that can be deallocated safely (no stack variables please!)
New code should prefer append_alias(Json_dom_ptr) to this function, because that makes the transfer of ownership more explicit. This function might be removed in the future.
[in] | value | a JSON value to be appended |
false | on success |
true | on failure |
|
inline |
Append the value to the end of the array and take over the ownership of the value.
value | the JSON value to be appended |
|
inline |
Append a clone of the value to the end of the array.
[in] | value | a JSON value to be appended |
false | on success |
true | on failure |
|
inline |
Returns a const_iterator that refers to the first element.
bool Json_array::binary_search | ( | Json_dom * | val | ) |
Check if the given value appears in the array.
val | value to look for |
|
inline |
Remove the values in the array.
|
overridevirtual |
Make a deep clone.
The ownership of the returned object is henceforth with the caller.
Implements Json_dom.
bool Json_array::consume | ( | Json_array_ptr | other | ) |
Moves all of the elements in the other array to the end of this array.
The other array is deleted.
[in] | other | a pointer to the array which will be consumed |
false | on success |
true | on failure |
|
overridevirtual |
Compute the depth of a document.
This is the value which would be returned by the JSON_DEPTH() system function.
For example: "abc", [] and {} have depth 1. ["abc", [3]] and {"a": "abc", "b": [3]} have depth 3.
Implements Json_dom.
|
inline |
Returns a const_iterator that refers past the last element.
bool Json_array::insert_alias | ( | size_t | index, |
Json_dom_ptr | value | ||
) |
Insert the value at position index of the array.
If beyond the end, insert at the end.
Ownership of the value is effectively transferred to the array and the value will be deallocated by the array so only append values that can be deallocated safely (no stack variables please!)
[in] | index | the position at which to insert |
[in] | value | a JSON value to be inserted |
false | on success |
true | on failure |
|
inline |
Insert a clone of the value at position index of the array.
If beyond the end, insert at the end.
[in] | index | the position at which to insert |
[in] | value | a JSON value to be inserted |
false | on success |
true | on failure |
|
inlineoverridevirtual |
Implements Json_dom.
|
inline |
Get the value at position index.
The value has not been cloned so it is the responsibility of the user to make a copy if needed. Do not try to deallocate the returned value - it is owned by the array and will be deallocated by it in time. It is admissible to modify its contents (in place; without a clone being taken) if it is a compound.
[in] | index | the array index |
bool Json_array::remove | ( | size_t | index | ) |
Remove the value at this index.
A no-op if index is larger than size. Deletes the value.
[in] | index | the index of the value to remove |
void Json_array::remove_duplicates | ( | const CHARSET_INFO * | cs | ) |
Sort array and remove duplicate elements.
Used by multi-value index implementation.
|
overridevirtual |
Replace oldv contained inside this container array or object) with newv.
If this container does not contain oldv, calling the method is a no-op.
[in] | oldv | the value to be replaced |
[in] | newv | the new value to put in the container |
Implements Json_container.
|
inline |
The cardinality of the array (number of values).
void Json_array::sort | ( | const CHARSET_INFO * | cs = nullptr | ) |
Sort the array.
|
inline |
Sort the array using a user-defined comparator.
friend Json_array::Json_dom |
|
private |
Holds the array values.