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

Represents a single row from a result that contains rows. More...

Public Member Functions

bytes getBytes (col_count_t pos) const
 Get raw bytes representing value of row field at position pos. More...
 
Valueget (col_count_t pos)
 Get reference to row field at position pos. More...
 
Valueset (col_count_t pos, const Value &val)
 Set value of row field at position pos. More...
 
const Valueoperator[] (col_count_t pos) const
 Get const reference to row field at position pos. More...
 
Valueoperator[] (col_count_t pos)
 Get modifiable reference to row field at position pos. More...
 
bool isNull () const
 Check if this row contains fields or is null.
 

Detailed Description

Represents a single row from a result that contains rows.

Such a row consists of a number of fields, each storing single value. The number of fields and types of values stored in each field are described by RowResult instance that produced this row.

Values of fields can be accessed with get() method or using row[pos] expression. Fields are identified by 0-based position. It is also possible to get raw bytes representing value of a given field with getBytes() method.

See also
Value class.

Member Function Documentation

◆ getBytes()

bytes getBytes ( col_count_t  pos) const
inline

Get raw bytes representing value of row field at position pos.

The raw bytes are as received from the server. In genral the value is represented using x-protocol encoding that corresponds to the type and other meta-data of the given column. This meta-data can be accessed via Column object returned by RowResult#getColumn() method.

The x-protocol represenation of different value types is documented here. Most types reported by Column#getType() method correspond to an x-protocol value type of the same name.

All integer types use the x-protocol UINT or SINT encoding, which is the protobuf variant encoding together with zig-zag encoding for the signed case (see https://developers.google.com/protocol-buffers/docs/encoding)

STRING values are encoded using the character set encoding as reported by Column#getCharacterSet() method of the corresponding Column object (usually utf8mb4).

JSON data is represented as a JSON string. ENUM values are represented as strings with enum constant names. Values of type DATE and TIMESTAMP use the same representation as DATETIME, with time part empty in case of DATE values. GEOMETRY values use the internal geometry storage format described here.

Note that raw representation of BYTES and STRING values has an extra 0x00 byte added at the end, which is not part of the originial data. It is used to distinguish null values from empty byte sequences.

Returns
null bytes range if given field is NULL.
Exceptions
out_of_rangeif given row was not fetched from server.

◆ get()

Value& get ( col_count_t  pos)
inline

Get reference to row field at position pos.

Exceptions
out_of_rangeif given field does not exist in the row.

◆ set()

Value& set ( col_count_t  pos,
const Value val 
)
inline

Set value of row field at position pos.

Creates new field if it does not exist.

Returns
Reference to the field that was set.

◆ operator[]() [1/2]

const Value& operator[] ( col_count_t  pos) const
inline

Get const reference to row field at position pos.

This is const version of method get().

Exceptions
out_of_rangeif given field does not exist in the row.

◆ operator[]() [2/2]

Value& operator[] ( col_count_t  pos)
inline

Get modifiable reference to row field at position pos.

The field is created if it does not exist. In this case the initial value of the field is NULL.


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