summaryrefslogtreecommitdiff
path: root/slicer/json/serializer.h
blob: a1c75bd04974f532b1ace1ea6ebd1327b00cc71b (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
56
57
58
59
60
61
62
#ifndef SLICER_JSON_H
#define SLICER_JSON_H

#include <slicer/serializer.h>
#include <jsonpp.h>

#ifndef DLL_PUBLIC
#define DLL_PUBLIC __attribute__ ((visibility ("default")))
#endif

namespace Slicer {
	class JsonSerializer : public Serializer {
		protected:
			static void ModelTreeIterate(json::Value *, const std::string &, ModelPartPtr mp);
			static void ModelTreeIterateSeq(json::Value *, ModelPartPtr mp);
			static void ModelTreeIterateRoot(json::Value *, ModelPartPtr mp);
	};

	class JsonFileSerializer : public JsonSerializer {
		public:
			DLL_PUBLIC JsonFileSerializer(const boost::filesystem::path &);

			virtual void Serialize(ModelPartPtr) override;

		private:
			const boost::filesystem::path path;
	};

	class JsonValueSerializer : public JsonSerializer {
		public:
			DLL_PUBLIC JsonValueSerializer(json::Value &);

			virtual void Serialize(ModelPartPtr) override;

		private:
			json::Value & value;
	};

	class JsonFileDeserializer : public Deserializer {
		public:
			DLL_PUBLIC JsonFileDeserializer(const boost::filesystem::path &);

			virtual void Deserialize(ModelPartPtr) override;

		private:
			const boost::filesystem::path path;
	};

	class JsonValueDeserializer : public Deserializer {
		public:
			DLL_PUBLIC JsonValueDeserializer(const json::Value &);

			virtual void Deserialize(ModelPartPtr) override;

		private:
			const json::Value & value;
	};
}

#endif