Hyper API for C++ 0.0.20746
Hyper client library for C++ applications
Loading...
Searching...
No Matches
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>
10#include <hyperapi/optional.hpp>
11#include <vector>
12
13namespace hyperapi {
14
15class Result;
16
20class 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
Represents an escaped SQL name.
Definition Name.hpp:18
const Name & getName() const noexcept
Gets the column name.
const SqlType & getType() const noexcept
Gets the type.
const Column & getColumn(hyper_field_index_t columnIndex) const
Returns the column at the given index.
const std::vector< Column > & getColumns() const noexcept
Returns all columns.
size_t getColumnCount() const noexcept
Returns the number of columns.
optional< hyper_field_index_t > getColumnPositionByName(const Name &name) const
Gets the position of the column with the given name.
const Column * getColumnByName(const Name &name) const
Gets the column with the given name.
Base class for a result of a query.
Definition Result.hpp:326
A Hyper SQL type.
Definition SqlType.hpp:44
Surrogate for C++17 std::optional
Definition optional.hpp:40
The primary namespace of the Hyper API for C++.
Definition ByteSpan.hpp:15