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