Merge lp:~saiarcot895/libopenshot/qt-json into lp:libopenshot/0.0
- qt-json
- Merge into trunk
Status: | Needs review |
---|---|
Proposed branch: | lp:~saiarcot895/libopenshot/qt-json |
Merge into: | lp:libopenshot/0.0 |
Diff against target: |
10412 lines (+959/-7310) 74 files modified
include/ChunkReader.h (+2/-2) include/ChunkWriter.h (+0/-1) include/Clip.h (+2/-2) include/ClipBase.h (+4/-4) include/Color.h (+2/-2) include/Coordinate.h (+2/-2) include/DecklinkReader.h (+2/-2) include/DummyReader.h (+2/-2) include/EffectBase.h (+3/-3) include/EffectInfo.h (+1/-1) include/FFmpegReader.h (+2/-2) include/FrameMapper.h (+2/-2) include/ImageReader.h (+2/-2) include/Json.h (+5/-1) include/KeyFrame.h (+2/-2) include/Point.h (+2/-2) include/Profiles.h (+2/-2) include/QtImageReader.h (+2/-2) include/ReaderBase.h (+4/-4) include/TextReader.h (+2/-2) include/Timeline.h (+6/-6) include/WriterBase.h (+4/-4) include/effects/Brightness.h (+2/-2) include/effects/ChromaKey.h (+2/-2) include/effects/Deinterlace.h (+2/-2) include/effects/Mask.h (+2/-2) include/effects/Negate.h (+2/-2) include/effects/Saturation.h (+2/-2) src/CMakeLists.txt (+1/-10) src/ChunkReader.cpp (+59/-48) src/Clip.cpp (+84/-78) src/ClipBase.cpp (+22/-22) src/Color.cpp (+20/-15) src/Coordinate.cpp (+25/-19) src/DecklinkReader.cpp (+14/-10) src/DummyReader.cpp (+16/-11) src/EffectBase.cpp (+25/-20) src/EffectInfo.cpp (+5/-3) src/FFmpegReader.cpp (+21/-14) src/FrameMapper.cpp (+17/-12) src/ImageReader.cpp (+19/-14) src/KeyFrame.cpp (+21/-16) src/Point.cpp (+21/-16) src/Profiles.cpp (+38/-30) src/QtImageReader.cpp (+19/-13) src/ReaderBase.cpp (+76/-78) src/TextReader.cpp (+31/-26) src/Timeline.cpp (+93/-81) src/WriterBase.cpp (+88/-84) src/effects/Brightness.cpp (+26/-18) src/effects/ChromaKey.cpp (+25/-17) src/effects/Deinterlace.cpp (+23/-15) src/effects/Mask.cpp (+35/-27) src/effects/Negate.cpp (+20/-12) src/effects/Saturation.cpp (+22/-14) tests/Clip_Tests.cpp (+24/-20) tests/ReaderBase_Tests.cpp (+2/-2) thirdparty/jsoncpp/LICENSE (+0/-1) thirdparty/jsoncpp/include/json/autolink.h (+0/-19) thirdparty/jsoncpp/include/json/config.h (+0/-43) thirdparty/jsoncpp/include/json/features.h (+0/-42) thirdparty/jsoncpp/include/json/forwards.h (+0/-39) thirdparty/jsoncpp/include/json/json.h (+0/-10) thirdparty/jsoncpp/include/json/reader.h (+0/-196) thirdparty/jsoncpp/include/json/value.h (+0/-1069) thirdparty/jsoncpp/include/json/writer.h (+0/-174) thirdparty/jsoncpp/src/lib_json/json_batchallocator.h (+0/-125) thirdparty/jsoncpp/src/lib_json/json_internalarray.inl (+0/-448) thirdparty/jsoncpp/src/lib_json/json_internalmap.inl (+0/-607) thirdparty/jsoncpp/src/lib_json/json_reader.cpp (+0/-883) thirdparty/jsoncpp/src/lib_json/json_value.cpp (+0/-1717) thirdparty/jsoncpp/src/lib_json/json_valueiterator.inl (+0/-292) thirdparty/jsoncpp/src/lib_json/json_writer.cpp (+0/-828) thirdparty/jsoncpp/src/lib_json/sconscript (+0/-8) |
To merge this branch: | bzr merge lp:~saiarcot895/libopenshot/qt-json |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenShot Code | Pending | ||
Review via email: mp+273331@code.launchpad.net |
Commit message
Description of the change
Switch from using JsonCPP to Qt Json.
Some things to note:
1. Qt 5.2 is required for this patch. If Qt 5.1 compatibility is needed, I can provide it.
2. The final JSON output with this patch is likely not compatible with the JSON output in the current version. This is in part because integers are being stored as literal integers instead of being converted to strings.
3. While none of the tests (I only found one) involving reading/writing JSON seem to have failed, there may be errors in the patch.
On another note, I found that the video length was being stored in "long int", which is 32 bits on Windows and 64 bits on Linux/Mac. Because of this, the lines that read/write the video length might not compile or work correctly on Windows.
Unmerged revisions
- 478. By Saikrishna Arcot
-
Switch from JsonCPP to Qt JSON.
Preview Diff
1 | === modified file 'include/ChunkReader.h' |
2 | --- include/ChunkReader.h 2015-08-24 06:05:48 +0000 |
3 | +++ include/ChunkReader.h 2015-10-04 15:21:00 +0000 |
4 | @@ -158,8 +158,8 @@ |
5 | /// Get and Set JSON methods |
6 | string Json(); ///< Generate JSON string of this object |
7 | void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object |
8 | - Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
9 | - void SetJsonValue(Json::Value root) throw(InvalidFile); ///< Load Json::JsonValue into this object |
10 | + QJsonObject JsonValue(); ///< Generate QJsonObject for this object |
11 | + void SetJsonValue(const QJsonObject root) throw(InvalidFile); ///< Load QJsonObject into this object |
12 | |
13 | /// Open the reader. This is required before you can access frames or data from the reader. |
14 | void Open() throw(InvalidFile); |
15 | |
16 | === modified file 'include/ChunkWriter.h' |
17 | --- include/ChunkWriter.h 2015-02-05 06:11:55 +0000 |
18 | +++ include/ChunkWriter.h 2015-10-04 15:21:00 +0000 |
19 | @@ -44,7 +44,6 @@ |
20 | #include "Magick++.h" |
21 | #include "Cache.h" |
22 | #include "Exceptions.h" |
23 | -#include "Json.h" |
24 | #include "Sleep.h" |
25 | |
26 | |
27 | |
28 | === modified file 'include/Clip.h' |
29 | --- include/Clip.h 2015-08-24 06:05:48 +0000 |
30 | +++ include/Clip.h 2015-10-04 15:21:00 +0000 |
31 | @@ -193,8 +193,8 @@ |
32 | /// Get and Set JSON methods |
33 | string Json(); ///< Generate JSON string of this object |
34 | void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object |
35 | - Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
36 | - void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object |
37 | + QJsonObject JsonValue(); ///< Generate QJsonObject for this object |
38 | + void SetJsonValue(QJsonObject root); ///< Load QJsonObject into this object |
39 | |
40 | /// Get all properties for a specific frame (perfect for a UI to display the current state |
41 | /// of all properties at any time) |
42 | |
43 | === modified file 'include/ClipBase.h' |
44 | --- include/ClipBase.h 2015-10-02 23:22:10 +0000 |
45 | +++ include/ClipBase.h 2015-10-04 15:21:00 +0000 |
46 | @@ -59,10 +59,10 @@ |
47 | string previous_properties; ///< This string contains the previous JSON properties |
48 | |
49 | /// Generate JSON for a property |
50 | - Json::Value add_property_json(string name, float value, string type, string memo, bool contains_point, int number_of_points, float min_value, float max_value, InterpolationType intepolation, int closest_point_x, bool readonly); |
51 | + QJsonObject add_property_json(string name, float value, string type, string memo, bool contains_point, int number_of_points, float min_value, float max_value, InterpolationType intepolation, int closest_point_x, bool readonly); |
52 | |
53 | /// Generate JSON choice for a property (dropdown properties) |
54 | - Json::Value add_property_choice_json(string name, int value, int selected_value); |
55 | + QJsonObject add_property_choice_json(string name, int value, int selected_value); |
56 | |
57 | public: |
58 | |
59 | @@ -90,8 +90,8 @@ |
60 | /// Get and Set JSON methods |
61 | virtual string Json() = 0; ///< Generate JSON string of this object |
62 | virtual void SetJson(string value) throw(InvalidJSON) = 0; ///< Load JSON string into this object |
63 | - virtual Json::Value JsonValue() = 0; ///< Generate Json::JsonValue for this object |
64 | - virtual void SetJsonValue(Json::Value root) = 0; ///< Load Json::JsonValue into this object |
65 | + virtual QJsonObject JsonValue() = 0; ///< Generate QJsonObject for this object |
66 | + virtual void SetJsonValue(const QJsonObject root) = 0; ///< Load QJsonObject into this object |
67 | |
68 | /// Get all properties for a specific frame (perfect for a UI to display the current state |
69 | /// of all properties at any time) |
70 | |
71 | === modified file 'include/Color.h' |
72 | --- include/Color.h 2015-08-24 06:05:48 +0000 |
73 | +++ include/Color.h 2015-10-04 15:21:00 +0000 |
74 | @@ -67,9 +67,9 @@ |
75 | |
76 | /// Get and Set JSON methods |
77 | string Json(); ///< Generate JSON string of this object |
78 | - Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
79 | + QJsonObject JsonValue(); ///< Generate QJsonObject for this object |
80 | void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object |
81 | - void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object |
82 | + void SetJsonValue(QJsonObject root); ///< Load QJsonObject into this object |
83 | }; |
84 | |
85 | |
86 | |
87 | === modified file 'include/Coordinate.h' |
88 | --- include/Coordinate.h 2015-02-05 06:11:55 +0000 |
89 | +++ include/Coordinate.h 2015-10-04 15:21:00 +0000 |
90 | @@ -92,9 +92,9 @@ |
91 | |
92 | /// Get and Set JSON methods |
93 | string Json(); ///< Generate JSON string of this object |
94 | - Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
95 | + QJsonObject JsonValue(); ///< Generate QJsonObject for this object |
96 | void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object |
97 | - void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object |
98 | + void SetJsonValue(QJsonObject root); ///< Load QJsonObject into this object |
99 | }; |
100 | |
101 | } |
102 | |
103 | === modified file 'include/DecklinkReader.h' |
104 | --- include/DecklinkReader.h 2015-08-24 06:05:48 +0000 |
105 | +++ include/DecklinkReader.h 2015-10-04 15:21:00 +0000 |
106 | @@ -117,8 +117,8 @@ |
107 | /// Get and Set JSON methods |
108 | string Json(); ///< Generate JSON string of this object |
109 | void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object |
110 | - Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
111 | - void SetJsonValue(Json::Value root) throw(InvalidFile); ///< Load Json::JsonValue into this object |
112 | + QJsonObject JsonValue(); ///< Generate QJsonObject for this object |
113 | + void SetJsonValue(QJsonObject root) throw(InvalidFile); ///< Load QJsonObject into this object |
114 | |
115 | /// Open device and video stream - which is called by the constructor automatically |
116 | void Open() throw(DecklinkError); |
117 | |
118 | === modified file 'include/DummyReader.h' |
119 | --- include/DummyReader.h 2015-08-24 06:05:48 +0000 |
120 | +++ include/DummyReader.h 2015-10-04 15:21:00 +0000 |
121 | @@ -84,8 +84,8 @@ |
122 | /// Get and Set JSON methods |
123 | string Json(); ///< Generate JSON string of this object |
124 | void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object |
125 | - Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
126 | - void SetJsonValue(Json::Value root) throw(InvalidFile); ///< Load Json::JsonValue into this object |
127 | + QJsonObject JsonValue(); ///< Generate QJsonObject for this object |
128 | + void SetJsonValue(QJsonObject root) throw(InvalidFile); ///< Load QJsonObject into this object |
129 | |
130 | /// Open File - which is called by the constructor automatically |
131 | void Open() throw(InvalidFile); |
132 | |
133 | === modified file 'include/EffectBase.h' |
134 | --- include/EffectBase.h 2015-08-24 06:05:48 +0000 |
135 | +++ include/EffectBase.h 2015-10-04 15:21:00 +0000 |
136 | @@ -93,9 +93,9 @@ |
137 | /// Get and Set JSON methods |
138 | virtual string Json() = 0; ///< Generate JSON string of this object |
139 | virtual void SetJson(string value) throw(InvalidJSON) = 0; ///< Load JSON string into this object |
140 | - virtual Json::Value JsonValue() = 0; ///< Generate Json::JsonValue for this object |
141 | - virtual void SetJsonValue(Json::Value root) = 0; ///< Load Json::JsonValue into this object |
142 | - Json::Value JsonInfo(); ///< Generate JSON object of meta data / info |
143 | + virtual QJsonObject JsonValue() = 0; ///< Generate QJsonObject for this object |
144 | + virtual void SetJsonValue(const QJsonObject root) = 0; ///< Load QJsonObject into this object |
145 | + QJsonObject JsonInfo(); ///< Generate JSON object of meta data / info |
146 | |
147 | /// Get the order that this effect should be executed. |
148 | int Order() { return order; } |
149 | |
150 | === modified file 'include/EffectInfo.h' |
151 | --- include/EffectInfo.h 2015-08-07 01:01:34 +0000 |
152 | +++ include/EffectInfo.h 2015-10-04 15:21:00 +0000 |
153 | @@ -48,7 +48,7 @@ |
154 | |
155 | /// JSON methods |
156 | static string Json(); ///< Generate JSON string of this object |
157 | - static Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
158 | + static QJsonArray JsonValue(); ///< Generate QJsonArray for this object |
159 | |
160 | }; |
161 | |
162 | |
163 | === modified file 'include/FFmpegReader.h' |
164 | --- include/FFmpegReader.h 2015-08-24 06:05:48 +0000 |
165 | +++ include/FFmpegReader.h 2015-10-04 15:21:00 +0000 |
166 | @@ -255,8 +255,8 @@ |
167 | /// Get and Set JSON methods |
168 | string Json(); ///< Generate JSON string of this object |
169 | void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object |
170 | - Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
171 | - void SetJsonValue(Json::Value root) throw(InvalidFile); ///< Load Json::JsonValue into this object |
172 | + QJsonObject JsonValue(); ///< Generate QJsonObject for this object |
173 | + void SetJsonValue(QJsonObject root) throw(InvalidFile); ///< Load QJsonObject into this object |
174 | |
175 | /// Open File - which is called by the constructor automatically |
176 | void Open() throw(InvalidFile, NoStreamsFound, InvalidCodec); |
177 | |
178 | === modified file 'include/FrameMapper.h' |
179 | --- include/FrameMapper.h 2015-08-24 06:05:48 +0000 |
180 | +++ include/FrameMapper.h 2015-10-04 15:21:00 +0000 |
181 | @@ -192,8 +192,8 @@ |
182 | /// Get and Set JSON methods |
183 | string Json(); ///< Generate JSON string of this object |
184 | void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object |
185 | - Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
186 | - void SetJsonValue(Json::Value root) throw(InvalidFile); ///< Load Json::JsonValue into this object |
187 | + QJsonObject JsonValue(); ///< Generate QJsonObject for this object |
188 | + void SetJsonValue(QJsonObject root) throw(InvalidFile); ///< Load QJsonObject into this object |
189 | |
190 | /// Open the internal reader |
191 | void Open() throw(InvalidFile); |
192 | |
193 | === modified file 'include/ImageReader.h' |
194 | --- include/ImageReader.h 2015-08-24 06:05:48 +0000 |
195 | +++ include/ImageReader.h 2015-10-04 15:21:00 +0000 |
196 | @@ -96,8 +96,8 @@ |
197 | /// Get and Set JSON methods |
198 | string Json(); ///< Generate JSON string of this object |
199 | void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object |
200 | - Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
201 | - void SetJsonValue(Json::Value root) throw(InvalidFile); ///< Load Json::JsonValue into this object |
202 | + QJsonObject JsonValue(); ///< Generate QJsonObject for this object |
203 | + void SetJsonValue(QJsonObject root) throw(InvalidFile); ///< Load QJsonObject into this object |
204 | |
205 | /// Open File - which is called by the constructor automatically |
206 | void Open() throw(InvalidFile); |
207 | |
208 | === modified file 'include/Json.h' |
209 | --- include/Json.h 2014-07-11 21:52:14 +0000 |
210 | +++ include/Json.h 2015-10-04 15:21:00 +0000 |
211 | @@ -28,6 +28,10 @@ |
212 | #ifndef OPENSHOT_JSON_H |
213 | #define OPENSHOT_JSON_H |
214 | |
215 | -#include "../thirdparty/jsoncpp/include/json/json.h" |
216 | +#include <QtCore/QJsonDocument> |
217 | +#include <QtCore/QJsonArray> |
218 | +#include <QtCore/QJsonObject> |
219 | +#include <QtCore/QJsonParseError> |
220 | +#include <QtCore/QVariant> // Needed for int conversion |
221 | |
222 | #endif |
223 | |
224 | === modified file 'include/KeyFrame.h' |
225 | --- include/KeyFrame.h 2015-08-24 06:05:48 +0000 |
226 | +++ include/KeyFrame.h 2015-10-04 15:21:00 +0000 |
227 | @@ -152,9 +152,9 @@ |
228 | |
229 | /// Get and Set JSON methods |
230 | string Json(); ///< Generate JSON string of this object |
231 | - Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
232 | + QJsonObject JsonValue(); ///< Generate QJsonObject for this object |
233 | void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object |
234 | - void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object |
235 | + void SetJsonValue(QJsonObject root); ///< Load QJsonObject into this object |
236 | |
237 | /** |
238 | * @brief Calculate all of the values for this keyframe. |
239 | |
240 | === modified file 'include/Point.h' |
241 | --- include/Point.h 2015-02-21 06:12:21 +0000 |
242 | +++ include/Point.h 2015-10-04 15:21:00 +0000 |
243 | @@ -116,9 +116,9 @@ |
244 | |
245 | /// Get and Set JSON methods |
246 | string Json(); ///< Generate JSON string of this object |
247 | - Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
248 | + QJsonObject JsonValue(); ///< Generate QJsonObject for this object |
249 | void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object |
250 | - void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object |
251 | + void SetJsonValue(const QJsonObject root); ///< Load QJsonObject into this object |
252 | |
253 | }; |
254 | |
255 | |
256 | === modified file 'include/Profiles.h' |
257 | --- include/Profiles.h 2014-07-11 21:52:14 +0000 |
258 | +++ include/Profiles.h 2015-10-04 15:21:00 +0000 |
259 | @@ -88,9 +88,9 @@ |
260 | |
261 | /// Get and Set JSON methods |
262 | string Json(); ///< Generate JSON string of this object |
263 | - Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
264 | + QJsonObject JsonValue(); ///< Generate QJsonObject for this object |
265 | void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object |
266 | - void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object |
267 | + void SetJsonValue(const QJsonObject root); ///< Load QJsonObject into this object |
268 | }; |
269 | |
270 | } |
271 | |
272 | === modified file 'include/QtImageReader.h' |
273 | --- include/QtImageReader.h 2015-08-24 06:05:48 +0000 |
274 | +++ include/QtImageReader.h 2015-10-04 15:21:00 +0000 |
275 | @@ -98,8 +98,8 @@ |
276 | /// Get and Set JSON methods |
277 | string Json(); ///< Generate JSON string of this object |
278 | void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object |
279 | - Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
280 | - void SetJsonValue(Json::Value root) throw(InvalidFile); ///< Load Json::JsonValue into this object |
281 | + QJsonObject JsonValue(); ///< Generate QJsonObject for this object |
282 | + void SetJsonValue(QJsonObject root) throw(InvalidFile); ///< Load QJsonObject into this object |
283 | |
284 | /// Open File - which is called by the constructor automatically |
285 | void Open() throw(InvalidFile); |
286 | |
287 | === modified file 'include/ReaderBase.h' |
288 | --- include/ReaderBase.h 2015-09-29 03:05:50 +0000 |
289 | +++ include/ReaderBase.h 2015-10-04 15:21:00 +0000 |
290 | @@ -98,10 +98,10 @@ |
291 | CriticalSection processingCriticalSection; |
292 | |
293 | /// Debug JSON root |
294 | - Json::Value debug_root; |
295 | + QJsonArray debug_root; |
296 | |
297 | /// Append debug information as JSON |
298 | - void AppendDebugItem(Json::Value debug_item); |
299 | + void AppendDebugItem(QJsonValue debug_item); |
300 | |
301 | /// Append debug information as JSON |
302 | void AppendDebugMethod(string method_name, string arg1_name, float arg1_value, |
303 | @@ -152,8 +152,8 @@ |
304 | /// Get and Set JSON methods |
305 | virtual string Json() = 0; ///< Generate JSON string of this object |
306 | virtual void SetJson(string value) throw(InvalidJSON) = 0; ///< Load JSON string into this object |
307 | - virtual Json::Value JsonValue() = 0; ///< Generate Json::JsonValue for this object |
308 | - virtual void SetJsonValue(Json::Value root) = 0; ///< Load Json::JsonValue into this object |
309 | + virtual QJsonObject JsonValue() = 0; ///< Generate QJsonObject for this object |
310 | + virtual void SetJsonValue(const QJsonObject root) = 0; ///< Load QJsonObject into this object |
311 | |
312 | /// Open the reader (and start consuming resources, such as images or video files) |
313 | virtual void Open() = 0; |
314 | |
315 | === modified file 'include/TextReader.h' |
316 | --- include/TextReader.h 2015-08-24 06:05:48 +0000 |
317 | +++ include/TextReader.h 2015-10-04 15:21:00 +0000 |
318 | @@ -132,8 +132,8 @@ |
319 | /// Get and Set JSON methods |
320 | string Json(); ///< Generate JSON string of this object |
321 | void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object |
322 | - Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
323 | - void SetJsonValue(Json::Value root) throw(InvalidFile); ///< Load Json::JsonValue into this object |
324 | + QJsonObject JsonValue(); ///< Generate QJsonObject for this object |
325 | + void SetJsonValue(const QJsonObject root) throw(InvalidFile); ///< Load QJsonObject into this object |
326 | |
327 | /// Open Reader - which is called by the constructor automatically |
328 | void Open(); |
329 | |
330 | === modified file 'include/Timeline.h' |
331 | --- include/Timeline.h 2015-08-24 06:05:48 +0000 |
332 | +++ include/Timeline.h 2015-10-04 15:21:00 +0000 |
333 | @@ -156,10 +156,10 @@ |
334 | void apply_mapper_to_clip(Clip* clip); |
335 | |
336 | /// Apply JSON Diffs to various objects contained in this timeline |
337 | - void apply_json_to_clips(Json::Value change) throw(InvalidJSONKey); ///<Apply JSON diff to clips |
338 | - void apply_json_to_effects(Json::Value change) throw(InvalidJSONKey); ///< Apply JSON diff to effects |
339 | - void apply_json_to_effects(Json::Value change, EffectBase* existing_effect) throw(InvalidJSONKey); ///<Apply JSON diff to a specific effect |
340 | - void apply_json_to_timeline(Json::Value change) throw(InvalidJSONKey); ///<Apply JSON diff to timeline properties |
341 | + void apply_json_to_clips(QJsonObject change) throw(InvalidJSONKey); ///<Apply JSON diff to clips |
342 | + void apply_json_to_effects(QJsonObject change) throw(InvalidJSONKey); ///<Apply JSON diff to effects |
343 | + void apply_json_to_effects(QJsonObject change, EffectBase* existing_effect) throw(InvalidJSONKey); ///<Apply JSON diff to a specific effect |
344 | + void apply_json_to_timeline(QJsonObject change) throw(InvalidJSONKey); ///<Apply JSON diff to timeline properties |
345 | |
346 | /// Calculate time of a frame number, based on a framerate |
347 | float calculate_time(long int number, Fraction rate); |
348 | @@ -247,8 +247,8 @@ |
349 | /// Get and Set JSON methods |
350 | string Json(); ///< Generate JSON string of this object |
351 | void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object |
352 | - Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
353 | - void SetJsonValue(Json::Value root) throw(InvalidFile, ReaderClosed); ///< Load Json::JsonValue into this object |
354 | + QJsonObject JsonValue(); ///< Generate QJsonObject for this object |
355 | + void SetJsonValue(QJsonObject root) throw(InvalidFile, ReaderClosed); ///< Load QJsonObject into this object |
356 | |
357 | /// @brief Apply a special formatted JSON object, which represents a change to the timeline (add, update, delete) |
358 | /// This is primarily designed to keep the timeline (and its child objects... such as clips and effects) in sync |
359 | |
360 | === modified file 'include/WriterBase.h' |
361 | --- include/WriterBase.h 2015-09-29 03:05:50 +0000 |
362 | +++ include/WriterBase.h 2015-10-04 15:21:00 +0000 |
363 | @@ -86,10 +86,10 @@ |
364 | protected: |
365 | |
366 | /// Debug JSON root |
367 | - Json::Value debug_root; |
368 | + QJsonArray debug_root; |
369 | |
370 | /// Append debug information as JSON |
371 | - void AppendDebugItem(Json::Value debug_item); |
372 | + void AppendDebugItem(QJsonValue debug_item); |
373 | |
374 | /// Append debug information as JSON |
375 | void AppendDebugMethod(string method_name, string arg1_name, float arg1_value, |
376 | @@ -125,9 +125,9 @@ |
377 | |
378 | /// Get and Set JSON methods |
379 | string Json(); ///< Generate JSON string of this object |
380 | - Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
381 | + QJsonObject JsonValue(); ///< Generate QJsonObject for this object |
382 | void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object |
383 | - void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object |
384 | + void SetJsonValue(const QJsonObject root); ///< Load QJsonObject into this object |
385 | |
386 | /// Display file information in the standard output stream (stdout) |
387 | void DisplayInfo(); |
388 | |
389 | === modified file 'include/effects/Brightness.h' |
390 | --- include/effects/Brightness.h 2015-08-24 06:05:48 +0000 |
391 | +++ include/effects/Brightness.h 2015-10-04 15:21:00 +0000 |
392 | @@ -95,8 +95,8 @@ |
393 | /// Get and Set JSON methods |
394 | string Json(); ///< Generate JSON string of this object |
395 | void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object |
396 | - Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
397 | - void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object |
398 | + QJsonObject JsonValue(); ///< Generate QJsonObject for this object |
399 | + void SetJsonValue(QJsonObject root); ///< Load QJsonObject into this object |
400 | |
401 | /// Get all properties for a specific frame (perfect for a UI to display the current state |
402 | /// of all properties at any time) |
403 | |
404 | === modified file 'include/effects/ChromaKey.h' |
405 | --- include/effects/ChromaKey.h 2015-08-24 06:05:48 +0000 |
406 | +++ include/effects/ChromaKey.h 2015-10-04 15:21:00 +0000 |
407 | @@ -88,8 +88,8 @@ |
408 | /// Get and Set JSON methods |
409 | string Json(); ///< Generate JSON string of this object |
410 | void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object |
411 | - Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
412 | - void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object |
413 | + QJsonObject JsonValue(); ///< Generate QJsonObject for this object |
414 | + void SetJsonValue(QJsonObject root); ///< Load QJsonObject into this object |
415 | |
416 | // Get all properties for a specific frame |
417 | string PropertiesJSON(long int requested_frame); |
418 | |
419 | === modified file 'include/effects/Deinterlace.h' |
420 | --- include/effects/Deinterlace.h 2015-08-24 06:05:48 +0000 |
421 | +++ include/effects/Deinterlace.h 2015-10-04 15:21:00 +0000 |
422 | @@ -84,8 +84,8 @@ |
423 | /// Get and Set JSON methods |
424 | string Json(); ///< Generate JSON string of this object |
425 | void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object |
426 | - Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
427 | - void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object |
428 | + QJsonObject JsonValue(); ///< Generate QJsonObject for this object |
429 | + void SetJsonValue(QJsonObject root); ///< Load QJsonObject into this object |
430 | |
431 | // Get all properties for a specific frame |
432 | string PropertiesJSON(long int requested_frame); |
433 | |
434 | === modified file 'include/effects/Mask.h' |
435 | --- include/effects/Mask.h 2015-08-24 06:05:48 +0000 |
436 | +++ include/effects/Mask.h 2015-10-04 15:21:00 +0000 |
437 | @@ -104,8 +104,8 @@ |
438 | /// Get and Set JSON methods |
439 | string Json(); ///< Generate JSON string of this object |
440 | void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object |
441 | - Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
442 | - void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object |
443 | + QJsonObject JsonValue(); ///< Generate QJsonObject for this object |
444 | + void SetJsonValue(QJsonObject root); ///< Load QJsonObject into this object |
445 | |
446 | /// Get all properties for a specific frame (perfect for a UI to display the current state |
447 | /// of all properties at any time) |
448 | |
449 | === modified file 'include/effects/Negate.h' |
450 | --- include/effects/Negate.h 2015-08-24 06:05:48 +0000 |
451 | +++ include/effects/Negate.h 2015-10-04 15:21:00 +0000 |
452 | @@ -72,8 +72,8 @@ |
453 | /// Get and Set JSON methods |
454 | string Json(); ///< Generate JSON string of this object |
455 | void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object |
456 | - Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
457 | - void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object |
458 | + QJsonObject JsonValue(); ///< Generate QJsonObject for this object |
459 | + void SetJsonValue(QJsonObject root); ///< Load QJsonObject into this object |
460 | |
461 | // Get all properties for a specific frame |
462 | string PropertiesJSON(long int requested_frame); |
463 | |
464 | === modified file 'include/effects/Saturation.h' |
465 | --- include/effects/Saturation.h 2015-08-24 06:05:48 +0000 |
466 | +++ include/effects/Saturation.h 2015-10-04 15:21:00 +0000 |
467 | @@ -92,8 +92,8 @@ |
468 | /// Get and Set JSON methods |
469 | string Json(); ///< Generate JSON string of this object |
470 | void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object |
471 | - Json::Value JsonValue(); ///< Generate Json::JsonValue for this object |
472 | - void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object |
473 | + QJsonObject JsonValue(); ///< Generate QJsonObject for this object |
474 | + void SetJsonValue(QJsonObject root); ///< Load QJsonObject into this object |
475 | |
476 | /// Get all properties for a specific frame (perfect for a UI to display the current state |
477 | /// of all properties at any time) |
478 | |
479 | === modified file 'src/CMakeLists.txt' |
480 | --- src/CMakeLists.txt 2015-08-07 01:01:34 +0000 |
481 | +++ src/CMakeLists.txt 2015-10-04 15:21:00 +0000 |
482 | @@ -145,10 +145,6 @@ |
483 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} ") |
484 | endif(OPENMP_FOUND) |
485 | |
486 | -################### JSONCPP ##################### |
487 | -# Include jsoncpp headers (needed for JSON parsing) |
488 | -include_directories("../thirdparty/jsoncpp/include") |
489 | - |
490 | ############### PROFILING ################# |
491 | #set(PROFILER "/usr/lib/libprofiler.so.0.3.2") |
492 | #set(PROFILER "/usr/lib/libtcmalloc.so.4") |
493 | @@ -196,12 +192,7 @@ |
494 | |
495 | # Qt Video Player |
496 | ${QT_PLAYER_FILES} |
497 | - ${MOC_FILES} |
498 | - |
499 | - # Third Party JSON Parser |
500 | - ../thirdparty/jsoncpp/src/lib_json/json_reader.cpp |
501 | - ../thirdparty/jsoncpp/src/lib_json/json_value.cpp |
502 | - ../thirdparty/jsoncpp/src/lib_json/json_writer.cpp ) |
503 | + ${MOC_FILES} ) |
504 | |
505 | IF (BLACKMAGIC_FOUND) |
506 | SET ( OPENSHOT_SOURCE_FILES ${OPENSHOT_SOURCE_FILES} |
507 | |
508 | === modified file 'src/ChunkReader.cpp' |
509 | --- src/ChunkReader.cpp 2015-08-24 06:05:48 +0000 |
510 | +++ src/ChunkReader.cpp 2015-10-04 15:21:00 +0000 |
511 | @@ -74,45 +74,51 @@ |
512 | } |
513 | |
514 | // Parse JSON string into JSON objects |
515 | - Json::Value root; |
516 | - Json::Reader reader; |
517 | - bool success = reader.parse( json_string.str(), root ); |
518 | - if (!success) |
519 | + QJsonParseError errors; |
520 | + |
521 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(json_string.str().c_str()), &errors); |
522 | + if (errors.error != QJsonParseError::NoError) { |
523 | // Raise exception |
524 | throw InvalidJSON("Chunk folder could not be opened.", path); |
525 | - |
526 | + } |
527 | + const QJsonObject root = document.object(); |
528 | |
529 | // Set info from the JSON objects |
530 | try |
531 | { |
532 | - info.has_video = root["has_video"].asBool(); |
533 | - info.has_audio = root["has_audio"].asBool(); |
534 | - info.duration = root["duration"].asDouble(); |
535 | - info.file_size = atoll(root["file_size"].asString().c_str()); |
536 | - info.height = root["height"].asInt(); |
537 | - info.width = root["width"].asInt(); |
538 | - info.pixel_format = root["pixel_format"].asInt(); |
539 | - info.fps.num = root["fps"]["num"].asInt(); |
540 | - info.fps.den = root["fps"]["den"].asInt(); |
541 | - info.video_bit_rate = root["video_bit_rate"].asUInt(); |
542 | - info.pixel_ratio.num = root["pixel_ratio"]["num"].asInt(); |
543 | - info.pixel_ratio.den = root["pixel_ratio"]["den"].asInt(); |
544 | - info.display_ratio.num = root["display_ratio"]["num"].asInt(); |
545 | - info.display_ratio.den = root["display_ratio"]["den"].asInt(); |
546 | - info.vcodec = root["vcodec"].asString(); |
547 | - info.video_length = atoll(root["video_length"].asString().c_str()); |
548 | - info.video_stream_index = root["video_stream_index"].asInt(); |
549 | - info.video_timebase.num = root["video_timebase"]["num"].asInt(); |
550 | - info.video_timebase.den = root["video_timebase"]["den"].asInt(); |
551 | - info.interlaced_frame = root["interlaced_frame"].asBool(); |
552 | - info.top_field_first = root["top_field_first"].asBool(); |
553 | - info.acodec = root["acodec"].asString(); |
554 | - info.audio_bit_rate = root["audio_bit_rate"].asUInt(); |
555 | - info.sample_rate = root["sample_rate"].asUInt(); |
556 | - info.channels = root["channels"].asInt(); |
557 | - info.audio_stream_index = root["audio_stream_index"].asInt(); |
558 | - info.audio_timebase.num = root["audio_timebase"]["num"].asInt(); |
559 | - info.audio_timebase.den = root["audio_timebase"]["den"].asInt(); |
560 | + info.has_video = root["has_video"].toBool(); |
561 | + info.has_audio = root["has_audio"].toBool(); |
562 | + info.duration = root["duration"].toDouble(); |
563 | + info.file_size = root["file_size"].toVariant().toLongLong(); |
564 | + info.height = root["height"].toVariant().toInt(); |
565 | + info.width = root["width"].toVariant().toInt(); |
566 | + info.pixel_format = root["pixel_format"].toVariant().toInt(); |
567 | + const QJsonObject fpsObject = root["fps"].toObject(); |
568 | + info.fps.num = fpsObject["num"].toVariant().toInt(); |
569 | + info.fps.den = fpsObject["den"].toVariant().toInt(); |
570 | + info.video_bit_rate = root["video_bit_rate"].toVariant().toUInt(); |
571 | + const QJsonObject pixelRatioObject = root["pixel_ratio"].toObject(); |
572 | + info.pixel_ratio.num = pixelRatioObject["num"].toVariant().toInt(); |
573 | + info.pixel_ratio.den = pixelRatioObject["den"].toVariant().toInt(); |
574 | + const QJsonObject displayRatioObject = root["display_ratio"].toObject(); |
575 | + info.display_ratio.num = displayRatioObject["num"].toVariant().toInt(); |
576 | + info.display_ratio.den = displayRatioObject["den"].toVariant().toInt(); |
577 | + info.vcodec = root["vcodec"].toString().toLocal8Bit().constData(); |
578 | + info.video_length = root["video_length"].toVariant().toLongLong(); |
579 | + info.video_stream_index = root["video_stream_index"].toVariant().toInt(); |
580 | + const QJsonObject videoTimebaseObject = root["video_timebase"].toObject(); |
581 | + info.video_timebase.num = videoTimebaseObject["num"].toVariant().toInt(); |
582 | + info.video_timebase.den = videoTimebaseObject["den"].toVariant().toInt(); |
583 | + info.interlaced_frame = root["interlaced_frame"].toBool(); |
584 | + info.top_field_first = root["top_field_first"].toBool(); |
585 | + info.acodec = root["acodec"].toString().toLocal8Bit().constData(); |
586 | + info.audio_bit_rate = root["audio_bit_rate"].toVariant().toUInt(); |
587 | + info.sample_rate = root["sample_rate"].toVariant().toUInt(); |
588 | + info.channels = root["channels"].toVariant().toInt(); |
589 | + info.audio_stream_index = root["audio_stream_index"].toVariant().toInt(); |
590 | + const QJsonObject audioTimebaseObject = root["audio_timebase"].toObject(); |
591 | + info.audio_timebase.num = audioTimebaseObject["num"].toVariant().toInt(); |
592 | + info.audio_timebase.den = audioTimebaseObject["den"].toVariant().toInt(); |
593 | |
594 | } |
595 | catch (exception e) |
596 | @@ -253,17 +259,18 @@ |
597 | // Generate JSON string of this object |
598 | string ChunkReader::Json() { |
599 | |
600 | - // Return formatted string |
601 | - return JsonValue().toStyledString(); |
602 | + QJsonDocument document; |
603 | + document.setObject(JsonValue()); |
604 | + return document.toJson().constData(); |
605 | } |
606 | |
607 | -// Generate Json::JsonValue for this object |
608 | -Json::Value ChunkReader::JsonValue() { |
609 | +// Generate QJsonObject for this object |
610 | +QJsonObject ChunkReader::JsonValue() { |
611 | |
612 | // Create root json object |
613 | - Json::Value root = ReaderBase::JsonValue(); // get parent properties |
614 | + QJsonObject root = ReaderBase::JsonValue(); // get parent properties |
615 | root["type"] = "ChunkReader"; |
616 | - root["path"] = path; |
617 | + root["path"] = path.c_str(); |
618 | root["chunk_size"] = chunk_size; |
619 | root["chunk_version"] = version; |
620 | |
621 | @@ -275,12 +282,16 @@ |
622 | void ChunkReader::SetJson(string value) throw(InvalidJSON) { |
623 | |
624 | // Parse JSON string into JSON objects |
625 | - Json::Value root; |
626 | - Json::Reader reader; |
627 | - bool success = reader.parse( value, root ); |
628 | - if (!success) |
629 | + QJsonObject root; |
630 | + QJsonParseError errors; |
631 | + |
632 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
633 | + if (errors.error != QJsonParseError::NoError) { |
634 | // Raise exception |
635 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
636 | + } |
637 | + |
638 | + root = document.object(); |
639 | |
640 | try |
641 | { |
642 | @@ -294,19 +305,19 @@ |
643 | } |
644 | } |
645 | |
646 | -// Load Json::JsonValue into this object |
647 | -void ChunkReader::SetJsonValue(Json::Value root) throw(InvalidFile) { |
648 | +// Load QJsonObject into this object |
649 | +void ChunkReader::SetJsonValue(const QJsonObject root) throw(InvalidFile) { |
650 | |
651 | // Set parent data |
652 | ReaderBase::SetJsonValue(root); |
653 | |
654 | // Set data from Json (if key is found) |
655 | if (!root["path"].isNull()) |
656 | - path = root["path"].asString(); |
657 | + path = root["path"].toString().toLocal8Bit().constData(); |
658 | if (!root["chunk_size"].isNull()) |
659 | - chunk_size = root["chunk_size"].asInt(); |
660 | + chunk_size = root["chunk_size"].toVariant().toInt(); |
661 | if (!root["chunk_version"].isNull()) |
662 | - version = (ChunkVersion) root["chunk_version"].asInt(); |
663 | + version = (ChunkVersion) root["chunk_version"].toVariant().toInt(); |
664 | |
665 | // Re-Open path, and re-init everything (if needed) |
666 | if (is_open) |
667 | |
668 | === modified file 'src/Clip.cpp' |
669 | --- src/Clip.cpp 2015-10-02 23:22:10 +0000 |
670 | +++ src/Clip.cpp 2015-10-04 15:21:00 +0000 |
671 | @@ -145,8 +145,8 @@ |
672 | } catch(...) { |
673 | try |
674 | { |
675 | - // Try a video reader |
676 | - reader = new FFmpegReader(path); |
677 | + // Try a video reader |
678 | + reader = new FFmpegReader(path); |
679 | |
680 | } catch(...) { } |
681 | } |
682 | @@ -531,7 +531,9 @@ |
683 | string Clip::Json() { |
684 | |
685 | // Return formatted string |
686 | - return JsonValue().toStyledString(); |
687 | + QJsonDocument document; |
688 | + document.setObject(JsonValue()); |
689 | + return document.toJson().constData(); |
690 | } |
691 | |
692 | // Get all properties for a specific frame |
693 | @@ -541,7 +543,7 @@ |
694 | Point requested_point(requested_frame, requested_frame); |
695 | |
696 | // Generate JSON properties list |
697 | - Json::Value root; |
698 | + QJsonObject root; |
699 | root["id"] = add_property_json("ID", 0.0, "string", Id(), false, 0, -1, -1, CONSTANT, -1, true); |
700 | root["position"] = add_property_json("Position", Position(), "float", "", false, 0, 0, 1000 * 60 * 30, CONSTANT, -1, false); |
701 | root["layer"] = add_property_json("Layer", Layer(), "int", "", false, 0, 0, 1000, CONSTANT, -1, false); |
702 | @@ -554,29 +556,29 @@ |
703 | root["waveform"] = add_property_json("Waveform", waveform, "bool", "", false, 0, -1, -1, CONSTANT, -1, false); |
704 | |
705 | // Add gravity choices (dropdown style) |
706 | - root["gravity"]["choices"].append(add_property_choice_json("Top Left", GRAVITY_TOP_LEFT, gravity)); |
707 | - root["gravity"]["choices"].append(add_property_choice_json("Top Center", GRAVITY_TOP, gravity)); |
708 | - root["gravity"]["choices"].append(add_property_choice_json("Top Right", GRAVITY_TOP_RIGHT, gravity)); |
709 | - root["gravity"]["choices"].append(add_property_choice_json("Left", GRAVITY_LEFT, gravity)); |
710 | - root["gravity"]["choices"].append(add_property_choice_json("Center", GRAVITY_CENTER, gravity)); |
711 | - root["gravity"]["choices"].append(add_property_choice_json("Right", GRAVITY_RIGHT, gravity)); |
712 | - root["gravity"]["choices"].append(add_property_choice_json("Bottom Left", GRAVITY_BOTTOM_LEFT, gravity)); |
713 | - root["gravity"]["choices"].append(add_property_choice_json("Bottom Center", GRAVITY_BOTTOM, gravity)); |
714 | - root["gravity"]["choices"].append(add_property_choice_json("Bottom Right", GRAVITY_BOTTOM_RIGHT, gravity)); |
715 | + root["gravity"].toObject()["choices"].toArray().append(add_property_choice_json("Top Left", GRAVITY_TOP_LEFT, gravity)); |
716 | + root["gravity"].toObject()["choices"].toArray().append(add_property_choice_json("Top Center", GRAVITY_TOP, gravity)); |
717 | + root["gravity"].toObject()["choices"].toArray().append(add_property_choice_json("Top Right", GRAVITY_TOP_RIGHT, gravity)); |
718 | + root["gravity"].toObject()["choices"].toArray().append(add_property_choice_json("Left", GRAVITY_LEFT, gravity)); |
719 | + root["gravity"].toObject()["choices"].toArray().append(add_property_choice_json("Center", GRAVITY_CENTER, gravity)); |
720 | + root["gravity"].toObject()["choices"].toArray().append(add_property_choice_json("Right", GRAVITY_RIGHT, gravity)); |
721 | + root["gravity"].toObject()["choices"].toArray().append(add_property_choice_json("Bottom Left", GRAVITY_BOTTOM_LEFT, gravity)); |
722 | + root["gravity"].toObject()["choices"].toArray().append(add_property_choice_json("Bottom Center", GRAVITY_BOTTOM, gravity)); |
723 | + root["gravity"].toObject()["choices"].toArray().append(add_property_choice_json("Bottom Right", GRAVITY_BOTTOM_RIGHT, gravity)); |
724 | |
725 | // Add scale choices (dropdown style) |
726 | - root["scale"]["choices"].append(add_property_choice_json("Crop", SCALE_CROP, scale)); |
727 | - root["scale"]["choices"].append(add_property_choice_json("Best Fit", SCALE_FIT, scale)); |
728 | - root["scale"]["choices"].append(add_property_choice_json("Stretch", SCALE_STRETCH, scale)); |
729 | - root["scale"]["choices"].append(add_property_choice_json("None", SCALE_NONE, scale)); |
730 | + root["scale"].toObject()["choices"].toArray().append(add_property_choice_json("Crop", SCALE_CROP, scale)); |
731 | + root["scale"].toObject()["choices"].toArray().append(add_property_choice_json("Best Fit", SCALE_FIT, scale)); |
732 | + root["scale"].toObject()["choices"].toArray().append(add_property_choice_json("Stretch", SCALE_STRETCH, scale)); |
733 | + root["scale"].toObject()["choices"].toArray().append(add_property_choice_json("None", SCALE_NONE, scale)); |
734 | |
735 | // Add anchor choices (dropdown style) |
736 | - root["anchor"]["choices"].append(add_property_choice_json("Canvas", ANCHOR_CANVAS, anchor)); |
737 | - root["anchor"]["choices"].append(add_property_choice_json("Viewport", ANCHOR_VIEWPORT, anchor)); |
738 | + root["anchor"].toObject()["choices"].toArray().append(add_property_choice_json("Canvas", ANCHOR_CANVAS, anchor)); |
739 | + root["anchor"].toObject()["choices"].toArray().append(add_property_choice_json("Viewport", ANCHOR_VIEWPORT, anchor)); |
740 | |
741 | // Add waveform choices (dropdown style) |
742 | - root["waveform"]["choices"].append(add_property_choice_json("Yes", true, waveform)); |
743 | - root["waveform"]["choices"].append(add_property_choice_json("No", false, waveform)); |
744 | + root["waveform"].toObject()["choices"].toArray().append(add_property_choice_json("Yes", true, waveform)); |
745 | + root["waveform"].toObject()["choices"].toArray().append(add_property_choice_json("No", false, waveform)); |
746 | |
747 | // Keyframes |
748 | root["location_x"] = add_property_json("Location X", location_x.GetValue(requested_frame), "float", "", location_x.Contains(requested_point), location_x.GetCount(), -10000, 10000, location_x.GetClosestPoint(requested_point).interpolation, location_x.GetClosestPoint(requested_point).co.X, false); |
749 | @@ -589,14 +591,16 @@ |
750 | root["time"] = add_property_json("Time", time.GetValue(requested_frame), "float", "", time.Contains(requested_point), time.GetCount(), 0.0, 1000 * 60 * 30, time.GetClosestPoint(requested_point).interpolation, time.GetClosestPoint(requested_point).co.X, false); |
751 | |
752 | // Return formatted string |
753 | - return root.toStyledString(); |
754 | + QJsonDocument document; |
755 | + document.setObject(root); |
756 | + return document.toJson().constData(); |
757 | } |
758 | |
759 | // Generate Json::JsonValue for this object |
760 | -Json::Value Clip::JsonValue() { |
761 | +QJsonObject Clip::JsonValue() { |
762 | |
763 | // Create root json object |
764 | - Json::Value root = ClipBase::JsonValue(); // get parent properties |
765 | + QJsonObject root = ClipBase::JsonValue(); // get parent properties |
766 | root["gravity"] = gravity; |
767 | root["scale"] = scale; |
768 | root["anchor"] = anchor; |
769 | @@ -626,7 +630,7 @@ |
770 | root["perspective_c4_y"] = perspective_c4_y.JsonValue(); |
771 | |
772 | // Add array of effects |
773 | - root["effects"] = Json::Value(Json::arrayValue); |
774 | + root["effects"] = QJsonArray(); |
775 | |
776 | // loop through effects |
777 | list<EffectBase*>::iterator effect_itr; |
778 | @@ -634,7 +638,7 @@ |
779 | { |
780 | // Get clip object from the iterator |
781 | EffectBase *existing_effect = (*effect_itr); |
782 | - root["effects"].append(existing_effect->JsonValue()); |
783 | + root["effects"].toArray().append(existing_effect->JsonValue()); |
784 | } |
785 | |
786 | if (reader) |
787 | @@ -648,12 +652,14 @@ |
788 | void Clip::SetJson(string value) throw(InvalidJSON) { |
789 | |
790 | // Parse JSON string into JSON objects |
791 | - Json::Value root; |
792 | - Json::Reader reader; |
793 | - bool success = reader.parse( value, root ); |
794 | - if (!success) |
795 | + QJsonObject root; |
796 | + QJsonParseError errors; |
797 | + |
798 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
799 | + if (errors.error != QJsonParseError::NoError) { |
800 | // Raise exception |
801 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
802 | + } |
803 | |
804 | try |
805 | { |
806 | @@ -668,97 +674,97 @@ |
807 | } |
808 | |
809 | // Load Json::JsonValue into this object |
810 | -void Clip::SetJsonValue(Json::Value root) { |
811 | +void Clip::SetJsonValue(QJsonObject root) { |
812 | |
813 | // Set parent data |
814 | ClipBase::SetJsonValue(root); |
815 | |
816 | // Set data from Json (if key is found) |
817 | if (!root["gravity"].isNull()) |
818 | - gravity = (GravityType) root["gravity"].asInt(); |
819 | + gravity = (GravityType) root["gravity"].toInt(); |
820 | if (!root["scale"].isNull()) |
821 | - scale = (ScaleType) root["scale"].asInt(); |
822 | + scale = (ScaleType) root["scale"].toInt(); |
823 | if (!root["anchor"].isNull()) |
824 | - anchor = (AnchorType) root["anchor"].asInt(); |
825 | + anchor = (AnchorType) root["anchor"].toInt(); |
826 | if (!root["waveform"].isNull()) |
827 | - waveform = root["waveform"].asBool(); |
828 | + waveform = root["waveform"].toBool(); |
829 | if (!root["scale_x"].isNull()) |
830 | - scale_x.SetJsonValue(root["scale_x"]); |
831 | + scale_x.SetJsonValue(root["scale_x"].toObject()); |
832 | if (!root["scale_y"].isNull()) |
833 | - scale_y.SetJsonValue(root["scale_y"]); |
834 | + scale_y.SetJsonValue(root["scale_y"].toObject()); |
835 | if (!root["location_x"].isNull()) |
836 | - location_x.SetJsonValue(root["location_x"]); |
837 | + location_x.SetJsonValue(root["location_x"].toObject()); |
838 | if (!root["location_y"].isNull()) |
839 | - location_y.SetJsonValue(root["location_y"]); |
840 | + location_y.SetJsonValue(root["location_y"].toObject()); |
841 | if (!root["alpha"].isNull()) |
842 | - alpha.SetJsonValue(root["alpha"]); |
843 | + alpha.SetJsonValue(root["alpha"].toObject()); |
844 | if (!root["rotation"].isNull()) |
845 | - rotation.SetJsonValue(root["rotation"]); |
846 | + rotation.SetJsonValue(root["rotation"].toObject()); |
847 | if (!root["time"].isNull()) |
848 | - time.SetJsonValue(root["time"]); |
849 | + time.SetJsonValue(root["time"].toObject()); |
850 | if (!root["volume"].isNull()) |
851 | - volume.SetJsonValue(root["volume"]); |
852 | + volume.SetJsonValue(root["volume"].toObject()); |
853 | if (!root["wave_color"].isNull()) |
854 | - wave_color.SetJsonValue(root["wave_color"]); |
855 | + wave_color.SetJsonValue(root["wave_color"].toObject()); |
856 | if (!root["crop_width"].isNull()) |
857 | - crop_width.SetJsonValue(root["crop_width"]); |
858 | + crop_width.SetJsonValue(root["crop_width"].toObject()); |
859 | if (!root["crop_height"].isNull()) |
860 | - crop_height.SetJsonValue(root["crop_height"]); |
861 | + crop_height.SetJsonValue(root["crop_height"].toObject()); |
862 | if (!root["crop_x"].isNull()) |
863 | - crop_x.SetJsonValue(root["crop_x"]); |
864 | + crop_x.SetJsonValue(root["crop_x"].toObject()); |
865 | if (!root["crop_y"].isNull()) |
866 | - crop_y.SetJsonValue(root["crop_y"]); |
867 | + crop_y.SetJsonValue(root["crop_y"].toObject()); |
868 | if (!root["shear_x"].isNull()) |
869 | - shear_x.SetJsonValue(root["shear_x"]); |
870 | + shear_x.SetJsonValue(root["shear_x"].toObject()); |
871 | if (!root["shear_y"].isNull()) |
872 | - shear_y.SetJsonValue(root["shear_y"]); |
873 | + shear_y.SetJsonValue(root["shear_y"].toObject()); |
874 | if (!root["perspective_c1_x"].isNull()) |
875 | - perspective_c1_x.SetJsonValue(root["perspective_c1_x"]); |
876 | + perspective_c1_x.SetJsonValue(root["perspective_c1_x"].toObject()); |
877 | if (!root["perspective_c1_y"].isNull()) |
878 | - perspective_c1_y.SetJsonValue(root["perspective_c1_y"]); |
879 | + perspective_c1_y.SetJsonValue(root["perspective_c1_y"].toObject()); |
880 | if (!root["perspective_c2_x"].isNull()) |
881 | - perspective_c2_x.SetJsonValue(root["perspective_c2_x"]); |
882 | + perspective_c2_x.SetJsonValue(root["perspective_c2_x"].toObject()); |
883 | if (!root["perspective_c2_y"].isNull()) |
884 | - perspective_c2_y.SetJsonValue(root["perspective_c2_y"]); |
885 | + perspective_c2_y.SetJsonValue(root["perspective_c2_y"].toObject()); |
886 | if (!root["perspective_c3_x"].isNull()) |
887 | - perspective_c3_x.SetJsonValue(root["perspective_c3_x"]); |
888 | + perspective_c3_x.SetJsonValue(root["perspective_c3_x"].toObject()); |
889 | if (!root["perspective_c3_y"].isNull()) |
890 | - perspective_c3_y.SetJsonValue(root["perspective_c3_y"]); |
891 | + perspective_c3_y.SetJsonValue(root["perspective_c3_y"].toObject()); |
892 | if (!root["perspective_c4_x"].isNull()) |
893 | - perspective_c4_x.SetJsonValue(root["perspective_c4_x"]); |
894 | + perspective_c4_x.SetJsonValue(root["perspective_c4_x"].toObject()); |
895 | if (!root["perspective_c4_y"].isNull()) |
896 | - perspective_c4_y.SetJsonValue(root["perspective_c4_y"]); |
897 | + perspective_c4_y.SetJsonValue(root["perspective_c4_y"].toObject()); |
898 | if (!root["effects"].isNull()) { |
899 | |
900 | // Clear existing effects |
901 | effects.clear(); |
902 | |
903 | // loop through effects |
904 | - for (int x = 0; x < root["effects"].size(); x++) { |
905 | + for (int x = 0; x < root["effects"].toArray().size(); x++) { |
906 | // Get each effect |
907 | - Json::Value existing_effect = root["effects"][x]; |
908 | + QJsonObject existing_effect = root["effects"].toArray()[x].toObject(); |
909 | |
910 | // Create Effect |
911 | EffectBase *e = NULL; |
912 | |
913 | if (!existing_effect["type"].isNull()) |
914 | // Init the matching effect object |
915 | - if (existing_effect["type"].asString() == "Brightness") |
916 | + if (existing_effect["type"].toString() == "Brightness") |
917 | e = new Brightness(); |
918 | |
919 | - else if (existing_effect["type"].asString() == "ChromaKey") |
920 | + else if (existing_effect["type"].toString() == "ChromaKey") |
921 | e = new ChromaKey(); |
922 | |
923 | - else if (existing_effect["type"].asString() == "Deinterlace") |
924 | + else if (existing_effect["type"].toString() == "Deinterlace") |
925 | e = new Deinterlace(); |
926 | |
927 | - else if (existing_effect["type"].asString() == "Mask") |
928 | + else if (existing_effect["type"].toString() == "Mask") |
929 | e = new Mask(); |
930 | |
931 | - else if (existing_effect["type"].asString() == "Negate") |
932 | + else if (existing_effect["type"].toString() == "Negate") |
933 | e = new Negate(); |
934 | |
935 | - else if (existing_effect["type"].asString() == "Saturation") |
936 | + else if (existing_effect["type"].toString() == "Saturation") |
937 | e = new Saturation(); |
938 | |
939 | // Load Json into Effect |
940 | @@ -770,7 +776,7 @@ |
941 | } |
942 | if (!root["reader"].isNull()) // does Json contain a reader? |
943 | { |
944 | - if (!root["reader"]["type"].isNull()) // does the reader Json contain a 'type'? |
945 | + if (!root["reader"].toObject()["type"].isNull()) // does the reader Json contain a 'type'? |
946 | { |
947 | // Close previous reader (if any) |
948 | bool already_open = false; |
949 | @@ -786,43 +792,43 @@ |
950 | } |
951 | |
952 | // Create new reader (and load properties) |
953 | - string type = root["reader"]["type"].asString(); |
954 | + string type = root["reader"].toObject()["type"].toString().toLocal8Bit().constData(); |
955 | |
956 | if (type == "FFmpegReader") { |
957 | |
958 | // Create new reader |
959 | - reader = new FFmpegReader(root["reader"]["path"].asString()); |
960 | - reader->SetJsonValue(root["reader"]); |
961 | + reader = new FFmpegReader(root["reader"].toObject()["path"].toString().toLocal8Bit().constData()); |
962 | + reader->SetJsonValue(root["reader"].toObject()); |
963 | |
964 | } else if (type == "QtImageReader") { |
965 | |
966 | // Create new reader |
967 | - reader = new QtImageReader(root["reader"]["path"].asString()); |
968 | - reader->SetJsonValue(root["reader"]); |
969 | + reader = new QtImageReader(root["reader"].toObject()["path"].toString().toLocal8Bit().constData()); |
970 | + reader->SetJsonValue(root["reader"].toObject()); |
971 | |
972 | } else if (type == "ImageReader") { |
973 | |
974 | // Create new reader |
975 | - reader = new ImageReader(root["reader"]["path"].asString()); |
976 | - reader->SetJsonValue(root["reader"]); |
977 | + reader = new ImageReader(root["reader"].toObject()["path"].toString().toLocal8Bit().constData()); |
978 | + reader->SetJsonValue(root["reader"].toObject()); |
979 | |
980 | } else if (type == "TextReader") { |
981 | |
982 | // Create new reader |
983 | reader = new TextReader(); |
984 | - reader->SetJsonValue(root["reader"]); |
985 | + reader->SetJsonValue(root["reader"].toObject()); |
986 | |
987 | } else if (type == "ChunkReader") { |
988 | |
989 | // Create new reader |
990 | - reader = new ChunkReader(root["reader"]["path"].asString(), (ChunkVersion) root["reader"]["chunk_version"].asInt()); |
991 | - reader->SetJsonValue(root["reader"]); |
992 | + reader = new ChunkReader(root["reader"].toObject()["path"].toString().toLocal8Bit().constData(), (ChunkVersion) root["reader"].toObject()["chunk_version"].toInt()); |
993 | + reader->SetJsonValue(root["reader"].toObject()); |
994 | |
995 | } else if (type == "DummyReader") { |
996 | |
997 | // Create new reader |
998 | reader = new DummyReader(); |
999 | - reader->SetJsonValue(root["reader"]); |
1000 | + reader->SetJsonValue(root["reader"].toObject()); |
1001 | } |
1002 | |
1003 | // mark as managed reader |
1004 | |
1005 | === modified file 'src/ClipBase.cpp' |
1006 | --- src/ClipBase.cpp 2015-10-02 23:22:10 +0000 |
1007 | +++ src/ClipBase.cpp 2015-10-04 15:21:00 +0000 |
1008 | @@ -29,12 +29,12 @@ |
1009 | |
1010 | using namespace openshot; |
1011 | |
1012 | -// Generate Json::JsonValue for this object |
1013 | -Json::Value ClipBase::JsonValue() { |
1014 | +// Generate QJsonObject for this object |
1015 | +QJsonObject ClipBase::JsonValue() { |
1016 | |
1017 | // Create root json object |
1018 | - Json::Value root; |
1019 | - root["id"] = Id(); |
1020 | + QJsonObject root; |
1021 | + root["id"] = Id().c_str(); |
1022 | root["position"] = Position(); |
1023 | root["layer"] = Layer(); |
1024 | root["start"] = Start(); |
1025 | @@ -45,31 +45,31 @@ |
1026 | return root; |
1027 | } |
1028 | |
1029 | -// Load Json::JsonValue into this object |
1030 | -void ClipBase::SetJsonValue(Json::Value root) { |
1031 | +// Load QJsonObject into this object |
1032 | +void ClipBase::SetJsonValue(const QJsonObject root) { |
1033 | |
1034 | // Set data from Json (if key is found) |
1035 | if (!root["id"].isNull()) |
1036 | - Id(root["id"].asString()); |
1037 | + Id(root["id"].toString().toLocal8Bit().constData()); |
1038 | if (!root["position"].isNull()) |
1039 | - Position(root["position"].asDouble()); |
1040 | + Position(root["position"].toDouble()); |
1041 | if (!root["layer"].isNull()) |
1042 | - Layer(root["layer"].asInt()); |
1043 | + Layer(root["layer"].toVariant().toInt()); |
1044 | if (!root["start"].isNull()) |
1045 | - Start(root["start"].asDouble()); |
1046 | + Start(root["start"].toDouble()); |
1047 | if (!root["end"].isNull()) |
1048 | - End(root["end"].asDouble()); |
1049 | + End(root["end"].toDouble()); |
1050 | } |
1051 | |
1052 | // Generate JSON for a property |
1053 | -Json::Value ClipBase::add_property_json(string name, float value, string type, string memo, bool contains_point, int number_of_points, float min_value, float max_value, InterpolationType intepolation, int closest_point_x, bool readonly) { |
1054 | +QJsonObject ClipBase::add_property_json(string name, float value, string type, string memo, bool contains_point, int number_of_points, float min_value, float max_value, InterpolationType intepolation, int closest_point_x, bool readonly) { |
1055 | |
1056 | // Create JSON Object |
1057 | - Json::Value prop = Json::Value(Json::objectValue); |
1058 | - prop["name"] = name; |
1059 | + QJsonObject prop; |
1060 | + prop["name"] = name.c_str(); |
1061 | prop["value"] = value; |
1062 | - prop["memo"] = memo; |
1063 | - prop["type"] = type; |
1064 | + prop["memo"] = memo.c_str(); |
1065 | + prop["type"] = type.c_str(); |
1066 | prop["min"] = min_value; |
1067 | prop["max"] = max_value; |
1068 | prop["keyframe"] = contains_point; |
1069 | @@ -77,20 +77,20 @@ |
1070 | prop["readonly"] = readonly; |
1071 | prop["interpolation"] = intepolation; |
1072 | prop["closest_point_x"] = closest_point_x; |
1073 | - prop["choices"] = Json::Value(Json::arrayValue); |
1074 | + prop["choices"] = QJsonArray(); |
1075 | |
1076 | // return JsonValue |
1077 | return prop; |
1078 | } |
1079 | |
1080 | -Json::Value ClipBase::add_property_choice_json(string name, int value, int selected_value) { |
1081 | +QJsonObject ClipBase::add_property_choice_json(string name, int value, int selected_value) { |
1082 | |
1083 | - // Create choice |
1084 | - Json::Value new_choice = Json::Value(Json::objectValue); |
1085 | - new_choice["name"] = name; |
1086 | + // Create choice |
1087 | + QJsonObject new_choice; |
1088 | + new_choice["name"] = name.c_str(); |
1089 | new_choice["value"] = value; |
1090 | new_choice["selected"] = (value == selected_value); |
1091 | |
1092 | // return JsonValue |
1093 | return new_choice; |
1094 | -} |
1095 | \ No newline at end of file |
1096 | +} |
1097 | |
1098 | === modified file 'src/Color.cpp' |
1099 | --- src/Color.cpp 2015-10-01 23:51:59 +0000 |
1100 | +++ src/Color.cpp 2015-10-04 15:21:00 +0000 |
1101 | @@ -84,15 +84,16 @@ |
1102 | // Generate JSON string of this object |
1103 | string Color::Json() { |
1104 | |
1105 | - // Return formatted string |
1106 | - return JsonValue().toStyledString(); |
1107 | + QJsonDocument document; |
1108 | + document.setObject(JsonValue()); |
1109 | + return document.toJson().constData(); |
1110 | } |
1111 | |
1112 | -// Generate Json::JsonValue for this object |
1113 | -Json::Value Color::JsonValue() { |
1114 | +// Generate QJsonObject for this object |
1115 | +QJsonObject Color::JsonValue() { |
1116 | |
1117 | // Create root json object |
1118 | - Json::Value root; |
1119 | + QJsonObject root; |
1120 | root["red"] = red.JsonValue(); |
1121 | root["green"] = green.JsonValue(); |
1122 | root["blue"] = blue.JsonValue(); |
1123 | @@ -106,12 +107,16 @@ |
1124 | void Color::SetJson(string value) throw(InvalidJSON) { |
1125 | |
1126 | // Parse JSON string into JSON objects |
1127 | - Json::Value root; |
1128 | - Json::Reader reader; |
1129 | - bool success = reader.parse( value, root ); |
1130 | - if (!success) |
1131 | + QJsonObject root; |
1132 | + QJsonParseError errors; |
1133 | + |
1134 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
1135 | + if (errors.error != QJsonParseError::NoError) { |
1136 | // Raise exception |
1137 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
1138 | + } |
1139 | + |
1140 | + root = document.object(); |
1141 | |
1142 | try |
1143 | { |
1144 | @@ -126,15 +131,15 @@ |
1145 | } |
1146 | |
1147 | // Load Json::JsonValue into this object |
1148 | -void Color::SetJsonValue(Json::Value root) { |
1149 | +void Color::SetJsonValue(QJsonObject root) { |
1150 | |
1151 | // Set data from Json (if key is found) |
1152 | - if (!root["red"].isNull()) |
1153 | - red.SetJsonValue(root["red"]); |
1154 | + if (!root["red"].isNull()) |
1155 | + red.SetJsonValue(root["red"].toObject()); |
1156 | if (!root["green"].isNull()) |
1157 | - green.SetJsonValue(root["green"]); |
1158 | + green.SetJsonValue(root["green"].toObject()); |
1159 | if (!root["blue"].isNull()) |
1160 | - blue.SetJsonValue(root["blue"]); |
1161 | + blue.SetJsonValue(root["blue"].toObject()); |
1162 | if (!root["alpha"].isNull()) |
1163 | - alpha.SetJsonValue(root["alpha"]); |
1164 | + alpha.SetJsonValue(root["alpha"].toObject()); |
1165 | } |
1166 | |
1167 | === modified file 'src/Coordinate.cpp' |
1168 | --- src/Coordinate.cpp 2014-07-11 21:52:14 +0000 |
1169 | +++ src/Coordinate.cpp 2015-10-04 15:21:00 +0000 |
1170 | @@ -44,15 +44,16 @@ |
1171 | // Generate JSON string of this object |
1172 | string Coordinate::Json() { |
1173 | |
1174 | - // Return formatted string |
1175 | - return JsonValue().toStyledString(); |
1176 | + QJsonDocument document; |
1177 | + document.setObject(JsonValue()); |
1178 | + return document.toJson().constData(); |
1179 | } |
1180 | |
1181 | -// Generate Json::JsonValue for this object |
1182 | -Json::Value Coordinate::JsonValue() { |
1183 | +// Generate QJsonObject for this object |
1184 | +QJsonObject Coordinate::JsonValue() { |
1185 | |
1186 | // Create root json object |
1187 | - Json::Value root; |
1188 | + QJsonObject root; |
1189 | root["X"] = X; |
1190 | root["Y"] = Y; |
1191 | //root["increasing"] = increasing; |
1192 | @@ -69,12 +70,16 @@ |
1193 | void Coordinate::SetJson(string value) throw(InvalidJSON) { |
1194 | |
1195 | // Parse JSON string into JSON objects |
1196 | - Json::Value root; |
1197 | - Json::Reader reader; |
1198 | - bool success = reader.parse( value, root ); |
1199 | - if (!success) |
1200 | + QJsonObject root; |
1201 | + QJsonParseError errors; |
1202 | + |
1203 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
1204 | + if (errors.error != QJsonParseError::NoError) { |
1205 | // Raise exception |
1206 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
1207 | + } |
1208 | + |
1209 | + root = document.object(); |
1210 | |
1211 | try |
1212 | { |
1213 | @@ -88,23 +93,24 @@ |
1214 | } |
1215 | } |
1216 | |
1217 | -// Load Json::JsonValue into this object |
1218 | -void Coordinate::SetJsonValue(Json::Value root) { |
1219 | +// Load QJsonObject into this object |
1220 | +void Coordinate::SetJsonValue(QJsonObject root) { |
1221 | |
1222 | // Set data from Json (if key is found) |
1223 | if (!root["X"].isNull()) |
1224 | - X = root["X"].asDouble(); |
1225 | + X = root["X"].toDouble(); |
1226 | if (!root["Y"].isNull()) |
1227 | - Y = root["Y"].asDouble(); |
1228 | + Y = root["Y"].toDouble(); |
1229 | if (!root["increasing"].isNull()) |
1230 | - increasing = root["increasing"].asBool(); |
1231 | + increasing = root["increasing"].toBool(); |
1232 | if (!root["repeated"].isNull() && root["repeated"].isObject()) |
1233 | { |
1234 | - if (!root["repeated"]["num"].isNull()) |
1235 | - repeated.num = root["repeated"]["num"].asInt(); |
1236 | - if (!root["repeated"]["den"].isNull()) |
1237 | - repeated.den = root["repeated"]["den"].asInt(); |
1238 | + const QJsonObject repeatedObject = root["repeated"].toObject(); |
1239 | + if (!root["repeated"].toObject()["num"].isNull()) |
1240 | + repeated.num = repeatedObject["num"].toVariant().toInt(); |
1241 | + if (!root["repeated"].toObject()["den"].isNull()) |
1242 | + repeated.den = repeatedObject["den"].toVariant().toInt(); |
1243 | } |
1244 | if (!root["delta"].isNull()) |
1245 | - delta = root["delta"].asDouble(); |
1246 | + delta = root["delta"].toDouble(); |
1247 | } |
1248 | |
1249 | === modified file 'src/DecklinkReader.cpp' |
1250 | --- src/DecklinkReader.cpp 2015-08-24 06:05:48 +0000 |
1251 | +++ src/DecklinkReader.cpp 2015-10-04 15:21:00 +0000 |
1252 | @@ -249,12 +249,12 @@ |
1253 | return JsonValue().toStyledString(); |
1254 | } |
1255 | |
1256 | -// Generate Json::JsonValue for this object |
1257 | -Json::Value DecklinkReader::JsonValue() { |
1258 | +// Generate QJsonObject for this object |
1259 | +QJsonObject DecklinkReader::JsonValue() { |
1260 | |
1261 | // Create root json object |
1262 | - Json::Value root = ReaderBase::JsonValue(); // get parent properties |
1263 | - root["type"] = "DecklinkReader"; |
1264 | + QJsonObject root = ReaderBase::JsonValue(); // get parent properties |
1265 | + root.insert("type", QJsonValue("DecklinkReader")); |
1266 | |
1267 | // return JsonValue |
1268 | return root; |
1269 | @@ -264,12 +264,16 @@ |
1270 | void DecklinkReader::SetJson(string value) throw(InvalidJSON) { |
1271 | |
1272 | // Parse JSON string into JSON objects |
1273 | - Json::Value root; |
1274 | - Json::Reader reader; |
1275 | - bool success = reader.parse( value, root ); |
1276 | - if (!success) |
1277 | + QJsonObject root; |
1278 | + QJsonParseError errors; |
1279 | + |
1280 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
1281 | + if (errors.error != QJsonParseError::NoError) { |
1282 | // Raise exception |
1283 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
1284 | + } |
1285 | + |
1286 | + root = document.object(); |
1287 | |
1288 | try |
1289 | { |
1290 | @@ -283,8 +287,8 @@ |
1291 | } |
1292 | } |
1293 | |
1294 | -// Load Json::JsonValue into this object |
1295 | -void DecklinkReader::SetJsonValue(Json::Value root) throw(InvalidFile) { |
1296 | +// Load QJsonObject into this object |
1297 | +void DecklinkReader::SetJsonValue(QJsonObject root) throw(InvalidFile) { |
1298 | |
1299 | // Set parent data |
1300 | ReaderBase::SetJsonValue(root); |
1301 | |
1302 | === modified file 'src/DummyReader.cpp' |
1303 | --- src/DummyReader.cpp 2015-08-24 06:05:48 +0000 |
1304 | +++ src/DummyReader.cpp 2015-10-04 15:21:00 +0000 |
1305 | @@ -120,15 +120,16 @@ |
1306 | // Generate JSON string of this object |
1307 | string DummyReader::Json() { |
1308 | |
1309 | - // Return formatted string |
1310 | - return JsonValue().toStyledString(); |
1311 | + QJsonDocument document; |
1312 | + document.setObject(JsonValue()); |
1313 | + return document.toJson().constData(); |
1314 | } |
1315 | |
1316 | -// Generate Json::JsonValue for this object |
1317 | -Json::Value DummyReader::JsonValue() { |
1318 | +// Generate QJsonObject for this object |
1319 | +QJsonObject DummyReader::JsonValue() { |
1320 | |
1321 | // Create root json object |
1322 | - Json::Value root = ReaderBase::JsonValue(); // get parent properties |
1323 | + QJsonObject root = ReaderBase::JsonValue(); // get parent properties |
1324 | root["type"] = "DummyReader"; |
1325 | |
1326 | // return JsonValue |
1327 | @@ -139,12 +140,16 @@ |
1328 | void DummyReader::SetJson(string value) throw(InvalidJSON) { |
1329 | |
1330 | // Parse JSON string into JSON objects |
1331 | - Json::Value root; |
1332 | - Json::Reader reader; |
1333 | - bool success = reader.parse( value, root ); |
1334 | - if (!success) |
1335 | + QJsonObject root; |
1336 | + QJsonParseError errors; |
1337 | + |
1338 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
1339 | + if (errors.error != QJsonParseError::NoError) { |
1340 | // Raise exception |
1341 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
1342 | + } |
1343 | + |
1344 | + root = document.object(); |
1345 | |
1346 | try |
1347 | { |
1348 | @@ -158,8 +163,8 @@ |
1349 | } |
1350 | } |
1351 | |
1352 | -// Load Json::JsonValue into this object |
1353 | -void DummyReader::SetJsonValue(Json::Value root) throw(InvalidFile) { |
1354 | +// Load QJsonObject into this object |
1355 | +void DummyReader::SetJsonValue(QJsonObject root) throw(InvalidFile) { |
1356 | |
1357 | // Set parent data |
1358 | ReaderBase::SetJsonValue(root); |
1359 | |
1360 | === modified file 'src/EffectBase.cpp' |
1361 | --- src/EffectBase.cpp 2015-08-07 01:01:34 +0000 |
1362 | +++ src/EffectBase.cpp 2015-10-04 15:21:00 +0000 |
1363 | @@ -61,15 +61,16 @@ |
1364 | // Generate JSON string of this object |
1365 | string EffectBase::Json() { |
1366 | |
1367 | - // Return formatted string |
1368 | - return JsonValue().toStyledString(); |
1369 | + QJsonDocument document; |
1370 | + document.setObject(JsonValue()); |
1371 | + return document.toJson().constData(); |
1372 | } |
1373 | |
1374 | -// Generate Json::JsonValue for this object |
1375 | -Json::Value EffectBase::JsonValue() { |
1376 | +// Generate QJsonObject for this object |
1377 | +QJsonObject EffectBase::JsonValue() { |
1378 | |
1379 | // Create root json object |
1380 | - Json::Value root = ClipBase::JsonValue(); // get parent properties |
1381 | + QJsonObject root = ClipBase::JsonValue(); // get parent properties |
1382 | root["order"] = Order(); |
1383 | |
1384 | // return JsonValue |
1385 | @@ -80,12 +81,16 @@ |
1386 | void EffectBase::SetJson(string value) throw(InvalidJSON) { |
1387 | |
1388 | // Parse JSON string into JSON objects |
1389 | - Json::Value root; |
1390 | - Json::Reader reader; |
1391 | - bool success = reader.parse( value, root ); |
1392 | - if (!success) |
1393 | + QJsonObject root; |
1394 | + QJsonParseError errors; |
1395 | + |
1396 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
1397 | + if (errors.error != QJsonParseError::NoError) { |
1398 | // Raise exception |
1399 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
1400 | + } |
1401 | + |
1402 | + root = document.object(); |
1403 | |
1404 | try |
1405 | { |
1406 | @@ -99,29 +104,29 @@ |
1407 | } |
1408 | } |
1409 | |
1410 | -// Load Json::JsonValue into this object |
1411 | -void EffectBase::SetJsonValue(Json::Value root) { |
1412 | +// Load QJsonObject into this object |
1413 | +void EffectBase::SetJsonValue(const QJsonObject root) { |
1414 | |
1415 | // Set parent data |
1416 | ClipBase::SetJsonValue(root); |
1417 | |
1418 | // Set data from Json (if key is found) |
1419 | if (!root["order"].isNull()) |
1420 | - Order(root["order"].asInt()); |
1421 | + Order(root["order"].toVariant().toInt()); |
1422 | } |
1423 | |
1424 | -// Generate Json::JsonValue for this object |
1425 | -Json::Value EffectBase::JsonInfo() { |
1426 | +// Generate QJsonObject for this object |
1427 | +QJsonObject EffectBase::JsonInfo() { |
1428 | |
1429 | // Create root json object |
1430 | - Json::Value root; |
1431 | - root["name"] = info.name; |
1432 | - root["class_name"] = info.class_name; |
1433 | - root["short_name"] = info.short_name; |
1434 | - root["description"] = info.description; |
1435 | + QJsonObject root; |
1436 | + root["name"] = info.name.c_str(); |
1437 | + root["class_name"] = info.class_name.c_str(); |
1438 | + root["short_name"] = info.short_name.c_str(); |
1439 | + root["description"] = info.description.c_str(); |
1440 | root["has_video"] = info.has_video; |
1441 | root["has_audio"] = info.has_audio; |
1442 | |
1443 | // return JsonValue |
1444 | return root; |
1445 | -} |
1446 | \ No newline at end of file |
1447 | +} |
1448 | |
1449 | === modified file 'src/EffectInfo.cpp' |
1450 | --- src/EffectInfo.cpp 2015-08-17 03:58:07 +0000 |
1451 | +++ src/EffectInfo.cpp 2015-10-04 15:21:00 +0000 |
1452 | @@ -35,14 +35,16 @@ |
1453 | string EffectInfo::Json() { |
1454 | |
1455 | // Return formatted string |
1456 | - return JsonValue().toStyledString(); |
1457 | + QJsonDocument document; |
1458 | + document.setArray(JsonValue()); |
1459 | + return document.toJson().constData(); |
1460 | } |
1461 | |
1462 | // Generate Json::JsonValue for this object |
1463 | -Json::Value EffectInfo::JsonValue() { |
1464 | +QJsonArray EffectInfo::JsonValue() { |
1465 | |
1466 | // Create root json object |
1467 | - Json::Value root; |
1468 | + QJsonArray root; |
1469 | |
1470 | // Append info JSON from each supported effect |
1471 | root.append(Brightness().JsonInfo()); |
1472 | |
1473 | === modified file 'src/FFmpegReader.cpp' |
1474 | --- src/FFmpegReader.cpp 2015-10-01 18:00:50 +0000 |
1475 | +++ src/FFmpegReader.cpp 2015-10-04 15:21:00 +0000 |
1476 | @@ -252,7 +252,9 @@ |
1477 | } |
1478 | |
1479 | // Clear debug json |
1480 | - debug_root.clear(); |
1481 | + while (!debug_root.isEmpty()) { |
1482 | + debug_root.removeFirst(); |
1483 | + } |
1484 | |
1485 | // Close the video file |
1486 | avformat_close_input(&pFormatCtx); |
1487 | @@ -1838,17 +1840,18 @@ |
1488 | // Generate JSON string of this object |
1489 | string FFmpegReader::Json() { |
1490 | |
1491 | - // Return formatted string |
1492 | - return JsonValue().toStyledString(); |
1493 | + QJsonDocument document; |
1494 | + document.setObject(JsonValue()); |
1495 | + return document.toJson().constData(); |
1496 | } |
1497 | |
1498 | -// Generate Json::JsonValue for this object |
1499 | -Json::Value FFmpegReader::JsonValue() { |
1500 | +// Generate QJsonObject for this object |
1501 | +QJsonObject FFmpegReader::JsonValue() { |
1502 | |
1503 | // Create root json object |
1504 | - Json::Value root = ReaderBase::JsonValue(); // get parent properties |
1505 | + QJsonObject root = ReaderBase::JsonValue(); // get parent properties |
1506 | root["type"] = "FFmpegReader"; |
1507 | - root["path"] = path; |
1508 | + root["path"] = path.c_str(); |
1509 | |
1510 | // return JsonValue |
1511 | return root; |
1512 | @@ -1858,12 +1861,16 @@ |
1513 | void FFmpegReader::SetJson(string value) throw(InvalidJSON) { |
1514 | |
1515 | // Parse JSON string into JSON objects |
1516 | - Json::Value root; |
1517 | - Json::Reader reader; |
1518 | - bool success = reader.parse( value, root ); |
1519 | - if (!success) |
1520 | + QJsonObject root; |
1521 | + QJsonParseError errors; |
1522 | + |
1523 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
1524 | + if (errors.error != QJsonParseError::NoError) { |
1525 | // Raise exception |
1526 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
1527 | + } |
1528 | + |
1529 | + root = document.object(); |
1530 | |
1531 | try |
1532 | { |
1533 | @@ -1877,15 +1884,15 @@ |
1534 | } |
1535 | } |
1536 | |
1537 | -// Load Json::JsonValue into this object |
1538 | -void FFmpegReader::SetJsonValue(Json::Value root) throw(InvalidFile) { |
1539 | +// Load QJsonObject into this object |
1540 | +void FFmpegReader::SetJsonValue(QJsonObject root) throw(InvalidFile) { |
1541 | |
1542 | // Set parent data |
1543 | ReaderBase::SetJsonValue(root); |
1544 | |
1545 | // Set data from Json (if key is found) |
1546 | if (!root["path"].isNull()) |
1547 | - path = root["path"].asString(); |
1548 | + path = root["path"].toString().toLocal8Bit().constData(); |
1549 | |
1550 | // Re-Open path, and re-init everything (if needed) |
1551 | if (is_open) |
1552 | |
1553 | === modified file 'src/FrameMapper.cpp' |
1554 | --- src/FrameMapper.cpp 2015-10-01 18:00:50 +0000 |
1555 | +++ src/FrameMapper.cpp 2015-10-04 15:21:00 +0000 |
1556 | @@ -538,18 +538,19 @@ |
1557 | // Generate JSON string of this object |
1558 | string FrameMapper::Json() { |
1559 | |
1560 | - // Return formatted string |
1561 | - return JsonValue().toStyledString(); |
1562 | + QJsonDocument document; |
1563 | + document.setObject(JsonValue()); |
1564 | + return document.toJson().constData(); |
1565 | } |
1566 | |
1567 | -// Generate Json::JsonValue for this object |
1568 | -Json::Value FrameMapper::JsonValue() { |
1569 | +// Generate QJsonObject for this object |
1570 | +QJsonObject FrameMapper::JsonValue() { |
1571 | |
1572 | // Create root json object |
1573 | - Json::Value root = ReaderBase::JsonValue(); // get parent properties |
1574 | + QJsonObject root = ReaderBase::JsonValue(); // get parent properties |
1575 | root["type"] = "FrameMapper"; |
1576 | |
1577 | - // return JsonValue |
1578 | + // return QJsonObject |
1579 | return root; |
1580 | } |
1581 | |
1582 | @@ -557,12 +558,16 @@ |
1583 | void FrameMapper::SetJson(string value) throw(InvalidJSON) { |
1584 | |
1585 | // Parse JSON string into JSON objects |
1586 | - Json::Value root; |
1587 | - Json::Reader reader; |
1588 | - bool success = reader.parse( value, root ); |
1589 | - if (!success) |
1590 | + QJsonObject root; |
1591 | + QJsonParseError errors; |
1592 | + |
1593 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
1594 | + if (errors.error != QJsonParseError::NoError) { |
1595 | // Raise exception |
1596 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
1597 | + } |
1598 | + |
1599 | + root = document.object(); |
1600 | |
1601 | try |
1602 | { |
1603 | @@ -576,8 +581,8 @@ |
1604 | } |
1605 | } |
1606 | |
1607 | -// Load Json::JsonValue into this object |
1608 | -void FrameMapper::SetJsonValue(Json::Value root) throw(InvalidFile) { |
1609 | +// Load QJsonObject into this object |
1610 | +void FrameMapper::SetJsonValue(QJsonObject root) throw(InvalidFile) { |
1611 | |
1612 | // Set parent data |
1613 | ReaderBase::SetJsonValue(root); |
1614 | |
1615 | === modified file 'src/ImageReader.cpp' |
1616 | --- src/ImageReader.cpp 2015-09-29 03:05:50 +0000 |
1617 | +++ src/ImageReader.cpp 2015-10-04 15:21:00 +0000 |
1618 | @@ -123,19 +123,20 @@ |
1619 | // Generate JSON string of this object |
1620 | string ImageReader::Json() { |
1621 | |
1622 | - // Return formatted string |
1623 | - return JsonValue().toStyledString(); |
1624 | + QJsonDocument document; |
1625 | + document.setObject(JsonValue()); |
1626 | + return document.toJson().constData(); |
1627 | } |
1628 | |
1629 | -// Generate Json::JsonValue for this object |
1630 | -Json::Value ImageReader::JsonValue() { |
1631 | +// Generate QJsonObject for this object |
1632 | +QJsonObject ImageReader::JsonValue() { |
1633 | |
1634 | // Create root json object |
1635 | - Json::Value root = ReaderBase::JsonValue(); // get parent properties |
1636 | + QJsonObject root = ReaderBase::JsonValue(); // get parent properties |
1637 | root["type"] = "ImageReader"; |
1638 | - root["path"] = path; |
1639 | + root["path"] = path.c_str(); |
1640 | |
1641 | - // return JsonValue |
1642 | + // return QJsonObject |
1643 | return root; |
1644 | } |
1645 | |
1646 | @@ -143,12 +144,16 @@ |
1647 | void ImageReader::SetJson(string value) throw(InvalidJSON) { |
1648 | |
1649 | // Parse JSON string into JSON objects |
1650 | - Json::Value root; |
1651 | - Json::Reader reader; |
1652 | - bool success = reader.parse( value, root ); |
1653 | - if (!success) |
1654 | + QJsonObject root; |
1655 | + QJsonParseError errors; |
1656 | + |
1657 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
1658 | + if (errors.error != QJsonParseError::NoError) { |
1659 | // Raise exception |
1660 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
1661 | + } |
1662 | + |
1663 | + root = document.object(); |
1664 | |
1665 | try |
1666 | { |
1667 | @@ -162,15 +167,15 @@ |
1668 | } |
1669 | } |
1670 | |
1671 | -// Load Json::JsonValue into this object |
1672 | -void ImageReader::SetJsonValue(Json::Value root) throw(InvalidFile) { |
1673 | +// Load QJsonObject into this object |
1674 | +void ImageReader::SetJsonValue(QJsonObject root) throw(InvalidFile) { |
1675 | |
1676 | // Set parent data |
1677 | ReaderBase::SetJsonValue(root); |
1678 | |
1679 | // Set data from Json (if key is found) |
1680 | if (!root["path"].isNull()) |
1681 | - path = root["path"].asString(); |
1682 | + path = root["path"].toString().toLocal8Bit().constData(); |
1683 | |
1684 | // Re-Open path, and re-init everything (if needed) |
1685 | if (is_open) |
1686 | |
1687 | === modified file 'src/KeyFrame.cpp' |
1688 | --- src/KeyFrame.cpp 2015-10-02 23:22:10 +0000 |
1689 | +++ src/KeyFrame.cpp 2015-10-04 15:21:00 +0000 |
1690 | @@ -305,22 +305,23 @@ |
1691 | // Generate JSON string of this object |
1692 | string Keyframe::Json() { |
1693 | |
1694 | - // Return formatted string |
1695 | - return JsonValue().toStyledString(); |
1696 | + QJsonDocument document; |
1697 | + document.setObject(JsonValue()); |
1698 | + return document.toJson().constData(); |
1699 | } |
1700 | |
1701 | -// Generate Json::JsonValue for this object |
1702 | -Json::Value Keyframe::JsonValue() { |
1703 | +// Generate QJsonObject for this object |
1704 | +QJsonObject Keyframe::JsonValue() { |
1705 | |
1706 | // Create root json object |
1707 | - Json::Value root; |
1708 | - root["Points"] = Json::Value(Json::arrayValue); |
1709 | + QJsonObject root; |
1710 | + root["Points"] = QJsonArray(); |
1711 | |
1712 | // loop through points, and find a matching coordinate |
1713 | for (int x = 0; x < Points.size(); x++) { |
1714 | // Get each point |
1715 | Point existing_point = Points[x]; |
1716 | - root["Points"].append(existing_point.JsonValue()); |
1717 | + root["Points"].toArray().append(existing_point.JsonValue()); |
1718 | } |
1719 | |
1720 | // return JsonValue |
1721 | @@ -331,12 +332,16 @@ |
1722 | void Keyframe::SetJson(string value) throw(InvalidJSON) { |
1723 | |
1724 | // Parse JSON string into JSON objects |
1725 | - Json::Value root; |
1726 | - Json::Reader reader; |
1727 | - bool success = reader.parse( value, root ); |
1728 | - if (!success) |
1729 | + QJsonObject root; |
1730 | + QJsonParseError errors; |
1731 | + |
1732 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
1733 | + if (errors.error != QJsonParseError::NoError) { |
1734 | // Raise exception |
1735 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
1736 | + } |
1737 | + |
1738 | + root = document.object(); |
1739 | |
1740 | try |
1741 | { |
1742 | @@ -350,8 +355,8 @@ |
1743 | } |
1744 | } |
1745 | |
1746 | -// Load Json::JsonValue into this object |
1747 | -void Keyframe::SetJsonValue(Json::Value root) { |
1748 | +// Load QJsonObject into this object |
1749 | +void Keyframe::SetJsonValue(QJsonObject root) { |
1750 | |
1751 | // mark as dirty |
1752 | needs_update = true; |
1753 | @@ -361,9 +366,9 @@ |
1754 | |
1755 | if (!root["Points"].isNull()) |
1756 | // loop through points |
1757 | - for (long int x = 0; x < root["Points"].size(); x++) { |
1758 | + for (long int x = 0; x < root["Points"].toArray().size(); x++) { |
1759 | // Get each point |
1760 | - Json::Value existing_point = root["Points"][x]; |
1761 | + QJsonObject existing_point = root["Points"].toArray()[x].toObject(); |
1762 | |
1763 | // Create Point |
1764 | Point p; |
1765 | @@ -376,7 +381,7 @@ |
1766 | } |
1767 | |
1768 | if (!root["Auto_Handle_Percentage"].isNull()) |
1769 | - Auto_Handle_Percentage = root["Auto_Handle_Percentage"].asBool(); |
1770 | + Auto_Handle_Percentage = root["Auto_Handle_Percentage"].toBool(); |
1771 | } |
1772 | |
1773 | // Get the fraction that represents how many times this value is repeated in the curve |
1774 | |
1775 | === modified file 'src/Point.cpp' |
1776 | --- src/Point.cpp 2015-02-21 09:10:38 +0000 |
1777 | +++ src/Point.cpp 2015-10-04 15:21:00 +0000 |
1778 | @@ -96,15 +96,16 @@ |
1779 | // Generate JSON string of this object |
1780 | string Point::Json() { |
1781 | |
1782 | - // Return formatted string |
1783 | - return JsonValue().toStyledString(); |
1784 | + QJsonDocument document; |
1785 | + document.setObject(JsonValue()); |
1786 | + return document.toJson().constData(); |
1787 | } |
1788 | |
1789 | -// Generate Json::JsonValue for this object |
1790 | -Json::Value Point::JsonValue() { |
1791 | +// Generate QJsonObject for this object |
1792 | +QJsonObject Point::JsonValue() { |
1793 | |
1794 | // Create root json object |
1795 | - Json::Value root; |
1796 | + QJsonObject root; |
1797 | root["co"] = co.JsonValue(); |
1798 | if (interpolation == BEZIER) { |
1799 | root["handle_left"] = handle_left.JsonValue(); |
1800 | @@ -121,12 +122,16 @@ |
1801 | void Point::SetJson(string value) throw(InvalidJSON) { |
1802 | |
1803 | // Parse JSON string into JSON objects |
1804 | - Json::Value root; |
1805 | - Json::Reader reader; |
1806 | - bool success = reader.parse( value, root ); |
1807 | - if (!success) |
1808 | + QJsonObject root; |
1809 | + QJsonParseError errors; |
1810 | + |
1811 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
1812 | + if (errors.error != QJsonParseError::NoError) { |
1813 | // Raise exception |
1814 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
1815 | + } |
1816 | + |
1817 | + root = document.object(); |
1818 | |
1819 | try |
1820 | { |
1821 | @@ -140,18 +145,18 @@ |
1822 | } |
1823 | } |
1824 | |
1825 | -// Load Json::JsonValue into this object |
1826 | -void Point::SetJsonValue(Json::Value root) { |
1827 | +// Load QJsonObject into this object |
1828 | +void Point::SetJsonValue(const QJsonObject root) { |
1829 | |
1830 | if (!root["co"].isNull()) |
1831 | - co.SetJsonValue(root["co"]); // update coordinate |
1832 | + co.SetJsonValue(root["co"].toObject()); // update coordinate |
1833 | if (!root["handle_left"].isNull()) |
1834 | - handle_left.SetJsonValue(root["handle_left"]); // update coordinate |
1835 | + handle_left.SetJsonValue(root["handle_left"].toObject()); // update coordinate |
1836 | if (!root["handle_right"].isNull()) |
1837 | - handle_right.SetJsonValue(root["handle_right"]); // update coordinate |
1838 | + handle_right.SetJsonValue(root["handle_right"].toObject()); // update coordinate |
1839 | if (!root["interpolation"].isNull()) |
1840 | - interpolation = (InterpolationType) root["interpolation"].asInt(); |
1841 | + interpolation = (InterpolationType) root["interpolation"].toVariant().toInt(); |
1842 | if (!root["handle_type"].isNull()) |
1843 | - handle_type = (HandleType) root["handle_type"].asInt(); |
1844 | + handle_type = (HandleType) root["handle_type"].toVariant().toInt(); |
1845 | |
1846 | } |
1847 | |
1848 | === modified file 'src/Profiles.cpp' |
1849 | --- src/Profiles.cpp 2014-07-11 21:52:14 +0000 |
1850 | +++ src/Profiles.cpp 2015-10-04 15:21:00 +0000 |
1851 | @@ -136,27 +136,28 @@ |
1852 | // Generate JSON string of this object |
1853 | string Profile::Json() { |
1854 | |
1855 | - // Return formatted string |
1856 | - return JsonValue().toStyledString(); |
1857 | + QJsonDocument document; |
1858 | + document.setObject(JsonValue()); |
1859 | + return document.toJson().constData(); |
1860 | } |
1861 | |
1862 | -// Generate Json::JsonValue for this object |
1863 | -Json::Value Profile::JsonValue() { |
1864 | +// Generate QJsonObject for this object |
1865 | +QJsonObject Profile::JsonValue() { |
1866 | |
1867 | // Create root json object |
1868 | - Json::Value root; |
1869 | + QJsonObject root; |
1870 | root["height"] = info.height; |
1871 | root["width"] = info.width; |
1872 | root["pixel_format"] = info.pixel_format; |
1873 | - root["fps"] = Json::Value(Json::objectValue); |
1874 | - root["fps"]["num"] = info.fps.num; |
1875 | - root["fps"]["den"] = info.fps.den; |
1876 | - root["pixel_ratio"] = Json::Value(Json::objectValue); |
1877 | - root["pixel_ratio"]["num"] = info.pixel_ratio.num; |
1878 | - root["pixel_ratio"]["den"] = info.pixel_ratio.den; |
1879 | - root["display_ratio"] = Json::Value(Json::objectValue); |
1880 | - root["display_ratio"]["num"] = info.display_ratio.num; |
1881 | - root["display_ratio"]["den"] = info.display_ratio.den; |
1882 | + root["fps"] = QJsonObject(); |
1883 | + root["fps"].toObject()["num"] = info.fps.num; |
1884 | + root["fps"].toObject()["den"] = info.fps.den; |
1885 | + root["pixel_ratio"] = QJsonObject(); |
1886 | + root["pixel_ratio"].toObject()["num"] = info.pixel_ratio.num; |
1887 | + root["pixel_ratio"].toObject()["den"] = info.pixel_ratio.den; |
1888 | + root["display_ratio"] = QJsonObject(); |
1889 | + root["display_ratio"].toObject()["num"] = info.display_ratio.num; |
1890 | + root["display_ratio"].toObject()["den"] = info.display_ratio.den; |
1891 | root["interlaced_frame"] = info.interlaced_frame; |
1892 | |
1893 | // return JsonValue |
1894 | @@ -167,12 +168,16 @@ |
1895 | void Profile::SetJson(string value) throw(InvalidJSON) { |
1896 | |
1897 | // Parse JSON string into JSON objects |
1898 | - Json::Value root; |
1899 | - Json::Reader reader; |
1900 | - bool success = reader.parse( value, root ); |
1901 | - if (!success) |
1902 | + QJsonObject root; |
1903 | + QJsonParseError errors; |
1904 | + |
1905 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
1906 | + if (errors.error != QJsonParseError::NoError) { |
1907 | // Raise exception |
1908 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
1909 | + } |
1910 | + |
1911 | + root = document.object(); |
1912 | |
1913 | try |
1914 | { |
1915 | @@ -186,28 +191,31 @@ |
1916 | } |
1917 | } |
1918 | |
1919 | -// Load Json::JsonValue into this object |
1920 | -void Profile::SetJsonValue(Json::Value root) { |
1921 | +// Load QJsonObject into this object |
1922 | +void Profile::SetJsonValue(const QJsonObject root) { |
1923 | |
1924 | if (!root["height"].isNull()) |
1925 | - info.height = root["height"].asInt(); |
1926 | + info.height = root["height"].toVariant().toInt(); |
1927 | if (!root["width"].isNull()) |
1928 | - info.width = root["width"].asInt(); |
1929 | + info.width = root["width"].toVariant().toInt(); |
1930 | if (!root["pixel_format"].isNull()) |
1931 | - info.pixel_format = root["pixel_format"].asInt(); |
1932 | + info.pixel_format = root["pixel_format"].toVariant().toInt(); |
1933 | if (!root["fps"].isNull()) { |
1934 | - info.fps.num = root["fps"]["num"].asInt(); |
1935 | - info.fps.den = root["fps"]["den"].asInt(); |
1936 | + const QJsonObject fpsObject = root["fps"].toObject(); |
1937 | + info.fps.num = fpsObject["num"].toVariant().toInt(); |
1938 | + info.fps.den = fpsObject["den"].toVariant().toInt(); |
1939 | } |
1940 | if (!root["pixel_ratio"].isNull()) { |
1941 | - info.pixel_ratio.num = root["pixel_ratio"]["num"].asInt(); |
1942 | - info.pixel_ratio.den = root["pixel_ratio"]["den"].asInt(); |
1943 | + const QJsonObject pixelRatioObject = root["pixel_ratio"].toObject(); |
1944 | + info.pixel_ratio.num = pixelRatioObject["num"].toVariant().toInt(); |
1945 | + info.pixel_ratio.den = pixelRatioObject["den"].toVariant().toInt(); |
1946 | } |
1947 | if (!root["display_ratio"].isNull()) { |
1948 | - info.display_ratio.num = root["display_ratio"]["num"].asInt(); |
1949 | - info.display_ratio.den = root["display_ratio"]["den"].asInt(); |
1950 | + const QJsonObject displayRatioObject = root["display_ratio"].toObject(); |
1951 | + info.display_ratio.num = displayRatioObject["num"].toVariant().toInt(); |
1952 | + info.display_ratio.den = displayRatioObject["den"].toVariant().toInt(); |
1953 | } |
1954 | if (!root["interlaced_frame"].isNull()) |
1955 | - info.interlaced_frame = root["interlaced_frame"].asBool(); |
1956 | + info.interlaced_frame = root["interlaced_frame"].toBool(); |
1957 | |
1958 | } |
1959 | |
1960 | === modified file 'src/QtImageReader.cpp' |
1961 | --- src/QtImageReader.cpp 2015-09-29 03:05:50 +0000 |
1962 | +++ src/QtImageReader.cpp 2015-10-04 15:21:00 +0000 |
1963 | @@ -123,16 +123,18 @@ |
1964 | string QtImageReader::Json() { |
1965 | |
1966 | // Return formatted string |
1967 | - return JsonValue().toStyledString(); |
1968 | + QJsonDocument document; |
1969 | + document.setObject(JsonValue()); |
1970 | + return document.toJson().constData(); |
1971 | } |
1972 | |
1973 | // Generate Json::JsonValue for this object |
1974 | -Json::Value QtImageReader::JsonValue() { |
1975 | +QJsonObject QtImageReader::JsonValue() { |
1976 | |
1977 | // Create root json object |
1978 | - Json::Value root = ReaderBase::JsonValue(); // get parent properties |
1979 | + QJsonObject root = ReaderBase::JsonValue(); // get parent properties |
1980 | root["type"] = "QtImageReader"; |
1981 | - root["path"] = path; |
1982 | + root["path"] = path.c_str(); |
1983 | |
1984 | // return JsonValue |
1985 | return root; |
1986 | @@ -141,13 +143,17 @@ |
1987 | // Load JSON string into this object |
1988 | void QtImageReader::SetJson(string value) throw(InvalidJSON) { |
1989 | |
1990 | - // Parse JSON string into JSON objects |
1991 | - Json::Value root; |
1992 | - Json::Reader reader; |
1993 | - bool success = reader.parse( value, root ); |
1994 | - if (!success) |
1995 | - // Raise exception |
1996 | - throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
1997 | + // Parse JSON string into JSON objects |
1998 | + QJsonObject root; |
1999 | + QJsonParseError errors; |
2000 | + |
2001 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
2002 | + if (errors.error != QJsonParseError::NoError) { |
2003 | + // Raise exception |
2004 | + throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
2005 | + } |
2006 | + |
2007 | + root = document.object(); |
2008 | |
2009 | try |
2010 | { |
2011 | @@ -162,14 +168,14 @@ |
2012 | } |
2013 | |
2014 | // Load Json::JsonValue into this object |
2015 | -void QtImageReader::SetJsonValue(Json::Value root) throw(InvalidFile) { |
2016 | +void QtImageReader::SetJsonValue(QJsonObject root) throw(InvalidFile) { |
2017 | |
2018 | // Set parent data |
2019 | ReaderBase::SetJsonValue(root); |
2020 | |
2021 | // Set data from Json (if key is found) |
2022 | if (!root["path"].isNull()) |
2023 | - path = root["path"].asString(); |
2024 | + path = root["path"].toString().toLocal8Bit().constData(); |
2025 | |
2026 | // Re-Open path, and re-init everything (if needed) |
2027 | if (is_open) |
2028 | |
2029 | === modified file 'src/ReaderBase.cpp' |
2030 | --- src/ReaderBase.cpp 2015-09-29 03:05:50 +0000 |
2031 | +++ src/ReaderBase.cpp 2015-10-04 15:21:00 +0000 |
2032 | @@ -67,12 +67,14 @@ |
2033 | string ReaderBase::OutputDebugJSON() |
2034 | { |
2035 | // Return formatted string |
2036 | - return debug_root.toStyledString(); |
2037 | + QJsonDocument document; |
2038 | + document.setArray(debug_root); |
2039 | + return document.toJson().constData(); |
2040 | } |
2041 | |
2042 | |
2043 | // Append debug information as JSON |
2044 | -void ReaderBase::AppendDebugItem(Json::Value debug_item) |
2045 | +void ReaderBase::AppendDebugItem(QJsonValue debug_item) |
2046 | { |
2047 | // Append item to root array |
2048 | debug_root.append(debug_item); |
2049 | @@ -90,8 +92,8 @@ |
2050 | // Don't do anything |
2051 | return; |
2052 | |
2053 | - Json::Value debug_item; |
2054 | - debug_item["method"] = method_name; |
2055 | + QJsonObject debug_item; |
2056 | + debug_item["method"] = method_name.c_str(); |
2057 | |
2058 | // Output to standard output |
2059 | #pragma omp critical (debug_output) |
2060 | @@ -101,27 +103,27 @@ |
2061 | |
2062 | // Add attributes to method JSON |
2063 | if (arg1_name.length() > 0) { |
2064 | - debug_item[arg1_name] = arg1_value; |
2065 | + debug_item[arg1_name.c_str()] = arg1_value; |
2066 | cout << arg1_name << "=" << arg1_value; |
2067 | } |
2068 | if (arg2_name.length() > 0) { |
2069 | - debug_item[arg2_name] = arg2_value; |
2070 | + debug_item[arg2_name.c_str()] = arg2_value; |
2071 | cout << ", " << arg2_name << "=" << arg2_value; |
2072 | } |
2073 | if (arg3_name.length() > 0) { |
2074 | - debug_item[arg3_name] = arg3_value; |
2075 | + debug_item[arg3_name.c_str()] = arg3_value; |
2076 | cout << ", " << arg3_name << "=" << arg3_value; |
2077 | } |
2078 | if (arg4_name.length() > 0) { |
2079 | - debug_item[arg4_name] = arg4_value; |
2080 | + debug_item[arg4_name.c_str()] = arg4_value; |
2081 | cout << ", " << arg4_name << "=" << arg4_value; |
2082 | } |
2083 | if (arg5_name.length() > 0) { |
2084 | - debug_item[arg5_name] = arg5_value; |
2085 | + debug_item[arg5_name.c_str()] = arg5_value; |
2086 | cout << ", " << arg5_name << "=" << arg5_value; |
2087 | } |
2088 | if (arg6_name.length() > 0) { |
2089 | - debug_item[arg6_name] = arg6_value; |
2090 | + debug_item[arg6_name.c_str()] = arg6_value; |
2091 | cout << ", " << arg6_name << "=" << arg6_value; |
2092 | } |
2093 | |
2094 | @@ -129,7 +131,7 @@ |
2095 | cout << ")" << endl; |
2096 | |
2097 | // Append method to root array |
2098 | - debug_root.append(debug_item); |
2099 | + debug_root.append(QJsonValue(debug_item)); |
2100 | } |
2101 | } |
2102 | |
2103 | @@ -174,128 +176,124 @@ |
2104 | } |
2105 | |
2106 | // Generate Json::JsonValue for this object |
2107 | -Json::Value ReaderBase::JsonValue() { |
2108 | +QJsonObject ReaderBase::JsonValue() { |
2109 | |
2110 | // Create root json object |
2111 | - Json::Value root; |
2112 | + QJsonObject root; |
2113 | root["has_video"] = info.has_video; |
2114 | root["has_audio"] = info.has_audio; |
2115 | root["has_single_image"] = info.has_single_image; |
2116 | - root["duration"] = info.duration; |
2117 | - stringstream filesize_stream; |
2118 | - filesize_stream << info.file_size; |
2119 | - root["file_size"] = filesize_stream.str(); |
2120 | + root["duration"] = info.duration; |
2121 | + root["file_size"] = info.file_size; |
2122 | root["height"] = info.height; |
2123 | root["width"] = info.width; |
2124 | root["pixel_format"] = info.pixel_format; |
2125 | - root["fps"] = Json::Value(Json::objectValue); |
2126 | - root["fps"]["num"] = info.fps.num; |
2127 | - root["fps"]["den"] = info.fps.den; |
2128 | + root["fps"] = QJsonObject(); |
2129 | + root["fps"].toObject()["num"] = info.fps.num; |
2130 | + root["fps"].toObject()["den"] = info.fps.den; |
2131 | root["video_bit_rate"] = info.video_bit_rate; |
2132 | - root["pixel_ratio"] = Json::Value(Json::objectValue); |
2133 | - root["pixel_ratio"]["num"] = info.pixel_ratio.num; |
2134 | - root["pixel_ratio"]["den"] = info.pixel_ratio.den; |
2135 | - root["display_ratio"] = Json::Value(Json::objectValue); |
2136 | - root["display_ratio"]["num"] = info.display_ratio.num; |
2137 | - root["display_ratio"]["den"] = info.display_ratio.den; |
2138 | - root["vcodec"] = info.vcodec; |
2139 | - stringstream video_length_stream; |
2140 | - video_length_stream << info.video_length; |
2141 | - root["video_length"] = video_length_stream.str(); |
2142 | + root["pixel_ratio"] = QJsonObject(); |
2143 | + root["pixel_ratio"].toObject()["num"] = info.pixel_ratio.num; |
2144 | + root["pixel_ratio"].toObject()["den"] = info.pixel_ratio.den; |
2145 | + root["display_ratio"] = QJsonObject(); |
2146 | + root["display_ratio"].toObject()["num"] = info.display_ratio.num; |
2147 | + root["display_ratio"].toObject()["den"] = info.display_ratio.den; |
2148 | + root["vcodec"] = info.vcodec.c_str(); |
2149 | + root["video_length"] = (long long) info.video_length; |
2150 | root["video_stream_index"] = info.video_stream_index; |
2151 | - root["video_timebase"] = Json::Value(Json::objectValue); |
2152 | - root["video_timebase"]["num"] = info.video_timebase.num; |
2153 | - root["video_timebase"]["den"] = info.video_timebase.den; |
2154 | + root["video_timebase"] = QJsonObject(); |
2155 | + root["video_timebase"].toObject()["num"] = info.video_timebase.num; |
2156 | + root["video_timebase"].toObject()["den"] = info.video_timebase.den; |
2157 | root["interlaced_frame"] = info.interlaced_frame; |
2158 | root["top_field_first"] = info.top_field_first; |
2159 | - root["acodec"] = info.acodec; |
2160 | + root["acodec"] = info.acodec.c_str(); |
2161 | root["audio_bit_rate"] = info.audio_bit_rate; |
2162 | root["sample_rate"] = info.sample_rate; |
2163 | root["channels"] = info.channels; |
2164 | root["channel_layout"] = info.channel_layout; |
2165 | root["audio_stream_index"] = info.audio_stream_index; |
2166 | - root["audio_timebase"] = Json::Value(Json::objectValue); |
2167 | - root["audio_timebase"]["num"] = info.audio_timebase.num; |
2168 | - root["audio_timebase"]["den"] = info.audio_timebase.den; |
2169 | + root["audio_timebase"] = QJsonObject(); |
2170 | + root["audio_timebase"].toObject()["num"] = info.audio_timebase.num; |
2171 | + root["audio_timebase"].toObject()["den"] = info.audio_timebase.den; |
2172 | |
2173 | // return JsonValue |
2174 | return root; |
2175 | } |
2176 | |
2177 | // Load Json::JsonValue into this object |
2178 | -void ReaderBase::SetJsonValue(Json::Value root) { |
2179 | +void ReaderBase::SetJsonValue(QJsonObject root) { |
2180 | |
2181 | // Set data from Json (if key is found) |
2182 | if (!root["has_video"].isNull()) |
2183 | - info.has_video = root["has_video"].asBool(); |
2184 | + info.has_video = root["has_video"].toBool(); |
2185 | if (!root["has_audio"].isNull()) |
2186 | - info.has_audio = root["has_audio"].asBool(); |
2187 | + info.has_audio = root["has_audio"].toBool(); |
2188 | if (!root["has_single_image"].isNull()) |
2189 | - info.has_single_image = root["has_single_image"].asBool(); |
2190 | + info.has_single_image = root["has_single_image"].toBool(); |
2191 | if (!root["duration"].isNull()) |
2192 | - info.duration = root["duration"].asDouble(); |
2193 | + info.duration = root["duration"].toDouble(); |
2194 | if (!root["file_size"].isNull()) |
2195 | - info.file_size = atoll(root["file_size"].asString().c_str()); |
2196 | + info.file_size = root.value("file_size").toVariant().toLongLong(); |
2197 | if (!root["height"].isNull()) |
2198 | - info.height = root["height"].asInt(); |
2199 | + info.height = root["height"].toInt(); |
2200 | if (!root["width"].isNull()) |
2201 | - info.width = root["width"].asInt(); |
2202 | + info.width = root["width"].toInt(); |
2203 | if (!root["pixel_format"].isNull()) |
2204 | - info.pixel_format = root["pixel_format"].asInt(); |
2205 | + info.pixel_format = root["pixel_format"].toInt(); |
2206 | if (!root["fps"].isNull() && root["fps"].isObject()) { |
2207 | - if (!root["fps"]["num"].isNull()) |
2208 | - info.fps.num = root["fps"]["num"].asInt(); |
2209 | - if (!root["fps"]["den"].isNull()) |
2210 | - info.fps.den = root["fps"]["den"].asInt(); |
2211 | + if (!root["fps"].toObject()["num"].isNull()) |
2212 | + info.fps.num = root["fps"].toObject()["num"].toInt(); |
2213 | + if (!root["fps"].toObject()["den"].isNull()) |
2214 | + info.fps.den = root["fps"].toObject()["den"].toInt(); |
2215 | } |
2216 | if (!root["video_bit_rate"].isNull()) |
2217 | - info.video_bit_rate = root["video_bit_rate"].asInt(); |
2218 | + info.video_bit_rate = root["video_bit_rate"].toInt(); |
2219 | if (!root["pixel_ratio"].isNull() && root["pixel_ratio"].isObject()) { |
2220 | - if (!root["pixel_ratio"]["num"].isNull()) |
2221 | - info.pixel_ratio.num = root["pixel_ratio"]["num"].asInt(); |
2222 | - if (!root["pixel_ratio"]["den"].isNull()) |
2223 | - info.pixel_ratio.den = root["pixel_ratio"]["den"].asInt(); |
2224 | + if (!root["pixel_ratio"].toObject()["num"].isNull()) |
2225 | + info.pixel_ratio.num = root["pixel_ratio"].toObject()["num"].toInt(); |
2226 | + if (!root["pixel_ratio"].toObject()["den"].isNull()) |
2227 | + info.pixel_ratio.den = root["pixel_ratio"].toObject()["den"].toInt(); |
2228 | } |
2229 | if (!root["display_ratio"].isNull() && root["display_ratio"].isObject()) { |
2230 | - if (!root["display_ratio"]["num"].isNull()) |
2231 | - info.display_ratio.num = root["display_ratio"]["num"].asInt(); |
2232 | - if (!root["display_ratio"]["den"].isNull()) |
2233 | - info.display_ratio.den = root["display_ratio"]["den"].asInt(); |
2234 | + if (!root["display_ratio"].toObject()["num"].isNull()) |
2235 | + info.display_ratio.num = root["display_ratio"].toObject()["num"].toInt(); |
2236 | + if (!root["display_ratio"].toObject()["den"].isNull()) |
2237 | + info.display_ratio.den = root["display_ratio"].toObject()["den"].toInt(); |
2238 | } |
2239 | if (!root["vcodec"].isNull()) |
2240 | - info.vcodec = root["vcodec"].asString(); |
2241 | + info.vcodec = root["vcodec"].toString().toLocal8Bit().constData(); |
2242 | if (!root["video_length"].isNull()) |
2243 | - info.video_length = atoll(root["video_length"].asString().c_str()); |
2244 | + info.video_length = root.value("video_length").toVariant().toLongLong(); |
2245 | if (!root["video_stream_index"].isNull()) |
2246 | - info.video_stream_index = root["video_stream_index"].asInt(); |
2247 | + info.video_stream_index = root["video_stream_index"].toInt(); |
2248 | if (!root["video_timebase"].isNull() && root["video_timebase"].isObject()) { |
2249 | - if (!root["video_timebase"]["num"].isNull()) |
2250 | - info.video_timebase.num = root["video_timebase"]["num"].asInt(); |
2251 | - if (!root["video_timebase"]["den"].isNull()) |
2252 | - info.video_timebase.den = root["video_timebase"]["den"].asInt(); |
2253 | + if (!root["video_timebase"].toObject()["num"].isNull()) |
2254 | + info.video_timebase.num = root["video_timebase"].toObject()["num"].toInt(); |
2255 | + if (!root["video_timebase"].toObject()["den"].isNull()) |
2256 | + info.video_timebase.den = root["video_timebase"].toObject()["den"].toInt(); |
2257 | } |
2258 | if (!root["interlaced_frame"].isNull()) |
2259 | - info.interlaced_frame = root["interlaced_frame"].asBool(); |
2260 | + info.interlaced_frame = root["interlaced_frame"].toBool(); |
2261 | if (!root["top_field_first"].isNull()) |
2262 | - info.top_field_first = root["top_field_first"].asBool(); |
2263 | + info.top_field_first = root["top_field_first"].toBool(); |
2264 | if (!root["acodec"].isNull()) |
2265 | - info.acodec = root["acodec"].asString(); |
2266 | + info.acodec = root["acodec"].toString().toLocal8Bit().constData(); |
2267 | |
2268 | if (!root["audio_bit_rate"].isNull()) |
2269 | - info.audio_bit_rate = root["audio_bit_rate"].asInt(); |
2270 | + info.audio_bit_rate = root["audio_bit_rate"].toInt(); |
2271 | if (!root["sample_rate"].isNull()) |
2272 | - info.sample_rate = root["sample_rate"].asInt(); |
2273 | + info.sample_rate = root["sample_rate"].toInt(); |
2274 | if (!root["channels"].isNull()) |
2275 | - info.channels = root["channels"].asInt(); |
2276 | + info.channels = root["channels"].toInt(); |
2277 | if (!root["channel_layout"].isNull()) |
2278 | - info.channel_layout = (ChannelLayout) root["channel_layout"].asInt(); |
2279 | + info.channel_layout = (ChannelLayout) root["channel_layout"].toInt(); |
2280 | if (!root["audio_stream_index"].isNull()) |
2281 | - info.audio_stream_index = root["audio_stream_index"].asInt(); |
2282 | + info.audio_stream_index = root["audio_stream_index"].toInt(); |
2283 | if (!root["audio_timebase"].isNull() && root["audio_timebase"].isObject()) { |
2284 | - if (!root["audio_timebase"]["num"].isNull()) |
2285 | - info.audio_timebase.num = root["audio_timebase"]["num"].asInt(); |
2286 | - if (!root["audio_timebase"]["den"].isNull()) |
2287 | - info.audio_timebase.den = root["audio_timebase"]["den"].asInt(); |
2288 | + if (!root["audio_timebase"].toObject()["num"].isNull()) |
2289 | + info.audio_timebase.num = root["audio_timebase"].toObject()["num"].toInt(); |
2290 | + if (!root["audio_timebase"].toObject()["den"].isNull()) |
2291 | + info.audio_timebase.den = root["audio_timebase"].toObject()["den"].toInt(); |
2292 | } |
2293 | } |
2294 | |
2295 | |
2296 | === modified file 'src/TextReader.cpp' |
2297 | --- src/TextReader.cpp 2015-08-24 06:05:48 +0000 |
2298 | +++ src/TextReader.cpp 2015-10-04 15:21:00 +0000 |
2299 | @@ -171,28 +171,29 @@ |
2300 | // Generate JSON string of this object |
2301 | string TextReader::Json() { |
2302 | |
2303 | - // Return formatted string |
2304 | - return JsonValue().toStyledString(); |
2305 | + QJsonDocument document; |
2306 | + document.setObject(JsonValue()); |
2307 | + return document.toJson().constData(); |
2308 | } |
2309 | |
2310 | -// Generate Json::JsonValue for this object |
2311 | -Json::Value TextReader::JsonValue() { |
2312 | +// Generate QJsonObject for this object |
2313 | +QJsonObject TextReader::JsonValue() { |
2314 | |
2315 | // Create root json object |
2316 | - Json::Value root = ReaderBase::JsonValue(); // get parent properties |
2317 | + QJsonObject root = ReaderBase::JsonValue(); // get parent properties |
2318 | root["type"] = "TextReader"; |
2319 | root["width"] = width; |
2320 | root["height"] = height; |
2321 | root["x_offset"] = x_offset; |
2322 | root["y_offset"] = y_offset; |
2323 | - root["text"] = text; |
2324 | - root["font"] = font; |
2325 | + root["text"] = text.c_str(); |
2326 | + root["font"] = font.c_str(); |
2327 | root["size"] = size; |
2328 | - root["text_color"] = text_color; |
2329 | - root["background_color"] = background_color; |
2330 | + root["text_color"] = text_color.c_str(); |
2331 | + root["background_color"] = background_color.c_str(); |
2332 | root["gravity"] = gravity; |
2333 | |
2334 | - // return JsonValue |
2335 | + // return QJsonObject |
2336 | return root; |
2337 | } |
2338 | |
2339 | @@ -200,12 +201,16 @@ |
2340 | void TextReader::SetJson(string value) throw(InvalidJSON) { |
2341 | |
2342 | // Parse JSON string into JSON objects |
2343 | - Json::Value root; |
2344 | - Json::Reader reader; |
2345 | - bool success = reader.parse( value, root ); |
2346 | - if (!success) |
2347 | + QJsonObject root; |
2348 | + QJsonParseError errors; |
2349 | + |
2350 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
2351 | + if (errors.error != QJsonParseError::NoError) { |
2352 | // Raise exception |
2353 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
2354 | + } |
2355 | + |
2356 | + root = document.object(); |
2357 | |
2358 | try |
2359 | { |
2360 | @@ -219,33 +224,33 @@ |
2361 | } |
2362 | } |
2363 | |
2364 | -// Load Json::JsonValue into this object |
2365 | -void TextReader::SetJsonValue(Json::Value root) throw(InvalidFile) { |
2366 | +// Load QJsonObject into this object |
2367 | +void TextReader::SetJsonValue(const QJsonObject root) throw(InvalidFile) { |
2368 | |
2369 | // Set parent data |
2370 | ReaderBase::SetJsonValue(root); |
2371 | |
2372 | // Set data from Json (if key is found) |
2373 | if (!root["width"].isNull()) |
2374 | - width = root["width"].asInt(); |
2375 | + width = root["width"].toVariant().toInt(); |
2376 | if (!root["height"].isNull()) |
2377 | - height = root["height"].asInt(); |
2378 | + height = root["height"].toVariant().toInt(); |
2379 | if (!root["x_offset"].isNull()) |
2380 | - x_offset = root["x_offset"].asInt(); |
2381 | + x_offset = root["x_offset"].toVariant().toInt(); |
2382 | if (!root["y_offset"].isNull()) |
2383 | - y_offset = root["y_offset"].asInt(); |
2384 | + y_offset = root["y_offset"].toVariant().toInt(); |
2385 | if (!root["text"].isNull()) |
2386 | - text = root["text"].asString(); |
2387 | + text = root["text"].toString().toLocal8Bit().constData(); |
2388 | if (!root["font"].isNull()) |
2389 | - font = root["font"].asString(); |
2390 | + font = root["font"].toString().toLocal8Bit().constData(); |
2391 | if (!root["size"].isNull()) |
2392 | - size = root["size"].asDouble(); |
2393 | + size = root["size"].toDouble(); |
2394 | if (!root["text_color"].isNull()) |
2395 | - text_color = root["text_color"].asString(); |
2396 | + text_color = root["text_color"].toString().toLocal8Bit().constData(); |
2397 | if (!root["background_color"].isNull()) |
2398 | - background_color = root["background_color"].asString(); |
2399 | + background_color = root["background_color"].toString().toLocal8Bit().constData(); |
2400 | if (!root["gravity"].isNull()) |
2401 | - gravity = (GravityType) root["gravity"].asInt(); |
2402 | + gravity = (GravityType) root["gravity"].toVariant().toInt(); |
2403 | |
2404 | // Re-Open path, and re-init everything (if needed) |
2405 | if (is_open) |
2406 | |
2407 | === modified file 'src/Timeline.cpp' |
2408 | --- src/Timeline.cpp 2015-08-25 04:49:45 +0000 |
2409 | +++ src/Timeline.cpp 2015-10-04 15:21:00 +0000 |
2410 | @@ -750,15 +750,16 @@ |
2411 | // Generate JSON string of this object |
2412 | string Timeline::Json() { |
2413 | |
2414 | - // Return formatted string |
2415 | - return JsonValue().toStyledString(); |
2416 | + QJsonDocument document; |
2417 | + document.setObject(JsonValue()); |
2418 | + return document.toJson().constData(); |
2419 | } |
2420 | |
2421 | -// Generate Json::JsonValue for this object |
2422 | -Json::Value Timeline::JsonValue() { |
2423 | +// Generate QJsonObject for this object |
2424 | +QJsonObject Timeline::JsonValue() { |
2425 | |
2426 | // Create root json object |
2427 | - Json::Value root = ReaderBase::JsonValue(); // get parent properties |
2428 | + QJsonObject root = ReaderBase::JsonValue(); // get parent properties |
2429 | root["type"] = "Timeline"; |
2430 | root["viewport_scale"] = viewport_scale.JsonValue(); |
2431 | root["viewport_x"] = viewport_x.JsonValue(); |
2432 | @@ -766,7 +767,7 @@ |
2433 | root["color"] = color.JsonValue(); |
2434 | |
2435 | // Add array of clips |
2436 | - root["clips"] = Json::Value(Json::arrayValue); |
2437 | + root["clips"] = QJsonArray(); |
2438 | |
2439 | // Find Clips at this time |
2440 | list<Clip*>::iterator clip_itr; |
2441 | @@ -774,11 +775,11 @@ |
2442 | { |
2443 | // Get clip object from the iterator |
2444 | Clip *existing_clip = (*clip_itr); |
2445 | - root["clips"].append(existing_clip->JsonValue()); |
2446 | + root["clips"].toArray().append(existing_clip->JsonValue()); |
2447 | } |
2448 | |
2449 | // Add array of effects |
2450 | - root["effects"] = Json::Value(Json::arrayValue); |
2451 | + root["effects"] = QJsonArray(); |
2452 | |
2453 | // loop through effects |
2454 | list<EffectBase*>::iterator effect_itr; |
2455 | @@ -786,7 +787,7 @@ |
2456 | { |
2457 | // Get clip object from the iterator |
2458 | EffectBase *existing_effect = (*effect_itr); |
2459 | - root["effects"].append(existing_effect->JsonValue()); |
2460 | + root["effects"].toArray().append(existing_effect->JsonValue()); |
2461 | } |
2462 | |
2463 | // return JsonValue |
2464 | @@ -797,12 +798,16 @@ |
2465 | void Timeline::SetJson(string value) throw(InvalidJSON) { |
2466 | |
2467 | // Parse JSON string into JSON objects |
2468 | - Json::Value root; |
2469 | - Json::Reader reader; |
2470 | - bool success = reader.parse( value, root ); |
2471 | - if (!success) |
2472 | + QJsonObject root; |
2473 | + QJsonParseError errors; |
2474 | + |
2475 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
2476 | + if (errors.error != QJsonParseError::NoError) { |
2477 | // Raise exception |
2478 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
2479 | + } |
2480 | + |
2481 | + root = document.object(); |
2482 | |
2483 | try |
2484 | { |
2485 | @@ -816,8 +821,8 @@ |
2486 | } |
2487 | } |
2488 | |
2489 | -// Load Json::JsonValue into this object |
2490 | -void Timeline::SetJsonValue(Json::Value root) throw(InvalidFile, ReaderClosed) { |
2491 | +// Load QJsonObject into this object |
2492 | +void Timeline::SetJsonValue(QJsonObject root) throw(InvalidFile, ReaderClosed) { |
2493 | |
2494 | // Close timeline before we do anything (this also removes all open and closing clips) |
2495 | Close(); |
2496 | @@ -830,9 +835,9 @@ |
2497 | clips.clear(); |
2498 | |
2499 | // loop through clips |
2500 | - for (int x = 0; x < root["clips"].size(); x++) { |
2501 | + for (int x = 0; x < root["clips"].toArray().size(); x++) { |
2502 | // Get each clip |
2503 | - Json::Value existing_clip = root["clips"][x]; |
2504 | + QJsonObject existing_clip = root["clips"].toArray()[x].toObject(); |
2505 | |
2506 | // Create Clip |
2507 | Clip *c = new Clip(); |
2508 | @@ -850,25 +855,25 @@ |
2509 | effects.clear(); |
2510 | |
2511 | // loop through effects |
2512 | - for (int x = 0; x < root["effects"].size(); x++) { |
2513 | + for (int x = 0; x < root["effects"].toArray().size(); x++) { |
2514 | // Get each effect |
2515 | - Json::Value existing_effect = root["effects"][x]; |
2516 | + QJsonObject existing_effect = root["effects"].toArray()[x].toObject(); |
2517 | |
2518 | // Create Effect |
2519 | EffectBase *e = NULL; |
2520 | |
2521 | if (!existing_effect["type"].isNull()) |
2522 | // Init the matching effect object |
2523 | - if (existing_effect["type"].asString() == "ChromaKey") |
2524 | + if (existing_effect["type"].toString() == "ChromaKey") |
2525 | e = new ChromaKey(); |
2526 | |
2527 | - else if (existing_effect["type"].asString() == "Deinterlace") |
2528 | + else if (existing_effect["type"].toString() == "Deinterlace") |
2529 | e = new Deinterlace(); |
2530 | |
2531 | - else if (existing_effect["type"].asString() == "Mask") |
2532 | + else if (existing_effect["type"].toString() == "Mask") |
2533 | e = new Mask(); |
2534 | |
2535 | - else if (existing_effect["type"].asString() == "Negate") |
2536 | + else if (existing_effect["type"].toString() == "Negate") |
2537 | e = new Negate(); |
2538 | |
2539 | // Load Json into Effect |
2540 | @@ -887,20 +892,24 @@ |
2541 | final_cache.Clear(); |
2542 | |
2543 | // Parse JSON string into JSON objects |
2544 | - Json::Value root; |
2545 | - Json::Reader reader; |
2546 | - bool success = reader.parse( value, root ); |
2547 | - if (!success || !root.isArray()) |
2548 | + QJsonArray root; |
2549 | + QJsonParseError errors; |
2550 | + |
2551 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
2552 | + if (errors.error != QJsonParseError::NoError) { |
2553 | // Raise exception |
2554 | - throw InvalidJSON("JSON could not be parsed (or is invalid).", ""); |
2555 | + throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
2556 | + } |
2557 | + |
2558 | + root = document.array(); |
2559 | |
2560 | try |
2561 | { |
2562 | // Process the JSON change array, loop through each item |
2563 | for (int x = 0; x < root.size(); x++) { |
2564 | // Get each change |
2565 | - Json::Value change = root[x]; |
2566 | - string root_key = change["key"][(uint)0].asString(); |
2567 | + QJsonObject change = root[x].toObject(); |
2568 | + QString root_key = change["key"].toArray()[0].toString(); |
2569 | |
2570 | // Process each type of change |
2571 | if (root_key == "clips") |
2572 | @@ -928,23 +937,23 @@ |
2573 | } |
2574 | |
2575 | // Apply JSON diff to clips |
2576 | -void Timeline::apply_json_to_clips(Json::Value change) throw(InvalidJSONKey) { |
2577 | +void Timeline::apply_json_to_clips(QJsonObject change) throw(InvalidJSONKey) { |
2578 | |
2579 | // Get key and type of change |
2580 | - string change_type = change["type"].asString(); |
2581 | - string clip_id = ""; |
2582 | + QString change_type = change["type"].toString(); |
2583 | + QString clip_id; |
2584 | Clip *existing_clip = NULL; |
2585 | |
2586 | // Find id of clip (if any) |
2587 | - for (int x = 0; x < change["key"].size(); x++) { |
2588 | + for (int x = 0; x < change["key"].toArray().size(); x++) { |
2589 | // Get each change |
2590 | - Json::Value key_part = change["key"][x]; |
2591 | + QJsonValue key_part = change["key"].toArray()[x]; |
2592 | |
2593 | if (key_part.isObject()) { |
2594 | // Check for id |
2595 | - if (!key_part["id"].isNull()) { |
2596 | + if (!key_part.toObject()["id"].isNull()) { |
2597 | // Set the id |
2598 | - clip_id = key_part["id"].asString(); |
2599 | + clip_id = key_part.toObject()["id"].toString(); |
2600 | |
2601 | // Find matching clip in timeline (if any) |
2602 | list<Clip*>::iterator clip_itr; |
2603 | @@ -952,7 +961,7 @@ |
2604 | { |
2605 | // Get clip object from the iterator |
2606 | Clip *c = (*clip_itr); |
2607 | - if (c->Id() == clip_id) { |
2608 | + if (c->Id().c_str() == clip_id) { |
2609 | existing_clip = c; |
2610 | break; // clip found, exit loop |
2611 | } |
2612 | @@ -964,18 +973,18 @@ |
2613 | |
2614 | // Check for a more specific key (targetting this clip's effects) |
2615 | // For example: ["clips", {"id:123}, "effects", {"id":432}] |
2616 | - if (existing_clip && change["key"].size() == 4 && change["key"][2] == "effects") |
2617 | + if (existing_clip && change["key"].toArray().size() == 4 && change["key"].toArray()[2].toString() == "effects") |
2618 | { |
2619 | // This change is actually targetting a specific effect under a clip (and not the clip) |
2620 | EffectBase *existing_effect = NULL; |
2621 | - Json::Value key_part = change["key"][3]; |
2622 | |
2623 | - if (key_part.isObject()) { |
2624 | + if (change["key"].toArray()[3].isObject()) { |
2625 | + QJsonObject key_part = change["key"].toArray()[3].toObject(); |
2626 | // Check for id |
2627 | if (!key_part["id"].isNull()) |
2628 | { |
2629 | // Set the id |
2630 | - string effect_id = key_part["id"].asString(); |
2631 | + string effect_id = key_part["id"].toString().toLocal8Bit().constData(); |
2632 | |
2633 | // Find matching effect in timeline (if any) |
2634 | list<EffectBase*>::iterator effect_itr; |
2635 | @@ -1000,14 +1009,14 @@ |
2636 | |
2637 | // Create new clip |
2638 | Clip *clip = new Clip(); |
2639 | - clip->SetJsonValue(change["value"]); // Set properties of new clip from JSON |
2640 | + clip->SetJsonValue(change["value"].toObject()); // Set properties of new clip from JSON |
2641 | AddClip(clip); // Add clip to timeline |
2642 | |
2643 | } else if (change_type == "update") { |
2644 | |
2645 | // Update existing clip |
2646 | if (existing_clip) |
2647 | - existing_clip->SetJsonValue(change["value"]); // Update clip properties from JSON |
2648 | + existing_clip->SetJsonValue(change["value"].toObject()); // Update clip properties from JSON |
2649 | |
2650 | } else if (change_type == "delete") { |
2651 | |
2652 | @@ -1020,23 +1029,21 @@ |
2653 | } |
2654 | |
2655 | // Apply JSON diff to effects |
2656 | -void Timeline::apply_json_to_effects(Json::Value change) throw(InvalidJSONKey) { |
2657 | +void Timeline::apply_json_to_effects(QJsonObject change) throw(InvalidJSONKey) { |
2658 | |
2659 | // Get key and type of change |
2660 | - string change_type = change["type"].asString(); |
2661 | + string change_type = change["type"].toString().toLocal8Bit().constData(); |
2662 | EffectBase *existing_effect = NULL; |
2663 | |
2664 | // Find id of an effect (if any) |
2665 | - for (int x = 0; x < change["key"].size(); x++) { |
2666 | - // Get each change |
2667 | - Json::Value key_part = change["key"][x]; |
2668 | - |
2669 | - if (key_part.isObject()) { |
2670 | + for (int x = 0; x < change["key"].toArray().size(); x++) { |
2671 | + if (change["key"].toArray()[x].isObject()) { |
2672 | + QJsonObject key_part = change["key"].toArray()[x].toObject(); |
2673 | // Check for id |
2674 | if (!key_part["id"].isNull()) |
2675 | { |
2676 | // Set the id |
2677 | - string effect_id = key_part["id"].asString(); |
2678 | + string effect_id = key_part["id"].toString().toLocal8Bit().constData(); |
2679 | |
2680 | // Find matching effect in timeline (if any) |
2681 | list<EffectBase*>::iterator effect_itr; |
2682 | @@ -1044,7 +1051,7 @@ |
2683 | { |
2684 | // Get effect object from the iterator |
2685 | EffectBase *e = (*effect_itr); |
2686 | - if (e->Id() == effect_id) { |
2687 | + if (e->Id().c_str() == effect_id) { |
2688 | existing_effect = e; |
2689 | break; // effect found, exit loop |
2690 | } |
2691 | @@ -1061,16 +1068,16 @@ |
2692 | } |
2693 | |
2694 | // Apply JSON diff to effects (if you already know which effect needs to be updated) |
2695 | -void Timeline::apply_json_to_effects(Json::Value change, EffectBase* existing_effect) throw(InvalidJSONKey) { |
2696 | +void Timeline::apply_json_to_effects(QJsonObject change, EffectBase* existing_effect) throw(InvalidJSONKey) { |
2697 | |
2698 | // Get key and type of change |
2699 | - string change_type = change["type"].asString(); |
2700 | + string change_type = change["type"].toString().toLocal8Bit().constData(); |
2701 | |
2702 | // Determine type of change operation |
2703 | if (change_type == "insert") { |
2704 | |
2705 | // Determine type of effect |
2706 | - string effect_type = change["value"]["type"].asString(); |
2707 | + QString effect_type = change["value"].toObject()["type"].toString(); |
2708 | |
2709 | // Create Effect |
2710 | EffectBase *e = NULL; |
2711 | @@ -1089,7 +1096,7 @@ |
2712 | e = new Negate(); |
2713 | |
2714 | // Load Json into Effect |
2715 | - e->SetJsonValue(change["value"]); |
2716 | + e->SetJsonValue(change["value"].toObject()); |
2717 | |
2718 | // Add Effect to Timeline |
2719 | AddEffect(e); |
2720 | @@ -1098,7 +1105,7 @@ |
2721 | |
2722 | // Update existing effect |
2723 | if (existing_effect) |
2724 | - existing_effect->SetJsonValue(change["value"]); // Update effect properties from JSON |
2725 | + existing_effect->SetJsonValue(change["value"].toObject()); // Update effect properties from JSON |
2726 | |
2727 | } else if (change_type == "delete") { |
2728 | |
2729 | @@ -1110,11 +1117,11 @@ |
2730 | } |
2731 | |
2732 | // Apply JSON diff to timeline properties |
2733 | -void Timeline::apply_json_to_timeline(Json::Value change) throw(InvalidJSONKey) { |
2734 | +void Timeline::apply_json_to_timeline(QJsonObject change) throw(InvalidJSONKey) { |
2735 | |
2736 | // Get key and type of change |
2737 | - string change_type = change["type"].asString(); |
2738 | - string root_key = change["key"][(uint)0].asString(); |
2739 | + QString change_type = change["type"].toString(); |
2740 | + QString root_key = change["key"].toArray()[0].toString(); |
2741 | |
2742 | // Determine type of change operation |
2743 | if (change_type == "insert" || change_type == "update") { |
2744 | @@ -1123,36 +1130,38 @@ |
2745 | // Check for valid property |
2746 | if (root_key == "color") |
2747 | // Set color |
2748 | - color.SetJsonValue(change["value"]); |
2749 | + color.SetJsonValue(change["value"].toObject()); |
2750 | else if (root_key == "viewport_scale") |
2751 | // Set viewport scale |
2752 | - viewport_scale.SetJsonValue(change["value"]); |
2753 | + viewport_scale.SetJsonValue(change["value"].toObject()); |
2754 | else if (root_key == "viewport_x") |
2755 | // Set viewport x offset |
2756 | - viewport_x.SetJsonValue(change["value"]); |
2757 | + viewport_x.SetJsonValue(change["value"].toObject()); |
2758 | else if (root_key == "viewport_y") |
2759 | // Set viewport y offset |
2760 | - viewport_y.SetJsonValue(change["value"]); |
2761 | + viewport_y.SetJsonValue(change["value"].toObject()); |
2762 | else if (root_key == "width") |
2763 | // Set width |
2764 | - info.width = change["value"].asInt(); |
2765 | + info.width = change["value"].toInt(); |
2766 | else if (root_key == "height") |
2767 | // Set height |
2768 | - info.height = change["value"].asInt(); |
2769 | - else if (root_key == "fps" && change["key"][(uint)1].asString() == "num") |
2770 | + info.height = change["value"].toInt(); |
2771 | + else if (root_key == "fps" && change["key"].toArray()[1].toString() == "num") |
2772 | // Set fps.num |
2773 | - info.fps.num = change["value"].asInt(); |
2774 | - else if (root_key == "fps" && change["key"][(uint)1].asString() == "den") |
2775 | + info.fps.num = change["value"].toInt(); |
2776 | + else if (root_key == "fps" && change["key"].toArray()[1].toString() == "den") |
2777 | // Set fps.den |
2778 | - info.fps.den = change["value"].asInt(); |
2779 | - |
2780 | - else |
2781 | - |
2782 | + info.fps.den = change["value"].toInt(); |
2783 | + |
2784 | + else { |
2785 | // Error parsing JSON (or missing keys) |
2786 | - throw InvalidJSONKey("JSON change key is invalid", change.toStyledString()); |
2787 | - |
2788 | - |
2789 | - } else if (change["type"].asString() == "delete") { |
2790 | + QJsonDocument document; |
2791 | + document.setObject(change); |
2792 | + throw InvalidJSONKey("JSON change key is invalid", document.toJson().constData()); |
2793 | + } |
2794 | + |
2795 | + |
2796 | + } else if (change["type"].toString() == "delete") { |
2797 | |
2798 | // DELETE / RESET |
2799 | // Reset the following properties (since we can't delete them) |
2800 | @@ -1168,9 +1177,12 @@ |
2801 | viewport_x = Keyframe(0.0); |
2802 | else if (root_key == "viewport_y") |
2803 | viewport_y = Keyframe(0.0); |
2804 | - else |
2805 | - // Error parsing JSON (or missing keys) |
2806 | - throw InvalidJSONKey("JSON change key is invalid", change.toStyledString()); |
2807 | + else { |
2808 | + // Error parsing JSON (or missing keys) |
2809 | + QJsonDocument document; |
2810 | + document.setObject(change); |
2811 | + throw InvalidJSONKey("JSON change key is invalid", document.toJson().constData()); |
2812 | + } |
2813 | |
2814 | } |
2815 | |
2816 | |
2817 | === modified file 'src/WriterBase.cpp' |
2818 | --- src/WriterBase.cpp 2015-09-29 03:05:50 +0000 |
2819 | +++ src/WriterBase.cpp 2015-10-04 15:21:00 +0000 |
2820 | @@ -67,11 +67,13 @@ |
2821 | string WriterBase::OutputDebugJSON() |
2822 | { |
2823 | // Return formatted string |
2824 | - return debug_root.toStyledString(); |
2825 | + QJsonDocument document; |
2826 | + document.setArray(debug_root); |
2827 | + return document.toJson().constData(); |
2828 | } |
2829 | |
2830 | // Append debug information as JSON |
2831 | -void WriterBase::AppendDebugItem(Json::Value debug_item) |
2832 | +void WriterBase::AppendDebugItem(QJsonValue debug_item) |
2833 | { |
2834 | // Append item to root array |
2835 | debug_root.append(debug_item); |
2836 | @@ -89,8 +91,8 @@ |
2837 | // Don't do anything |
2838 | return; |
2839 | |
2840 | - Json::Value debug_item; |
2841 | - debug_item["method"] = method_name; |
2842 | + QJsonObject debug_item; |
2843 | + debug_item["method"] = method_name.c_str(); |
2844 | |
2845 | // Output to standard output |
2846 | cout << fixed << setprecision(4); |
2847 | @@ -98,27 +100,27 @@ |
2848 | |
2849 | // Add attributes to method JSON |
2850 | if (arg1_name.length() > 0) { |
2851 | - debug_item[arg1_name] = arg1_value; |
2852 | + debug_item[arg1_name.c_str()] = arg1_value; |
2853 | cout << arg1_name << "=" << arg1_value; |
2854 | } |
2855 | if (arg2_name.length() > 0) { |
2856 | - debug_item[arg2_name] = arg2_value; |
2857 | + debug_item[arg2_name.c_str()] = arg2_value; |
2858 | cout << ", " << arg2_name << "=" << arg2_value; |
2859 | } |
2860 | if (arg3_name.length() > 0) { |
2861 | - debug_item[arg3_name] = arg3_value; |
2862 | + debug_item[arg3_name.c_str()] = arg3_value; |
2863 | cout << ", " << arg3_name << "=" << arg3_value; |
2864 | } |
2865 | if (arg4_name.length() > 0) { |
2866 | - debug_item[arg4_name] = arg4_value; |
2867 | + debug_item[arg4_name.c_str()] = arg4_value; |
2868 | cout << ", " << arg4_name << "=" << arg4_value; |
2869 | } |
2870 | if (arg5_name.length() > 0) { |
2871 | - debug_item[arg5_name] = arg5_value; |
2872 | + debug_item[arg5_name.c_str()] = arg5_value; |
2873 | cout << ", " << arg5_name << "=" << arg5_value; |
2874 | } |
2875 | if (arg6_name.length() > 0) { |
2876 | - debug_item[arg6_name] = arg6_value; |
2877 | + debug_item[arg6_name.c_str()] = arg6_value; |
2878 | cout << ", " << arg6_name << "=" << arg6_value; |
2879 | } |
2880 | |
2881 | @@ -126,7 +128,7 @@ |
2882 | cout << ")" << endl; |
2883 | |
2884 | // Append method to root array |
2885 | - debug_root.append(debug_item); |
2886 | + debug_root.append(QJsonValue(debug_item)); |
2887 | } |
2888 | |
2889 | // This method copy's the info struct of a reader, and sets the writer with the same info |
2890 | @@ -208,53 +210,51 @@ |
2891 | string WriterBase::Json() { |
2892 | |
2893 | // Return formatted string |
2894 | - return JsonValue().toStyledString(); |
2895 | + QJsonDocument document; |
2896 | + document.setObject(JsonValue()); |
2897 | + return document.toJson().constData(); |
2898 | } |
2899 | |
2900 | -// Generate Json::JsonValue for this object |
2901 | -Json::Value WriterBase::JsonValue() { |
2902 | +// Generate QJsonObject for this object |
2903 | +QJsonObject WriterBase::JsonValue() { |
2904 | |
2905 | // Create root json object |
2906 | - Json::Value root; |
2907 | + QJsonObject root; |
2908 | root["has_video"] = info.has_video; |
2909 | root["has_audio"] = info.has_audio; |
2910 | root["has_single_image"] = info.has_single_image; |
2911 | - root["duration"] = info.duration; |
2912 | - stringstream filesize_stream; |
2913 | - filesize_stream << info.file_size; |
2914 | - root["file_size"] = filesize_stream.str(); |
2915 | + root["duration"] = info.duration; |
2916 | + root["file_size"] = info.file_size; |
2917 | root["height"] = info.height; |
2918 | root["width"] = info.width; |
2919 | root["pixel_format"] = info.pixel_format; |
2920 | - root["fps"] = Json::Value(Json::objectValue); |
2921 | - root["fps"]["num"] = info.fps.num; |
2922 | - root["fps"]["den"] = info.fps.den; |
2923 | + root["fps"] = QJsonObject(); |
2924 | + root["fps"].toObject()["num"] = info.fps.num; |
2925 | + root["fps"].toObject()["den"] = info.fps.den; |
2926 | root["video_bit_rate"] = info.video_bit_rate; |
2927 | - root["pixel_ratio"] = Json::Value(Json::objectValue); |
2928 | - root["pixel_ratio"]["num"] = info.pixel_ratio.num; |
2929 | - root["pixel_ratio"]["den"] = info.pixel_ratio.den; |
2930 | - root["display_ratio"] = Json::Value(Json::objectValue); |
2931 | - root["display_ratio"]["num"] = info.display_ratio.num; |
2932 | - root["display_ratio"]["den"] = info.display_ratio.den; |
2933 | - root["vcodec"] = info.vcodec; |
2934 | - stringstream video_length_stream; |
2935 | - video_length_stream << info.video_length; |
2936 | - root["video_length"] = video_length_stream.str(); |
2937 | + root["pixel_ratio"] = QJsonObject(); |
2938 | + root["pixel_ratio"].toObject()["num"] = info.pixel_ratio.num; |
2939 | + root["pixel_ratio"].toObject()["den"] = info.pixel_ratio.den; |
2940 | + root["display_ratio"] = QJsonObject(); |
2941 | + root["display_ratio"].toObject()["num"] = info.display_ratio.num; |
2942 | + root["display_ratio"].toObject()["den"] = info.display_ratio.den; |
2943 | + root["vcodec"] = info.vcodec.c_str(); |
2944 | + root["video_length"] = (long long) info.video_length; |
2945 | root["video_stream_index"] = info.video_stream_index; |
2946 | - root["video_timebase"] = Json::Value(Json::objectValue); |
2947 | - root["video_timebase"]["num"] = info.video_timebase.num; |
2948 | - root["video_timebase"]["den"] = info.video_timebase.den; |
2949 | + root["video_timebase"] = QJsonObject(); |
2950 | + root["video_timebase"].toObject()["num"] = info.video_timebase.num; |
2951 | + root["video_timebase"].toObject()["den"] = info.video_timebase.den; |
2952 | root["interlaced_frame"] = info.interlaced_frame; |
2953 | root["top_field_first"] = info.top_field_first; |
2954 | - root["acodec"] = info.acodec; |
2955 | + root["acodec"] = info.acodec.c_str(); |
2956 | root["audio_bit_rate"] = info.audio_bit_rate; |
2957 | root["sample_rate"] = info.sample_rate; |
2958 | root["channels"] = info.channels; |
2959 | root["channel_layout"] = info.channel_layout; |
2960 | root["audio_stream_index"] = info.audio_stream_index; |
2961 | - root["audio_timebase"] = Json::Value(Json::objectValue); |
2962 | - root["audio_timebase"]["num"] = info.audio_timebase.num; |
2963 | - root["audio_timebase"]["den"] = info.audio_timebase.den; |
2964 | + root["audio_timebase"] = QJsonObject(); |
2965 | + root["audio_timebase"].toObject()["num"] = info.audio_timebase.num; |
2966 | + root["audio_timebase"].toObject()["den"] = info.audio_timebase.den; |
2967 | |
2968 | // return JsonValue |
2969 | return root; |
2970 | @@ -264,12 +264,16 @@ |
2971 | void WriterBase::SetJson(string value) throw(InvalidJSON) { |
2972 | |
2973 | // Parse JSON string into JSON objects |
2974 | - Json::Value root; |
2975 | - Json::Reader reader; |
2976 | - bool success = reader.parse( value, root ); |
2977 | - if (!success) |
2978 | + QJsonObject root; |
2979 | + QJsonParseError errors; |
2980 | + |
2981 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
2982 | + if (errors.error != QJsonParseError::NoError) { |
2983 | // Raise exception |
2984 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
2985 | + } |
2986 | + |
2987 | + root = document.object(); |
2988 | |
2989 | try |
2990 | { |
2991 | @@ -284,78 +288,78 @@ |
2992 | } |
2993 | |
2994 | // Load Json::JsonValue into this object |
2995 | -void WriterBase::SetJsonValue(Json::Value root) { |
2996 | +void WriterBase::SetJsonValue(QJsonObject root) { |
2997 | |
2998 | // Set data from Json (if key is found) |
2999 | if (!root["has_video"].isNull()) |
3000 | - info.has_video = root["has_video"].asBool(); |
3001 | + info.has_video = root["has_video"].toBool(); |
3002 | if (!root["has_audio"].isNull()) |
3003 | - info.has_audio = root["has_audio"].asBool(); |
3004 | + info.has_audio = root["has_audio"].toBool(); |
3005 | if (!root["has_single_image"].isNull()) |
3006 | - info.has_single_image = root["has_single_image"].asBool(); |
3007 | + info.has_single_image = root["has_single_image"].toBool(); |
3008 | if (!root["duration"].isNull()) |
3009 | - info.duration = root["duration"].asDouble(); |
3010 | + info.duration = root["duration"].toDouble(); |
3011 | if (!root["file_size"].isNull()) |
3012 | - info.file_size = (long long) root["file_size"].asUInt(); |
3013 | + info.file_size = root.value("file_size").toVariant().toLongLong(); |
3014 | if (!root["height"].isNull()) |
3015 | - info.height = root["height"].asInt(); |
3016 | + info.height = root["height"].toInt(); |
3017 | if (!root["width"].isNull()) |
3018 | - info.width = root["width"].asInt(); |
3019 | + info.width = root["width"].toInt(); |
3020 | if (!root["pixel_format"].isNull()) |
3021 | - info.pixel_format = root["pixel_format"].asInt(); |
3022 | + info.pixel_format = root["pixel_format"].toInt(); |
3023 | if (!root["fps"].isNull() && root["fps"].isObject()) { |
3024 | - if (!root["fps"]["num"].isNull()) |
3025 | - info.fps.num = root["fps"]["num"].asInt(); |
3026 | - if (!root["fps"]["den"].isNull()) |
3027 | - info.fps.den = root["fps"]["den"].asInt(); |
3028 | + if (!root["fps"].toObject()["num"].isNull()) |
3029 | + info.fps.num = root["fps"].toObject()["num"].toInt(); |
3030 | + if (!root["fps"].toObject()["den"].isNull()) |
3031 | + info.fps.den = root["fps"].toObject()["den"].toInt(); |
3032 | } |
3033 | if (!root["video_bit_rate"].isNull()) |
3034 | - info.video_bit_rate = root["video_bit_rate"].asInt(); |
3035 | + info.video_bit_rate = root["video_bit_rate"].toInt(); |
3036 | if (!root["pixel_ratio"].isNull() && root["pixel_ratio"].isObject()) { |
3037 | - if (!root["pixel_ratio"]["num"].isNull()) |
3038 | - info.pixel_ratio.num = root["pixel_ratio"]["num"].asInt(); |
3039 | - if (!root["pixel_ratio"]["den"].isNull()) |
3040 | - info.pixel_ratio.den = root["pixel_ratio"]["den"].asInt(); |
3041 | + if (!root["pixel_ratio"].toObject()["num"].isNull()) |
3042 | + info.pixel_ratio.num = root["pixel_ratio"].toObject()["num"].toInt(); |
3043 | + if (!root["pixel_ratio"].toObject()["den"].isNull()) |
3044 | + info.pixel_ratio.den = root["pixel_ratio"].toObject()["den"].toInt(); |
3045 | } |
3046 | if (!root["display_ratio"].isNull() && root["display_ratio"].isObject()) { |
3047 | - if (!root["display_ratio"]["num"].isNull()) |
3048 | - info.display_ratio.num = root["display_ratio"]["num"].asInt(); |
3049 | - if (!root["display_ratio"]["den"].isNull()) |
3050 | - info.display_ratio.den = root["display_ratio"]["den"].asInt(); |
3051 | + if (!root["display_ratio"].toObject()["num"].isNull()) |
3052 | + info.display_ratio.num = root["display_ratio"].toObject()["num"].toInt(); |
3053 | + if (!root["display_ratio"].toObject()["den"].isNull()) |
3054 | + info.display_ratio.den = root["display_ratio"].toObject()["den"].toInt(); |
3055 | } |
3056 | if (!root["vcodec"].isNull()) |
3057 | - info.vcodec = root["vcodec"].asString(); |
3058 | + info.vcodec = root["vcodec"].toString().toLocal8Bit().constData(); |
3059 | if (!root["video_length"].isNull()) |
3060 | - info.video_length = (long int) root["video_length"].asUInt(); |
3061 | + info.video_length = root.value("video_length").toVariant().toLongLong(); |
3062 | if (!root["video_stream_index"].isNull()) |
3063 | - info.video_stream_index = root["video_stream_index"].asInt(); |
3064 | + info.video_stream_index = root["video_stream_index"].toInt(); |
3065 | if (!root["video_timebase"].isNull() && root["video_timebase"].isObject()) { |
3066 | - if (!root["video_timebase"]["num"].isNull()) |
3067 | - info.video_timebase.num = root["video_timebase"]["num"].asInt(); |
3068 | - if (!root["video_timebase"]["den"].isNull()) |
3069 | - info.video_timebase.den = root["video_timebase"]["den"].asInt(); |
3070 | + if (!root["video_timebase"].toObject()["num"].isNull()) |
3071 | + info.video_timebase.num = root["video_timebase"].toObject()["num"].toInt(); |
3072 | + if (!root["video_timebase"].toObject()["den"].isNull()) |
3073 | + info.video_timebase.den = root["video_timebase"].toObject()["den"].toInt(); |
3074 | } |
3075 | if (!root["interlaced_frame"].isNull()) |
3076 | - info.interlaced_frame = root["interlaced_frame"].asBool(); |
3077 | + info.interlaced_frame = root["interlaced_frame"].toBool(); |
3078 | if (!root["top_field_first"].isNull()) |
3079 | - info.top_field_first = root["top_field_first"].asBool(); |
3080 | + info.top_field_first = root["top_field_first"].toBool(); |
3081 | if (!root["acodec"].isNull()) |
3082 | - info.acodec = root["acodec"].asString(); |
3083 | + info.acodec = root["acodec"].toString().toLocal8Bit().constData(); |
3084 | |
3085 | if (!root["audio_bit_rate"].isNull()) |
3086 | - info.audio_bit_rate = root["audio_bit_rate"].asInt(); |
3087 | + info.audio_bit_rate = root["audio_bit_rate"].toInt(); |
3088 | if (!root["sample_rate"].isNull()) |
3089 | - info.sample_rate = root["sample_rate"].asInt(); |
3090 | + info.sample_rate = root["sample_rate"].toInt(); |
3091 | if (!root["channels"].isNull()) |
3092 | - info.channels = root["channels"].asInt(); |
3093 | + info.channels = root["channels"].toInt(); |
3094 | if (!root["channel_layout"].isNull()) |
3095 | - info.channel_layout = (ChannelLayout) root["channel_layout"].asInt(); |
3096 | + info.channel_layout = (ChannelLayout) root["channel_layout"].toInt(); |
3097 | if (!root["audio_stream_index"].isNull()) |
3098 | - info.audio_stream_index = root["audio_stream_index"].asInt(); |
3099 | + info.audio_stream_index = root["audio_stream_index"].toInt(); |
3100 | if (!root["audio_timebase"].isNull() && root["audio_timebase"].isObject()) { |
3101 | - if (!root["audio_timebase"]["num"].isNull()) |
3102 | - info.audio_timebase.num = root["audio_timebase"]["num"].asInt(); |
3103 | - if (!root["audio_timebase"]["den"].isNull()) |
3104 | - info.audio_timebase.den = root["audio_timebase"]["den"].asInt(); |
3105 | + if (!root["audio_timebase"].toObject()["num"].isNull()) |
3106 | + info.audio_timebase.num = root["audio_timebase"].toObject()["num"].toInt(); |
3107 | + if (!root["audio_timebase"].toObject()["den"].isNull()) |
3108 | + info.audio_timebase.den = root["audio_timebase"].toObject()["den"].toInt(); |
3109 | } |
3110 | } |
3111 | |
3112 | === modified file 'src/effects/Brightness.cpp' |
3113 | --- src/effects/Brightness.cpp 2015-10-02 23:22:10 +0000 |
3114 | +++ src/effects/Brightness.cpp 2015-10-04 15:21:00 +0000 |
3115 | @@ -117,19 +117,21 @@ |
3116 | string Brightness::Json() { |
3117 | |
3118 | // Return formatted string |
3119 | - return JsonValue().toStyledString(); |
3120 | + QJsonDocument document; |
3121 | + document.setObject(JsonValue()); |
3122 | + return document.toJson().constData(); |
3123 | } |
3124 | |
3125 | -// Generate Json::JsonValue for this object |
3126 | -Json::Value Brightness::JsonValue() { |
3127 | +// Generate QJsonObject for this object |
3128 | +QJsonObject Brightness::JsonValue() { |
3129 | |
3130 | // Create root json object |
3131 | - Json::Value root = EffectBase::JsonValue(); // get parent properties |
3132 | - root["type"] = info.class_name; |
3133 | + QJsonObject root = EffectBase::JsonValue(); // get parent properties |
3134 | + root["type"] = info.class_name.c_str(); |
3135 | root["brightness"] = brightness.JsonValue(); |
3136 | root["contrast"] = contrast.JsonValue(); |
3137 | |
3138 | - // return JsonValue |
3139 | + // return QJsonObject |
3140 | return root; |
3141 | } |
3142 | |
3143 | @@ -137,12 +139,16 @@ |
3144 | void Brightness::SetJson(string value) throw(InvalidJSON) { |
3145 | |
3146 | // Parse JSON string into JSON objects |
3147 | - Json::Value root; |
3148 | - Json::Reader reader; |
3149 | - bool success = reader.parse( value, root ); |
3150 | - if (!success) |
3151 | - // Raise exception |
3152 | - throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
3153 | + QJsonObject root; |
3154 | + QJsonParseError errors; |
3155 | + |
3156 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
3157 | + if (errors.error != QJsonParseError::NoError) { |
3158 | + // Raise exception |
3159 | + throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
3160 | + } |
3161 | + |
3162 | + root = document.object(); |
3163 | |
3164 | try |
3165 | { |
3166 | @@ -156,17 +162,17 @@ |
3167 | } |
3168 | } |
3169 | |
3170 | -// Load Json::JsonValue into this object |
3171 | -void Brightness::SetJsonValue(Json::Value root) { |
3172 | +// Load QJsonObject into this object |
3173 | +void Brightness::SetJsonValue(QJsonObject root) { |
3174 | |
3175 | // Set parent data |
3176 | EffectBase::SetJsonValue(root); |
3177 | |
3178 | // Set data from Json (if key is found) |
3179 | if (!root["brightness"].isNull()) |
3180 | - brightness.SetJsonValue(root["brightness"]); |
3181 | + brightness.SetJsonValue(root["brightness"].toObject()); |
3182 | if (!root["contrast"].isNull()) |
3183 | - contrast.SetJsonValue(root["contrast"]); |
3184 | + contrast.SetJsonValue(root["contrast"].toObject()); |
3185 | } |
3186 | |
3187 | // Get all properties for a specific frame |
3188 | @@ -176,7 +182,7 @@ |
3189 | Point requested_point(requested_frame, requested_frame); |
3190 | |
3191 | // Generate JSON properties list |
3192 | - Json::Value root; |
3193 | + QJsonObject root; |
3194 | root["id"] = add_property_json("ID", 0.0, "string", Id(), false, 0, -1, -1, CONSTANT, -1, true); |
3195 | root["position"] = add_property_json("Position", Position(), "float", "", false, 0, 0, 1000 * 60 * 30, CONSTANT, -1, false); |
3196 | root["layer"] = add_property_json("Layer", Layer(), "int", "", false, 0, 0, 1000, CONSTANT, -1, false); |
3197 | @@ -189,6 +195,8 @@ |
3198 | root["contrast"] = add_property_json("Contrast", contrast.GetValue(requested_frame), "float", "", contrast.Contains(requested_point), contrast.GetCount(), -10000, 10000, contrast.GetClosestPoint(requested_point).interpolation, contrast.GetClosestPoint(requested_point).co.X, false); |
3199 | |
3200 | // Return formatted string |
3201 | - return root.toStyledString(); |
3202 | + QJsonDocument document; |
3203 | + document.setObject(root); |
3204 | + return document.toJson().constData(); |
3205 | } |
3206 | |
3207 | |
3208 | === modified file 'src/effects/ChromaKey.cpp' |
3209 | --- src/effects/ChromaKey.cpp 2015-10-02 23:22:10 +0000 |
3210 | +++ src/effects/ChromaKey.cpp 2015-10-04 15:21:00 +0000 |
3211 | @@ -101,15 +101,17 @@ |
3212 | string ChromaKey::Json() { |
3213 | |
3214 | // Return formatted string |
3215 | - return JsonValue().toStyledString(); |
3216 | + QJsonDocument document; |
3217 | + document.setObject(JsonValue()); |
3218 | + return document.toJson().constData(); |
3219 | } |
3220 | |
3221 | // Generate Json::JsonValue for this object |
3222 | -Json::Value ChromaKey::JsonValue() { |
3223 | +QJsonObject ChromaKey::JsonValue() { |
3224 | |
3225 | // Create root json object |
3226 | - Json::Value root = EffectBase::JsonValue(); // get parent properties |
3227 | - root["type"] = info.class_name; |
3228 | + QJsonObject root = EffectBase::JsonValue(); // get parent properties |
3229 | + root["type"] = info.class_name.c_str(); |
3230 | root["color"] = color.JsonValue(); |
3231 | root["fuzz"] = fuzz.JsonValue(); |
3232 | |
3233 | @@ -121,12 +123,16 @@ |
3234 | void ChromaKey::SetJson(string value) throw(InvalidJSON) { |
3235 | |
3236 | // Parse JSON string into JSON objects |
3237 | - Json::Value root; |
3238 | - Json::Reader reader; |
3239 | - bool success = reader.parse( value, root ); |
3240 | - if (!success) |
3241 | + QJsonObject root; |
3242 | + QJsonParseError errors; |
3243 | + |
3244 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
3245 | + if (errors.error != QJsonParseError::NoError) { |
3246 | // Raise exception |
3247 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
3248 | + } |
3249 | + |
3250 | + root = document.object(); |
3251 | |
3252 | try |
3253 | { |
3254 | @@ -140,17 +146,17 @@ |
3255 | } |
3256 | } |
3257 | |
3258 | -// Load Json::JsonValue into this object |
3259 | -void ChromaKey::SetJsonValue(Json::Value root) { |
3260 | +// Load QJsonObject into this object |
3261 | +void ChromaKey::SetJsonValue(QJsonObject root) { |
3262 | |
3263 | // Set parent data |
3264 | EffectBase::SetJsonValue(root); |
3265 | |
3266 | // Set data from Json (if key is found) |
3267 | if (!root["color"].isNull()) |
3268 | - color.SetJsonValue(root["color"]); |
3269 | + color.SetJsonValue(root["color"].toObject()); |
3270 | if (!root["fuzz"].isNull()) |
3271 | - fuzz.SetJsonValue(root["fuzz"]); |
3272 | + fuzz.SetJsonValue(root["fuzz"].toObject()); |
3273 | } |
3274 | |
3275 | // Get all properties for a specific frame |
3276 | @@ -160,7 +166,7 @@ |
3277 | Point requested_point(requested_frame, requested_frame); |
3278 | |
3279 | // Generate JSON properties list |
3280 | - Json::Value root; |
3281 | + QJsonObject root; |
3282 | root["id"] = add_property_json("ID", 0.0, "string", Id(), false, 0, -1, -1, CONSTANT, -1, true); |
3283 | root["position"] = add_property_json("Position", Position(), "float", "", false, 0, 0, 1000 * 60 * 30, CONSTANT, -1, false); |
3284 | root["layer"] = add_property_json("Layer", Layer(), "int", "", false, 0, 0, 1000, CONSTANT, -1, false); |
3285 | @@ -170,11 +176,13 @@ |
3286 | |
3287 | // Keyframes |
3288 | root["color"] = add_property_json("Key Color", 0.0, "color", "", color.red.Contains(requested_point), color.red.GetCount(), -10000, 10000, color.red.GetClosestPoint(requested_point).interpolation, color.red.GetClosestPoint(requested_point).co.X, false); |
3289 | - root["color"]["red"] = add_property_json("Red", color.red.GetValue(requested_frame), "float", "", color.red.Contains(requested_point), color.red.GetCount(), -10000, 10000, color.red.GetClosestPoint(requested_point).interpolation, color.red.GetClosestPoint(requested_point).co.X, false); |
3290 | - root["color"]["blue"] = add_property_json("Blue", color.blue.GetValue(requested_frame), "float", "", color.blue.Contains(requested_point), color.blue.GetCount(), -10000, 10000, color.blue.GetClosestPoint(requested_point).interpolation, color.blue.GetClosestPoint(requested_point).co.X, false); |
3291 | - root["color"]["green"] = add_property_json("Green", color.green.GetValue(requested_frame), "float", "", color.green.Contains(requested_point), color.green.GetCount(), -10000, 10000, color.green.GetClosestPoint(requested_point).interpolation, color.green.GetClosestPoint(requested_point).co.X, false); |
3292 | + root["color"].toObject()["red"] = add_property_json("Red", color.red.GetValue(requested_frame), "float", "", color.red.Contains(requested_point), color.red.GetCount(), -10000, 10000, color.red.GetClosestPoint(requested_point).interpolation, color.red.GetClosestPoint(requested_point).co.X, false); |
3293 | + root["color"].toObject()["blue"] = add_property_json("Blue", color.blue.GetValue(requested_frame), "float", "", color.blue.Contains(requested_point), color.blue.GetCount(), -10000, 10000, color.blue.GetClosestPoint(requested_point).interpolation, color.blue.GetClosestPoint(requested_point).co.X, false); |
3294 | + root["color"].toObject()["green"] = add_property_json("Green", color.green.GetValue(requested_frame), "float", "", color.green.Contains(requested_point), color.green.GetCount(), -10000, 10000, color.green.GetClosestPoint(requested_point).interpolation, color.green.GetClosestPoint(requested_point).co.X, false); |
3295 | root["fuzz"] = add_property_json("Fuzz", fuzz.GetValue(requested_frame), "float", "", fuzz.Contains(requested_point), fuzz.GetCount(), -10000, 10000, fuzz.GetClosestPoint(requested_point).interpolation, fuzz.GetClosestPoint(requested_point).co.X, false); |
3296 | |
3297 | // Return formatted string |
3298 | - return root.toStyledString(); |
3299 | + QJsonDocument document; |
3300 | + document.setObject(root); |
3301 | + return document.toJson().constData(); |
3302 | } |
3303 | |
3304 | === modified file 'src/effects/Deinterlace.cpp' |
3305 | --- src/effects/Deinterlace.cpp 2015-10-02 23:22:10 +0000 |
3306 | +++ src/effects/Deinterlace.cpp 2015-10-04 15:21:00 +0000 |
3307 | @@ -96,15 +96,17 @@ |
3308 | string Deinterlace::Json() { |
3309 | |
3310 | // Return formatted string |
3311 | - return JsonValue().toStyledString(); |
3312 | + QJsonDocument document; |
3313 | + document.setObject(JsonValue()); |
3314 | + return document.toJson().constData(); |
3315 | } |
3316 | |
3317 | // Generate Json::JsonValue for this object |
3318 | -Json::Value Deinterlace::JsonValue() { |
3319 | +QJsonObject Deinterlace::JsonValue() { |
3320 | |
3321 | // Create root json object |
3322 | - Json::Value root = EffectBase::JsonValue(); // get parent properties |
3323 | - root["type"] = info.class_name; |
3324 | + QJsonObject root = EffectBase::JsonValue(); // get parent properties |
3325 | + root["type"] = info.class_name.c_str(); |
3326 | root["isOdd"] = isOdd; |
3327 | |
3328 | // return JsonValue |
3329 | @@ -115,12 +117,16 @@ |
3330 | void Deinterlace::SetJson(string value) throw(InvalidJSON) { |
3331 | |
3332 | // Parse JSON string into JSON objects |
3333 | - Json::Value root; |
3334 | - Json::Reader reader; |
3335 | - bool success = reader.parse( value, root ); |
3336 | - if (!success) |
3337 | + QJsonObject root; |
3338 | + QJsonParseError errors; |
3339 | + |
3340 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
3341 | + if (errors.error != QJsonParseError::NoError) { |
3342 | // Raise exception |
3343 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
3344 | + } |
3345 | + |
3346 | + root = document.object(); |
3347 | |
3348 | try |
3349 | { |
3350 | @@ -134,15 +140,15 @@ |
3351 | } |
3352 | } |
3353 | |
3354 | -// Load Json::JsonValue into this object |
3355 | -void Deinterlace::SetJsonValue(Json::Value root) { |
3356 | +// Load QJsonObject into this object |
3357 | +void Deinterlace::SetJsonValue(QJsonObject root) { |
3358 | |
3359 | // Set parent data |
3360 | EffectBase::SetJsonValue(root); |
3361 | |
3362 | // Set data from Json (if key is found) |
3363 | if (!root["isOdd"].isNull()) |
3364 | - isOdd = root["isOdd"].asBool(); |
3365 | + isOdd = root["isOdd"].toBool(); |
3366 | } |
3367 | |
3368 | // Get all properties for a specific frame |
3369 | @@ -152,7 +158,7 @@ |
3370 | Point requested_point(requested_frame, requested_frame); |
3371 | |
3372 | // Generate JSON properties list |
3373 | - Json::Value root; |
3374 | + QJsonObject root; |
3375 | root["id"] = add_property_json("ID", 0.0, "string", Id(), false, 0, -1, -1, CONSTANT, -1, true); |
3376 | root["position"] = add_property_json("Position", Position(), "float", "", false, 0, 0, 1000 * 60 * 30, CONSTANT, -1, false); |
3377 | root["layer"] = add_property_json("Layer", Layer(), "int", "", false, 0, 0, 1000, CONSTANT, -1, false); |
3378 | @@ -162,9 +168,11 @@ |
3379 | root["isOdd"] = add_property_json("Is Odd Frame", isOdd, "bool", "", false, 0, 0, 1, CONSTANT, -1, true); |
3380 | |
3381 | // Add Is Odd Frame choices (dropdown style) |
3382 | - root["isOdd"]["choices"].append(add_property_choice_json("Yes", true, isOdd)); |
3383 | - root["isOdd"]["choices"].append(add_property_choice_json("No", false, isOdd)); |
3384 | + root["isOdd"].toObject()["choices"].toArray().append(add_property_choice_json("Yes", true, isOdd)); |
3385 | + root["isOdd"].toObject()["choices"].toArray().append(add_property_choice_json("No", false, isOdd)); |
3386 | |
3387 | // Return formatted string |
3388 | - return root.toStyledString(); |
3389 | + QJsonDocument document; |
3390 | + document.setObject(root); |
3391 | + return document.toJson().constData(); |
3392 | } |
3393 | |
3394 | === modified file 'src/effects/Mask.cpp' |
3395 | --- src/effects/Mask.cpp 2015-10-02 23:22:10 +0000 |
3396 | +++ src/effects/Mask.cpp 2015-10-04 15:21:00 +0000 |
3397 | @@ -159,21 +159,23 @@ |
3398 | string Mask::Json() { |
3399 | |
3400 | // Return formatted string |
3401 | - return JsonValue().toStyledString(); |
3402 | + QJsonDocument document; |
3403 | + document.setObject(JsonValue()); |
3404 | + return document.toJson().constData(); |
3405 | } |
3406 | |
3407 | // Generate Json::JsonValue for this object |
3408 | -Json::Value Mask::JsonValue() { |
3409 | +QJsonObject Mask::JsonValue() { |
3410 | |
3411 | // Create root json object |
3412 | - Json::Value root = EffectBase::JsonValue(); // get parent properties |
3413 | - root["type"] = info.class_name; |
3414 | + QJsonObject root = EffectBase::JsonValue(); // get parent properties |
3415 | + root["type"] = info.class_name.c_str(); |
3416 | root["brightness"] = brightness.JsonValue(); |
3417 | root["contrast"] = contrast.JsonValue(); |
3418 | if (reader) |
3419 | root["reader"] = reader->JsonValue(); |
3420 | else |
3421 | - root["reader"] = Json::objectValue; |
3422 | + root["reader"] = QJsonObject(); |
3423 | root["replace_image"] = replace_image; |
3424 | |
3425 | // return JsonValue |
3426 | @@ -184,12 +186,16 @@ |
3427 | void Mask::SetJson(string value) throw(InvalidJSON) { |
3428 | |
3429 | // Parse JSON string into JSON objects |
3430 | - Json::Value root; |
3431 | - Json::Reader reader; |
3432 | - bool success = reader.parse( value, root ); |
3433 | - if (!success) |
3434 | + QJsonObject root; |
3435 | + QJsonParseError errors; |
3436 | + |
3437 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
3438 | + if (errors.error != QJsonParseError::NoError) { |
3439 | // Raise exception |
3440 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
3441 | + } |
3442 | + |
3443 | + root = document.object(); |
3444 | |
3445 | try |
3446 | { |
3447 | @@ -204,22 +210,22 @@ |
3448 | } |
3449 | |
3450 | // Load Json::JsonValue into this object |
3451 | -void Mask::SetJsonValue(Json::Value root) { |
3452 | +void Mask::SetJsonValue(QJsonObject root) { |
3453 | |
3454 | // Set parent data |
3455 | EffectBase::SetJsonValue(root); |
3456 | |
3457 | // Set data from Json (if key is found) |
3458 | if (!root["replace_image"].isNull()) |
3459 | - replace_image = root["replace_image"].asBool(); |
3460 | + replace_image = root["replace_image"].toBool(); |
3461 | if (!root["brightness"].isNull()) |
3462 | - brightness.SetJsonValue(root["brightness"]); |
3463 | + brightness.SetJsonValue(root["brightness"].toObject()); |
3464 | if (!root["contrast"].isNull()) |
3465 | - contrast.SetJsonValue(root["contrast"]); |
3466 | + contrast.SetJsonValue(root["contrast"].toObject()); |
3467 | if (!root["reader"].isNull()) // does Json contain a reader? |
3468 | { |
3469 | |
3470 | - if (!root["reader"]["type"].isNull()) // does the reader Json contain a 'type'? |
3471 | + if (!root["reader"].toObject()["type"].isNull()) // does the reader Json contain a 'type'? |
3472 | { |
3473 | // Close previous reader (if any) |
3474 | if (reader) |
3475 | @@ -231,31 +237,31 @@ |
3476 | } |
3477 | |
3478 | // Create new reader (and load properties) |
3479 | - string type = root["reader"]["type"].asString(); |
3480 | + string type = root["reader"].toObject()["type"].toString().toLocal8Bit().constData(); |
3481 | |
3482 | if (type == "FFmpegReader") { |
3483 | |
3484 | // Create new reader |
3485 | - reader = new FFmpegReader(root["reader"]["path"].asString()); |
3486 | - reader->SetJsonValue(root["reader"]); |
3487 | + reader = new FFmpegReader(root["reader"].toObject()["path"].toString().toLocal8Bit().constData()); |
3488 | + reader->SetJsonValue(root["reader"].toObject()); |
3489 | |
3490 | } else if (type == "ImageReader") { |
3491 | |
3492 | // Create new reader |
3493 | - reader = new ImageReader(root["reader"]["path"].asString()); |
3494 | - reader->SetJsonValue(root["reader"]); |
3495 | + reader = new ImageReader(root["reader"].toObject()["path"].toString().toLocal8Bit().constData()); |
3496 | + reader->SetJsonValue(root["reader"].toObject()); |
3497 | |
3498 | } else if (type == "QtImageReader") { |
3499 | |
3500 | // Create new reader |
3501 | - reader = new QtImageReader(root["reader"]["path"].asString()); |
3502 | - reader->SetJsonValue(root["reader"]); |
3503 | + reader = new QtImageReader(root["reader"].toObject()["path"].toString().toLocal8Bit().constData()); |
3504 | + reader->SetJsonValue(root["reader"].toObject()); |
3505 | |
3506 | } else if (type == "ChunkReader") { |
3507 | |
3508 | // Create new reader |
3509 | - reader = new ChunkReader(root["reader"]["path"].asString(), (ChunkVersion) root["reader"]["chunk_version"].asInt()); |
3510 | - reader->SetJsonValue(root["reader"]); |
3511 | + reader = new ChunkReader(root["reader"].toObject()["path"].toString().toLocal8Bit().constData(), (ChunkVersion) root["reader"].toObject()["chunk_version"].toInt()); |
3512 | + reader->SetJsonValue(root["reader"].toObject()); |
3513 | |
3514 | } |
3515 | |
3516 | @@ -271,7 +277,7 @@ |
3517 | Point requested_point(requested_frame, requested_frame); |
3518 | |
3519 | // Generate JSON properties list |
3520 | - Json::Value root; |
3521 | + QJsonObject root; |
3522 | root["id"] = add_property_json("ID", 0.0, "string", Id(), false, 0, -1, -1, CONSTANT, -1, true); |
3523 | root["position"] = add_property_json("Position", Position(), "float", "", false, 0, 0, 1000 * 60 * 30, CONSTANT, -1, false); |
3524 | root["layer"] = add_property_json("Layer", Layer(), "int", "", false, 0, 0, 1000, CONSTANT, -1, false); |
3525 | @@ -281,14 +287,16 @@ |
3526 | root["replace_image"] = add_property_json("Replace Image", replace_image, "bool", "", false, 0, 0, 1, CONSTANT, -1, false); |
3527 | |
3528 | // Add replace_image choices (dropdown style) |
3529 | - root["replace_image"]["choices"].append(add_property_choice_json("Yes", true, replace_image)); |
3530 | - root["replace_image"]["choices"].append(add_property_choice_json("No", false, replace_image)); |
3531 | + root["replace_image"].toObject()["choices"].toArray().append(add_property_choice_json("Yes", true, replace_image)); |
3532 | + root["replace_image"].toObject()["choices"].toArray().append(add_property_choice_json("No", false, replace_image)); |
3533 | |
3534 | // Keyframes |
3535 | root["brightness"] = add_property_json("Brightness", brightness.GetValue(requested_frame), "float", "", brightness.Contains(requested_point), brightness.GetCount(), -10000, 10000, brightness.GetClosestPoint(requested_point).interpolation, brightness.GetClosestPoint(requested_point).co.X, false); |
3536 | root["contrast"] = add_property_json("Contrast", contrast.GetValue(requested_frame), "float", "", contrast.Contains(requested_point), contrast.GetCount(), -10000, 10000, contrast.GetClosestPoint(requested_point).interpolation, contrast.GetClosestPoint(requested_point).co.X, false); |
3537 | |
3538 | // Return formatted string |
3539 | - return root.toStyledString(); |
3540 | + QJsonDocument document; |
3541 | + document.setObject(root); |
3542 | + return document.toJson().constData(); |
3543 | } |
3544 | |
3545 | |
3546 | === modified file 'src/effects/Negate.cpp' |
3547 | --- src/effects/Negate.cpp 2015-08-24 06:05:48 +0000 |
3548 | +++ src/effects/Negate.cpp 2015-10-04 15:21:00 +0000 |
3549 | @@ -58,15 +58,17 @@ |
3550 | string Negate::Json() { |
3551 | |
3552 | // Return formatted string |
3553 | - return JsonValue().toStyledString(); |
3554 | + QJsonDocument document; |
3555 | + document.setObject(JsonValue()); |
3556 | + return document.toJson().constData(); |
3557 | } |
3558 | |
3559 | // Generate Json::JsonValue for this object |
3560 | -Json::Value Negate::JsonValue() { |
3561 | +QJsonObject Negate::JsonValue() { |
3562 | |
3563 | // Create root json object |
3564 | - Json::Value root = EffectBase::JsonValue(); // get parent properties |
3565 | - root["type"] = info.class_name; |
3566 | + QJsonObject root = EffectBase::JsonValue(); // get parent properties |
3567 | + root["type"] = info.class_name.c_str(); |
3568 | |
3569 | // return JsonValue |
3570 | return root; |
3571 | @@ -76,12 +78,16 @@ |
3572 | void Negate::SetJson(string value) throw(InvalidJSON) { |
3573 | |
3574 | // Parse JSON string into JSON objects |
3575 | - Json::Value root; |
3576 | - Json::Reader reader; |
3577 | - bool success = reader.parse( value, root ); |
3578 | - if (!success) |
3579 | + QJsonObject root; |
3580 | + QJsonParseError errors; |
3581 | + |
3582 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
3583 | + if (errors.error != QJsonParseError::NoError) { |
3584 | // Raise exception |
3585 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
3586 | + } |
3587 | + |
3588 | + root = document.object(); |
3589 | |
3590 | try |
3591 | { |
3592 | @@ -95,8 +101,8 @@ |
3593 | } |
3594 | } |
3595 | |
3596 | -// Load Json::JsonValue into this object |
3597 | -void Negate::SetJsonValue(Json::Value root) { |
3598 | +// Load QJsonObject into this object |
3599 | +void Negate::SetJsonValue(QJsonObject root) { |
3600 | |
3601 | // Set parent data |
3602 | EffectBase::SetJsonValue(root); |
3603 | @@ -110,7 +116,7 @@ |
3604 | Point requested_point(requested_frame, requested_frame); |
3605 | |
3606 | // Generate JSON properties list |
3607 | - Json::Value root; |
3608 | + QJsonObject root; |
3609 | root["id"] = add_property_json("ID", 0.0, "string", Id(), false, 0, -1, -1, CONSTANT, -1, true); |
3610 | root["position"] = add_property_json("Position", Position(), "float", "", false, 0, 0, 1000 * 60 * 30, CONSTANT, -1, false); |
3611 | root["layer"] = add_property_json("Layer", Layer(), "int", "", false, 0, 0, 1000, CONSTANT, -1, false); |
3612 | @@ -119,5 +125,7 @@ |
3613 | root["duration"] = add_property_json("Duration", Duration(), "float", "", false, 0, 0, 1000 * 60 * 30, CONSTANT, -1, true); |
3614 | |
3615 | // Return formatted string |
3616 | - return root.toStyledString(); |
3617 | + QJsonDocument document; |
3618 | + document.setObject(root); |
3619 | + return document.toJson().constData(); |
3620 | } |
3621 | |
3622 | === modified file 'src/effects/Saturation.cpp' |
3623 | --- src/effects/Saturation.cpp 2015-10-02 23:22:10 +0000 |
3624 | +++ src/effects/Saturation.cpp 2015-10-04 15:21:00 +0000 |
3625 | @@ -120,15 +120,17 @@ |
3626 | string Saturation::Json() { |
3627 | |
3628 | // Return formatted string |
3629 | - return JsonValue().toStyledString(); |
3630 | + QJsonDocument document; |
3631 | + document.setObject(JsonValue()); |
3632 | + return document.toJson().constData(); |
3633 | } |
3634 | |
3635 | // Generate Json::JsonValue for this object |
3636 | -Json::Value Saturation::JsonValue() { |
3637 | +QJsonObject Saturation::JsonValue() { |
3638 | |
3639 | // Create root json object |
3640 | - Json::Value root = EffectBase::JsonValue(); // get parent properties |
3641 | - root["type"] = info.class_name; |
3642 | + QJsonObject root = EffectBase::JsonValue(); // get parent properties |
3643 | + root["type"] = info.class_name.c_str(); |
3644 | root["saturation"] = saturation.JsonValue(); |
3645 | |
3646 | // return JsonValue |
3647 | @@ -139,12 +141,16 @@ |
3648 | void Saturation::SetJson(string value) throw(InvalidJSON) { |
3649 | |
3650 | // Parse JSON string into JSON objects |
3651 | - Json::Value root; |
3652 | - Json::Reader reader; |
3653 | - bool success = reader.parse( value, root ); |
3654 | - if (!success) |
3655 | - // Raise exception |
3656 | - throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
3657 | + QJsonObject root; |
3658 | + QJsonParseError errors; |
3659 | + |
3660 | + QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors); |
3661 | + if (errors.error != QJsonParseError::NoError) { |
3662 | + // Raise exception |
3663 | + throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
3664 | + } |
3665 | + |
3666 | + root = document.object(); |
3667 | |
3668 | try |
3669 | { |
3670 | @@ -159,14 +165,14 @@ |
3671 | } |
3672 | |
3673 | // Load Json::JsonValue into this object |
3674 | -void Saturation::SetJsonValue(Json::Value root) { |
3675 | +void Saturation::SetJsonValue(QJsonObject root) { |
3676 | |
3677 | // Set parent data |
3678 | EffectBase::SetJsonValue(root); |
3679 | |
3680 | // Set data from Json (if key is found) |
3681 | if (!root["saturation"].isNull()) |
3682 | - saturation.SetJsonValue(root["saturation"]); |
3683 | + saturation.SetJsonValue(root["saturation"].toObject()); |
3684 | } |
3685 | |
3686 | // Get all properties for a specific frame |
3687 | @@ -176,7 +182,7 @@ |
3688 | Point requested_point(requested_frame, requested_frame); |
3689 | |
3690 | // Generate JSON properties list |
3691 | - Json::Value root; |
3692 | + QJsonObject root; |
3693 | root["id"] = add_property_json("ID", 0.0, "string", Id(), false, 0, -1, -1, CONSTANT, -1, true); |
3694 | root["position"] = add_property_json("Position", Position(), "float", "", false, 0, 0, 1000 * 60 * 30, CONSTANT, -1, false); |
3695 | root["layer"] = add_property_json("Layer", Layer(), "int", "", false, 0, 0, 1000, CONSTANT, -1, false); |
3696 | @@ -188,6 +194,8 @@ |
3697 | root["saturation"] = add_property_json("Saturation", saturation.GetValue(requested_frame), "float", "", saturation.Contains(requested_point), saturation.GetCount(), -10000, 10000, saturation.GetClosestPoint(requested_point).interpolation, saturation.GetClosestPoint(requested_point).co.X, false); |
3698 | |
3699 | // Return formatted string |
3700 | - return root.toStyledString(); |
3701 | + QJsonDocument document; |
3702 | + document.setObject(root); |
3703 | + return document.toJson().constData(); |
3704 | } |
3705 | |
3706 | |
3707 | === modified file 'tests/Clip_Tests.cpp' |
3708 | --- tests/Clip_Tests.cpp 2015-09-29 03:17:29 +0000 |
3709 | +++ tests/Clip_Tests.cpp 2015-10-04 15:21:00 +0000 |
3710 | @@ -109,18 +109,19 @@ |
3711 | string properties = c1.PropertiesJSON(1); |
3712 | |
3713 | // Parse JSON string into JSON objects |
3714 | - Json::Value root; |
3715 | - Json::Reader reader; |
3716 | - bool success = reader.parse( properties, root ); |
3717 | - if (!success) |
3718 | + QJsonParseError error; |
3719 | + QJsonDocument rootDocument = QJsonDocument::fromJson(properties.c_str(), &error); |
3720 | + if (error.error != QJsonParseError::NoError) |
3721 | // Raise exception |
3722 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
3723 | |
3724 | + QJsonObject root = rootDocument.object(); |
3725 | + |
3726 | try |
3727 | { |
3728 | // Check for specific things |
3729 | - CHECK_CLOSE(1.0f, root["alpha"]["value"].asDouble(), 0.01); |
3730 | - CHECK_EQUAL(true, root["alpha"]["keyframe"].asBool()); |
3731 | + CHECK_CLOSE(1.0f, root["alpha"].toObject()["value"].toDouble(), 0.01); |
3732 | + CHECK_EQUAL(true, root["alpha"].toObject()["keyframe"].toBool()); |
3733 | |
3734 | } |
3735 | catch (exception e) |
3736 | @@ -134,17 +135,18 @@ |
3737 | properties = c1.PropertiesJSON(250); |
3738 | |
3739 | // Parse JSON string into JSON objects |
3740 | - root.clear(); |
3741 | - success = reader.parse( properties, root ); |
3742 | - if (!success) |
3743 | + rootDocument = QJsonDocument::fromJson(properties.c_str(), &error); |
3744 | + if (error.error != QJsonParseError::NoError) |
3745 | // Raise exception |
3746 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
3747 | |
3748 | + root = rootDocument.object(); |
3749 | + |
3750 | try |
3751 | { |
3752 | // Check for specific things |
3753 | - CHECK_CLOSE(0.5f, root["alpha"]["value"].asDouble(), 0.01); |
3754 | - CHECK_EQUAL(false, root["alpha"]["keyframe"].asBool()); |
3755 | + CHECK_CLOSE(0.5f, root["alpha"].toObject()["value"].toDouble(), 0.01); |
3756 | + CHECK_EQUAL(false, root["alpha"].toObject()["keyframe"].toBool()); |
3757 | |
3758 | } |
3759 | catch (exception e) |
3760 | @@ -158,16 +160,17 @@ |
3761 | properties = c1.PropertiesJSON(250); // again |
3762 | |
3763 | // Parse JSON string into JSON objects |
3764 | - root.clear(); |
3765 | - success = reader.parse( properties, root ); |
3766 | - if (!success) |
3767 | + rootDocument = QJsonDocument::fromJson(properties.c_str(), &error); |
3768 | + if (error.error != QJsonParseError::NoError) |
3769 | // Raise exception |
3770 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
3771 | |
3772 | + root = rootDocument.object(); |
3773 | + |
3774 | try |
3775 | { |
3776 | // Check for specific things |
3777 | - CHECK_EQUAL(false, root["alpha"]["keyframe"].asBool()); |
3778 | + CHECK_EQUAL(false, root["alpha"].toObject()["keyframe"].toBool()); |
3779 | |
3780 | } |
3781 | catch (exception e) |
3782 | @@ -181,17 +184,18 @@ |
3783 | properties = c1.PropertiesJSON(500); |
3784 | |
3785 | // Parse JSON string into JSON objects |
3786 | - root.clear(); |
3787 | - success = reader.parse( properties, root ); |
3788 | - if (!success) |
3789 | + rootDocument = QJsonDocument::fromJson(properties.c_str(), &error); |
3790 | + if (error.error != QJsonParseError::NoError) |
3791 | // Raise exception |
3792 | throw InvalidJSON("JSON could not be parsed (or is invalid)", ""); |
3793 | |
3794 | + root = rootDocument.object(); |
3795 | + |
3796 | try |
3797 | { |
3798 | // Check for specific things |
3799 | - CHECK_CLOSE(0.0f, root["alpha"]["value"].asDouble(), 0.00001); |
3800 | - CHECK_EQUAL(true, root["alpha"]["keyframe"].asBool()); |
3801 | + CHECK_CLOSE(0.0f, root["alpha"].toObject()["value"].toDouble(), 0.00001); |
3802 | + CHECK_EQUAL(true, root["alpha"].toObject()["keyframe"].toBool()); |
3803 | |
3804 | } |
3805 | catch (exception e) |
3806 | |
3807 | === modified file 'tests/ReaderBase_Tests.cpp' |
3808 | --- tests/ReaderBase_Tests.cpp 2015-08-24 06:05:48 +0000 |
3809 | +++ tests/ReaderBase_Tests.cpp 2015-10-04 15:21:00 +0000 |
3810 | @@ -46,8 +46,8 @@ |
3811 | void Open() { }; |
3812 | string Json() { }; |
3813 | void SetJson(string value) throw(InvalidJSON) { }; |
3814 | - Json::Value JsonValue() { }; |
3815 | - void SetJsonValue(Json::Value root) { }; |
3816 | + QJsonObject JsonValue() { }; |
3817 | + void SetJsonValue(QJsonObject root) { }; |
3818 | bool IsOpen() { return true; }; |
3819 | }; |
3820 | |
3821 | |
3822 | === removed directory 'thirdparty' |
3823 | === removed directory 'thirdparty/jsoncpp' |
3824 | === removed file 'thirdparty/jsoncpp/LICENSE' |
3825 | --- thirdparty/jsoncpp/LICENSE 2013-08-01 18:45:09 +0000 |
3826 | +++ thirdparty/jsoncpp/LICENSE 1970-01-01 00:00:00 +0000 |
3827 | @@ -1,1 +0,0 @@ |
3828 | -The json-cpp library and this documentation are in Public Domain. |
3829 | |
3830 | === removed directory 'thirdparty/jsoncpp/include' |
3831 | === removed directory 'thirdparty/jsoncpp/include/json' |
3832 | === removed file 'thirdparty/jsoncpp/include/json/autolink.h' |
3833 | --- thirdparty/jsoncpp/include/json/autolink.h 2013-07-31 21:18:54 +0000 |
3834 | +++ thirdparty/jsoncpp/include/json/autolink.h 1970-01-01 00:00:00 +0000 |
3835 | @@ -1,19 +0,0 @@ |
3836 | -#ifndef JSON_AUTOLINK_H_INCLUDED |
3837 | -# define JSON_AUTOLINK_H_INCLUDED |
3838 | - |
3839 | -# include "config.h" |
3840 | - |
3841 | -# ifdef JSON_IN_CPPTL |
3842 | -# include <cpptl/cpptl_autolink.h> |
3843 | -# endif |
3844 | - |
3845 | -# if !defined(JSON_NO_AUTOLINK) && !defined(JSON_DLL_BUILD) && !defined(JSON_IN_CPPTL) |
3846 | -# define CPPTL_AUTOLINK_NAME "json" |
3847 | -# undef CPPTL_AUTOLINK_DLL |
3848 | -# ifdef JSON_DLL |
3849 | -# define CPPTL_AUTOLINK_DLL |
3850 | -# endif |
3851 | -# include "autolink.h" |
3852 | -# endif |
3853 | - |
3854 | -#endif // JSON_AUTOLINK_H_INCLUDED |
3855 | |
3856 | === removed file 'thirdparty/jsoncpp/include/json/config.h' |
3857 | --- thirdparty/jsoncpp/include/json/config.h 2013-07-31 21:18:54 +0000 |
3858 | +++ thirdparty/jsoncpp/include/json/config.h 1970-01-01 00:00:00 +0000 |
3859 | @@ -1,43 +0,0 @@ |
3860 | -#ifndef JSON_CONFIG_H_INCLUDED |
3861 | -# define JSON_CONFIG_H_INCLUDED |
3862 | - |
3863 | -/// If defined, indicates that json library is embedded in CppTL library. |
3864 | -//# define JSON_IN_CPPTL 1 |
3865 | - |
3866 | -/// If defined, indicates that json may leverage CppTL library |
3867 | -//# define JSON_USE_CPPTL 1 |
3868 | -/// If defined, indicates that cpptl vector based map should be used instead of std::map |
3869 | -/// as Value container. |
3870 | -//# define JSON_USE_CPPTL_SMALLMAP 1 |
3871 | -/// If defined, indicates that Json specific container should be used |
3872 | -/// (hash table & simple deque container with customizable allocator). |
3873 | -/// THIS FEATURE IS STILL EXPERIMENTAL! |
3874 | -//# define JSON_VALUE_USE_INTERNAL_MAP 1 |
3875 | -/// Force usage of standard new/malloc based allocator instead of memory pool based allocator. |
3876 | -/// The memory pools allocator used optimization (initializing Value and ValueInternalLink |
3877 | -/// as if it was a POD) that may cause some validation tool to report errors. |
3878 | -/// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined. |
3879 | -//# define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1 |
3880 | - |
3881 | -/// If defined, indicates that Json use exception to report invalid type manipulation |
3882 | -/// instead of C assert macro. |
3883 | -# define JSON_USE_EXCEPTION 1 |
3884 | - |
3885 | -# ifdef JSON_IN_CPPTL |
3886 | -# include <cpptl/config.h> |
3887 | -# ifndef JSON_USE_CPPTL |
3888 | -# define JSON_USE_CPPTL 1 |
3889 | -# endif |
3890 | -# endif |
3891 | - |
3892 | -# ifdef JSON_IN_CPPTL |
3893 | -# define JSON_API CPPTL_API |
3894 | -# elif defined(JSON_DLL_BUILD) |
3895 | -# define JSON_API __declspec(dllexport) |
3896 | -# elif defined(JSON_DLL) |
3897 | -# define JSON_API __declspec(dllimport) |
3898 | -# else |
3899 | -# define JSON_API |
3900 | -# endif |
3901 | - |
3902 | -#endif // JSON_CONFIG_H_INCLUDED |
3903 | |
3904 | === removed file 'thirdparty/jsoncpp/include/json/features.h' |
3905 | --- thirdparty/jsoncpp/include/json/features.h 2013-09-10 04:32:16 +0000 |
3906 | +++ thirdparty/jsoncpp/include/json/features.h 1970-01-01 00:00:00 +0000 |
3907 | @@ -1,42 +0,0 @@ |
3908 | -#ifndef CPPTL_JSON_FEATURES_H_INCLUDED |
3909 | -# define CPPTL_JSON_FEATURES_H_INCLUDED |
3910 | - |
3911 | -# include "forwards.h" |
3912 | - |
3913 | -namespace Json { |
3914 | - |
3915 | - /** @brief Configuration passed to reader and writer. |
3916 | - * This configuration object can be used to force the Reader or Writer |
3917 | - * to behave in a standard conforming way. |
3918 | - */ |
3919 | - class JSON_API Features |
3920 | - { |
3921 | - public: |
3922 | - /** @brief A configuration that allows all features and assumes all strings are UTF-8. |
3923 | - * - C & C++ comments are allowed |
3924 | - * - Root object can be any JSON value |
3925 | - * - Assumes Value strings are encoded in UTF-8 |
3926 | - */ |
3927 | - static Features all(); |
3928 | - |
3929 | - /** @brief A configuration that is strictly compatible with the JSON specification. |
3930 | - * - Comments are forbidden. |
3931 | - * - Root object must be either an array or an object value. |
3932 | - * - Assumes Value strings are encoded in UTF-8 |
3933 | - */ |
3934 | - static Features strictMode(); |
3935 | - |
3936 | - /** @brief Initialize the configuration like JsonConfig::allFeatures; |
3937 | - */ |
3938 | - Features(); |
3939 | - |
3940 | - /// \c true if comments are allowed. Default: \c true. |
3941 | - bool allowComments_; |
3942 | - |
3943 | - /// \c true if root must be either an array or an object value. Default: \c false. |
3944 | - bool strictRoot_; |
3945 | - }; |
3946 | - |
3947 | -} // namespace Json |
3948 | - |
3949 | -#endif // CPPTL_JSON_FEATURES_H_INCLUDED |
3950 | |
3951 | === removed file 'thirdparty/jsoncpp/include/json/forwards.h' |
3952 | --- thirdparty/jsoncpp/include/json/forwards.h 2013-07-31 21:18:54 +0000 |
3953 | +++ thirdparty/jsoncpp/include/json/forwards.h 1970-01-01 00:00:00 +0000 |
3954 | @@ -1,39 +0,0 @@ |
3955 | -#ifndef JSON_FORWARDS_H_INCLUDED |
3956 | -# define JSON_FORWARDS_H_INCLUDED |
3957 | - |
3958 | -# include "config.h" |
3959 | - |
3960 | -namespace Json { |
3961 | - |
3962 | - // writer.h |
3963 | - class FastWriter; |
3964 | - class StyledWriter; |
3965 | - |
3966 | - // reader.h |
3967 | - class Reader; |
3968 | - |
3969 | - // features.h |
3970 | - class Features; |
3971 | - |
3972 | - // value.h |
3973 | - typedef int Int; |
3974 | - typedef unsigned int UInt; |
3975 | - class StaticString; |
3976 | - class Path; |
3977 | - class PathArgument; |
3978 | - class Value; |
3979 | - class ValueIteratorBase; |
3980 | - class ValueIterator; |
3981 | - class ValueConstIterator; |
3982 | -#ifdef JSON_VALUE_USE_INTERNAL_MAP |
3983 | - class ValueAllocator; |
3984 | - class ValueMapAllocator; |
3985 | - class ValueInternalLink; |
3986 | - class ValueInternalArray; |
3987 | - class ValueInternalMap; |
3988 | -#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP |
3989 | - |
3990 | -} // namespace Json |
3991 | - |
3992 | - |
3993 | -#endif // JSON_FORWARDS_H_INCLUDED |
3994 | |
3995 | === removed file 'thirdparty/jsoncpp/include/json/json.h' |
3996 | --- thirdparty/jsoncpp/include/json/json.h 2013-07-31 21:18:54 +0000 |
3997 | +++ thirdparty/jsoncpp/include/json/json.h 1970-01-01 00:00:00 +0000 |
3998 | @@ -1,10 +0,0 @@ |
3999 | -#ifndef JSON_JSON_H_INCLUDED |
4000 | -# define JSON_JSON_H_INCLUDED |
4001 | - |
4002 | -# include "autolink.h" |
4003 | -# include "value.h" |
4004 | -# include "reader.h" |
4005 | -# include "writer.h" |
4006 | -# include "features.h" |
4007 | - |
4008 | -#endif // JSON_JSON_H_INCLUDED |
4009 | |
4010 | === removed file 'thirdparty/jsoncpp/include/json/reader.h' |
4011 | --- thirdparty/jsoncpp/include/json/reader.h 2013-09-10 04:32:16 +0000 |
4012 | +++ thirdparty/jsoncpp/include/json/reader.h 1970-01-01 00:00:00 +0000 |
4013 | @@ -1,196 +0,0 @@ |
4014 | -#ifndef CPPTL_JSON_READER_H_INCLUDED |
4015 | -# define CPPTL_JSON_READER_H_INCLUDED |
4016 | - |
4017 | -# include "features.h" |
4018 | -# include "value.h" |
4019 | -# include <deque> |
4020 | -# include <stack> |
4021 | -# include <string> |
4022 | -# include <iostream> |
4023 | - |
4024 | -namespace Json { |
4025 | - |
4026 | - /** @brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a Value. |
4027 | - * |
4028 | - */ |
4029 | - class JSON_API Reader |
4030 | - { |
4031 | - public: |
4032 | - typedef char Char; |
4033 | - typedef const Char *Location; |
4034 | - |
4035 | - /** @brief Constructs a Reader allowing all features |
4036 | - * for parsing. |
4037 | - */ |
4038 | - Reader(); |
4039 | - |
4040 | - /** @brief Constructs a Reader allowing the specified feature set |
4041 | - * for parsing. |
4042 | - */ |
4043 | - Reader( const Features &features ); |
4044 | - |
4045 | - /** @brief Read a Value from a <a HREF="http://www.json.org">JSON</a> document. |
4046 | - * \param document UTF-8 encoded string containing the document to read. |
4047 | - * \param root [out] Contains the root value of the document if it was |
4048 | - * successfully parsed. |
4049 | - * \param collectComments \c true to collect comment and allow writing them back during |
4050 | - * serialization, \c false to discard comments. |
4051 | - * This parameter is ignored if Features::allowComments_ |
4052 | - * is \c false. |
4053 | - * \return \c true if the document was successfully parsed, \c false if an error occurred. |
4054 | - */ |
4055 | - bool parse( const std::string &document, |
4056 | - Value &root, |
4057 | - bool collectComments = true ); |
4058 | - |
4059 | - /** @brief Read a Value from a <a HREF="http://www.json.org">JSON</a> document. |
4060 | - * \param document UTF-8 encoded string containing the document to read. |
4061 | - * \param root [out] Contains the root value of the document if it was |
4062 | - * successfully parsed. |
4063 | - * \param collectComments \c true to collect comment and allow writing them back during |
4064 | - * serialization, \c false to discard comments. |
4065 | - * This parameter is ignored if Features::allowComments_ |
4066 | - * is \c false. |
4067 | - * \return \c true if the document was successfully parsed, \c false if an error occurred. |
4068 | - */ |
4069 | - bool parse( const char *beginDoc, const char *endDoc, |
4070 | - Value &root, |
4071 | - bool collectComments = true ); |
4072 | - |
4073 | - /// @brief Parse from input stream. |
4074 | - /// \see Json::operator>>(std::istream&, Json::Value&). |
4075 | - bool parse( std::istream &is, |
4076 | - Value &root, |
4077 | - bool collectComments = true ); |
4078 | - |
4079 | - /** @brief Returns a user friendly string that list errors in the parsed document. |
4080 | - * \return Formatted error message with the list of errors with their location in |
4081 | - * the parsed document. An empty string is returned if no error occurred |
4082 | - * during parsing. |
4083 | - */ |
4084 | - std::string getFormatedErrorMessages() const; |
4085 | - |
4086 | - private: |
4087 | - enum TokenType |
4088 | - { |
4089 | - tokenEndOfStream = 0, |
4090 | - tokenObjectBegin, |
4091 | - tokenObjectEnd, |
4092 | - tokenArrayBegin, |
4093 | - tokenArrayEnd, |
4094 | - tokenString, |
4095 | - tokenNumber, |
4096 | - tokenTrue, |
4097 | - tokenFalse, |
4098 | - tokenNull, |
4099 | - tokenArraySeparator, |
4100 | - tokenMemberSeparator, |
4101 | - tokenComment, |
4102 | - tokenError |
4103 | - }; |
4104 | - |
4105 | - class Token |
4106 | - { |
4107 | - public: |
4108 | - TokenType type_; |
4109 | - Location start_; |
4110 | - Location end_; |
4111 | - }; |
4112 | - |
4113 | - class ErrorInfo |
4114 | - { |
4115 | - public: |
4116 | - Token token_; |
4117 | - std::string message_; |
4118 | - Location extra_; |
4119 | - }; |
4120 | - |
4121 | - typedef std::deque<ErrorInfo> Errors; |
4122 | - |
4123 | - bool expectToken( TokenType type, Token &token, const char *message ); |
4124 | - bool readToken( Token &token ); |
4125 | - void skipSpaces(); |
4126 | - bool match( Location pattern, |
4127 | - int patternLength ); |
4128 | - bool readComment(); |
4129 | - bool readCStyleComment(); |
4130 | - bool readCppStyleComment(); |
4131 | - bool readString(); |
4132 | - void readNumber(); |
4133 | - bool readValue(); |
4134 | - bool readObject( Token &token ); |
4135 | - bool readArray( Token &token ); |
4136 | - bool decodeNumber( Token &token ); |
4137 | - bool decodeString( Token &token ); |
4138 | - bool decodeString( Token &token, std::string &decoded ); |
4139 | - bool decodeDouble( Token &token ); |
4140 | - bool decodeUnicodeCodePoint( Token &token, |
4141 | - Location ¤t, |
4142 | - Location end, |
4143 | - unsigned int &unicode ); |
4144 | - bool decodeUnicodeEscapeSequence( Token &token, |
4145 | - Location ¤t, |
4146 | - Location end, |
4147 | - unsigned int &unicode ); |
4148 | - bool addError( const std::string &message, |
4149 | - Token &token, |
4150 | - Location extra = 0 ); |
4151 | - bool recoverFromError( TokenType skipUntilToken ); |
4152 | - bool addErrorAndRecover( const std::string &message, |
4153 | - Token &token, |
4154 | - TokenType skipUntilToken ); |
4155 | - void skipUntilSpace(); |
4156 | - Value ¤tValue(); |
4157 | - Char getNextChar(); |
4158 | - void getLocationLineAndColumn( Location location, |
4159 | - int &line, |
4160 | - int &column ) const; |
4161 | - std::string getLocationLineAndColumn( Location location ) const; |
4162 | - void addComment( Location begin, |
4163 | - Location end, |
4164 | - CommentPlacement placement ); |
4165 | - void skipCommentTokens( Token &token ); |
4166 | - |
4167 | - typedef std::stack<Value *> Nodes; |
4168 | - Nodes nodes_; |
4169 | - Errors errors_; |
4170 | - std::string document_; |
4171 | - Location begin_; |
4172 | - Location end_; |
4173 | - Location current_; |
4174 | - Location lastValueEnd_; |
4175 | - Value *lastValue_; |
4176 | - std::string commentsBefore_; |
4177 | - Features features_; |
4178 | - bool collectComments_; |
4179 | - }; |
4180 | - |
4181 | - /** @brief Read from 'sin' into 'root'. |
4182 | - |
4183 | - Always keep comments from the input JSON. |
4184 | - |
4185 | - This can be used to read a file into a particular sub-object. |
4186 | - For example: |
4187 | - \code |
4188 | - Json::Value root; |
4189 | - cin >> root["dir"]["file"]; |
4190 | - cout << root; |
4191 | - \endcode |
4192 | - Result: |
4193 | - \verbatim |
4194 | - { |
4195 | - "dir": { |
4196 | - "file": { |
4197 | - // The input stream JSON would be nested here. |
4198 | - } |
4199 | - } |
4200 | - } |
4201 | - \endverbatim |
4202 | - \throw std::exception on parse error. |
4203 | - \see Json::operator<<() |
4204 | - */ |
4205 | - std::istream& operator>>( std::istream&, Value& ); |
4206 | - |
4207 | -} // namespace Json |
4208 | - |
4209 | -#endif // CPPTL_JSON_READER_H_INCLUDED |
4210 | |
4211 | === removed file 'thirdparty/jsoncpp/include/json/value.h' |
4212 | --- thirdparty/jsoncpp/include/json/value.h 2013-09-10 04:32:16 +0000 |
4213 | +++ thirdparty/jsoncpp/include/json/value.h 1970-01-01 00:00:00 +0000 |
4214 | @@ -1,1069 +0,0 @@ |
4215 | -#ifndef CPPTL_JSON_H_INCLUDED |
4216 | -# define CPPTL_JSON_H_INCLUDED |
4217 | - |
4218 | -# include "forwards.h" |
4219 | -# include <string> |
4220 | -# include <vector> |
4221 | - |
4222 | -# ifndef JSON_USE_CPPTL_SMALLMAP |
4223 | -# include <map> |
4224 | -# else |
4225 | -# include <cpptl/smallmap.h> |
4226 | -# endif |
4227 | -# ifdef JSON_USE_CPPTL |
4228 | -# include <cpptl/forwards.h> |
4229 | -# endif |
4230 | - |
4231 | -/** @brief JSON (JavaScript Object Notation). |
4232 | - */ |
4233 | -namespace Json { |
4234 | - |
4235 | - /** @brief Type of the value held by a Value object. |
4236 | - */ |
4237 | - enum ValueType |
4238 | - { |
4239 | - nullValue = 0, ///< 'null' value |
4240 | - intValue, ///< signed integer value |
4241 | - uintValue, ///< unsigned integer value |
4242 | - realValue, ///< double value |
4243 | - stringValue, ///< UTF-8 string value |
4244 | - booleanValue, ///< bool value |
4245 | - arrayValue, ///< array value (ordered list) |
4246 | - objectValue ///< object value (collection of name/value pairs). |
4247 | - }; |
4248 | - |
4249 | - enum CommentPlacement |
4250 | - { |
4251 | - commentBefore = 0, ///< a comment placed on the line before a value |
4252 | - commentAfterOnSameLine, ///< a comment just after a value on the same line |
4253 | - commentAfter, ///< a comment on the line after a value (only make sense for root value) |
4254 | - numberOfCommentPlacement |
4255 | - }; |
4256 | - |
4257 | -//# ifdef JSON_USE_CPPTL |
4258 | -// typedef CppTL::AnyEnumerator<const char *> EnumMemberNames; |
4259 | -// typedef CppTL::AnyEnumerator<const Value &> EnumValues; |
4260 | -//# endif |
4261 | - |
4262 | - /** @brief Lightweight wrapper to tag static string. |
4263 | - * |
4264 | - * Value constructor and objectValue member assignement takes advantage of the |
4265 | - * StaticString and avoid the cost of string duplication when storing the |
4266 | - * string or the member name. |
4267 | - * |
4268 | - * Example of usage: |
4269 | - * \code |
4270 | - * Json::Value aValue( StaticString("some text") ); |
4271 | - * Json::Value object; |
4272 | - * static const StaticString code("code"); |
4273 | - * object[code] = 1234; |
4274 | - * \endcode |
4275 | - */ |
4276 | - class JSON_API StaticString |
4277 | - { |
4278 | - public: |
4279 | - explicit StaticString( const char *czstring ) |
4280 | - : str_( czstring ) |
4281 | - { |
4282 | - } |
4283 | - |
4284 | - operator const char *() const |
4285 | - { |
4286 | - return str_; |
4287 | - } |
4288 | - |
4289 | - const char *c_str() const |
4290 | - { |
4291 | - return str_; |
4292 | - } |
4293 | - |
4294 | - private: |
4295 | - const char *str_; |
4296 | - }; |
4297 | - |
4298 | - /** @brief Represents a <a HREF="http://www.json.org">JSON</a> value. |
4299 | - * |
4300 | - * This class is a discriminated union wrapper that can represents a: |
4301 | - * - signed integer [range: Value::minInt - Value::maxInt] |
4302 | - * - unsigned integer (range: 0 - Value::maxUInt) |
4303 | - * - double |
4304 | - * - UTF-8 string |
4305 | - * - boolean |
4306 | - * - 'null' |
4307 | - * - an ordered list of Value |
4308 | - * - collection of name/value pairs (javascript object) |
4309 | - * |
4310 | - * The type of the held value is represented by a #ValueType and |
4311 | - * can be obtained using type(). |
4312 | - * |
4313 | - * values of an #objectValue or #arrayValue can be accessed using operator[]() methods. |
4314 | - * Non const methods will automatically create the a #nullValue element |
4315 | - * if it does not exist. |
4316 | - * The sequence of an #arrayValue will be automatically resize and initialized |
4317 | - * with #nullValue. resize() can be used to enlarge or truncate an #arrayValue. |
4318 | - * |
4319 | - * The get() methods can be used to obtanis default value in the case the required element |
4320 | - * does not exist. |
4321 | - * |
4322 | - * It is possible to iterate over the list of a #objectValue values using |
4323 | - * the getMemberNames() method. |
4324 | - */ |
4325 | - class JSON_API Value |
4326 | - { |
4327 | - friend class ValueIteratorBase; |
4328 | -# ifdef JSON_VALUE_USE_INTERNAL_MAP |
4329 | - friend class ValueInternalLink; |
4330 | - friend class ValueInternalMap; |
4331 | -# endif |
4332 | - public: |
4333 | - typedef std::vector<std::string> Members; |
4334 | - typedef ValueIterator iterator; |
4335 | - typedef ValueConstIterator const_iterator; |
4336 | - typedef Json::UInt UInt; |
4337 | - typedef Json::Int Int; |
4338 | - typedef UInt ArrayIndex; |
4339 | - |
4340 | - static const Value null; |
4341 | - static const Int minInt; |
4342 | - static const Int maxInt; |
4343 | - static const UInt maxUInt; |
4344 | - |
4345 | - private: |
4346 | -#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION |
4347 | -# ifndef JSON_VALUE_USE_INTERNAL_MAP |
4348 | - class CZString |
4349 | - { |
4350 | - public: |
4351 | - enum DuplicationPolicy |
4352 | - { |
4353 | - noDuplication = 0, |
4354 | - duplicate, |
4355 | - duplicateOnCopy |
4356 | - }; |
4357 | - CZString( int index ); |
4358 | - CZString( const char *cstr, DuplicationPolicy allocate ); |
4359 | - CZString( const CZString &other ); |
4360 | - ~CZString(); |
4361 | - CZString &operator =( const CZString &other ); |
4362 | - bool operator<( const CZString &other ) const; |
4363 | - bool operator==( const CZString &other ) const; |
4364 | - int index() const; |
4365 | - const char *c_str() const; |
4366 | - bool isStaticString() const; |
4367 | - private: |
4368 | - void swap( CZString &other ); |
4369 | - const char *cstr_; |
4370 | - int index_; |
4371 | - }; |
4372 | - |
4373 | - public: |
4374 | -# ifndef JSON_USE_CPPTL_SMALLMAP |
4375 | - typedef std::map<CZString, Value> ObjectValues; |
4376 | -# else |
4377 | - typedef CppTL::SmallMap<CZString, Value> ObjectValues; |
4378 | -# endif // ifndef JSON_USE_CPPTL_SMALLMAP |
4379 | -# endif // ifndef JSON_VALUE_USE_INTERNAL_MAP |
4380 | -#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION |
4381 | - |
4382 | - public: |
4383 | - /** @brief Create a default Value of the given type. |
4384 | - |
4385 | - This is a very useful constructor. |
4386 | - To create an empty array, pass arrayValue. |
4387 | - To create an empty object, pass objectValue. |
4388 | - Another Value can then be set to this one by assignment. |
4389 | - This is useful since clear() and resize() will not alter types. |
4390 | - |
4391 | - Examples: |
4392 | - \code |
4393 | - Json::Value null_value; // null |
4394 | - Json::Value arr_value(Json::arrayValue); // [] |
4395 | - Json::Value obj_value(Json::objectValue); // {} |
4396 | - \endcode |
4397 | - */ |
4398 | - Value( ValueType type = nullValue ); |
4399 | - Value( Int value ); |
4400 | - Value( UInt value ); |
4401 | - Value( double value ); |
4402 | - Value( const char *value ); |
4403 | - Value( const char *beginValue, const char *endValue ); |
4404 | - /** @brief Constructs a value from a static string. |
4405 | - |
4406 | - * Like other value string constructor but do not duplicate the string for |
4407 | - * internal storage. The given string must remain alive after the call to this |
4408 | - * constructor. |
4409 | - * Example of usage: |
4410 | - * \code |
4411 | - * Json::Value aValue( StaticString("some text") ); |
4412 | - * \endcode |
4413 | - */ |
4414 | - Value( const StaticString &value ); |
4415 | - Value( const std::string &value ); |
4416 | -# ifdef JSON_USE_CPPTL |
4417 | - Value( const CppTL::ConstString &value ); |
4418 | -# endif |
4419 | - Value( bool value ); |
4420 | - Value( const Value &other ); |
4421 | - ~Value(); |
4422 | - |
4423 | - Value &operator=( const Value &other ); |
4424 | - /// Swap values. |
4425 | - /// \note Currently, comments are intentionally not swapped, for |
4426 | - /// both logic and efficiency. |
4427 | - void swap( Value &other ); |
4428 | - |
4429 | - ValueType type() const; |
4430 | - |
4431 | - bool operator <( const Value &other ) const; |
4432 | - bool operator <=( const Value &other ) const; |
4433 | - bool operator >=( const Value &other ) const; |
4434 | - bool operator >( const Value &other ) const; |
4435 | - |
4436 | - bool operator ==( const Value &other ) const; |
4437 | - bool operator !=( const Value &other ) const; |
4438 | - |
4439 | - int compare( const Value &other ); |
4440 | - |
4441 | - const char *asCString() const; |
4442 | - std::string asString() const; |
4443 | -# ifdef JSON_USE_CPPTL |
4444 | - CppTL::ConstString asConstString() const; |
4445 | -# endif |
4446 | - Int asInt() const; |
4447 | - UInt asUInt() const; |
4448 | - double asDouble() const; |
4449 | - bool asBool() const; |
4450 | - |
4451 | - bool isNull() const; |
4452 | - bool isBool() const; |
4453 | - bool isInt() const; |
4454 | - bool isUInt() const; |
4455 | - bool isIntegral() const; |
4456 | - bool isDouble() const; |
4457 | - bool isNumeric() const; |
4458 | - bool isString() const; |
4459 | - bool isArray() const; |
4460 | - bool isObject() const; |
4461 | - |
4462 | - bool isConvertibleTo( ValueType other ) const; |
4463 | - |
4464 | - /// Number of values in array or object |
4465 | - UInt size() const; |
4466 | - |
4467 | - /// @brief Return true if empty array, empty object, or null; |
4468 | - /// otherwise, false. |
4469 | - bool empty() const; |
4470 | - |
4471 | - /// Return isNull() |
4472 | - bool operator!() const; |
4473 | - |
4474 | - /// Remove all object members and array elements. |
4475 | - /// \pre type() is arrayValue, objectValue, or nullValue |
4476 | - /// \post type() is unchanged |
4477 | - void clear(); |
4478 | - |
4479 | - /// Resize the array to size elements. |
4480 | - /// New elements are initialized to null. |
4481 | - /// May only be called on nullValue or arrayValue. |
4482 | - /// \pre type() is arrayValue or nullValue |
4483 | - /// \post type() is arrayValue |
4484 | - void resize( UInt size ); |
4485 | - |
4486 | - /// Access an array element (zero based index ). |
4487 | - /// If the array contains less than index element, then null value are inserted |
4488 | - /// in the array so that its size is index+1. |
4489 | - /// (You may need to say 'value[0u]' to get your compiler to distinguish |
4490 | - /// this from the operator[] which takes a string.) |
4491 | - Value &operator[]( UInt index ); |
4492 | - /// Access an array element (zero based index ) |
4493 | - /// (You may need to say 'value[0u]' to get your compiler to distinguish |
4494 | - /// this from the operator[] which takes a string.) |
4495 | - const Value &operator[]( UInt index ) const; |
4496 | - /// If the array contains at least index+1 elements, returns the element value, |
4497 | - /// otherwise returns defaultValue. |
4498 | - Value get( UInt index, |
4499 | - const Value &defaultValue ) const; |
4500 | - /// Return true if index < size(). |
4501 | - bool isValidIndex( UInt index ) const; |
4502 | - /// @brief Append value to array at the end. |
4503 | - /// |
4504 | - /// Equivalent to jsonvalue[jsonvalue.size()] = value; |
4505 | - Value &append( const Value &value ); |
4506 | - |
4507 | - /// Access an object value by name, create a null member if it does not exist. |
4508 | - Value &operator[]( const char *key ); |
4509 | - /// Access an object value by name, returns null if there is no member with that name. |
4510 | - const Value &operator[]( const char *key ) const; |
4511 | - /// Access an object value by name, create a null member if it does not exist. |
4512 | - Value &operator[]( const std::string &key ); |
4513 | - /// Access an object value by name, returns null if there is no member with that name. |
4514 | - const Value &operator[]( const std::string &key ) const; |
4515 | - /** @brief Access an object value by name, create a null member if it does not exist. |
4516 | - |
4517 | - * If the object as no entry for that name, then the member name used to store |
4518 | - * the new entry is not duplicated. |
4519 | - * Example of use: |
4520 | - * \code |
4521 | - * Json::Value object; |
4522 | - * static const StaticString code("code"); |
4523 | - * object[code] = 1234; |
4524 | - * \endcode |
4525 | - */ |
4526 | - Value &operator[]( const StaticString &key ); |
4527 | -# ifdef JSON_USE_CPPTL |
4528 | - /// Access an object value by name, create a null member if it does not exist. |
4529 | - Value &operator[]( const CppTL::ConstString &key ); |
4530 | - /// Access an object value by name, returns null if there is no member with that name. |
4531 | - const Value &operator[]( const CppTL::ConstString &key ) const; |
4532 | -# endif |
4533 | - /// Return the member named key if it exist, defaultValue otherwise. |
4534 | - Value get( const char *key, |
4535 | - const Value &defaultValue ) const; |
4536 | - /// Return the member named key if it exist, defaultValue otherwise. |
4537 | - Value get( const std::string &key, |
4538 | - const Value &defaultValue ) const; |
4539 | -# ifdef JSON_USE_CPPTL |
4540 | - /// Return the member named key if it exist, defaultValue otherwise. |
4541 | - Value get( const CppTL::ConstString &key, |
4542 | - const Value &defaultValue ) const; |
4543 | -# endif |
4544 | - /// @brief Remove and return the named member. |
4545 | - /// |
4546 | - /// Do nothing if it did not exist. |
4547 | - /// \return the removed Value, or null. |
4548 | - /// \pre type() is objectValue or nullValue |
4549 | - /// \post type() is unchanged |
4550 | - Value removeMember( const char* key ); |
4551 | - /// Same as removeMember(const char*) |
4552 | - Value removeMember( const std::string &key ); |
4553 | - |
4554 | - /// Return true if the object has a member named key. |
4555 | - bool isMember( const char *key ) const; |
4556 | - /// Return true if the object has a member named key. |
4557 | - bool isMember( const std::string &key ) const; |
4558 | -# ifdef JSON_USE_CPPTL |
4559 | - /// Return true if the object has a member named key. |
4560 | - bool isMember( const CppTL::ConstString &key ) const; |
4561 | -# endif |
4562 | - |
4563 | - /// @brief Return a list of the member names. |
4564 | - /// |
4565 | - /// If null, return an empty list. |
4566 | - /// \pre type() is objectValue or nullValue |
4567 | - /// \post if type() was nullValue, it remains nullValue |
4568 | - Members getMemberNames() const; |
4569 | - |
4570 | -//# ifdef JSON_USE_CPPTL |
4571 | -// EnumMemberNames enumMemberNames() const; |
4572 | -// EnumValues enumValues() const; |
4573 | -//# endif |
4574 | - |
4575 | - /// Comments must be //... or /* ... */ |
4576 | - void setComment( const char *comment, |
4577 | - CommentPlacement placement ); |
4578 | - /// Comments must be //... or /* ... */ |
4579 | - void setComment( const std::string &comment, |
4580 | - CommentPlacement placement ); |
4581 | - bool hasComment( CommentPlacement placement ) const; |
4582 | - /// Include delimiters and embedded newlines. |
4583 | - std::string getComment( CommentPlacement placement ) const; |
4584 | - |
4585 | - std::string toStyledString() const; |
4586 | - |
4587 | - const_iterator begin() const; |
4588 | - const_iterator end() const; |
4589 | - |
4590 | - iterator begin(); |
4591 | - iterator end(); |
4592 | - |
4593 | - private: |
4594 | - Value &resolveReference( const char *key, |
4595 | - bool isStatic ); |
4596 | - |
4597 | -# ifdef JSON_VALUE_USE_INTERNAL_MAP |
4598 | - inline bool isItemAvailable() const |
4599 | - { |
4600 | - return itemIsUsed_ == 0; |
4601 | - } |
4602 | - |
4603 | - inline void setItemUsed( bool isUsed = true ) |
4604 | - { |
4605 | - itemIsUsed_ = isUsed ? 1 : 0; |
4606 | - } |
4607 | - |
4608 | - inline bool isMemberNameStatic() const |
4609 | - { |
4610 | - return memberNameIsStatic_ == 0; |
4611 | - } |
4612 | - |
4613 | - inline void setMemberNameIsStatic( bool isStatic ) |
4614 | - { |
4615 | - memberNameIsStatic_ = isStatic ? 1 : 0; |
4616 | - } |
4617 | -# endif // # ifdef JSON_VALUE_USE_INTERNAL_MAP |
4618 | - |
4619 | - private: |
4620 | - struct CommentInfo |
4621 | - { |
4622 | - CommentInfo(); |
4623 | - ~CommentInfo(); |
4624 | - |
4625 | - void setComment( const char *text ); |
4626 | - |
4627 | - char *comment_; |
4628 | - }; |
4629 | - |
4630 | - //struct MemberNamesTransform |
4631 | - //{ |
4632 | - // typedef const char *result_type; |
4633 | - // const char *operator()( const CZString &name ) const |
4634 | - // { |
4635 | - // return name.c_str(); |
4636 | - // } |
4637 | - //}; |
4638 | - |
4639 | - union ValueHolder |
4640 | - { |
4641 | - Int int_; |
4642 | - UInt uint_; |
4643 | - double real_; |
4644 | - bool bool_; |
4645 | - char *string_; |
4646 | -# ifdef JSON_VALUE_USE_INTERNAL_MAP |
4647 | - ValueInternalArray *array_; |
4648 | - ValueInternalMap *map_; |
4649 | -#else |
4650 | - ObjectValues *map_; |
4651 | -# endif |
4652 | - } value_; |
4653 | - ValueType type_ : 8; |
4654 | - int allocated_ : 1; // Notes: if declared as bool, bitfield is useless. |
4655 | -# ifdef JSON_VALUE_USE_INTERNAL_MAP |
4656 | - unsigned int itemIsUsed_ : 1; // used by the ValueInternalMap container. |
4657 | - int memberNameIsStatic_ : 1; // used by the ValueInternalMap container. |
4658 | -# endif |
4659 | - CommentInfo *comments_; |
4660 | - }; |
4661 | - |
4662 | - |
4663 | - /** @brief Experimental and untested: represents an element of the "path" to access a node. |
4664 | - */ |
4665 | - class PathArgument |
4666 | - { |
4667 | - public: |
4668 | - friend class Path; |
4669 | - |
4670 | - PathArgument(); |
4671 | - PathArgument( UInt index ); |
4672 | - PathArgument( const char *key ); |
4673 | - PathArgument( const std::string &key ); |
4674 | - |
4675 | - private: |
4676 | - enum Kind |
4677 | - { |
4678 | - kindNone = 0, |
4679 | - kindIndex, |
4680 | - kindKey |
4681 | - }; |
4682 | - std::string key_; |
4683 | - UInt index_; |
4684 | - Kind kind_; |
4685 | - }; |
4686 | - |
4687 | - /** @brief Experimental and untested: represents a "path" to access a node. |
4688 | - * |
4689 | - * Syntax: |
4690 | - * - "." => root node |
4691 | - * - ".[n]" => elements at index 'n' of root node (an array value) |
4692 | - * - ".name" => member named 'name' of root node (an object value) |
4693 | - * - ".name1.name2.name3" |
4694 | - * - ".[0][1][2].name1[3]" |
4695 | - * - ".%" => member name is provided as parameter |
4696 | - * - ".[%]" => index is provied as parameter |
4697 | - */ |
4698 | - class Path |
4699 | - { |
4700 | - public: |
4701 | - Path( const std::string &path, |
4702 | - const PathArgument &a1 = PathArgument(), |
4703 | - const PathArgument &a2 = PathArgument(), |
4704 | - const PathArgument &a3 = PathArgument(), |
4705 | - const PathArgument &a4 = PathArgument(), |
4706 | - const PathArgument &a5 = PathArgument() ); |
4707 | - |
4708 | - const Value &resolve( const Value &root ) const; |
4709 | - Value resolve( const Value &root, |
4710 | - const Value &defaultValue ) const; |
4711 | - /// Creates the "path" to access the specified node and returns a reference on the node. |
4712 | - Value &make( Value &root ) const; |
4713 | - |
4714 | - private: |
4715 | - typedef std::vector<const PathArgument *> InArgs; |
4716 | - typedef std::vector<PathArgument> Args; |
4717 | - |
4718 | - void makePath( const std::string &path, |
4719 | - const InArgs &in ); |
4720 | - void addPathInArg( const std::string &path, |
4721 | - const InArgs &in, |
4722 | - InArgs::const_iterator &itInArg, |
4723 | - PathArgument::Kind kind ); |
4724 | - void invalidPath( const std::string &path, |
4725 | - int location ); |
4726 | - |
4727 | - Args args_; |
4728 | - }; |
4729 | - |
4730 | - /** @brief Experimental do not use: Allocator to customize member name and string value memory management done by Value. |
4731 | - * |
4732 | - * - makeMemberName() and releaseMemberName() are called to respectively duplicate and |
4733 | - * free an Json::objectValue member name. |
4734 | - * - duplicateStringValue() and releaseStringValue() are called similarly to |
4735 | - * duplicate and free a Json::stringValue value. |
4736 | - */ |
4737 | - class ValueAllocator |
4738 | - { |
4739 | - public: |
4740 | - enum { unknown = (unsigned)-1 }; |
4741 | - |
4742 | - virtual ~ValueAllocator(); |
4743 | - |
4744 | - virtual char *makeMemberName( const char *memberName ) = 0; |
4745 | - virtual void releaseMemberName( char *memberName ) = 0; |
4746 | - virtual char *duplicateStringValue( const char *value, |
4747 | - unsigned int length = unknown ) = 0; |
4748 | - virtual void releaseStringValue( char *value ) = 0; |
4749 | - }; |
4750 | - |
4751 | -#ifdef JSON_VALUE_USE_INTERNAL_MAP |
4752 | - /** @brief Allocator to customize Value internal map. |
4753 | - * Below is an example of a simple implementation (default implementation actually |
4754 | - * use memory pool for speed). |
4755 | - * \code |
4756 | - class DefaultValueMapAllocator : public ValueMapAllocator |
4757 | - { |
4758 | - public: // overridden from ValueMapAllocator |
4759 | - virtual ValueInternalMap *newMap() |
4760 | - { |
4761 | - return new ValueInternalMap(); |
4762 | - } |
4763 | - |
4764 | - virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other ) |
4765 | - { |
4766 | - return new ValueInternalMap( other ); |
4767 | - } |
4768 | - |
4769 | - virtual void destructMap( ValueInternalMap *map ) |
4770 | - { |
4771 | - delete map; |
4772 | - } |
4773 | - |
4774 | - virtual ValueInternalLink *allocateMapBuckets( unsigned int size ) |
4775 | - { |
4776 | - return new ValueInternalLink[size]; |
4777 | - } |
4778 | - |
4779 | - virtual void releaseMapBuckets( ValueInternalLink *links ) |
4780 | - { |
4781 | - delete [] links; |
4782 | - } |
4783 | - |
4784 | - virtual ValueInternalLink *allocateMapLink() |
4785 | - { |
4786 | - return new ValueInternalLink(); |
4787 | - } |
4788 | - |
4789 | - virtual void releaseMapLink( ValueInternalLink *link ) |
4790 | - { |
4791 | - delete link; |
4792 | - } |
4793 | - }; |
4794 | - * \endcode |
4795 | - */ |
4796 | - class JSON_API ValueMapAllocator |
4797 | - { |
4798 | - public: |
4799 | - virtual ~ValueMapAllocator(); |
4800 | - virtual ValueInternalMap *newMap() = 0; |
4801 | - virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other ) = 0; |
4802 | - virtual void destructMap( ValueInternalMap *map ) = 0; |
4803 | - virtual ValueInternalLink *allocateMapBuckets( unsigned int size ) = 0; |
4804 | - virtual void releaseMapBuckets( ValueInternalLink *links ) = 0; |
4805 | - virtual ValueInternalLink *allocateMapLink() = 0; |
4806 | - virtual void releaseMapLink( ValueInternalLink *link ) = 0; |
4807 | - }; |
4808 | - |
4809 | - /** @brief ValueInternalMap hash-map bucket chain link (for internal use only). |
4810 | - * \internal previous_ & next_ allows for bidirectional traversal. |
4811 | - */ |
4812 | - class JSON_API ValueInternalLink |
4813 | - { |
4814 | - public: |
4815 | - enum { itemPerLink = 6 }; // sizeof(ValueInternalLink) = 128 on 32 bits architecture. |
4816 | - enum InternalFlags { |
4817 | - flagAvailable = 0, |
4818 | - flagUsed = 1 |
4819 | - }; |
4820 | - |
4821 | - ValueInternalLink(); |
4822 | - |
4823 | - ~ValueInternalLink(); |
4824 | - |
4825 | - Value items_[itemPerLink]; |
4826 | - char *keys_[itemPerLink]; |
4827 | - ValueInternalLink *previous_; |
4828 | - ValueInternalLink *next_; |
4829 | - }; |
4830 | - |
4831 | - |
4832 | - /** @brief A linked page based hash-table implementation used internally by Value. |
4833 | - * \internal ValueInternalMap is a tradional bucket based hash-table, with a linked |
4834 | - * list in each bucket to handle collision. There is an addional twist in that |
4835 | - * each node of the collision linked list is a page containing a fixed amount of |
4836 | - * value. This provides a better compromise between memory usage and speed. |
4837 | - * |
4838 | - * Each bucket is made up of a chained list of ValueInternalLink. The last |
4839 | - * link of a given bucket can be found in the 'previous_' field of the following bucket. |
4840 | - * The last link of the last bucket is stored in tailLink_ as it has no following bucket. |
4841 | - * Only the last link of a bucket may contains 'available' item. The last link always |
4842 | - * contains at least one element unless is it the bucket one very first link. |
4843 | - */ |
4844 | - class JSON_API ValueInternalMap |
4845 | - { |
4846 | - friend class ValueIteratorBase; |
4847 | - friend class Value; |
4848 | - public: |
4849 | - typedef unsigned int HashKey; |
4850 | - typedef unsigned int BucketIndex; |
4851 | - |
4852 | -# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION |
4853 | - struct IteratorState |
4854 | - { |
4855 | - IteratorState() |
4856 | - : map_(0) |
4857 | - , link_(0) |
4858 | - , itemIndex_(0) |
4859 | - , bucketIndex_(0) |
4860 | - { |
4861 | - } |
4862 | - ValueInternalMap *map_; |
4863 | - ValueInternalLink *link_; |
4864 | - BucketIndex itemIndex_; |
4865 | - BucketIndex bucketIndex_; |
4866 | - }; |
4867 | -# endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION |
4868 | - |
4869 | - ValueInternalMap(); |
4870 | - ValueInternalMap( const ValueInternalMap &other ); |
4871 | - ValueInternalMap &operator =( const ValueInternalMap &other ); |
4872 | - ~ValueInternalMap(); |
4873 | - |
4874 | - void swap( ValueInternalMap &other ); |
4875 | - |
4876 | - BucketIndex size() const; |
4877 | - |
4878 | - void clear(); |
4879 | - |
4880 | - bool reserveDelta( BucketIndex growth ); |
4881 | - |
4882 | - bool reserve( BucketIndex newItemCount ); |
4883 | - |
4884 | - const Value *find( const char *key ) const; |
4885 | - |
4886 | - Value *find( const char *key ); |
4887 | - |
4888 | - Value &resolveReference( const char *key, |
4889 | - bool isStatic ); |
4890 | - |
4891 | - void remove( const char *key ); |
4892 | - |
4893 | - void doActualRemove( ValueInternalLink *link, |
4894 | - BucketIndex index, |
4895 | - BucketIndex bucketIndex ); |
4896 | - |
4897 | - ValueInternalLink *&getLastLinkInBucket( BucketIndex bucketIndex ); |
4898 | - |
4899 | - Value &setNewItem( const char *key, |
4900 | - bool isStatic, |
4901 | - ValueInternalLink *link, |
4902 | - BucketIndex index ); |
4903 | - |
4904 | - Value &unsafeAdd( const char *key, |
4905 | - bool isStatic, |
4906 | - HashKey hashedKey ); |
4907 | - |
4908 | - HashKey hash( const char *key ) const; |
4909 | - |
4910 | - int compare( const ValueInternalMap &other ) const; |
4911 | - |
4912 | - private: |
4913 | - void makeBeginIterator( IteratorState &it ) const; |
4914 | - void makeEndIterator( IteratorState &it ) const; |
4915 | - static bool equals( const IteratorState &x, const IteratorState &other ); |
4916 | - static void increment( IteratorState &iterator ); |
4917 | - static void incrementBucket( IteratorState &iterator ); |
4918 | - static void decrement( IteratorState &iterator ); |
4919 | - static const char *key( const IteratorState &iterator ); |
4920 | - static const char *key( const IteratorState &iterator, bool &isStatic ); |
4921 | - static Value &value( const IteratorState &iterator ); |
4922 | - static int distance( const IteratorState &x, const IteratorState &y ); |
4923 | - |
4924 | - private: |
4925 | - ValueInternalLink *buckets_; |
4926 | - ValueInternalLink *tailLink_; |
4927 | - BucketIndex bucketsSize_; |
4928 | - BucketIndex itemCount_; |
4929 | - }; |
4930 | - |
4931 | - /** @brief A simplified deque implementation used internally by Value. |
4932 | - * \internal |
4933 | - * It is based on a list of fixed "page", each page contains a fixed number of items. |
4934 | - * Instead of using a linked-list, a array of pointer is used for fast item look-up. |
4935 | - * Look-up for an element is as follow: |
4936 | - * - compute page index: pageIndex = itemIndex / itemsPerPage |
4937 | - * - look-up item in page: pages_[pageIndex][itemIndex % itemsPerPage] |
4938 | - * |
4939 | - * Insertion is amortized constant time (only the array containing the index of pointers |
4940 | - * need to be reallocated when items are appended). |
4941 | - */ |
4942 | - class JSON_API ValueInternalArray |
4943 | - { |
4944 | - friend class Value; |
4945 | - friend class ValueIteratorBase; |
4946 | - public: |
4947 | - enum { itemsPerPage = 8 }; // should be a power of 2 for fast divide and modulo. |
4948 | - typedef Value::ArrayIndex ArrayIndex; |
4949 | - typedef unsigned int PageIndex; |
4950 | - |
4951 | -# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION |
4952 | - struct IteratorState // Must be a POD |
4953 | - { |
4954 | - IteratorState() |
4955 | - : array_(0) |
4956 | - , currentPageIndex_(0) |
4957 | - , currentItemIndex_(0) |
4958 | - { |
4959 | - } |
4960 | - ValueInternalArray *array_; |
4961 | - Value **currentPageIndex_; |
4962 | - unsigned int currentItemIndex_; |
4963 | - }; |
4964 | -# endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION |
4965 | - |
4966 | - ValueInternalArray(); |
4967 | - ValueInternalArray( const ValueInternalArray &other ); |
4968 | - ValueInternalArray &operator =( const ValueInternalArray &other ); |
4969 | - ~ValueInternalArray(); |
4970 | - void swap( ValueInternalArray &other ); |
4971 | - |
4972 | - void clear(); |
4973 | - void resize( ArrayIndex newSize ); |
4974 | - |
4975 | - Value &resolveReference( ArrayIndex index ); |
4976 | - |
4977 | - Value *find( ArrayIndex index ) const; |
4978 | - |
4979 | - ArrayIndex size() const; |
4980 | - |
4981 | - int compare( const ValueInternalArray &other ) const; |
4982 | - |
4983 | - private: |
4984 | - static bool equals( const IteratorState &x, const IteratorState &other ); |
4985 | - static void increment( IteratorState &iterator ); |
4986 | - static void decrement( IteratorState &iterator ); |
4987 | - static Value &dereference( const IteratorState &iterator ); |
4988 | - static Value &unsafeDereference( const IteratorState &iterator ); |
4989 | - static int distance( const IteratorState &x, const IteratorState &y ); |
4990 | - static ArrayIndex indexOf( const IteratorState &iterator ); |
4991 | - void makeBeginIterator( IteratorState &it ) const; |
4992 | - void makeEndIterator( IteratorState &it ) const; |
4993 | - void makeIterator( IteratorState &it, ArrayIndex index ) const; |
4994 | - |
4995 | - void makeIndexValid( ArrayIndex index ); |
4996 | - |
4997 | - Value **pages_; |
4998 | - ArrayIndex size_; |
4999 | - PageIndex pageCount_; |
5000 | - }; |