Class Row (2.19.0)

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
NameDescription
Row const &

Row(Row &&)

Copy and move.

Parameter
NameDescription
Row &&

Row()

Default constructs an empty row with no columns nor values.

Operators

operator=(Row const &)

Copy and move.

Parameter
NameDescription
Row const &
Returns
TypeDescription
Row &

operator=(Row &&)

Copy and move.

Parameter
NameDescription
Row &&
Returns
TypeDescription
Row &

Functions

size() const

Returns the number of columns in the row.

Returns
TypeDescription
std::size_t

columns() const

Returns the column names for the row.

Returns
TypeDescription
std::vector< std::string > const &

values() const &

Returns the Value objects in the given row.

Returns
TypeDescription
std::vector< Value > const &

values() &&

Returns the Value objects in the given row.

Returns
TypeDescription
std::vector< Value > &&

get(std::size_t) const

Returns the Value at the given pos.

Parameter
NameDescription
pos std::size_t
Returns
TypeDescription
StatusOr< Value >

get(std::string const &) const

Returns the Value in the column with name.

Parameter
NameDescription
name std::string const &
Returns
TypeDescription
StatusOr< Value >

get(Arg &&) const

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

Parameters
NameDescription
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
TypeDescription
StatusOr< T >

get() const &

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

Parameter
NameDescription
typename Tuple

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

Returns
TypeDescription
StatusOr< Tuple >

get() &&

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

Parameter
NameDescription
typename Tuple

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

Returns
TypeDescription
StatusOr< Tuple >