summaryrefslogtreecommitdiffstats
blob: d51694f572b66f93fb92be8ab3704ecdd84dfdc4 (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
/*
 * Copyright (c) 2012 Mateusz Piękos
 * Licensed under the simplified BSD license.
 * See Documentation/Licenses/BSD-simplified.txt for more information.
 */

#pragma once

#include <Swiften/Elements/WhiteboardPayload.h>
#include <Swiften/Elements/Whiteboard/WhiteboardLineElement.h>
#include <Swiften/Elements/Whiteboard/WhiteboardFreehandPathElement.h>
#include <Swiften/Elements/Whiteboard/WhiteboardRectElement.h>
#include <Swiften/Elements/Whiteboard/WhiteboardPolygonElement.h>
#include <Swiften/Elements/Whiteboard/WhiteboardTextElement.h>
#include <Swiften/Elements/Whiteboard/WhiteboardEllipseElement.h>
#include <Swiften/Elements/Whiteboard/WhiteboardElementVisitor.h>
#include <Swiften/Serializer/GenericPayloadSerializer.h>
#include <Swiften/Serializer/XML/XMLElement.h>

namespace Swift {
	class WhiteboardElementSerializingVisitor : public WhiteboardElementVisitor {
	public:
		void visit(WhiteboardLineElement& line);
		void visit(WhiteboardFreehandPathElement& path);
		void visit(WhiteboardRectElement& rect);
		void visit(WhiteboardPolygonElement& polygon);
		void visit(WhiteboardTextElement& text);
		void visit(WhiteboardEllipseElement& ellipse);
		XMLElement::ref getResult() const;

	private:
		std::string intToStr(const int t) const;
		std::string alphaToOpacity(int alpha) const;
		
		XMLElement::ref element;
	};

	class WhiteboardSerializer : public GenericPayloadSerializer<WhiteboardPayload> {
	public:
		std::string serializePayload(boost::shared_ptr<WhiteboardPayload> payload) const;

	private:
		std::string typeToString(WhiteboardPayload::Type type) const;
	};
}