MySQL Connector/C++ 9.1.0
MySQL connector library for C and C++ applications
Public Types | List of all members

Value object can store value of scalar type, string, array or document. More...

Public Types

enum  Type {
  VNULL , UINT64 , INT64 , FLOAT ,
  DOUBLE , BOOL , STRING , DOCUMENT ,
  RAW , ARRAY
}
 Possible types of values. More...
 

Public Member Functions

Value Constructors
 Value ()
 Constructs Null value.
 
 Value (std::nullptr_t)
 Constructs Null value.
 
 Value (const mysqlx::string &str)
 Constructs Null value.
 
 Value (mysqlx::string &&str)
 Constructs Null value.
 
 Value (const std::string &str)
 Constructs Null value.
 
 Value (std::string &&str)
 Constructs Null value.
 
 Value (const char *str)
 Constructs Null value.
 
template<typename C >
 Value (const std::basic_string< C > &str)
 Constructs Null value.
 
template<typename C >
 Value (const C *str)
 Constructs Null value.
 
 Value (const bytes &)
 Constructs Null value.
 
 Value (int64_t)
 Constructs Null value.
 
 Value (uint64_t)
 Constructs Null value.
 
 Value (float)
 Constructs Null value.
 
 Value (double)
 Constructs Null value.
 
 Value (bool)
 Constructs Null value.
 
 Value (const DbDoc &doc)
 Constructs Null value.
 
 Value (const std::initializer_list< Value > &list)
 Constructs Null value.
 
template<typename Iterator >
 Value (Iterator begin_, Iterator end_)
 Constructs Null value.
 

Conversion to C++ Types

Attempt to convert value of non-compatible type throws an error.

typedef std::vector< ValueArray
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
enum mysqlx::abi2::r0::Value:: { ... }  m_type = VAL
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
DbDoc m_doc
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
std::shared_ptr< Arraym_arr
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
friend SessionSettings
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
friend DbDoc
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
friend Access
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
 operator int () const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
 operator unsigned () const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
 operator int64_t () const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
 operator uint64_t () const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
 operator float () const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
 operator double () const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
 operator bool () const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
 operator mysqlx::string () const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
 operator std::string () const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
template<typename C >
 operator std::basic_string< C > () const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
 operator bytes () const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
 operator DbDoc () const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
template<typename T >
get () const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
bytes getRawBytes () const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
Type getType () const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
bool isNull () const
 Convenience method for checking if value is null.
 
bool hasField (const Field &) const
 Check if document value contains given (top-level) field. More...
 
const Valueoperator[] (const Field &) const
 If this value is not a document, throws error. More...
 
const Valueoperator[] (const char *name) const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
const Valueoperator[] (const mysqlx::string &name) const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
iterator begin ()
 Access to elements of an array value. More...
 
const_iterator begin () const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
iterator end ()
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
const_iterator end () const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
size_t elementCount () const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
const Valueoperator[] (unsigned) const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
const Valueoperator[] (int pos) const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
void print (std::ostream &out) const
 Print the value to a stream.
 
void check_type (Type t) const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
bool is_expr () const
 Return type of the value stored in this instance (or VNULL if no value is stored).
 
void set_as_expr ()
 Return type of the value stored in this instance (or VNULL if no value is stored).
 

Detailed Description

Value object can store value of scalar type, string, array or document.

Implicit conversions to and from corresponding C++ types are defined. If conversion to wrong type is attempted, an error is thrown. If Value object holds an array or document, then array elements or fields of the document can be accessed using operator[]. Array values can be used as STL containers.

Only direct conversions of stored value to the corresponding C++ type are supported. There are no implicit number->string conversions etc.

Values of type RAW can refer to a region of memory containing raw bytes. Such values are created from bytes and can by casted to bytes type.

Note
Value object copies the values it stores. Thus, after storing value in Value object, the original value can be destroyed without invalidating the copy. This includes RAW Values which hold a copy of bytes.

Member Enumeration Documentation

◆ Type

enum Type

Possible types of values.

See also
getType()
Enumerator
VNULL 

Null value.

UINT64 

Unsigned integer.

INT64 

Signed integer.

FLOAT 

Float number.

DOUBLE 

Double number.

BOOL 

Boolean.

STRING 

String.

DOCUMENT 

Document.

RAW 

Raw bytes.

ARRAY 

Array of values.

Member Function Documentation

◆ hasField()

bool hasField ( const Field &  fld) const
inline

Check if document value contains given (top-level) field.

Throws error if this is not a document value.

◆ operator[]()

const Value & operator[] ( const Field &  fld) const
inline

If this value is not a document, throws error.

Otherwise returns value of given field of the document.

◆ begin()

Value::iterator begin ( )
inline

Access to elements of an array value.

If non-array value is accessed like an array, an error is thrown.


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