From bea53d09b21de050841dee75fa4cc58e71532afb Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 19 Aug 2014 18:56:11 +0100 Subject: Remove option checkers, handle that through the type system Use a specific type for InsertCompleterDesc with checks in the option_{from,to}_string functions --- src/insert_completer.hh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/insert_completer.hh') diff --git a/src/insert_completer.hh b/src/insert_completer.hh index dcbf3ba1..88759edf 100644 --- a/src/insert_completer.hh +++ b/src/insert_completer.hh @@ -4,9 +4,41 @@ #include "buffer.hh" #include "option_manager.hh" +#include "optional.hh" + namespace Kakoune { +struct InsertCompleterDesc +{ + enum Mode + { + Word, + Option, + Filename + }; + + InsertCompleterDesc(Mode mode = Filename, + Optional param = Optional{}) + : mode{mode}, param{std::move(param)} + {} + + bool operator==(const InsertCompleterDesc& other) const + { return mode == other.mode && param == other.param; } + + bool operator!=(const InsertCompleterDesc& other) const + { return !(*this == other); } + + Mode mode; + Optional param; +}; + +using InsertCompleterDescList = std::vector; + + +String option_to_string(const InsertCompleterDesc& opt); +void option_from_string(const String& str, InsertCompleterDesc& opt); + struct InsertCompletion { ByteCoord begin; -- cgit v1.2.3