]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add some utility methods
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 2 Oct 2021 13:57:04 +0000 (14:57 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 2 Oct 2021 13:57:04 +0000 (14:57 +0100)
src/libmime/mime_string.hxx

index 7474c6381c1b9cc22f2f5de92fb54cb53b074eed..3294cd980b58c2522bd31ffde24a1be4b0fa3260 100644 (file)
@@ -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