Hyper API for C++ 0.0.18825
Hyper client library for C++ applications
Loading...
Searching...
No Matches
TableName.hpp
Go to the documentation of this file.
1
5#ifndef TABLEAU_HYPER_TABLENAME_HPP
6#define TABLEAU_HYPER_TABLENAME_HPP
7
9#include <hyperapi/Name.hpp>
11
12namespace hyperapi {
13
15class TableName {
16 public:
18 TableName(Name name) : name_(std::move(name)) {}
19
21 TableName(std::string name) : TableName(Name(name)) {}
22
27 TableName(const char* name) : TableName(Name(name)) {}
28
30 TableName(SchemaName schemaName, Name name) : schemaName_(std::move(schemaName)), name_(std::move(name)) {}
31
33 TableName(DatabaseName databaseName, Name schemaName, Name name) : schemaName_({std::move(databaseName), std::move(schemaName)}), name_(std::move(name)) {}
34
36 std::string toString() const;
37
39 const Name& getName() const noexcept { return name_; }
40
42 const optional<SchemaName>& getSchemaName() const noexcept { return schemaName_; }
43
45 const optional<DatabaseName>& getDatabaseName() const noexcept;
46
48 bool isFullyQualified() const noexcept { return schemaName_.has_value() && schemaName_->isFullyQualified(); }
49
50 private:
52 optional<SchemaName> schemaName_;
54 Name name_;
55};
56
58inline std::ostream& operator<<(std::ostream& os, const TableName& name) { return os << name.toString(); }
59
61inline bool operator<(const TableName& a, const TableName& b) noexcept;
63inline bool operator==(const TableName& a, const TableName& b) noexcept { return (a.getSchemaName() == b.getSchemaName()) && (a.getName() == b.getName()); }
65inline bool operator>(const TableName& a, const TableName& b) noexcept { return b < a; }
67inline bool operator!=(const TableName& a, const TableName& b) noexcept { return !(a == b); }
69inline bool operator<=(const TableName& a, const TableName& b) noexcept { return !(a > b); }
71inline bool operator>=(const TableName& a, const TableName& b) noexcept { return !(a < b); }
72}
73
74#include <hyperapi/impl/TableName.impl.hpp>
75#endif
Represents an escaped SQL database name.
Represents an escaped SQL name.
Definition Name.hpp:18
Represents an escaped SQL schema name.
Represents an escaped SQL table name.
Definition TableName.hpp:15
TableName(const char *name)
Constructor for a non-qualified table name.
Definition TableName.hpp:27
std::string toString() const
bool isFullyQualified() const noexcept
Definition TableName.hpp:48
const optional< SchemaName > & getSchemaName() const noexcept
Definition TableName.hpp:42
TableName(SchemaName schemaName, Name name)
Constructor for a partly qualified table name.
Definition TableName.hpp:30
TableName(Name name)
Constructor for a non-qualified table name.
Definition TableName.hpp:18
TableName(std::string name)
Constructor for a non-qualified table name.
Definition TableName.hpp:21
const Name & getName() const noexcept
Definition TableName.hpp:39
const optional< DatabaseName > & getDatabaseName() const noexcept
TableName(DatabaseName databaseName, Name schemaName, Name name)
Constructor for a fully qualified table name.
Definition TableName.hpp:33
Surrogate for C++17 std::optional
Definition optional.hpp:40
The primary namespace of the Hyper API for C++.
Definition ByteSpan.hpp:15
bool operator<(const DatabaseName &a, const DatabaseName &b) noexcept
Smaller operator.
bool operator==(const DatabaseName &a, const DatabaseName &b) noexcept
Equality operator.
bool operator>(const DatabaseName &a, const DatabaseName &b) noexcept
Greater operator.
bool operator!=(const DatabaseName &a, const DatabaseName &b) noexcept
Not equal operator.
bool operator>=(const DatabaseName &a, const DatabaseName &b) noexcept
Greater or equal operator.
std::ostream & operator<<(std::ostream &os, const DatabaseName &name)
Stream output operator.
bool operator<=(const DatabaseName &a, const DatabaseName &b) noexcept
Smaller or equal operator.