Hyper API for C++ 0.0.20746
Hyper client library for C++ applications
Loading...
Searching...
No Matches
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
10namespace hyperapi {
12class 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
48inline std::ostream& operator<<(std::ostream& os, const DatabaseName& name) { return os << name.toString(); }
49
51inline bool operator<(const DatabaseName& a, const DatabaseName& b) noexcept { return a.getName() < b.getName(); }
53inline bool operator==(const DatabaseName& a, const DatabaseName& b) noexcept { return a.getName() == b.getName(); }
55inline bool operator>(const DatabaseName& a, const DatabaseName& b) noexcept { return b < a; }
57inline bool operator!=(const DatabaseName& a, const DatabaseName& b) noexcept { return !(a == b); }
59inline bool operator<=(const DatabaseName& a, const DatabaseName& b) noexcept { return !(a > b); }
61inline bool operator>=(const DatabaseName& a, const DatabaseName& b) noexcept { return !(a < b); }
62}
63
64namespace std {
66template <>
67struct hash<hyperapi::DatabaseName> {
69 size_t operator()(const hyperapi::DatabaseName& name) const noexcept { return hash<string>()(name.toString()); }
70};
71}
72
73#endif
Represents an escaped SQL database name.
DatabaseName(Name name)
Constructs a properly quoted and escaped SQL Database name.
const Name & getName() const noexcept
DatabaseName(std::string name)
Constructs a properly quoted and escaped SQL Database name.
DatabaseName(const char *name)
Constructs a properly quoted and escaped SQL Database name.
const std::string & toString() const noexcept
Returns the properly quoted and escaped string representation of this name.
Represents an escaped SQL name.
Definition Name.hpp:18
const std::string & toString() const
Definition Name.hpp:41
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.
size_t operator()(const hyperapi::DatabaseName &name) const noexcept
Calculates the hash value of the given name.