#ifndef option_hh_INCLUDED #define option_hh_INCLUDED #include "exception.hh" #include "meta.hh" #include "string.hh" #include "vector.hh" namespace Kakoune { class String; enum class Quoting; // 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); // Default fallback to single value functions template decltype(option_from_string(Meta::Type{}, StringView{})) option_from_strings(Meta::Type, ConstArrayView strs) { if (strs.size() != 1) throw runtime_error("expected a single value for option"); return option_from_string(Meta::Type{}, strs[0]); } template Vector(), Quoting{}))> option_to_strings(const T& opt) { return Vector{option_to_string(opt, Quoting{})}; } template decltype(option_add(std::declval(), std::declval())) option_add_from_strings(T& opt, ConstArrayView strs) { if (strs.size() != 1) throw runtime_error("expected a single value for option"); return option_add(opt, strs[0]); } template decltype(option_add(std::declval(), std::declval())) option_remove_from_strings(T& opt, ConstArrayView strs) { if (strs.size() != 1) throw runtime_error("expected a single value for option"); return option_remove(opt, strs[0]); } template struct PrefixedList { P prefix; Vector list; friend bool operator==(const PrefixedList& lhs, const PrefixedList& rhs) = default; }; template using TimestampedList = PrefixedList; } #endif // option_hh_INCLUDED