MySQL 9.0.0
Source Code Documentation
Json_decimal Class Referencefinal

Represents a MySQL decimal number, type J_DECIMAL. More...

#include <json_dom.h>

Inheritance diagram for Json_decimal:
[legend]

Public Member Functions

 Json_decimal (const my_decimal &value)
 
int binary_size () const
 Get the number of bytes needed to store this decimal in a Json_opaque. More...
 
bool get_binary (char *dest) const
 Get the binary representation of the wrapped my_decimal, so that this value can be stored inside of a Json_opaque. More...
 
enum_json_type json_type () const override
 
const my_decimalvalue () const
 Get a pointer to the MySQL decimal held by this object. More...
 
Json_dom_ptr clone () const override
 Make a deep clone. More...
 
- Public Member Functions inherited from Json_number
bool is_number () const final
 
- Public Member Functions inherited from Json_scalar
uint32 depth () const final
 Compute the depth of a document. More...
 
bool is_scalar () const final
 
- 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_containerparent () const
 Get the parent dom to which this dom is attached. 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 bool convert_from_binary (const char *bin, size_t len, my_decimal *dec)
 Convert a binary value produced by get_binary() back to a my_decimal. More...
 
static const char * get_encoded_binary (const char *bin)
 Returns stored DECIMAL binary. More...
 
static size_t get_encoded_binary_len (size_t length)
 Returns length of stored DECIMAL binary. More...
 
- 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...
 

Static Public Attributes

static const int MAX_BINARY_SIZE = DECIMAL_MAX_FIELD_SIZE + 2
 

Private Attributes

my_decimal m_dec
 holds the decimal number More...
 

Detailed Description

Represents a MySQL decimal number, type J_DECIMAL.

Constructor & Destructor Documentation

◆ Json_decimal()

Json_decimal::Json_decimal ( const my_decimal value)
explicit

Member Function Documentation

◆ binary_size()

int Json_decimal::binary_size ( ) const

Get the number of bytes needed to store this decimal in a Json_opaque.

Returns
the number of bytes.

◆ clone()

Json_dom_ptr Json_decimal::clone ( ) const
inlineoverridevirtual

Make a deep clone.

The ownership of the returned object is henceforth with the caller.

Returns
a cloned Json_dom object.

Implements Json_dom.

◆ convert_from_binary()

bool Json_decimal::convert_from_binary ( const char *  bin,
size_t  len,
my_decimal dec 
)
static

Convert a binary value produced by get_binary() back to a my_decimal.

This and two next functions help storage engine to deal with decimal value in a serialized JSON document. This function converts serialized value to my_decimal. The later two functions extract the decimal value from serialized JSON, so SE can index it in multi-valued index.

Parameters
[in]bindecimal value in binary format
[in]lenlength of the binary value
[out]decmy_decimal object to store the value to
Returns
false on success, true on failure

◆ get_binary()

bool Json_decimal::get_binary ( char *  dest) const

Get the binary representation of the wrapped my_decimal, so that this value can be stored inside of a Json_opaque.

Parameters
destthe destination buffer to which the binary representation is written
Returns
false on success, true on error

◆ get_encoded_binary()

static const char * Json_decimal::get_encoded_binary ( const char *  bin)
inlinestatic

Returns stored DECIMAL binary.

Parameters
binserialized Json_decimal object
Returns
pointer to the binary decimal value
See also
convert_from_binary

◆ get_encoded_binary_len()

static size_t Json_decimal::get_encoded_binary_len ( size_t  length)
inlinestatic

Returns length of stored DECIMAL binary.

Parameters
lengthlength of serialized Json_decimal object
Returns
length of the binary decimal value
See also
convert_from_binary

◆ json_type()

enum_json_type Json_decimal::json_type ( ) const
inlineoverridevirtual
Returns
the type corresponding to the actual Json_dom subclass

Implements Json_dom.

◆ value()

const my_decimal * Json_decimal::value ( ) const
inline

Get a pointer to the MySQL decimal held by this object.

Ownership is not transferred.

Returns
the decimal

Member Data Documentation

◆ m_dec

my_decimal Json_decimal::m_dec
private

holds the decimal number

◆ MAX_BINARY_SIZE

const int Json_decimal::MAX_BINARY_SIZE = DECIMAL_MAX_FIELD_SIZE + 2
static

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