aboutsummaryrefslogtreecommitdiff
path: root/lib/util.h
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-09-26 09:44:20 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-09-26 10:46:34 +0200
commit363a7e40e8aa12cb780b076cca8db4f47b70f4fa (patch)
treee5c8d796415114f46c84ba39f25a42c4ad400311 /lib/util.h
parenta923750c7a1efadaa66f24dc17010063776e6246 (diff)
downloadlibquotient-363a7e40e8aa12cb780b076cca8db4f47b70f4fa.tar.gz
libquotient-363a7e40e8aa12cb780b076cca8db4f47b70f4fa.zip
Replace QOlmError with OlmErrorCode
QOlmError represents a subset of OlmErrorCode, and the associated fromString() function uses undocumented strings produced inside Olm; meanwhile OlmErrorCode is documented in its own header file. Each QOlm* class now has lastErrorCode() next to lastError() (that, from now, returns a textual representation straight from Olm, not QOlmError enum). Also: including olm/error.h in e2ee/e2ee.h required some rearrangement of the code to make sure non-E2EE configuration still builds.
Diffstat (limited to 'lib/util.h')
-rw-r--r--lib/util.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/util.h b/lib/util.h
index 9efda5d1..ab219488 100644
--- a/lib/util.h
+++ b/lib/util.h
@@ -111,6 +111,23 @@ private:
iterator to;
};
+template <typename T>
+class asKeyValueRange
+{
+public:
+ asKeyValueRange(T& data)
+ : m_data { data }
+ {}
+
+ auto begin() { return m_data.keyValueBegin(); }
+ auto end() { return m_data.keyValueEnd(); }
+
+private:
+ T &m_data;
+};
+template <typename T>
+asKeyValueRange(T&) -> asKeyValueRange<T>;
+
/** A replica of std::find_first_of that returns a pair of iterators
*
* Convenient for cases when you need to know which particular "first of"