summaryrefslogtreecommitdiff
path: root/src/option.hh
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-03-16 09:57:39 +0000
committerMaxime Coste <mawww@kakoune.org>2017-03-16 09:57:39 +0000
commit5f7464d90d0bfe641dd2c7bbbca6e78d92d9d818 (patch)
tree2f83259b53104545893c7e59f7a96d04e037278e /src/option.hh
parent7eaa05845043420c8f8c58932667b71b6784714a (diff)
Try to clean up option include a bit
Diffstat (limited to 'src/option.hh')
-rw-r--r--src/option.hh59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/option.hh b/src/option.hh
new file mode 100644
index 00000000..c54de083
--- /dev/null
+++ b/src/option.hh
@@ -0,0 +1,59 @@
+#ifndef option_hh_INCLUDED
+#define option_hh_INCLUDED
+
+#include "enum.hh"
+
+namespace Kakoune
+{
+
+class String;
+
+// Forward declare functions that wont get found by ADL
+inline String option_to_string(int opt);
+inline String option_to_string(size_t opt);
+inline String option_to_string(bool opt);
+
+template<typename P, typename T>
+struct PrefixedList
+{
+ P prefix;
+ Vector<T, MemoryDomain::Options> list;
+
+ friend bool operator==(const PrefixedList& lhs, const PrefixedList& rhs)
+ {
+ return lhs.prefix == rhs.prefix and lhs.list == rhs.list;
+ }
+
+ friend bool operator!=(const PrefixedList& lhs, const PrefixedList& rhs)
+ {
+ return not (lhs == rhs);
+ }
+};
+
+template<typename T>
+using TimestampedList = PrefixedList<size_t, T>;
+
+enum class DebugFlags
+{
+ None = 0,
+ Hooks = 1 << 0,
+ Shell = 1 << 1,
+ Profile = 1 << 2,
+ Keys = 1 << 3,
+};
+
+constexpr bool with_bit_ops(Meta::Type<DebugFlags>) { return true; }
+
+constexpr Array<EnumDesc<DebugFlags>, 4> enum_desc(Meta::Type<DebugFlags>)
+{
+ return { {
+ { DebugFlags::Hooks, "hooks" },
+ { DebugFlags::Shell, "shell" },
+ { DebugFlags::Profile, "profile" },
+ { DebugFlags::Keys, "keys" }
+ } };
+}
+
+}
+
+#endif // option_hh_INCLUDED