MySQL 9.1.0
Source Code Documentation
Syntax_check_handler Class Reference

This class implements a handler for use with rapidjson::Reader when we want to check if a string is a valid JSON text. More...

#include <json_syntax_check.h>

Inheritance diagram for Syntax_check_handler:
[legend]

Public Member Functions

bool StartObject ()
 
bool EndObject (rapidjson::SizeType)
 
bool StartArray ()
 
bool EndArray (rapidjson::SizeType)
 
bool too_deep_error_raised () const
 
 Syntax_check_handler (JsonErrorHandler m_depth_handler)
 

Private Attributes

size_t m_depth {0}
 The current depth of the document. More...
 
bool m_too_deep_error_raised {false}
 
JsonErrorHandler m_depth_handler {nullptr}
 Pointer to a function that should handle error occurred when depth is exceeded. More...
 

Detailed Description

This class implements a handler for use with rapidjson::Reader when we want to check if a string is a valid JSON text.

The handler does not build a DOM structure, so it is quicker than Json_dom::parse() in the cases where we don't care about the DOM, such as in the JSON_VALID() function.

The handler keeps track of how deeply nested the document is, and it raises an error and stops parsing when the depth exceeds JSON_DOCUMENT_MAX_DEPTH.

All the member functions follow the rapidjson convention of returning true on success and false on failure.

Constructor & Destructor Documentation

◆ Syntax_check_handler()

Syntax_check_handler::Syntax_check_handler ( JsonErrorHandler  m_depth_handler)
explicit

Member Function Documentation

◆ EndArray()

bool Syntax_check_handler::EndArray ( rapidjson::SizeType  )

◆ EndObject()

bool Syntax_check_handler::EndObject ( rapidjson::SizeType  )

◆ StartArray()

bool Syntax_check_handler::StartArray ( )

◆ StartObject()

bool Syntax_check_handler::StartObject ( )

◆ too_deep_error_raised()

bool Syntax_check_handler::too_deep_error_raised ( ) const
inline

Member Data Documentation

◆ m_depth

size_t Syntax_check_handler::m_depth {0}
private

The current depth of the document.

◆ m_depth_handler

JsonErrorHandler Syntax_check_handler::m_depth_handler {nullptr}
private

Pointer to a function that should handle error occurred when depth is exceeded.

◆ m_too_deep_error_raised

bool Syntax_check_handler::m_too_deep_error_raised {false}
private

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