MySQL 8.0.40
Source Code Documentation
|
JSON DOM abstract base class. More...
#include <json_dom.h>
Public Member Functions | |
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 enum_json_type | json_type () const =0 |
virtual bool | is_scalar () const |
virtual bool | is_number () const |
virtual uint32 | depth () const =0 |
Compute the depth of a document. More... | |
virtual Json_dom_ptr | clone () const =0 |
Make a deep clone. More... | |
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... | |
Static Public Member Functions | |
static Json_dom_ptr | parse (const char *text, size_t length, const JsonParseErrorHandler &error_handler, const JsonDocumentDepthHandler &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... | |
Private Member Functions | |
void | set_parent (Json_container *parent) |
Set the parent dom to which this dom is attached. More... | |
Private Attributes | |
Json_container * | m_parent {nullptr} |
Parent pointer. More... | |
Friends | |
class | Json_object |
class | Json_array |
JSON DOM abstract base class.
MySQL representation of in-memory JSON objects used by the JSON type Supports access, deep cloning, and updates. See also Json_wrapper and json_binary::Value. Uses heap for space allocation for now. FIXME.
Class hierarchy:
Json_dom (abstract) Json_scalar (abstract) Json_string Json_number (abstract) Json_decimal Json_int Json_uint Json_double Json_boolean Json_null Json_datetime Json_opaque Json_container (abstract) Json_object Json_array
At the outset, object and array add/insert/append operations takes a clone unless specified in the method, e.g. add_alias hands the responsibility for the passed in object over to the object.
|
virtualdefault |
|
pure virtual |
Make a deep clone.
The ownership of the returned object is henceforth with the caller.
Implemented in Json_object, Json_array, Json_string, Json_decimal, Json_double, Json_int, Json_uint, Json_null, Json_datetime, Json_opaque, and Json_boolean.
|
pure virtual |
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.
Implemented in Json_scalar, Json_object, and Json_array.
Json_path Json_dom::get_location | ( | ) | const |
Get the path location of this dom, measured from the outermost document it nests inside.
|
inlinevirtual |
Reimplemented in Json_number.
|
inlinevirtual |
Reimplemented in Json_scalar.
|
pure virtual |
Implemented in Json_object, Json_array, Json_string, Json_decimal, Json_double, Json_int, Json_uint, Json_null, Json_datetime, Json_opaque, and Json_boolean.
|
noexcept |
Deallocate the space used by a Json_dom object.
|
noexcept |
Nothrow delete.
|
noexcept |
Allocate space on the heap for a Json_dom object.
|
inline |
Get the parent dom to which this dom is attached.
|
static |
Parse Json text to DOM (using rapidjson).
The text must be valid JSON. The results when supplying an invalid document is undefined. The ownership of the returned object is henceforth with the caller.
If the parsing fails because of a syntax error, the errmsg and offset arguments will be given values that point to a detailed error message and where the syntax error was located. The caller will have to generate an error message with my_error() in this case.
If the parsing fails because of some other error (such as out of memory), errmsg will point to a location that holds the value NULL. In this case, parse() will already have called my_error(), and the caller doesn't need to generate an error message.
[in] | text | the JSON text |
[in] | length | the length of the text |
[out] | errmsg | any syntax error message (will be ignored if it is NULL) |
[out] | offset | the position in the parsed string a syntax error was found (will be ignored if it is NULL) |
[in] | error_handler | Pointer to a function that should handle reporting of parsing error. |
[in] | depth_handler | Pointer to a function that should handle error occurred when depth is exceeded. |
|
static |
Construct a DOM object based on a binary JSON value.
The ownership of the returned object is henceforth with the caller.
thd | current session |
v | the binary value to parse |
bool Json_dom::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.
Adds a vector element for each match.
See the header comment for Json_wrapper.seek() for a discussion of complexities involving path expression with more than one ellipsis (**) token.
[in] | path | the (possibly wildcarded) address of the sub-documents |
[in] | legs | the number of legs to use from path |
[out] | hits | one element per match |
[in] | auto_wrap | if true, match a tailing [0] to scalar at that position. |
[in] | only_need_one | True if we can stop after finding one match |
|
inlineprivate |
Set the parent dom to which this dom is attached.
[in] | parent | the parent we're being attached to |
|
friend |
|
friend |
|
private |
Parent pointer.