CppSerialization  1.0.4.0
C++ Serialization Library
serializer.inl
Go to the documentation of this file.
1 
9 namespace CppSerialization {
10 namespace JSON {
11 
12 template <class OutputStream>
14 {
15  if (!Writer<OutputStream>::StartObject())
16  throwex SerializationException("Cannot start to serialize JSON object!");
17 }
18 
19 template <class OutputStream>
21 {
22  if (!Writer<OutputStream>::EndObject())
23  throwex SerializationException("Cannot end to serialize JSON object!");
24 }
25 
26 template <class OutputStream>
28 {
29  if (!Writer<OutputStream>::StartArray())
30  throwex SerializationException("Cannot start to serialize JSON array!");
31 }
32 
33 template <class OutputStream>
35 {
36  if (!Writer<OutputStream>::EndArray())
37  throwex SerializationException("Cannot end to serialize JSON array!");
38 }
39 
40 template <class OutputStream>
41 inline void Serializer<OutputStream>::Key(const char* key)
42 {
43  if (!Writer<OutputStream>::Key(key))
44  throwex SerializationException("Cannot serialize JSON key!");
45 }
46 
47 template <class OutputStream>
48 inline void Serializer<OutputStream>::Key(const char* key, size_t size)
49 {
50  if (!Writer<OutputStream>::Key(key, size))
51  throwex SerializationException("Cannot serialize JSON key!");
52 }
53 
54 template <class OutputStream>
55 inline void Serializer<OutputStream>::Key(const std::string& key)
56 {
57  if (!Writer<OutputStream>::Key(key))
58  throwex SerializationException("Cannot serialize JSON key!");
59 }
60 
61 template <class OutputStream>
62 template <std::size_t N>
63 inline void Serializer<OutputStream>::Key(const char (&key)[N])
64 {
65  if (!Writer<OutputStream>::Key(key, N))
66  throwex SerializationException("Cannot serialize JSON key!");
67 }
68 
69 template <class OutputStream>
70 inline void Serializer<OutputStream>::Value(std::nullptr_t value)
71 {
72  if (!Writer<OutputStream>::Null())
73  throwex SerializationException("Cannot serialize JSON null value!");
74 }
75 
76 template <class OutputStream>
77 inline void Serializer<OutputStream>::Value(bool value)
78 {
79  if (!Writer<OutputStream>::Bool(value))
80  throwex SerializationException("Cannot serialize JSON bool value!");
81 }
82 
83 template <class OutputStream>
84 inline void Serializer<OutputStream>::Value(int value)
85 {
86  if (!Writer<OutputStream>::Int(value))
87  throwex SerializationException("Cannot serialize JSON integer value!");
88 }
89 
90 template <class OutputStream>
91 inline void Serializer<OutputStream>::Value(unsigned value)
92 {
93  if (!Writer<OutputStream>::UInt(value))
94  throwex SerializationException("Cannot serialize JSON unsigned value!");
95 }
96 
97 template <class OutputStream>
98 inline void Serializer<OutputStream>::Value(int64_t value)
99 {
100  if (!Writer<OutputStream>::Int64(value))
101  throwex SerializationException("Cannot serialize JSON 64-bit integer value!");
102 }
103 
104 template <class OutputStream>
105 inline void Serializer<OutputStream>::Value(uint64_t value)
106 {
107  if (!Writer<OutputStream>::UInt64(value))
108  throwex SerializationException("Cannot serialize JSON 64-bit unsigned value!");
109 }
110 
111 template <class OutputStream>
112 inline void Serializer<OutputStream>::Value(double value)
113 {
114  if (!Writer<OutputStream>::Double(value))
115  throwex SerializationException("Cannot serialize JSON double value!");
116 }
117 
118 template <class OutputStream>
119 inline void Serializer<OutputStream>::Value(const char* value)
120 {
121  if (!Writer<OutputStream>::String(value))
122  throwex SerializationException("Cannot serialize JSON C-string value!");
123 }
124 
125 template <class OutputStream>
126 inline void Serializer<OutputStream>::Value(const char* value, size_t size)
127 {
128  if (!Writer<OutputStream>::String(value, size))
129  throwex SerializationException("Cannot serialize JSON C-string value with a given size!");
130 }
131 
132 template <class OutputStream>
133 inline void Serializer<OutputStream>::Value(const std::string& value)
134 {
135  if (!Writer<OutputStream>::String(value))
136  throwex SerializationException("Cannot serialize JSON string value!");
137 }
138 
139 template <class OutputStream>
140 template <std::size_t N>
141 inline void Serializer<OutputStream>::Value(const char (&value)[N])
142 {
143  if (!Writer<OutputStream>::String(value, N))
144  throwex SerializationException("Cannot serialize JSON string array value!");
145 }
146 
147 } // namespace JSON
148 } // namespace CppSerialization
void StartArray()
Start new array.
Definition: serializer.inl:27
void EndObject()
End the current object.
Definition: serializer.inl:20
void StartObject()
Start new object.
Definition: serializer.inl:13
void Key(const char *key)
Put the C-string key.
Definition: serializer.inl:41
void EndArray()
End the current array.
Definition: serializer.inl:34
void Value(std::nullptr_t value)
Put the null value.
Definition: serializer.inl:70
C++ Serialization project definitions.
Definition: exceptions.h:14