#include <cstdlib>
#include <cstring>
#include <iosfwd>
+#include "libutil/mem_pool.h"
#include "function2/function2.hpp"
#include "unicode/utf8.h"
#include "contrib/fastutf8/fastutf8.h"
class Functor = fu2::function_view<UChar32(UChar32)>> class basic_mime_string;
using mime_string = basic_mime_string<char>;
+using mime_pool_string = basic_mime_string<char, mempool_allocator<char>>;
/* Helpers for type safe flags */
enum class mime_string_flags : std::uint8_t {
append_c_string_unfiltered(other.data(), other.size());
}
}
+ 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());
+ }
+ }
/* Mutators */
auto append(const CharT* str, std::size_t size) -> std::size_t {
}
#endif
+#ifdef __cplusplus
+#include <memory> /* For allocator */
+namespace rspamd {
+
+template<class T>
+class mempool_allocator {
+public:
+ typedef T value_type;
+
+ mempool_allocator() = delete;
+ template<class U>
+ mempool_allocator(const mempool_allocator<U> &other) : pool(other.pool) {}
+ mempool_allocator(rspamd_mempool_t *_pool) : pool(_pool) {}
+ [[nodiscard]] constexpr T* allocate(std::size_t n)
+ {
+ if (G_MAXSIZE / 2 / sizeof(T) > n) {
+ throw std::runtime_error("integer overflow");
+ }
+ return reinterpret_cast<T*>(rspamd_mempool_alloc(pool, n * sizeof(T)));
+ }
+ constexpr void deallocate(T* p, std::size_t n) {
+ /* Do nothing */
+ }
+private:
+ rspamd_mempool_t *pool;
+};
+
+}
+#endif
+
#endif