diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2015-12-12 11:45:45 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2015-12-12 11:45:45 +0000 |
| commit | 4cb74623bbfd489b46edfadde5529e07a0dc557a (patch) | |
| tree | 121c950258da7007886fe5e349e76048fc9aaa6b /src/option_types.hh | |
| parent | 70250fc1e344e50b4af96e0963e22f18a1978eb5 (diff) | |
Store the buffer timestamp in line flags options respect it for highlighting
Option content is auto updated to match current buffer, so that line flags
are updated according to buffer modifications.
Diffstat (limited to 'src/option_types.hh')
| -rw-r--r-- | src/option_types.hh | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/option_types.hh b/src/option_types.hh index 12f5e4fd..73a8bcfb 100644 --- a/src/option_types.hh +++ b/src/option_types.hh @@ -223,6 +223,45 @@ constexpr Array<EnumDesc<DebugFlags>, 3> enum_desc(DebugFlags) } }; } +template<typename T> +struct TimestampedList +{ + size_t timestamp; + Vector<T, MemoryDomain::Options> list; +}; + +template<typename T> +inline bool operator==(const TimestampedList<T>& lhs, const TimestampedList<T>& rhs) +{ + return lhs.timestamp == rhs.timestamp and lhs.list == rhs.list; +} + +template<typename T> +inline bool operator!=(const TimestampedList<T>& lhs, const TimestampedList<T>& rhs) +{ + return not (lhs == rhs); +} + +template<typename T> +inline String option_to_string(const TimestampedList<T>& opt) +{ + return format("{}:{}", opt.timestamp, option_to_string(opt.list)); +} + +template<typename T> +inline void option_from_string(StringView str, TimestampedList<T>& opt) +{ + auto it = find(str, ':'); + opt.timestamp = str_to_int({str.begin(), it}); + option_from_string({it+1, str.end()}, opt.list); +} + +template<typename T> +inline bool option_add(TimestampedList<T>& opt, StringView str) +{ + return option_add(opt.list, str); +} + } #endif // option_types_hh_INCLUDED |
