summaryrefslogtreecommitdiff
path: root/icetray/icetray/mimeImpl.h
blob: c87dea0b0f233e5a418b3265314cf6e8d7255767 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef ICETRAY_MIME_IMPL_H
#define ICETRAY_MIME_IMPL_H

#include <mime.h>
#include <visibility.h>

namespace IceTray::Mime {
	class DLL_PUBLIC PartHelper {
	protected:
		static void writeHeaders(const Headers & headers, const StreamPtr & ms);
	};

	class DLL_PUBLIC TextPart : public BasicSinglePart, PartHelper {
	public:
		TextPart(const Headers &, const std::string &, std::string);

		void write(const StreamPtr & ms, Ice::Int depth) const override;

		static void quotedPrintable(const std::string_view & input, FILE * ms, const size_t maxWidth = 74);

		const std::string payload;
	};

	class DLL_PUBLIC BinaryViewPart : public BasicSinglePart, PartHelper {
	public:
		using byte = uint8_t;
		using byte_range = std::basic_string_view<byte>;

		BinaryViewPart(const Headers &, const std::string &, const byte_range &);

		void write(const StreamPtr & ms, Ice::Int depth) const override;

		static void base64(const byte_range & input, FILE * ms, const size_t maxWidth = 76);

		const byte_range payload;
	};

	class DLL_PUBLIC BinaryCopyPart : public BinaryViewPart {
	public:
		using bytes = std::vector<byte>;

		BinaryCopyPart(const Headers &, const std::string &, bytes);

		const bytes payload;
	};

	class DLL_PUBLIC MultiPart : public BasicMultiPart, PartHelper {
	public:
		MultiPart(const Headers &, const std::string &, const Parts &);

		void write(const StreamPtr & ms, Ice::Int depth) const override;
	};
}

#endif