MySQL 8.4.3
Source Code Documentation
Show_parse_tree Class Reference

Holds the json parse tree being generated by the SHOW PARSE_TREE command. More...

#include <parse_tree_node_base.h>

Classes

struct  Parse_tree_comparator
 

Public Member Functions

 Show_parse_tree (Show_parse_tree *parent_tree=nullptr)
 
bool push_level (const POS &pos, const char *typname)
 Create a json node out of the parse tree node position and type name, and push it onto the json object stack. More...
 
Json_objectget_current_parent ()
 Get the current object under which new json objects are to be added as children. More...
 
std::string get_parse_tree ()
 Generate the json tree text from the json tree, and return it. More...
 
bool pop_level ()
 Pop out the json node pushed by push_level() and make it a child of the inner json object in the stack. More...
 

Private Member Functions

bool make_child (Json_object *obj)
 Make the obj a child of the current parent object in the object stack. More...
 
Json_objectpop_json_object ()
 Pop the current object in the object stack, and return it. More...
 

Private Attributes

std::vector< Json_object * > m_json_obj_stack {}
 
Json_object_ptr m_root_obj = nullptr
 
Show_parse_treem_parent_show_parse_tree = nullptr
 
const char * m_reference_pos = nullptr
 

Static Private Attributes

static constexpr Parse_tree_comparator m_comparator = {}
 

Detailed Description

Holds the json parse tree being generated by the SHOW PARSE_TREE command.

The json tree gets built with the help of the two parse tree node walkers namely contextualize() and itemize(). Each contextualize() (or itemize()) creates a new json subtree. In the beginning of contextualize(), push_level() is called, where a new Json object is created and pushed to m_json_obj_stack. This object now becomes a parent json object to which all the subtrees created by the inner contextualize() calls will be added as its children. Each contextualize() will end with a call to pop_level() where the current parent will be popped out and made the child of the now-current parent object in the stack. This way the json tree is built identical to the tree of Parse_tree_node's.

Constructor & Destructor Documentation

◆ Show_parse_tree()

Show_parse_tree::Show_parse_tree ( Show_parse_tree parent_tree = nullptr)
inlineexplicit

Member Function Documentation

◆ get_current_parent()

Json_object * Show_parse_tree::get_current_parent ( )
inline

Get the current object under which new json objects are to be added as children.

Effectively, this is the outermost object in the object stack.

retval nullptr if the object stack is empty.

◆ get_parse_tree()

std::string Show_parse_tree::get_parse_tree ( )

Generate the json tree text from the json tree, and return it.

Return values
non-emptysuccess
emptyerror

◆ make_child()

bool Show_parse_tree::make_child ( Json_object obj)
private

Make the obj a child of the current parent object in the object stack.

If there is a current parent, assign this object as child of that parent.

Parameters
objInput json object resembling a parse tree node.
Return values
falsesuccess; true: error

If there is no parent, make this object the root of this parse tree, unless there is a parent parse tree in which case make this object a child of the parent explain tree's leaf parent.

◆ pop_json_object()

Json_object * Show_parse_tree::pop_json_object ( )
private

Pop the current object in the object stack, and return it.

◆ pop_level()

bool Show_parse_tree::pop_level ( )
inline

Pop out the json node pushed by push_level() and make it a child of the inner json object in the stack.

Return values
falsesuccess; true: error

◆ push_level()

bool Show_parse_tree::push_level ( const POS pos,
const char *  typname 
)

Create a json node out of the parse tree node position and type name, and push it onto the json object stack.

Effectively, a new json stack level is created, to which json children would be added.

Parameters
possyntax position of the parse tree node
typnametype name of the class of the parse tree node
Return values
falsesuccess
trueerror

Member Data Documentation

◆ m_comparator

constexpr Parse_tree_comparator Show_parse_tree::m_comparator = {}
staticconstexprprivate

◆ m_json_obj_stack

std::vector<Json_object *> Show_parse_tree::m_json_obj_stack {}
private

◆ m_parent_show_parse_tree

Show_parse_tree* Show_parse_tree::m_parent_show_parse_tree = nullptr
private

◆ m_reference_pos

const char* Show_parse_tree::m_reference_pos = nullptr
private

◆ m_root_obj

Json_object_ptr Show_parse_tree::m_root_obj = nullptr
private

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