diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-10-02 14:57:04 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-10-02 14:57:04 +0100 |
commit | 0751ed286c565d0aaf7b3eacc0773c2e1ed6625a (patch) | |
tree | 855d52b1bb2c3800a0c660922d2fcd039bbe314e | |
parent | 65803d93db5b08e5a87e71797438046e0859758e (diff) | |
download | rspamd-0751ed286c565d0aaf7b3eacc0773c2e1ed6625a.tar.gz rspamd-0751ed286c565d0aaf7b3eacc0773c2e1ed6625a.zip |
[Minor] Add some utility methods
-rw-r--r-- | src/libmime/mime_string.hxx | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/libmime/mime_string.hxx b/src/libmime/mime_string.hxx index 7474c6381..3294cd980 100644 --- a/src/libmime/mime_string.hxx +++ b/src/libmime/mime_string.hxx @@ -353,6 +353,16 @@ public: * @param other * @return */ + auto assign_copy(const view_type &other) { + storage.clear(); + + if (filter_func) { + append_c_string_filtered(other.data(), other.size()); + } + else { + append_c_string_unfiltered(other.data(), other.size()); + } + } auto assign_copy(const storage_type &other) { storage.clear(); @@ -363,7 +373,7 @@ public: append_c_string_unfiltered(other.data(), other.size()); } } - auto assign_copy(const view_type &other) { + auto assign_copy(const basic_mime_string &other) { storage.clear(); if (filter_func) { @@ -462,6 +472,18 @@ public: return storage; } + inline auto as_view() const noexcept -> view_type { + return view_type{storage}; + } + + constexpr CharT operator[](std::size_t pos) const { + return storage[pos]; + } + constexpr CharT at(std::size_t pos) const { + return storage.at(pos); + } + + /* For doctest stringify */ friend std::ostream& operator<< (std::ostream& os, const CharT& value) { os << value.storage; @@ -556,4 +578,5 @@ private: } + #endif //RSPAMD_MIME_STRING_HXX |