Hyper API for C++  0.0.15888
Hyper client library for C++ applications
DatabaseName.hpp
Go to the documentation of this file.
1 
5 #ifndef TABLEAU_HYPER_DATABASENAME_HPP
6 #define TABLEAU_HYPER_DATABASENAME_HPP
7 
8 #include <hyperapi/Name.hpp>
9 
10 namespace hyperapi {
12 class DatabaseName final {
13  public:
20  DatabaseName(Name name) : name(std::move(name)) {}
21 
23  DatabaseName(std::string name) : DatabaseName(Name(name)) {}
24 
29  DatabaseName(const char* name) : DatabaseName(Name(name)) {}
30 
35  const std::string& toString() const noexcept { return name.toString(); }
36 
40  const Name& getName() const noexcept { return name; }
41 
42  private:
44  Name name;
45 };
46 
48 inline std::ostream& operator<<(std::ostream& os, const DatabaseName& name) { return os << name.toString(); }
49 
51 inline bool operator<(const DatabaseName& a, const DatabaseName& b) noexcept { return a.getName() < b.getName(); }
53 inline bool operator==(const DatabaseName& a, const DatabaseName& b) noexcept { return a.getName() == b.getName(); }
55 inline bool operator>(const DatabaseName& a, const DatabaseName& b) noexcept { return b < a; }
57 inline bool operator!=(const DatabaseName& a, const DatabaseName& b) noexcept { return !(a == b); }
59 inline bool operator<=(const DatabaseName& a, const DatabaseName& b) noexcept { return !(a > b); }
61 inline bool operator>=(const DatabaseName& a, const DatabaseName& b) noexcept { return !(a < b); }
62 }
63 
64 namespace std {
66 template <>
67 struct hash<hyperapi::DatabaseName> {
69  size_t operator()(const hyperapi::DatabaseName& name) const noexcept { return hash<string>()(name.toString()); }
70 };
71 }
72 
73 #endif
hyperapi::DatabaseName::DatabaseName
DatabaseName(Name name)
Constructs a properly quoted and escaped SQL Database name.
Definition: DatabaseName.hpp:20
hyperapi::operator<
bool operator<(const DatabaseName &a, const DatabaseName &b) noexcept
Smaller operator.
Definition: DatabaseName.hpp:51
std::hash< hyperapi::DatabaseName >::operator()
size_t operator()(const hyperapi::DatabaseName &name) const noexcept
Calculates the hash value of the given name.
Definition: DatabaseName.hpp:69
hyperapi::DatabaseName::toString
const std::string & toString() const noexcept
Returns the properly quoted and escaped string representation of this name.
Definition: DatabaseName.hpp:35
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::DatabaseName::getName
const Name & getName() const noexcept
Definition: DatabaseName.hpp:40
hyperapi::operator>
bool operator>(const DatabaseName &a, const DatabaseName &b) noexcept
Greater operator.
Definition: DatabaseName.hpp:55
hyperapi::Name::toString
const std::string & toString() const
Definition: Name.hpp:41
hyperapi::operator<<
std::ostream & operator<<(std::ostream &os, const DatabaseName &name)
Stream output operator.
Definition: DatabaseName.hpp:48
hyperapi::DatabaseName::DatabaseName
DatabaseName(std::string name)
Constructs a properly quoted and escaped SQL Database name.
Definition: DatabaseName.hpp:23
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::DatabaseName::DatabaseName
DatabaseName(const char *name)
Constructs a properly quoted and escaped SQL Database name.
Definition: DatabaseName.hpp:29
hyperapi::DatabaseName
Represents an escaped SQL database name.
Definition: DatabaseName.hpp:12
Name.hpp