Class Row (2.32.0-rc)

A Row is a sequence of columns each with a name and an associated Value.

The Row class is a regular value type that may be copied, moved, assigned, compared for equality, etc. Instances may be large if they hold lots of Value data, so copy only when necessary.

Row instances are typically returned as the result of queries or reads of a Cloud Spanner table (see Client::Read and Client::ExecuteQuery). Users will mostly just use the accessor methods on Row, and will rarely (if ever) need to construct aRow` of their own.

The number of columns in a Row can be obtained from the size() member function. The Values can be obtained using the values() accessor. The names of each column in the row can be obtained using the columns() accessor.

Perhaps the most convenient way to access the Values in a row is through the variety of "get" accessors. A user may access a column's Value by calling get with a std::size_t 0-indexed position, or a std::string column name. Furthermore, callers may directly extract the native C++ type by specifying the C++ type along with the column's position or name.

Example
Row row = ...;
if (StatusOr<std::string> x = row.get<std::string>("LastName")) {
  std::cout << "LastName=" << *x << "\n";
}

Constructors

Row(Row const &)

Copy and move.

Parameter
Name Description
Row const &

Row(Row &&)

Copy and move.

Parameter
Name Description
Row &&

Row()

Default constructs an empty row with no columns nor values.

Operators

operator=(Row const &)

Copy and move.

Parameter
Name Description
Row const &
Returns
Type Description
Row &

operator=(Row &&)

Copy and move.

Parameter
Name Description
Row &&
Returns
Type Description
Row &

Functions

size() const

Returns the number of columns in the row.

Returns
Type Description
std::size_t

columns() const

Returns the column names for the row.

Returns
Type Description
std::vector< std::string > const &

values() const &

Returns the Value objects in the given row.

Returns
Type Description
std::vector< Value > const &

values() &&

Returns the Value objects in the given row.

Returns
Type Description
std::vector< Value > &&

get(std::size_t) const

Returns the Value at the given pos.

Parameter
Name Description
pos std::size_t
Returns
Type Description
StatusOr< Value >

get(std::string const &) const

Returns the Value in the column with name.

Parameter
Name Description
name std::string const &
Returns
Type Description
StatusOr< Value >

get(Arg &&) const

Returns the native C++ value at the given position or column name.

Parameters
Name Description
arg Arg &&
typename T

the native C++ type, e.g., std::int64_t or std::string

typename Arg

a deduced parameter convertible to a std::size_t or std::string

Returns
Type Description
StatusOr< T >

get() const &

Returns all the native C++ values for the whole row in a std::tuple with the specified type.

Parameter
Name Description
typename Tuple

the std::tuple type that the whole row must unpack into.

Returns
Type Description
StatusOr< Tuple >

get() &&

Returns all the native C++ values for the whole row in a std::tuple with the specified type.

Parameter
Name Description
typename Tuple

the std::tuple type that the whole row must unpack into.

Returns
Type Description
StatusOr< Tuple >