summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2017-10-04 21:28:18 +0200
committerlouiz’ <louiz@louiz.org>2017-12-02 20:08:47 +0100
commit0168b96b79db2627fdba77a8712956408aa081d1 (patch)
tree5591527ed8a04be8ea04c49521d9e9c868677bd1 /src/utils
parent5b27cee97272d4ae6ff30f03dc57221fa3e3183f (diff)
downloadbiboumi-0168b96b79db2627fdba77a8712956408aa081d1.tar.gz
biboumi-0168b96b79db2627fdba77a8712956408aa081d1.tar.bz2
biboumi-0168b96b79db2627fdba77a8712956408aa081d1.tar.xz
biboumi-0168b96b79db2627fdba77a8712956408aa081d1.zip
Add postgresql support
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/is_one_of.hpp17
-rw-r--r--src/utils/optional_bool.cpp8
-rw-r--r--src/utils/optional_bool.hpp4
3 files changed, 28 insertions, 1 deletions
diff --git a/src/utils/is_one_of.hpp b/src/utils/is_one_of.hpp
new file mode 100644
index 0000000..4d6770e
--- /dev/null
+++ b/src/utils/is_one_of.hpp
@@ -0,0 +1,17 @@
+#pragma once
+
+#include <type_traits>
+
+template <typename...>
+struct is_one_of_implem {
+ static constexpr bool value = false;
+};
+
+template <typename F, typename S, typename... T>
+struct is_one_of_implem<F, S, T...> {
+ static constexpr bool value =
+ std::is_same<F, S>::value || is_one_of_implem<F, T...>::value;
+};
+
+template<typename... T>
+constexpr bool is_one_of = is_one_of_implem<T...>::value;
diff --git a/src/utils/optional_bool.cpp b/src/utils/optional_bool.cpp
new file mode 100644
index 0000000..56fdca2
--- /dev/null
+++ b/src/utils/optional_bool.cpp
@@ -0,0 +1,8 @@
+#include <utils/optional_bool.hpp>
+
+
+std::ostream& operator<<(std::ostream& os, const OptionalBool& o)
+{
+ os << o.to_string();
+ return os;
+}
diff --git a/src/utils/optional_bool.hpp b/src/utils/optional_bool.hpp
index 59bbbab..867aca2 100644
--- a/src/utils/optional_bool.hpp
+++ b/src/utils/optional_bool.hpp
@@ -20,7 +20,7 @@ struct OptionalBool
this->is_set = false;
}
- std::string to_string()
+ std::string to_string() const
{
if (this->is_set == false)
return "unset";
@@ -33,3 +33,5 @@ struct OptionalBool
bool is_set{false};
bool value{false};
};
+
+std::ostream& operator<<(std::ostream& os, const OptionalBool& o);