lintel 0.2.0
Loading...
Searching...
No Matches
ConnectionType.h
Go to the documentation of this file.
1#ifndef LINTEL_CONNECTIONTYPE_H
2#define LINTEL_CONNECTIONTYPE_H
3
4#include <cstdint>
5#include <magic_enum/magic_enum.hpp>
6#include <set>
7#include <string>
8
9namespace lintel {
10namespace db {
15 {
16 public:
17 // value is defining priority of property repository type
18 enum Value : std::int8_t { UNDEFINED = -1, SQLite = 0, PostgreSQL };
19
21 ConnectionType() = default;
22
27 constexpr ConnectionType(Value value) : m_value(value) {}
28
33 constexpr explicit ConnectionType(std::string_view enumName)
35 {}
36
38 constexpr operator Value() const { return m_value; }
39
41 constexpr Value value() const { return m_value; }
42
43 explicit operator bool() = delete;
44
46 static std::set<Value> values()
47 {
48 auto values = magic_enum::enum_values<Value>();
49 return std::set<Value>(values.begin(), values.end());
50 }
51
53 std::string toString() const { return std::string(magic_enum::enum_name<>(m_value)); }
54
56 friend std::ostream &operator<<(std::ostream &os, const ConnectionType &connectionType)
57 {
59 return os;
60 }
61
62 private:
63 Value m_value;
64 };
65}// namespace db
66
67}// namespace lintel
68#endif// LINTEL_CONNECTIONTYPE_H
Definition ConnectionType.h:15
Value
Definition ConnectionType.h:18
@ SQLite
Definition ConnectionType.h:18
@ PostgreSQL
Definition ConnectionType.h:18
@ UNDEFINED
Definition ConnectionType.h:18
constexpr ConnectionType(std::string_view enumName)
Definition ConnectionType.h:33
std::string toString() const
Definition ConnectionType.h:53
static std::set< Value > values()
Definition ConnectionType.h:46
friend std::ostream & operator<<(std::ostream &os, const ConnectionType &connectionType)
Definition ConnectionType.h:56
constexpr Value value() const
Definition ConnectionType.h:41
constexpr ConnectionType(Value value)
Definition ConnectionType.h:27
Definition BaseFeature.h:6
constexpr std::string_view type_name()
Definition TypeName.h:9