MySQL 9.0.0
Source Code Documentation
Json_datetime Class Referencefinal

Represents a MySQL date/time value (DATE, TIME, DATETIME or TIMESTAMP) - an extension to the ECMA set of JSON scalar types, types J_DATE, J_TIME, J_DATETIME and J_TIMESTAMP respectively. More...

#include <json_dom.h>

Inheritance diagram for Json_datetime:
[legend]

Public Member Functions

 Json_datetime (const MYSQL_TIME &t, enum_field_types ft)
 Constructs a object to hold a MySQL date/time value. More...
 
enum_json_type json_type () const override
 
Json_dom_ptr clone () const override
 Make a deep clone. More...
 
const MYSQL_TIMEvalue () const
 Return a pointer the date/time value. More...
 
enum_field_types field_type () const
 Return what kind of date/time value this object holds. More...
 
void to_packed (char *dest) const
 Convert the datetime to the packed format used when storing datetime values. More...
 
- 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...
 
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...
 

Static Public Member Functions

static void from_packed (const char *from, enum_field_types ft, MYSQL_TIME *to)
 Convert a packed datetime back to a MYSQL_TIME. More...
 
static void from_packed_to_key (const char *from, enum_field_types ft, uchar *to, uint8 dec)
 Convert a packed datetime to key string for indexing by SE. 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 size_t PACKED_SIZE = 8
 Datetimes are packed in eight bytes. More...
 

Private Attributes

MYSQL_TIME m_t
 holds the date/time value More...
 
enum_field_types m_field_type
 identifies which type of date/time More...
 

Detailed Description

Represents a MySQL date/time value (DATE, TIME, DATETIME or TIMESTAMP) - an extension to the ECMA set of JSON scalar types, types J_DATE, J_TIME, J_DATETIME and J_TIMESTAMP respectively.

The method field_type identifies which of the four it is.

Constructor & Destructor Documentation

◆ Json_datetime()

Json_datetime::Json_datetime ( const MYSQL_TIME t,
enum_field_types  ft 
)
inline

Constructs a object to hold a MySQL date/time value.

Parameters
[in]tthe time/value
[in]ftthe field type: must be one of MYSQL_TYPE_TIME, MYSQL_TYPE_DATE, MYSQL_TYPE_DATETIME or MYSQL_TYPE_TIMESTAMP.

Member Function Documentation

◆ clone()

Json_dom_ptr Json_datetime::clone ( ) const
overridevirtual

Make a deep clone.

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

Returns
a cloned Json_dom object.

Implements Json_dom.

◆ field_type()

enum_field_types Json_datetime::field_type ( ) const
inline

Return what kind of date/time value this object holds.

Returns
One of MYSQL_TYPE_TIME, MYSQL_TYPE_DATE, MYSQL_TYPE_DATETIME or MYSQL_TYPE_TIMESTAMP.

◆ from_packed()

void Json_datetime::from_packed ( const char *  from,
enum_field_types  ft,
MYSQL_TIME to 
)
static

Convert a packed datetime back to a MYSQL_TIME.

Parameters
fromthe buffer to read from (must have at least PACKED_SIZE bytes)
ftthe field type of the value
tothe MYSQL_TIME to write the value to

◆ from_packed_to_key()

void Json_datetime::from_packed_to_key ( const char *  from,
enum_field_types  ft,
uchar to,
uint8  dec 
)
static

Convert a packed datetime to key string for indexing by SE.

Parameters
fromthe buffer to read from
ftthe field type of the value
tothe destination buffer
decvalue's decimals

◆ json_type()

enum_json_type Json_datetime::json_type ( ) const
overridevirtual
Returns
the type corresponding to the actual Json_dom subclass

Implements Json_dom.

◆ to_packed()

void Json_datetime::to_packed ( char *  dest) const

Convert the datetime to the packed format used when storing datetime values.

Parameters
destthe destination buffer to write the packed datetime to (must at least have size PACKED_SIZE)

◆ value()

const MYSQL_TIME * Json_datetime::value ( ) const
inline

Return a pointer the date/time value.

Ownership is not transferred. To identify which time time the value represents, use field_type.

Returns
the pointer

Member Data Documentation

◆ m_field_type

enum_field_types Json_datetime::m_field_type
private

identifies which type of date/time

◆ m_t

MYSQL_TIME Json_datetime::m_t
private

holds the date/time value

◆ PACKED_SIZE

const size_t Json_datetime::PACKED_SIZE = 8
static

Datetimes are packed in eight bytes.


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