Hazelcast C++ Client
Hazelcast C++ Client Library
Loading...
Searching...
No Matches
hazelcast::client::sql::sql_row_metadata Class Reference

SQL row metadata. More...

#include <sql_row_metadata.h>

Public Types

using const_iterator
 key is the column name, value is the column index.

Public Member Functions

 sql_row_metadata (std::vector< sql_column_metadata > columns)
std::size_t column_count () const
 Gets the number of columns in the row.
const sql_column_metadatacolumn (std::size_t index) const
 Gets column metadata.
const std::vector< sql_column_metadata > & columns () const
 Gets columns metadata.
const_iterator find_column (const std::string &column_name) const
 Find index of the column with the given name.
const_iterator end () const
 Constant indicating that the column is not found.

Friends

bool HAZELCAST_API operator== (const sql_row_metadata &lhs, const sql_row_metadata &rhs)

Detailed Description

SQL row metadata.

Definition at line 31 of file sql_row_metadata.h.

Member Typedef Documentation

◆ const_iterator

Initial value:
std::unordered_map<std::string, std::size_t>::const_iterator

key is the column name, value is the column index.

Definition at line 37 of file sql_row_metadata.h.

Constructor & Destructor Documentation

◆ sql_row_metadata()

hazelcast::client::sql::sql_row_metadata::sql_row_metadata ( std::vector< sql_column_metadata > columns)
explicit

Definition at line 1264 of file sql.cpp.

1265 : columns_(std::move(columns))
1266{
1267 assert(!columns_.empty());
1268
1269 name_to_index_.reserve(columns_.size());
1270 for (std::size_t i = 0; i < columns_.size(); ++i) {
1271 name_to_index_.emplace(columns_[i].name, i);
1272 }
1273}
const std::vector< sql_column_metadata > & columns() const
Gets columns metadata.
Definition sql.cpp:1294

Member Function Documentation

◆ column()

const sql_column_metadata & hazelcast::client::sql::sql_row_metadata::column ( std::size_t index) const

Gets column metadata.

Parameters
indexcolumn index, zero-based
Returns
column metadata
Exceptions
IndexOutOfBoundsExceptionIf the column index is out of bounds

Definition at line 1282 of file sql.cpp.

1283{
1284 if (index >= columns_.size()) {
1285 throw exception::index_out_of_bounds(
1286 "sql_row_metadata::column(std::size_t index)",
1287 (boost::format("Column index is out of bounds: %1%") % index).str());
1288 }
1289
1290 return columns_[index];
1291}

◆ column_count()

std::size_t hazelcast::client::sql::sql_row_metadata::column_count ( ) const

Gets the number of columns in the row.

Returns
the number of columns in the row

Definition at line 1276 of file sql.cpp.

1277{
1278 return columns_.size();
1279}

◆ columns()

const std::vector< sql_column_metadata > & hazelcast::client::sql::sql_row_metadata::columns ( ) const

Gets columns metadata.

Returns
columns metadata

Definition at line 1294 of file sql.cpp.

1295{
1296 return columns_;
1297}

◆ end()

sql_row_metadata::const_iterator hazelcast::client::sql::sql_row_metadata::end ( ) const

Constant indicating that the column is not found.

Definition at line 1306 of file sql.cpp.

1307{
1308 return name_to_index_.end();
1309}

◆ find_column()

sql_row_metadata::const_iterator hazelcast::client::sql::sql_row_metadata::find_column ( const std::string & column_name) const

Find index of the column with the given name.

Returned index can be used to get column value from sql_row.

Parameters
column_namecolumn name (case sensitive)
Returns
the iterator pointing to the found item or end() if not found.
See also
sql_row

Definition at line 1300 of file sql.cpp.

1301{
1302 return name_to_index_.find(column_name);
1303}

◆ operator==

bool HAZELCAST_API operator== ( const sql_row_metadata & lhs,
const sql_row_metadata & rhs )
friend

Definition at line 1311 of file sql.cpp.

1312{
1313 return lhs.columns_ == rhs.columns_;
1314}

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