Hyper API for C++  0.0.15888
Hyper client library for C++ applications
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>
10 #include <hyperapi/SchemaName.hpp>
11 
12 namespace hyperapi {
13 
15 class 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 
58 inline std::ostream& operator<<(std::ostream& os, const TableName& name) { return os << name.toString(); }
59 
61 inline bool operator<(const TableName& a, const TableName& b) noexcept;
63 inline bool operator==(const TableName& a, const TableName& b) noexcept { return (a.getSchemaName() == b.getSchemaName()) && (a.getName() == b.getName()); }
65 inline bool operator>(const TableName& a, const TableName& b) noexcept { return b < a; }
67 inline bool operator!=(const TableName& a, const TableName& b) noexcept { return !(a == b); }
69 inline bool operator<=(const TableName& a, const TableName& b) noexcept { return !(a > b); }
71 inline bool operator>=(const TableName& a, const TableName& b) noexcept { return !(a < b); }
72 }
73 
74 #include <hyperapi/impl/TableName.impl.hpp>
75 #endif
hyperapi::operator<
bool operator<(const DatabaseName &a, const DatabaseName &b) noexcept
Smaller operator.
Definition: DatabaseName.hpp:51
hyperapi::TableName::TableName
TableName(DatabaseName databaseName, Name schemaName, Name name)
Constructor for a fully qualified table name.
Definition: TableName.hpp:33
hyperapi::operator<=
bool operator<=(const DatabaseName &a, const DatabaseName &b) noexcept
Smaller or equal operator.
Definition: DatabaseName.hpp:59
hyperapi::operator>=
bool operator>=(const DatabaseName &a, const DatabaseName &b) noexcept
Greater or equal operator.
Definition: DatabaseName.hpp:61
hyperapi::Name
Represents an escaped SQL name.
Definition: Name.hpp:18
hyperapi::TableName::getDatabaseName
const optional< DatabaseName > & getDatabaseName() const noexcept
hyperapi::TableName::TableName
TableName(SchemaName schemaName, Name name)
Constructor for a partly qualified table name.
Definition: TableName.hpp:30
DatabaseName.hpp
hyperapi::operator>
bool operator>(const DatabaseName &a, const DatabaseName &b) noexcept
Greater operator.
Definition: DatabaseName.hpp:55
hyperapi::optional
Surrogate for C++17 std::optional
Definition: optional.hpp:40
hyperapi::operator<<
std::ostream & operator<<(std::ostream &os, const DatabaseName &name)
Stream output operator.
Definition: DatabaseName.hpp:48
hyperapi::TableName::isFullyQualified
bool isFullyQualified() const noexcept
Definition: TableName.hpp:48
hyperapi::TableName::TableName
TableName(const char *name)
Constructor for a non-qualified table name.
Definition: TableName.hpp:27
hyperapi::TableName::TableName
TableName(Name name)
Constructor for a non-qualified table name.
Definition: TableName.hpp:18
hyperapi::operator==
bool operator==(const DatabaseName &a, const DatabaseName &b) noexcept
Equality operator.
Definition: DatabaseName.hpp:53
hyperapi::operator!=
bool operator!=(const DatabaseName &a, const DatabaseName &b) noexcept
Not equal operator.
Definition: DatabaseName.hpp:57
hyperapi
The primary namespace of the Hyper API for C++.
Definition: ByteSpan.hpp:15
hyperapi::SchemaName
Represents an escaped SQL schema name.
Definition: SchemaName.hpp:13
SchemaName.hpp
hyperapi::TableName::toString
std::string toString() const
hyperapi::TableName::getSchemaName
const optional< SchemaName > & getSchemaName() const noexcept
Definition: TableName.hpp:42
hyperapi::TableName
Represents an escaped SQL table name.
Definition: TableName.hpp:15
hyperapi::DatabaseName
Represents an escaped SQL database name.
Definition: DatabaseName.hpp:12
hyperapi::TableName::getName
const Name & getName() const noexcept
Definition: TableName.hpp:39
hyperapi::TableName::TableName
TableName(std::string name)
Constructor for a non-qualified table name.
Definition: TableName.hpp:21
Name.hpp