Hyper API for C++  0.0.15530
Hyper client library for C++ applications
Name.hpp
Go to the documentation of this file.
1 
5 #ifndef TABLEAU_HYPER_NAME_HPP
6 #define TABLEAU_HYPER_NAME_HPP
7 
8 #include "hyperapi/optional.hpp"
10 #include <stdexcept>
11 #include <string>
12 
13 namespace hyperapi {
14 
18 class Name final {
19  private:
21  std::string name;
23  std::string unescaped;
24 
25  public:
32  Name(std::string name);
33 
38  Name(const char* name);
39 
41  const std::string& toString() const { return name; }
42 
44  bool isEmpty() const noexcept { return name.empty(); }
45 
52  const std::string& getUnescaped() const { return unescaped; }
53 };
54 
56 inline std::ostream& operator<<(std::ostream& os, const Name& name) { return os << name.toString(); }
57 
59 inline bool operator<(const Name& a, const Name& b) noexcept { return a.getUnescaped() < b.getUnescaped(); }
61 inline bool operator==(const Name& a, const Name& b) noexcept { return a.getUnescaped() == b.getUnescaped(); }
63 inline bool operator>(const Name& a, const Name& b) noexcept { return b < a; }
65 inline bool operator!=(const Name& a, const Name& b) noexcept { return !(a == b); }
67 inline bool operator<=(const Name& a, const Name& b) noexcept { return !(a > b); }
69 inline bool operator>=(const Name& a, const Name& b) noexcept { return !(a < b); }
70 }
71 #include <hyperapi/impl/Name.impl.hpp>
72 
73 #endif
hyperapi::operator<
bool operator<(const DatabaseName &a, const DatabaseName &b) noexcept
Smaller operator.
Definition: DatabaseName.hpp:51
string_view.hpp
hyperapi::Name::isEmpty
bool isEmpty() const noexcept
Definition: Name.hpp:44
hyperapi::Name::Name
Name(std::string name)
Constructs a properly quoted and escaped SQL name.
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::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::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::Name::getUnescaped
const std::string & getUnescaped() const
Definition: Name.hpp:52
optional.hpp