Hyper API for C++  0.0.16638
Hyper client library for C++ applications
ResultSchema.hpp
Go to the documentation of this file.
1 
5 #ifndef TABLEAU_HYPER_RESULTSCHEMA_HPP
6 #define TABLEAU_HYPER_RESULTSCHEMA_HPP
7 
8 #include <hyperapi/Name.hpp>
9 #include <hyperapi/SqlType.hpp>
10 #include <hyperapi/optional.hpp>
11 #include <vector>
12 
13 namespace hyperapi {
14 
15 class Result;
16 
20 class ResultSchema final {
21  public:
23  class Column final {
24  friend class ResultSchemaTest;
25  friend class Result;
26 
27  public:
29  const Name& getName() const noexcept { return name; }
31  const SqlType& getType() const noexcept { return type; }
32 
33  private:
35  const Name name;
37  const SqlType type;
38 
40  Column(Name&& name, SqlType&& type);
41  };
42 
43  public:
47  const std::vector<Column>& getColumns() const noexcept { return columns; }
48 
56  const Column& getColumn(hyper_field_index_t columnIndex) const;
57 
61  size_t getColumnCount() const noexcept { return columns.size(); }
62 
69  const Column* getColumnByName(const Name& name) const;
70 
78 
79  private:
80  // TODO 940803 Avoid private methods; move into impl header
85  void addColumn(Column&& column) { columns.emplace_back(std::move(column)); }
86 
88  std::vector<Column> columns;
89 
90  friend class ResultSchemaTest;
91  friend class Result;
92 };
93 }
94 
95 #include <hyperapi/impl/ResultSchema.impl.hpp>
96 
97 #endif
hyperapi::SqlType
A Hyper SQL type.
Definition: SqlType.hpp:43
hyperapi::ResultSchema
A result schema.
Definition: ResultSchema.hpp:20
hyperapi::ResultSchema::getColumn
const Column & getColumn(hyper_field_index_t columnIndex) const
Returns the column at the given index.
hyperapi::Name
Represents an escaped SQL name.
Definition: Name.hpp:18
hyperapi::ResultSchema::Column::getName
const Name & getName() const noexcept
Gets the column name.
Definition: ResultSchema.hpp:29
hyperapi::ResultSchema::getColumnPositionByName
optional< hyper_field_index_t > getColumnPositionByName(const Name &name) const
Gets the position of the column with the given name.
hyperapi::ResultSchema::getColumnByName
const Column * getColumnByName(const Name &name) const
Gets the column with the given name.
hyperapi::Result
Base class for a result of a query.
Definition: Result.hpp:325
hyperapi::optional
Surrogate for C++17 std::optional
Definition: optional.hpp:40
hyperapi::ResultSchema::Column::getType
const SqlType & getType() const noexcept
Gets the type.
Definition: ResultSchema.hpp:31
SqlType.hpp
hyperapi
The primary namespace of the Hyper API for C++.
Definition: ByteSpan.hpp:15
hyperapi::TableDefinition::Column
A Column of a table definition.
Definition: TableDefinition.hpp:50
hyperapi::ResultSchema::getColumns
const std::vector< Column > & getColumns() const noexcept
Returns all columns.
Definition: ResultSchema.hpp:47
hyperapi::ResultSchema::Column
A column of a result.
Definition: ResultSchema.hpp:23
hyperapi::ResultSchema::getColumnCount
size_t getColumnCount() const noexcept
Returns the number of columns.
Definition: ResultSchema.hpp:61
Name.hpp
optional.hpp