Merge lp:~saiarcot895/libopenshot/qt-json into lp:libopenshot/0.0

Proposed by Saikrishna Arcot
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
Reviewer Review Type Date Requested Status
OpenShot Code Pending
Review via email: mp+273331@code.launchpad.net

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.

To post a comment you must log in.

Unmerged revisions

478. By Saikrishna Arcot

Switch from JsonCPP to Qt JSON.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/ChunkReader.h'
--- include/ChunkReader.h 2015-08-24 06:05:48 +0000
+++ include/ChunkReader.h 2015-10-04 15:21:00 +0000
@@ -158,8 +158,8 @@
158 /// Get and Set JSON methods158 /// Get and Set JSON methods
159 string Json(); ///< Generate JSON string of this object159 string Json(); ///< Generate JSON string of this object
160 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object160 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object
161 Json::Value JsonValue(); ///< Generate Json::JsonValue for this object161 QJsonObject JsonValue(); ///< Generate QJsonObject for this object
162 void SetJsonValue(Json::Value root) throw(InvalidFile); ///< Load Json::JsonValue into this object162 void SetJsonValue(const QJsonObject root) throw(InvalidFile); ///< Load QJsonObject into this object
163163
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.
165 void Open() throw(InvalidFile);165 void Open() throw(InvalidFile);
166166
=== modified file 'include/ChunkWriter.h'
--- include/ChunkWriter.h 2015-02-05 06:11:55 +0000
+++ include/ChunkWriter.h 2015-10-04 15:21:00 +0000
@@ -44,7 +44,6 @@
44#include "Magick++.h"44#include "Magick++.h"
45#include "Cache.h"45#include "Cache.h"
46#include "Exceptions.h"46#include "Exceptions.h"
47#include "Json.h"
48#include "Sleep.h"47#include "Sleep.h"
4948
5049
5150
=== modified file 'include/Clip.h'
--- include/Clip.h 2015-08-24 06:05:48 +0000
+++ include/Clip.h 2015-10-04 15:21:00 +0000
@@ -193,8 +193,8 @@
193 /// Get and Set JSON methods193 /// Get and Set JSON methods
194 string Json(); ///< Generate JSON string of this object194 string Json(); ///< Generate JSON string of this object
195 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object195 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object
196 Json::Value JsonValue(); ///< Generate Json::JsonValue for this object196 QJsonObject JsonValue(); ///< Generate QJsonObject for this object
197 void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object197 void SetJsonValue(QJsonObject root); ///< Load QJsonObject into this object
198198
199 /// Get all properties for a specific frame (perfect for a UI to display the current state199 /// Get all properties for a specific frame (perfect for a UI to display the current state
200 /// of all properties at any time)200 /// of all properties at any time)
201201
=== modified file 'include/ClipBase.h'
--- include/ClipBase.h 2015-10-02 23:22:10 +0000
+++ include/ClipBase.h 2015-10-04 15:21:00 +0000
@@ -59,10 +59,10 @@
59 string previous_properties; ///< This string contains the previous JSON properties59 string previous_properties; ///< This string contains the previous JSON properties
6060
61 /// Generate JSON for a property61 /// Generate JSON for a property
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);
6363
64 /// Generate JSON choice for a property (dropdown properties)64 /// Generate JSON choice for a property (dropdown properties)
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);
6666
67 public:67 public:
6868
@@ -90,8 +90,8 @@
90 /// Get and Set JSON methods90 /// Get and Set JSON methods
91 virtual string Json() = 0; ///< Generate JSON string of this object91 virtual string Json() = 0; ///< Generate JSON string of this object
92 virtual void SetJson(string value) throw(InvalidJSON) = 0; ///< Load JSON string into this object92 virtual void SetJson(string value) throw(InvalidJSON) = 0; ///< Load JSON string into this object
93 virtual Json::Value JsonValue() = 0; ///< Generate Json::JsonValue for this object93 virtual QJsonObject JsonValue() = 0; ///< Generate QJsonObject for this object
94 virtual void SetJsonValue(Json::Value root) = 0; ///< Load Json::JsonValue into this object94 virtual void SetJsonValue(const QJsonObject root) = 0; ///< Load QJsonObject into this object
9595
96 /// Get all properties for a specific frame (perfect for a UI to display the current state96 /// Get all properties for a specific frame (perfect for a UI to display the current state
97 /// of all properties at any time)97 /// of all properties at any time)
9898
=== modified file 'include/Color.h'
--- include/Color.h 2015-08-24 06:05:48 +0000
+++ include/Color.h 2015-10-04 15:21:00 +0000
@@ -67,9 +67,9 @@
6767
68 /// Get and Set JSON methods68 /// Get and Set JSON methods
69 string Json(); ///< Generate JSON string of this object69 string Json(); ///< Generate JSON string of this object
70 Json::Value JsonValue(); ///< Generate Json::JsonValue for this object70 QJsonObject JsonValue(); ///< Generate QJsonObject for this object
71 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object71 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object
72 void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object72 void SetJsonValue(QJsonObject root); ///< Load QJsonObject into this object
73 };73 };
7474
7575
7676
=== modified file 'include/Coordinate.h'
--- include/Coordinate.h 2015-02-05 06:11:55 +0000
+++ include/Coordinate.h 2015-10-04 15:21:00 +0000
@@ -92,9 +92,9 @@
9292
93 /// Get and Set JSON methods93 /// Get and Set JSON methods
94 string Json(); ///< Generate JSON string of this object94 string Json(); ///< Generate JSON string of this object
95 Json::Value JsonValue(); ///< Generate Json::JsonValue for this object95 QJsonObject JsonValue(); ///< Generate QJsonObject for this object
96 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object96 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object
97 void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object97 void SetJsonValue(QJsonObject root); ///< Load QJsonObject into this object
98 };98 };
9999
100}100}
101101
=== modified file 'include/DecklinkReader.h'
--- include/DecklinkReader.h 2015-08-24 06:05:48 +0000
+++ include/DecklinkReader.h 2015-10-04 15:21:00 +0000
@@ -117,8 +117,8 @@
117 /// Get and Set JSON methods117 /// Get and Set JSON methods
118 string Json(); ///< Generate JSON string of this object118 string Json(); ///< Generate JSON string of this object
119 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object119 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object
120 Json::Value JsonValue(); ///< Generate Json::JsonValue for this object120 QJsonObject JsonValue(); ///< Generate QJsonObject for this object
121 void SetJsonValue(Json::Value root) throw(InvalidFile); ///< Load Json::JsonValue into this object121 void SetJsonValue(QJsonObject root) throw(InvalidFile); ///< Load QJsonObject into this object
122122
123 /// Open device and video stream - which is called by the constructor automatically123 /// Open device and video stream - which is called by the constructor automatically
124 void Open() throw(DecklinkError);124 void Open() throw(DecklinkError);
125125
=== modified file 'include/DummyReader.h'
--- include/DummyReader.h 2015-08-24 06:05:48 +0000
+++ include/DummyReader.h 2015-10-04 15:21:00 +0000
@@ -84,8 +84,8 @@
84 /// Get and Set JSON methods84 /// Get and Set JSON methods
85 string Json(); ///< Generate JSON string of this object85 string Json(); ///< Generate JSON string of this object
86 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object86 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object
87 Json::Value JsonValue(); ///< Generate Json::JsonValue for this object87 QJsonObject JsonValue(); ///< Generate QJsonObject for this object
88 void SetJsonValue(Json::Value root) throw(InvalidFile); ///< Load Json::JsonValue into this object88 void SetJsonValue(QJsonObject root) throw(InvalidFile); ///< Load QJsonObject into this object
8989
90 /// Open File - which is called by the constructor automatically90 /// Open File - which is called by the constructor automatically
91 void Open() throw(InvalidFile);91 void Open() throw(InvalidFile);
9292
=== modified file 'include/EffectBase.h'
--- include/EffectBase.h 2015-08-24 06:05:48 +0000
+++ include/EffectBase.h 2015-10-04 15:21:00 +0000
@@ -93,9 +93,9 @@
93 /// Get and Set JSON methods93 /// Get and Set JSON methods
94 virtual string Json() = 0; ///< Generate JSON string of this object94 virtual string Json() = 0; ///< Generate JSON string of this object
95 virtual void SetJson(string value) throw(InvalidJSON) = 0; ///< Load JSON string into this object95 virtual void SetJson(string value) throw(InvalidJSON) = 0; ///< Load JSON string into this object
96 virtual Json::Value JsonValue() = 0; ///< Generate Json::JsonValue for this object96 virtual QJsonObject JsonValue() = 0; ///< Generate QJsonObject for this object
97 virtual void SetJsonValue(Json::Value root) = 0; ///< Load Json::JsonValue into this object97 virtual void SetJsonValue(const QJsonObject root) = 0; ///< Load QJsonObject into this object
98 Json::Value JsonInfo(); ///< Generate JSON object of meta data / info98 QJsonObject JsonInfo(); ///< Generate JSON object of meta data / info
9999
100 /// Get the order that this effect should be executed.100 /// Get the order that this effect should be executed.
101 int Order() { return order; }101 int Order() { return order; }
102102
=== modified file 'include/EffectInfo.h'
--- include/EffectInfo.h 2015-08-07 01:01:34 +0000
+++ include/EffectInfo.h 2015-10-04 15:21:00 +0000
@@ -48,7 +48,7 @@
4848
49 /// JSON methods49 /// JSON methods
50 static string Json(); ///< Generate JSON string of this object50 static string Json(); ///< Generate JSON string of this object
51 static Json::Value JsonValue(); ///< Generate Json::JsonValue for this object51 static QJsonArray JsonValue(); ///< Generate QJsonArray for this object
5252
53 };53 };
5454
5555
=== modified file 'include/FFmpegReader.h'
--- include/FFmpegReader.h 2015-08-24 06:05:48 +0000
+++ include/FFmpegReader.h 2015-10-04 15:21:00 +0000
@@ -255,8 +255,8 @@
255 /// Get and Set JSON methods255 /// Get and Set JSON methods
256 string Json(); ///< Generate JSON string of this object256 string Json(); ///< Generate JSON string of this object
257 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object257 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object
258 Json::Value JsonValue(); ///< Generate Json::JsonValue for this object258 QJsonObject JsonValue(); ///< Generate QJsonObject for this object
259 void SetJsonValue(Json::Value root) throw(InvalidFile); ///< Load Json::JsonValue into this object259 void SetJsonValue(QJsonObject root) throw(InvalidFile); ///< Load QJsonObject into this object
260260
261 /// Open File - which is called by the constructor automatically261 /// Open File - which is called by the constructor automatically
262 void Open() throw(InvalidFile, NoStreamsFound, InvalidCodec);262 void Open() throw(InvalidFile, NoStreamsFound, InvalidCodec);
263263
=== modified file 'include/FrameMapper.h'
--- include/FrameMapper.h 2015-08-24 06:05:48 +0000
+++ include/FrameMapper.h 2015-10-04 15:21:00 +0000
@@ -192,8 +192,8 @@
192 /// Get and Set JSON methods192 /// Get and Set JSON methods
193 string Json(); ///< Generate JSON string of this object193 string Json(); ///< Generate JSON string of this object
194 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object194 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object
195 Json::Value JsonValue(); ///< Generate Json::JsonValue for this object195 QJsonObject JsonValue(); ///< Generate QJsonObject for this object
196 void SetJsonValue(Json::Value root) throw(InvalidFile); ///< Load Json::JsonValue into this object196 void SetJsonValue(QJsonObject root) throw(InvalidFile); ///< Load QJsonObject into this object
197197
198 /// Open the internal reader198 /// Open the internal reader
199 void Open() throw(InvalidFile);199 void Open() throw(InvalidFile);
200200
=== modified file 'include/ImageReader.h'
--- include/ImageReader.h 2015-08-24 06:05:48 +0000
+++ include/ImageReader.h 2015-10-04 15:21:00 +0000
@@ -96,8 +96,8 @@
96 /// Get and Set JSON methods96 /// Get and Set JSON methods
97 string Json(); ///< Generate JSON string of this object97 string Json(); ///< Generate JSON string of this object
98 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object98 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object
99 Json::Value JsonValue(); ///< Generate Json::JsonValue for this object99 QJsonObject JsonValue(); ///< Generate QJsonObject for this object
100 void SetJsonValue(Json::Value root) throw(InvalidFile); ///< Load Json::JsonValue into this object100 void SetJsonValue(QJsonObject root) throw(InvalidFile); ///< Load QJsonObject into this object
101101
102 /// Open File - which is called by the constructor automatically102 /// Open File - which is called by the constructor automatically
103 void Open() throw(InvalidFile);103 void Open() throw(InvalidFile);
104104
=== modified file 'include/Json.h'
--- include/Json.h 2014-07-11 21:52:14 +0000
+++ include/Json.h 2015-10-04 15:21:00 +0000
@@ -28,6 +28,10 @@
28#ifndef OPENSHOT_JSON_H28#ifndef OPENSHOT_JSON_H
29#define OPENSHOT_JSON_H29#define OPENSHOT_JSON_H
3030
31#include "../thirdparty/jsoncpp/include/json/json.h"31#include <QtCore/QJsonDocument>
32#include <QtCore/QJsonArray>
33#include <QtCore/QJsonObject>
34#include <QtCore/QJsonParseError>
35#include <QtCore/QVariant> // Needed for int conversion
3236
33#endif37#endif
3438
=== modified file 'include/KeyFrame.h'
--- include/KeyFrame.h 2015-08-24 06:05:48 +0000
+++ include/KeyFrame.h 2015-10-04 15:21:00 +0000
@@ -152,9 +152,9 @@
152152
153 /// Get and Set JSON methods153 /// Get and Set JSON methods
154 string Json(); ///< Generate JSON string of this object154 string Json(); ///< Generate JSON string of this object
155 Json::Value JsonValue(); ///< Generate Json::JsonValue for this object155 QJsonObject JsonValue(); ///< Generate QJsonObject for this object
156 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object156 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object
157 void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object157 void SetJsonValue(QJsonObject root); ///< Load QJsonObject into this object
158158
159 /**159 /**
160 * @brief Calculate all of the values for this keyframe.160 * @brief Calculate all of the values for this keyframe.
161161
=== modified file 'include/Point.h'
--- include/Point.h 2015-02-21 06:12:21 +0000
+++ include/Point.h 2015-10-04 15:21:00 +0000
@@ -116,9 +116,9 @@
116116
117 /// Get and Set JSON methods117 /// Get and Set JSON methods
118 string Json(); ///< Generate JSON string of this object118 string Json(); ///< Generate JSON string of this object
119 Json::Value JsonValue(); ///< Generate Json::JsonValue for this object119 QJsonObject JsonValue(); ///< Generate QJsonObject for this object
120 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object120 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object
121 void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object121 void SetJsonValue(const QJsonObject root); ///< Load QJsonObject into this object
122122
123 };123 };
124124
125125
=== modified file 'include/Profiles.h'
--- include/Profiles.h 2014-07-11 21:52:14 +0000
+++ include/Profiles.h 2015-10-04 15:21:00 +0000
@@ -88,9 +88,9 @@
8888
89 /// Get and Set JSON methods89 /// Get and Set JSON methods
90 string Json(); ///< Generate JSON string of this object90 string Json(); ///< Generate JSON string of this object
91 Json::Value JsonValue(); ///< Generate Json::JsonValue for this object91 QJsonObject JsonValue(); ///< Generate QJsonObject for this object
92 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object92 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object
93 void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object93 void SetJsonValue(const QJsonObject root); ///< Load QJsonObject into this object
94 };94 };
9595
96}96}
9797
=== modified file 'include/QtImageReader.h'
--- include/QtImageReader.h 2015-08-24 06:05:48 +0000
+++ include/QtImageReader.h 2015-10-04 15:21:00 +0000
@@ -98,8 +98,8 @@
98 /// Get and Set JSON methods98 /// Get and Set JSON methods
99 string Json(); ///< Generate JSON string of this object99 string Json(); ///< Generate JSON string of this object
100 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object100 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object
101 Json::Value JsonValue(); ///< Generate Json::JsonValue for this object101 QJsonObject JsonValue(); ///< Generate QJsonObject for this object
102 void SetJsonValue(Json::Value root) throw(InvalidFile); ///< Load Json::JsonValue into this object102 void SetJsonValue(QJsonObject root) throw(InvalidFile); ///< Load QJsonObject into this object
103103
104 /// Open File - which is called by the constructor automatically104 /// Open File - which is called by the constructor automatically
105 void Open() throw(InvalidFile);105 void Open() throw(InvalidFile);
106106
=== modified file 'include/ReaderBase.h'
--- include/ReaderBase.h 2015-09-29 03:05:50 +0000
+++ include/ReaderBase.h 2015-10-04 15:21:00 +0000
@@ -98,10 +98,10 @@
98 CriticalSection processingCriticalSection;98 CriticalSection processingCriticalSection;
9999
100 /// Debug JSON root100 /// Debug JSON root
101 Json::Value debug_root;101 QJsonArray debug_root;
102102
103 /// Append debug information as JSON103 /// Append debug information as JSON
104 void AppendDebugItem(Json::Value debug_item);104 void AppendDebugItem(QJsonValue debug_item);
105105
106 /// Append debug information as JSON106 /// Append debug information as JSON
107 void AppendDebugMethod(string method_name, string arg1_name, float arg1_value,107 void AppendDebugMethod(string method_name, string arg1_name, float arg1_value,
@@ -152,8 +152,8 @@
152 /// Get and Set JSON methods152 /// Get and Set JSON methods
153 virtual string Json() = 0; ///< Generate JSON string of this object153 virtual string Json() = 0; ///< Generate JSON string of this object
154 virtual void SetJson(string value) throw(InvalidJSON) = 0; ///< Load JSON string into this object154 virtual void SetJson(string value) throw(InvalidJSON) = 0; ///< Load JSON string into this object
155 virtual Json::Value JsonValue() = 0; ///< Generate Json::JsonValue for this object155 virtual QJsonObject JsonValue() = 0; ///< Generate QJsonObject for this object
156 virtual void SetJsonValue(Json::Value root) = 0; ///< Load Json::JsonValue into this object156 virtual void SetJsonValue(const QJsonObject root) = 0; ///< Load QJsonObject into this object
157157
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)
159 virtual void Open() = 0;159 virtual void Open() = 0;
160160
=== modified file 'include/TextReader.h'
--- include/TextReader.h 2015-08-24 06:05:48 +0000
+++ include/TextReader.h 2015-10-04 15:21:00 +0000
@@ -132,8 +132,8 @@
132 /// Get and Set JSON methods132 /// Get and Set JSON methods
133 string Json(); ///< Generate JSON string of this object133 string Json(); ///< Generate JSON string of this object
134 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object134 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object
135 Json::Value JsonValue(); ///< Generate Json::JsonValue for this object135 QJsonObject JsonValue(); ///< Generate QJsonObject for this object
136 void SetJsonValue(Json::Value root) throw(InvalidFile); ///< Load Json::JsonValue into this object136 void SetJsonValue(const QJsonObject root) throw(InvalidFile); ///< Load QJsonObject into this object
137137
138 /// Open Reader - which is called by the constructor automatically138 /// Open Reader - which is called by the constructor automatically
139 void Open();139 void Open();
140140
=== modified file 'include/Timeline.h'
--- include/Timeline.h 2015-08-24 06:05:48 +0000
+++ include/Timeline.h 2015-10-04 15:21:00 +0000
@@ -156,10 +156,10 @@
156 void apply_mapper_to_clip(Clip* clip);156 void apply_mapper_to_clip(Clip* clip);
157157
158 /// Apply JSON Diffs to various objects contained in this timeline158 /// Apply JSON Diffs to various objects contained in this timeline
159 void apply_json_to_clips(Json::Value change) throw(InvalidJSONKey); ///<Apply JSON diff to clips159 void apply_json_to_clips(QJsonObject change) throw(InvalidJSONKey); ///<Apply JSON diff to clips
160 void apply_json_to_effects(Json::Value change) throw(InvalidJSONKey); ///< Apply JSON diff to effects160 void apply_json_to_effects(QJsonObject change) throw(InvalidJSONKey); ///<Apply JSON diff to effects
161 void apply_json_to_effects(Json::Value change, EffectBase* existing_effect) throw(InvalidJSONKey); ///<Apply JSON diff to a specific effect161 void apply_json_to_effects(QJsonObject change, EffectBase* existing_effect) throw(InvalidJSONKey); ///<Apply JSON diff to a specific effect
162 void apply_json_to_timeline(Json::Value change) throw(InvalidJSONKey); ///<Apply JSON diff to timeline properties162 void apply_json_to_timeline(QJsonObject change) throw(InvalidJSONKey); ///<Apply JSON diff to timeline properties
163163
164 /// Calculate time of a frame number, based on a framerate164 /// Calculate time of a frame number, based on a framerate
165 float calculate_time(long int number, Fraction rate);165 float calculate_time(long int number, Fraction rate);
@@ -247,8 +247,8 @@
247 /// Get and Set JSON methods247 /// Get and Set JSON methods
248 string Json(); ///< Generate JSON string of this object248 string Json(); ///< Generate JSON string of this object
249 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object249 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object
250 Json::Value JsonValue(); ///< Generate Json::JsonValue for this object250 QJsonObject JsonValue(); ///< Generate QJsonObject for this object
251 void SetJsonValue(Json::Value root) throw(InvalidFile, ReaderClosed); ///< Load Json::JsonValue into this object251 void SetJsonValue(QJsonObject root) throw(InvalidFile, ReaderClosed); ///< Load QJsonObject into this object
252252
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)
254 /// This is primarily designed to keep the timeline (and its child objects... such as clips and effects) in sync254 /// This is primarily designed to keep the timeline (and its child objects... such as clips and effects) in sync
255255
=== modified file 'include/WriterBase.h'
--- include/WriterBase.h 2015-09-29 03:05:50 +0000
+++ include/WriterBase.h 2015-10-04 15:21:00 +0000
@@ -86,10 +86,10 @@
86 protected:86 protected:
8787
88 /// Debug JSON root88 /// Debug JSON root
89 Json::Value debug_root;89 QJsonArray debug_root;
9090
91 /// Append debug information as JSON91 /// Append debug information as JSON
92 void AppendDebugItem(Json::Value debug_item);92 void AppendDebugItem(QJsonValue debug_item);
9393
94 /// Append debug information as JSON94 /// Append debug information as JSON
95 void AppendDebugMethod(string method_name, string arg1_name, float arg1_value,95 void AppendDebugMethod(string method_name, string arg1_name, float arg1_value,
@@ -125,9 +125,9 @@
125125
126 /// Get and Set JSON methods126 /// Get and Set JSON methods
127 string Json(); ///< Generate JSON string of this object127 string Json(); ///< Generate JSON string of this object
128 Json::Value JsonValue(); ///< Generate Json::JsonValue for this object128 QJsonObject JsonValue(); ///< Generate QJsonObject for this object
129 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object129 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object
130 void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object130 void SetJsonValue(const QJsonObject root); ///< Load QJsonObject into this object
131131
132 /// Display file information in the standard output stream (stdout)132 /// Display file information in the standard output stream (stdout)
133 void DisplayInfo();133 void DisplayInfo();
134134
=== modified file 'include/effects/Brightness.h'
--- include/effects/Brightness.h 2015-08-24 06:05:48 +0000
+++ include/effects/Brightness.h 2015-10-04 15:21:00 +0000
@@ -95,8 +95,8 @@
95 /// Get and Set JSON methods95 /// Get and Set JSON methods
96 string Json(); ///< Generate JSON string of this object96 string Json(); ///< Generate JSON string of this object
97 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object97 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object
98 Json::Value JsonValue(); ///< Generate Json::JsonValue for this object98 QJsonObject JsonValue(); ///< Generate QJsonObject for this object
99 void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object99 void SetJsonValue(QJsonObject root); ///< Load QJsonObject into this object
100100
101 /// Get all properties for a specific frame (perfect for a UI to display the current state101 /// Get all properties for a specific frame (perfect for a UI to display the current state
102 /// of all properties at any time)102 /// of all properties at any time)
103103
=== modified file 'include/effects/ChromaKey.h'
--- include/effects/ChromaKey.h 2015-08-24 06:05:48 +0000
+++ include/effects/ChromaKey.h 2015-10-04 15:21:00 +0000
@@ -88,8 +88,8 @@
88 /// Get and Set JSON methods88 /// Get and Set JSON methods
89 string Json(); ///< Generate JSON string of this object89 string Json(); ///< Generate JSON string of this object
90 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object90 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object
91 Json::Value JsonValue(); ///< Generate Json::JsonValue for this object91 QJsonObject JsonValue(); ///< Generate QJsonObject for this object
92 void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object92 void SetJsonValue(QJsonObject root); ///< Load QJsonObject into this object
9393
94 // Get all properties for a specific frame94 // Get all properties for a specific frame
95 string PropertiesJSON(long int requested_frame);95 string PropertiesJSON(long int requested_frame);
9696
=== modified file 'include/effects/Deinterlace.h'
--- include/effects/Deinterlace.h 2015-08-24 06:05:48 +0000
+++ include/effects/Deinterlace.h 2015-10-04 15:21:00 +0000
@@ -84,8 +84,8 @@
84 /// Get and Set JSON methods84 /// Get and Set JSON methods
85 string Json(); ///< Generate JSON string of this object85 string Json(); ///< Generate JSON string of this object
86 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object86 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object
87 Json::Value JsonValue(); ///< Generate Json::JsonValue for this object87 QJsonObject JsonValue(); ///< Generate QJsonObject for this object
88 void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object88 void SetJsonValue(QJsonObject root); ///< Load QJsonObject into this object
8989
90 // Get all properties for a specific frame90 // Get all properties for a specific frame
91 string PropertiesJSON(long int requested_frame);91 string PropertiesJSON(long int requested_frame);
9292
=== modified file 'include/effects/Mask.h'
--- include/effects/Mask.h 2015-08-24 06:05:48 +0000
+++ include/effects/Mask.h 2015-10-04 15:21:00 +0000
@@ -104,8 +104,8 @@
104 /// Get and Set JSON methods104 /// Get and Set JSON methods
105 string Json(); ///< Generate JSON string of this object105 string Json(); ///< Generate JSON string of this object
106 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object106 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object
107 Json::Value JsonValue(); ///< Generate Json::JsonValue for this object107 QJsonObject JsonValue(); ///< Generate QJsonObject for this object
108 void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object108 void SetJsonValue(QJsonObject root); ///< Load QJsonObject into this object
109109
110 /// Get all properties for a specific frame (perfect for a UI to display the current state110 /// Get all properties for a specific frame (perfect for a UI to display the current state
111 /// of all properties at any time)111 /// of all properties at any time)
112112
=== modified file 'include/effects/Negate.h'
--- include/effects/Negate.h 2015-08-24 06:05:48 +0000
+++ include/effects/Negate.h 2015-10-04 15:21:00 +0000
@@ -72,8 +72,8 @@
72 /// Get and Set JSON methods72 /// Get and Set JSON methods
73 string Json(); ///< Generate JSON string of this object73 string Json(); ///< Generate JSON string of this object
74 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object74 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object
75 Json::Value JsonValue(); ///< Generate Json::JsonValue for this object75 QJsonObject JsonValue(); ///< Generate QJsonObject for this object
76 void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object76 void SetJsonValue(QJsonObject root); ///< Load QJsonObject into this object
7777
78 // Get all properties for a specific frame78 // Get all properties for a specific frame
79 string PropertiesJSON(long int requested_frame);79 string PropertiesJSON(long int requested_frame);
8080
=== modified file 'include/effects/Saturation.h'
--- include/effects/Saturation.h 2015-08-24 06:05:48 +0000
+++ include/effects/Saturation.h 2015-10-04 15:21:00 +0000
@@ -92,8 +92,8 @@
92 /// Get and Set JSON methods92 /// Get and Set JSON methods
93 string Json(); ///< Generate JSON string of this object93 string Json(); ///< Generate JSON string of this object
94 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object94 void SetJson(string value) throw(InvalidJSON); ///< Load JSON string into this object
95 Json::Value JsonValue(); ///< Generate Json::JsonValue for this object95 QJsonObject JsonValue(); ///< Generate QJsonObject for this object
96 void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object96 void SetJsonValue(QJsonObject root); ///< Load QJsonObject into this object
9797
98 /// Get all properties for a specific frame (perfect for a UI to display the current state98 /// Get all properties for a specific frame (perfect for a UI to display the current state
99 /// of all properties at any time)99 /// of all properties at any time)
100100
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2015-08-07 01:01:34 +0000
+++ src/CMakeLists.txt 2015-10-04 15:21:00 +0000
@@ -145,10 +145,6 @@
145 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} ")145 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} ")
146endif(OPENMP_FOUND)146endif(OPENMP_FOUND)
147147
148################### JSONCPP #####################
149# Include jsoncpp headers (needed for JSON parsing)
150include_directories("../thirdparty/jsoncpp/include")
151
152############### PROFILING #################148############### PROFILING #################
153#set(PROFILER "/usr/lib/libprofiler.so.0.3.2")149#set(PROFILER "/usr/lib/libprofiler.so.0.3.2")
154#set(PROFILER "/usr/lib/libtcmalloc.so.4")150#set(PROFILER "/usr/lib/libtcmalloc.so.4")
@@ -196,12 +192,7 @@
196 192
197 # Qt Video Player193 # Qt Video Player
198 ${QT_PLAYER_FILES}194 ${QT_PLAYER_FILES}
199 ${MOC_FILES}195 ${MOC_FILES} )
200
201 # Third Party JSON Parser
202 ../thirdparty/jsoncpp/src/lib_json/json_reader.cpp
203 ../thirdparty/jsoncpp/src/lib_json/json_value.cpp
204 ../thirdparty/jsoncpp/src/lib_json/json_writer.cpp )
205 196
206 IF (BLACKMAGIC_FOUND)197 IF (BLACKMAGIC_FOUND)
207 SET ( OPENSHOT_SOURCE_FILES ${OPENSHOT_SOURCE_FILES} 198 SET ( OPENSHOT_SOURCE_FILES ${OPENSHOT_SOURCE_FILES}
208199
=== modified file 'src/ChunkReader.cpp'
--- src/ChunkReader.cpp 2015-08-24 06:05:48 +0000
+++ src/ChunkReader.cpp 2015-10-04 15:21:00 +0000
@@ -74,45 +74,51 @@
74 }74 }
7575
76 // Parse JSON string into JSON objects76 // Parse JSON string into JSON objects
77 Json::Value root;77 QJsonParseError errors;
78 Json::Reader reader;78
79 bool success = reader.parse( json_string.str(), root );79 QJsonDocument document = QJsonDocument::fromJson(QByteArray(json_string.str().c_str()), &errors);
80 if (!success)80 if (errors.error != QJsonParseError::NoError) {
81 // Raise exception81 // Raise exception
82 throw InvalidJSON("Chunk folder could not be opened.", path);82 throw InvalidJSON("Chunk folder could not be opened.", path);
8383 }
84 const QJsonObject root = document.object();
8485
85 // Set info from the JSON objects86 // Set info from the JSON objects
86 try87 try
87 {88 {
88 info.has_video = root["has_video"].asBool();89 info.has_video = root["has_video"].toBool();
89 info.has_audio = root["has_audio"].asBool();90 info.has_audio = root["has_audio"].toBool();
90 info.duration = root["duration"].asDouble();91 info.duration = root["duration"].toDouble();
91 info.file_size = atoll(root["file_size"].asString().c_str());92 info.file_size = root["file_size"].toVariant().toLongLong();
92 info.height = root["height"].asInt();93 info.height = root["height"].toVariant().toInt();
93 info.width = root["width"].asInt();94 info.width = root["width"].toVariant().toInt();
94 info.pixel_format = root["pixel_format"].asInt();95 info.pixel_format = root["pixel_format"].toVariant().toInt();
95 info.fps.num = root["fps"]["num"].asInt();96 const QJsonObject fpsObject = root["fps"].toObject();
96 info.fps.den = root["fps"]["den"].asInt();97 info.fps.num = fpsObject["num"].toVariant().toInt();
97 info.video_bit_rate = root["video_bit_rate"].asUInt();98 info.fps.den = fpsObject["den"].toVariant().toInt();
98 info.pixel_ratio.num = root["pixel_ratio"]["num"].asInt();99 info.video_bit_rate = root["video_bit_rate"].toVariant().toUInt();
99 info.pixel_ratio.den = root["pixel_ratio"]["den"].asInt();100 const QJsonObject pixelRatioObject = root["pixel_ratio"].toObject();
100 info.display_ratio.num = root["display_ratio"]["num"].asInt();101 info.pixel_ratio.num = pixelRatioObject["num"].toVariant().toInt();
101 info.display_ratio.den = root["display_ratio"]["den"].asInt();102 info.pixel_ratio.den = pixelRatioObject["den"].toVariant().toInt();
102 info.vcodec = root["vcodec"].asString();103 const QJsonObject displayRatioObject = root["display_ratio"].toObject();
103 info.video_length = atoll(root["video_length"].asString().c_str());104 info.display_ratio.num = displayRatioObject["num"].toVariant().toInt();
104 info.video_stream_index = root["video_stream_index"].asInt();105 info.display_ratio.den = displayRatioObject["den"].toVariant().toInt();
105 info.video_timebase.num = root["video_timebase"]["num"].asInt();106 info.vcodec = root["vcodec"].toString().toLocal8Bit().constData();
106 info.video_timebase.den = root["video_timebase"]["den"].asInt();107 info.video_length = root["video_length"].toVariant().toLongLong();
107 info.interlaced_frame = root["interlaced_frame"].asBool();108 info.video_stream_index = root["video_stream_index"].toVariant().toInt();
108 info.top_field_first = root["top_field_first"].asBool();109 const QJsonObject videoTimebaseObject = root["video_timebase"].toObject();
109 info.acodec = root["acodec"].asString();110 info.video_timebase.num = videoTimebaseObject["num"].toVariant().toInt();
110 info.audio_bit_rate = root["audio_bit_rate"].asUInt();111 info.video_timebase.den = videoTimebaseObject["den"].toVariant().toInt();
111 info.sample_rate = root["sample_rate"].asUInt();112 info.interlaced_frame = root["interlaced_frame"].toBool();
112 info.channels = root["channels"].asInt();113 info.top_field_first = root["top_field_first"].toBool();
113 info.audio_stream_index = root["audio_stream_index"].asInt();114 info.acodec = root["acodec"].toString().toLocal8Bit().constData();
114 info.audio_timebase.num = root["audio_timebase"]["num"].asInt();115 info.audio_bit_rate = root["audio_bit_rate"].toVariant().toUInt();
115 info.audio_timebase.den = root["audio_timebase"]["den"].asInt();116 info.sample_rate = root["sample_rate"].toVariant().toUInt();
117 info.channels = root["channels"].toVariant().toInt();
118 info.audio_stream_index = root["audio_stream_index"].toVariant().toInt();
119 const QJsonObject audioTimebaseObject = root["audio_timebase"].toObject();
120 info.audio_timebase.num = audioTimebaseObject["num"].toVariant().toInt();
121 info.audio_timebase.den = audioTimebaseObject["den"].toVariant().toInt();
116122
117 }123 }
118 catch (exception e)124 catch (exception e)
@@ -253,17 +259,18 @@
253// Generate JSON string of this object259// Generate JSON string of this object
254string ChunkReader::Json() {260string ChunkReader::Json() {
255261
256 // Return formatted string262 QJsonDocument document;
257 return JsonValue().toStyledString();263 document.setObject(JsonValue());
264 return document.toJson().constData();
258}265}
259266
260// Generate Json::JsonValue for this object267// Generate QJsonObject for this object
261Json::Value ChunkReader::JsonValue() {268QJsonObject ChunkReader::JsonValue() {
262269
263 // Create root json object270 // Create root json object
264 Json::Value root = ReaderBase::JsonValue(); // get parent properties271 QJsonObject root = ReaderBase::JsonValue(); // get parent properties
265 root["type"] = "ChunkReader";272 root["type"] = "ChunkReader";
266 root["path"] = path;273 root["path"] = path.c_str();
267 root["chunk_size"] = chunk_size;274 root["chunk_size"] = chunk_size;
268 root["chunk_version"] = version;275 root["chunk_version"] = version;
269276
@@ -275,12 +282,16 @@
275void ChunkReader::SetJson(string value) throw(InvalidJSON) {282void ChunkReader::SetJson(string value) throw(InvalidJSON) {
276283
277 // Parse JSON string into JSON objects284 // Parse JSON string into JSON objects
278 Json::Value root;285 QJsonObject root;
279 Json::Reader reader;286 QJsonParseError errors;
280 bool success = reader.parse( value, root );287
281 if (!success)288 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
289 if (errors.error != QJsonParseError::NoError) {
282 // Raise exception290 // Raise exception
283 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");291 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
292 }
293
294 root = document.object();
284295
285 try296 try
286 {297 {
@@ -294,19 +305,19 @@
294 }305 }
295}306}
296307
297// Load Json::JsonValue into this object308// Load QJsonObject into this object
298void ChunkReader::SetJsonValue(Json::Value root) throw(InvalidFile) {309void ChunkReader::SetJsonValue(const QJsonObject root) throw(InvalidFile) {
299310
300 // Set parent data311 // Set parent data
301 ReaderBase::SetJsonValue(root);312 ReaderBase::SetJsonValue(root);
302313
303 // Set data from Json (if key is found)314 // Set data from Json (if key is found)
304 if (!root["path"].isNull())315 if (!root["path"].isNull())
305 path = root["path"].asString();316 path = root["path"].toString().toLocal8Bit().constData();
306 if (!root["chunk_size"].isNull())317 if (!root["chunk_size"].isNull())
307 chunk_size = root["chunk_size"].asInt();318 chunk_size = root["chunk_size"].toVariant().toInt();
308 if (!root["chunk_version"].isNull())319 if (!root["chunk_version"].isNull())
309 version = (ChunkVersion) root["chunk_version"].asInt();320 version = (ChunkVersion) root["chunk_version"].toVariant().toInt();
310321
311 // Re-Open path, and re-init everything (if needed)322 // Re-Open path, and re-init everything (if needed)
312 if (is_open)323 if (is_open)
313324
=== modified file 'src/Clip.cpp'
--- src/Clip.cpp 2015-10-02 23:22:10 +0000
+++ src/Clip.cpp 2015-10-04 15:21:00 +0000
@@ -145,8 +145,8 @@
145 } catch(...) {145 } catch(...) {
146 try146 try
147 {147 {
148 // Try a video reader148 // Try a video reader
149 reader = new FFmpegReader(path);149 reader = new FFmpegReader(path);
150150
151 } catch(...) { }151 } catch(...) { }
152 }152 }
@@ -531,7 +531,9 @@
531string Clip::Json() {531string Clip::Json() {
532532
533 // Return formatted string533 // Return formatted string
534 return JsonValue().toStyledString();534 QJsonDocument document;
535 document.setObject(JsonValue());
536 return document.toJson().constData();
535}537}
536538
537// Get all properties for a specific frame539// Get all properties for a specific frame
@@ -541,7 +543,7 @@
541 Point requested_point(requested_frame, requested_frame);543 Point requested_point(requested_frame, requested_frame);
542544
543 // Generate JSON properties list545 // Generate JSON properties list
544 Json::Value root;546 QJsonObject root;
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);
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);
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);
@@ -554,29 +556,29 @@
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);
555557
556 // Add gravity choices (dropdown style)558 // Add gravity choices (dropdown style)
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));
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));
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));
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));
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));
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));
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));
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));
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));
566568
567 // Add scale choices (dropdown style)569 // Add scale choices (dropdown style)
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));
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));
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));
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));
572574
573 // Add anchor choices (dropdown style)575 // Add anchor choices (dropdown style)
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));
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));
576578
577 // Add waveform choices (dropdown style)579 // Add waveform choices (dropdown style)
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));
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));
580582
581 // Keyframes583 // Keyframes
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);
@@ -589,14 +591,16 @@
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);
590592
591 // Return formatted string593 // Return formatted string
592 return root.toStyledString();594 QJsonDocument document;
595 document.setObject(root);
596 return document.toJson().constData();
593}597}
594598
595// Generate Json::JsonValue for this object599// Generate Json::JsonValue for this object
596Json::Value Clip::JsonValue() {600QJsonObject Clip::JsonValue() {
597601
598 // Create root json object602 // Create root json object
599 Json::Value root = ClipBase::JsonValue(); // get parent properties603 QJsonObject root = ClipBase::JsonValue(); // get parent properties
600 root["gravity"] = gravity;604 root["gravity"] = gravity;
601 root["scale"] = scale;605 root["scale"] = scale;
602 root["anchor"] = anchor;606 root["anchor"] = anchor;
@@ -626,7 +630,7 @@
626 root["perspective_c4_y"] = perspective_c4_y.JsonValue();630 root["perspective_c4_y"] = perspective_c4_y.JsonValue();
627631
628 // Add array of effects632 // Add array of effects
629 root["effects"] = Json::Value(Json::arrayValue);633 root["effects"] = QJsonArray();
630634
631 // loop through effects635 // loop through effects
632 list<EffectBase*>::iterator effect_itr;636 list<EffectBase*>::iterator effect_itr;
@@ -634,7 +638,7 @@
634 {638 {
635 // Get clip object from the iterator639 // Get clip object from the iterator
636 EffectBase *existing_effect = (*effect_itr);640 EffectBase *existing_effect = (*effect_itr);
637 root["effects"].append(existing_effect->JsonValue());641 root["effects"].toArray().append(existing_effect->JsonValue());
638 }642 }
639643
640 if (reader)644 if (reader)
@@ -648,12 +652,14 @@
648void Clip::SetJson(string value) throw(InvalidJSON) {652void Clip::SetJson(string value) throw(InvalidJSON) {
649653
650 // Parse JSON string into JSON objects654 // Parse JSON string into JSON objects
651 Json::Value root;655 QJsonObject root;
652 Json::Reader reader;656 QJsonParseError errors;
653 bool success = reader.parse( value, root );657
654 if (!success)658 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
659 if (errors.error != QJsonParseError::NoError) {
655 // Raise exception660 // Raise exception
656 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");661 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
662 }
657663
658 try664 try
659 {665 {
@@ -668,97 +674,97 @@
668}674}
669675
670// Load Json::JsonValue into this object676// Load Json::JsonValue into this object
671void Clip::SetJsonValue(Json::Value root) {677void Clip::SetJsonValue(QJsonObject root) {
672678
673 // Set parent data679 // Set parent data
674 ClipBase::SetJsonValue(root);680 ClipBase::SetJsonValue(root);
675681
676 // Set data from Json (if key is found)682 // Set data from Json (if key is found)
677 if (!root["gravity"].isNull())683 if (!root["gravity"].isNull())
678 gravity = (GravityType) root["gravity"].asInt();684 gravity = (GravityType) root["gravity"].toInt();
679 if (!root["scale"].isNull())685 if (!root["scale"].isNull())
680 scale = (ScaleType) root["scale"].asInt();686 scale = (ScaleType) root["scale"].toInt();
681 if (!root["anchor"].isNull())687 if (!root["anchor"].isNull())
682 anchor = (AnchorType) root["anchor"].asInt();688 anchor = (AnchorType) root["anchor"].toInt();
683 if (!root["waveform"].isNull())689 if (!root["waveform"].isNull())
684 waveform = root["waveform"].asBool();690 waveform = root["waveform"].toBool();
685 if (!root["scale_x"].isNull())691 if (!root["scale_x"].isNull())
686 scale_x.SetJsonValue(root["scale_x"]);692 scale_x.SetJsonValue(root["scale_x"].toObject());
687 if (!root["scale_y"].isNull())693 if (!root["scale_y"].isNull())
688 scale_y.SetJsonValue(root["scale_y"]);694 scale_y.SetJsonValue(root["scale_y"].toObject());
689 if (!root["location_x"].isNull())695 if (!root["location_x"].isNull())
690 location_x.SetJsonValue(root["location_x"]);696 location_x.SetJsonValue(root["location_x"].toObject());
691 if (!root["location_y"].isNull())697 if (!root["location_y"].isNull())
692 location_y.SetJsonValue(root["location_y"]);698 location_y.SetJsonValue(root["location_y"].toObject());
693 if (!root["alpha"].isNull())699 if (!root["alpha"].isNull())
694 alpha.SetJsonValue(root["alpha"]);700 alpha.SetJsonValue(root["alpha"].toObject());
695 if (!root["rotation"].isNull())701 if (!root["rotation"].isNull())
696 rotation.SetJsonValue(root["rotation"]);702 rotation.SetJsonValue(root["rotation"].toObject());
697 if (!root["time"].isNull())703 if (!root["time"].isNull())
698 time.SetJsonValue(root["time"]);704 time.SetJsonValue(root["time"].toObject());
699 if (!root["volume"].isNull())705 if (!root["volume"].isNull())
700 volume.SetJsonValue(root["volume"]);706 volume.SetJsonValue(root["volume"].toObject());
701 if (!root["wave_color"].isNull())707 if (!root["wave_color"].isNull())
702 wave_color.SetJsonValue(root["wave_color"]);708 wave_color.SetJsonValue(root["wave_color"].toObject());
703 if (!root["crop_width"].isNull())709 if (!root["crop_width"].isNull())
704 crop_width.SetJsonValue(root["crop_width"]);710 crop_width.SetJsonValue(root["crop_width"].toObject());
705 if (!root["crop_height"].isNull())711 if (!root["crop_height"].isNull())
706 crop_height.SetJsonValue(root["crop_height"]);712 crop_height.SetJsonValue(root["crop_height"].toObject());
707 if (!root["crop_x"].isNull())713 if (!root["crop_x"].isNull())
708 crop_x.SetJsonValue(root["crop_x"]);714 crop_x.SetJsonValue(root["crop_x"].toObject());
709 if (!root["crop_y"].isNull())715 if (!root["crop_y"].isNull())
710 crop_y.SetJsonValue(root["crop_y"]);716 crop_y.SetJsonValue(root["crop_y"].toObject());
711 if (!root["shear_x"].isNull())717 if (!root["shear_x"].isNull())
712 shear_x.SetJsonValue(root["shear_x"]);718 shear_x.SetJsonValue(root["shear_x"].toObject());
713 if (!root["shear_y"].isNull())719 if (!root["shear_y"].isNull())
714 shear_y.SetJsonValue(root["shear_y"]);720 shear_y.SetJsonValue(root["shear_y"].toObject());
715 if (!root["perspective_c1_x"].isNull())721 if (!root["perspective_c1_x"].isNull())
716 perspective_c1_x.SetJsonValue(root["perspective_c1_x"]);722 perspective_c1_x.SetJsonValue(root["perspective_c1_x"].toObject());
717 if (!root["perspective_c1_y"].isNull())723 if (!root["perspective_c1_y"].isNull())
718 perspective_c1_y.SetJsonValue(root["perspective_c1_y"]);724 perspective_c1_y.SetJsonValue(root["perspective_c1_y"].toObject());
719 if (!root["perspective_c2_x"].isNull())725 if (!root["perspective_c2_x"].isNull())
720 perspective_c2_x.SetJsonValue(root["perspective_c2_x"]);726 perspective_c2_x.SetJsonValue(root["perspective_c2_x"].toObject());
721 if (!root["perspective_c2_y"].isNull())727 if (!root["perspective_c2_y"].isNull())
722 perspective_c2_y.SetJsonValue(root["perspective_c2_y"]);728 perspective_c2_y.SetJsonValue(root["perspective_c2_y"].toObject());
723 if (!root["perspective_c3_x"].isNull())729 if (!root["perspective_c3_x"].isNull())
724 perspective_c3_x.SetJsonValue(root["perspective_c3_x"]);730 perspective_c3_x.SetJsonValue(root["perspective_c3_x"].toObject());
725 if (!root["perspective_c3_y"].isNull())731 if (!root["perspective_c3_y"].isNull())
726 perspective_c3_y.SetJsonValue(root["perspective_c3_y"]);732 perspective_c3_y.SetJsonValue(root["perspective_c3_y"].toObject());
727 if (!root["perspective_c4_x"].isNull())733 if (!root["perspective_c4_x"].isNull())
728 perspective_c4_x.SetJsonValue(root["perspective_c4_x"]);734 perspective_c4_x.SetJsonValue(root["perspective_c4_x"].toObject());
729 if (!root["perspective_c4_y"].isNull())735 if (!root["perspective_c4_y"].isNull())
730 perspective_c4_y.SetJsonValue(root["perspective_c4_y"]);736 perspective_c4_y.SetJsonValue(root["perspective_c4_y"].toObject());
731 if (!root["effects"].isNull()) {737 if (!root["effects"].isNull()) {
732738
733 // Clear existing effects739 // Clear existing effects
734 effects.clear();740 effects.clear();
735741
736 // loop through effects742 // loop through effects
737 for (int x = 0; x < root["effects"].size(); x++) {743 for (int x = 0; x < root["effects"].toArray().size(); x++) {
738 // Get each effect744 // Get each effect
739 Json::Value existing_effect = root["effects"][x];745 QJsonObject existing_effect = root["effects"].toArray()[x].toObject();
740746
741 // Create Effect747 // Create Effect
742 EffectBase *e = NULL;748 EffectBase *e = NULL;
743749
744 if (!existing_effect["type"].isNull())750 if (!existing_effect["type"].isNull())
745 // Init the matching effect object751 // Init the matching effect object
746 if (existing_effect["type"].asString() == "Brightness")752 if (existing_effect["type"].toString() == "Brightness")
747 e = new Brightness();753 e = new Brightness();
748754
749 else if (existing_effect["type"].asString() == "ChromaKey")755 else if (existing_effect["type"].toString() == "ChromaKey")
750 e = new ChromaKey();756 e = new ChromaKey();
751757
752 else if (existing_effect["type"].asString() == "Deinterlace")758 else if (existing_effect["type"].toString() == "Deinterlace")
753 e = new Deinterlace();759 e = new Deinterlace();
754760
755 else if (existing_effect["type"].asString() == "Mask")761 else if (existing_effect["type"].toString() == "Mask")
756 e = new Mask();762 e = new Mask();
757763
758 else if (existing_effect["type"].asString() == "Negate")764 else if (existing_effect["type"].toString() == "Negate")
759 e = new Negate();765 e = new Negate();
760766
761 else if (existing_effect["type"].asString() == "Saturation")767 else if (existing_effect["type"].toString() == "Saturation")
762 e = new Saturation();768 e = new Saturation();
763769
764 // Load Json into Effect770 // Load Json into Effect
@@ -770,7 +776,7 @@
770 }776 }
771 if (!root["reader"].isNull()) // does Json contain a reader?777 if (!root["reader"].isNull()) // does Json contain a reader?
772 {778 {
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'?
774 {780 {
775 // Close previous reader (if any)781 // Close previous reader (if any)
776 bool already_open = false;782 bool already_open = false;
@@ -786,43 +792,43 @@
786 }792 }
787793
788 // Create new reader (and load properties)794 // Create new reader (and load properties)
789 string type = root["reader"]["type"].asString();795 string type = root["reader"].toObject()["type"].toString().toLocal8Bit().constData();
790796
791 if (type == "FFmpegReader") {797 if (type == "FFmpegReader") {
792798
793 // Create new reader799 // Create new reader
794 reader = new FFmpegReader(root["reader"]["path"].asString());800 reader = new FFmpegReader(root["reader"].toObject()["path"].toString().toLocal8Bit().constData());
795 reader->SetJsonValue(root["reader"]);801 reader->SetJsonValue(root["reader"].toObject());
796802
797 } else if (type == "QtImageReader") {803 } else if (type == "QtImageReader") {
798804
799 // Create new reader805 // Create new reader
800 reader = new QtImageReader(root["reader"]["path"].asString());806 reader = new QtImageReader(root["reader"].toObject()["path"].toString().toLocal8Bit().constData());
801 reader->SetJsonValue(root["reader"]);807 reader->SetJsonValue(root["reader"].toObject());
802808
803 } else if (type == "ImageReader") {809 } else if (type == "ImageReader") {
804810
805 // Create new reader811 // Create new reader
806 reader = new ImageReader(root["reader"]["path"].asString());812 reader = new ImageReader(root["reader"].toObject()["path"].toString().toLocal8Bit().constData());
807 reader->SetJsonValue(root["reader"]);813 reader->SetJsonValue(root["reader"].toObject());
808814
809 } else if (type == "TextReader") {815 } else if (type == "TextReader") {
810816
811 // Create new reader817 // Create new reader
812 reader = new TextReader();818 reader = new TextReader();
813 reader->SetJsonValue(root["reader"]);819 reader->SetJsonValue(root["reader"].toObject());
814820
815 } else if (type == "ChunkReader") {821 } else if (type == "ChunkReader") {
816822
817 // Create new reader823 // Create new reader
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());
819 reader->SetJsonValue(root["reader"]);825 reader->SetJsonValue(root["reader"].toObject());
820826
821 } else if (type == "DummyReader") {827 } else if (type == "DummyReader") {
822828
823 // Create new reader829 // Create new reader
824 reader = new DummyReader();830 reader = new DummyReader();
825 reader->SetJsonValue(root["reader"]);831 reader->SetJsonValue(root["reader"].toObject());
826 }832 }
827833
828 // mark as managed reader834 // mark as managed reader
829835
=== modified file 'src/ClipBase.cpp'
--- src/ClipBase.cpp 2015-10-02 23:22:10 +0000
+++ src/ClipBase.cpp 2015-10-04 15:21:00 +0000
@@ -29,12 +29,12 @@
2929
30using namespace openshot;30using namespace openshot;
3131
32// Generate Json::JsonValue for this object32// Generate QJsonObject for this object
33Json::Value ClipBase::JsonValue() {33QJsonObject ClipBase::JsonValue() {
3434
35 // Create root json object35 // Create root json object
36 Json::Value root;36 QJsonObject root;
37 root["id"] = Id();37 root["id"] = Id().c_str();
38 root["position"] = Position();38 root["position"] = Position();
39 root["layer"] = Layer();39 root["layer"] = Layer();
40 root["start"] = Start();40 root["start"] = Start();
@@ -45,31 +45,31 @@
45 return root;45 return root;
46}46}
4747
48// Load Json::JsonValue into this object48// Load QJsonObject into this object
49void ClipBase::SetJsonValue(Json::Value root) {49void ClipBase::SetJsonValue(const QJsonObject root) {
5050
51 // Set data from Json (if key is found)51 // Set data from Json (if key is found)
52 if (!root["id"].isNull())52 if (!root["id"].isNull())
53 Id(root["id"].asString());53 Id(root["id"].toString().toLocal8Bit().constData());
54 if (!root["position"].isNull())54 if (!root["position"].isNull())
55 Position(root["position"].asDouble());55 Position(root["position"].toDouble());
56 if (!root["layer"].isNull())56 if (!root["layer"].isNull())
57 Layer(root["layer"].asInt());57 Layer(root["layer"].toVariant().toInt());
58 if (!root["start"].isNull())58 if (!root["start"].isNull())
59 Start(root["start"].asDouble());59 Start(root["start"].toDouble());
60 if (!root["end"].isNull())60 if (!root["end"].isNull())
61 End(root["end"].asDouble());61 End(root["end"].toDouble());
62}62}
6363
64// Generate JSON for a property64// Generate JSON for a property
65Json::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) {65QJsonObject 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) {
6666
67 // Create JSON Object67 // Create JSON Object
68 Json::Value prop = Json::Value(Json::objectValue);68 QJsonObject prop;
69 prop["name"] = name;69 prop["name"] = name.c_str();
70 prop["value"] = value;70 prop["value"] = value;
71 prop["memo"] = memo;71 prop["memo"] = memo.c_str();
72 prop["type"] = type;72 prop["type"] = type.c_str();
73 prop["min"] = min_value;73 prop["min"] = min_value;
74 prop["max"] = max_value;74 prop["max"] = max_value;
75 prop["keyframe"] = contains_point;75 prop["keyframe"] = contains_point;
@@ -77,20 +77,20 @@
77 prop["readonly"] = readonly;77 prop["readonly"] = readonly;
78 prop["interpolation"] = intepolation;78 prop["interpolation"] = intepolation;
79 prop["closest_point_x"] = closest_point_x;79 prop["closest_point_x"] = closest_point_x;
80 prop["choices"] = Json::Value(Json::arrayValue);80 prop["choices"] = QJsonArray();
8181
82 // return JsonValue82 // return JsonValue
83 return prop;83 return prop;
84}84}
8585
86Json::Value ClipBase::add_property_choice_json(string name, int value, int selected_value) {86QJsonObject ClipBase::add_property_choice_json(string name, int value, int selected_value) {
8787
88 // Create choice88 // Create choice
89 Json::Value new_choice = Json::Value(Json::objectValue);89 QJsonObject new_choice;
90 new_choice["name"] = name;90 new_choice["name"] = name.c_str();
91 new_choice["value"] = value;91 new_choice["value"] = value;
92 new_choice["selected"] = (value == selected_value);92 new_choice["selected"] = (value == selected_value);
9393
94 // return JsonValue94 // return JsonValue
95 return new_choice;95 return new_choice;
96}
97\ No newline at end of file96\ No newline at end of file
97}
9898
=== modified file 'src/Color.cpp'
--- src/Color.cpp 2015-10-01 23:51:59 +0000
+++ src/Color.cpp 2015-10-04 15:21:00 +0000
@@ -84,15 +84,16 @@
84// Generate JSON string of this object84// Generate JSON string of this object
85string Color::Json() {85string Color::Json() {
8686
87 // Return formatted string87 QJsonDocument document;
88 return JsonValue().toStyledString();88 document.setObject(JsonValue());
89 return document.toJson().constData();
89}90}
9091
91// Generate Json::JsonValue for this object92// Generate QJsonObject for this object
92Json::Value Color::JsonValue() {93QJsonObject Color::JsonValue() {
9394
94 // Create root json object95 // Create root json object
95 Json::Value root;96 QJsonObject root;
96 root["red"] = red.JsonValue();97 root["red"] = red.JsonValue();
97 root["green"] = green.JsonValue();98 root["green"] = green.JsonValue();
98 root["blue"] = blue.JsonValue();99 root["blue"] = blue.JsonValue();
@@ -106,12 +107,16 @@
106void Color::SetJson(string value) throw(InvalidJSON) {107void Color::SetJson(string value) throw(InvalidJSON) {
107108
108 // Parse JSON string into JSON objects109 // Parse JSON string into JSON objects
109 Json::Value root;110 QJsonObject root;
110 Json::Reader reader;111 QJsonParseError errors;
111 bool success = reader.parse( value, root );112
112 if (!success)113 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
114 if (errors.error != QJsonParseError::NoError) {
113 // Raise exception115 // Raise exception
114 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");116 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
117 }
118
119 root = document.object();
115120
116 try121 try
117 {122 {
@@ -126,15 +131,15 @@
126}131}
127132
128// Load Json::JsonValue into this object133// Load Json::JsonValue into this object
129void Color::SetJsonValue(Json::Value root) {134void Color::SetJsonValue(QJsonObject root) {
130135
131 // Set data from Json (if key is found)136 // Set data from Json (if key is found)
132 if (!root["red"].isNull())137 if (!root["red"].isNull())
133 red.SetJsonValue(root["red"]);138 red.SetJsonValue(root["red"].toObject());
134 if (!root["green"].isNull())139 if (!root["green"].isNull())
135 green.SetJsonValue(root["green"]);140 green.SetJsonValue(root["green"].toObject());
136 if (!root["blue"].isNull())141 if (!root["blue"].isNull())
137 blue.SetJsonValue(root["blue"]);142 blue.SetJsonValue(root["blue"].toObject());
138 if (!root["alpha"].isNull())143 if (!root["alpha"].isNull())
139 alpha.SetJsonValue(root["alpha"]);144 alpha.SetJsonValue(root["alpha"].toObject());
140}145}
141146
=== modified file 'src/Coordinate.cpp'
--- src/Coordinate.cpp 2014-07-11 21:52:14 +0000
+++ src/Coordinate.cpp 2015-10-04 15:21:00 +0000
@@ -44,15 +44,16 @@
44// Generate JSON string of this object44// Generate JSON string of this object
45string Coordinate::Json() {45string Coordinate::Json() {
4646
47 // Return formatted string47 QJsonDocument document;
48 return JsonValue().toStyledString();48 document.setObject(JsonValue());
49 return document.toJson().constData();
49}50}
5051
51// Generate Json::JsonValue for this object52// Generate QJsonObject for this object
52Json::Value Coordinate::JsonValue() {53QJsonObject Coordinate::JsonValue() {
5354
54 // Create root json object55 // Create root json object
55 Json::Value root;56 QJsonObject root;
56 root["X"] = X;57 root["X"] = X;
57 root["Y"] = Y;58 root["Y"] = Y;
58 //root["increasing"] = increasing;59 //root["increasing"] = increasing;
@@ -69,12 +70,16 @@
69void Coordinate::SetJson(string value) throw(InvalidJSON) {70void Coordinate::SetJson(string value) throw(InvalidJSON) {
7071
71 // Parse JSON string into JSON objects72 // Parse JSON string into JSON objects
72 Json::Value root;73 QJsonObject root;
73 Json::Reader reader;74 QJsonParseError errors;
74 bool success = reader.parse( value, root );75
75 if (!success)76 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
77 if (errors.error != QJsonParseError::NoError) {
76 // Raise exception78 // Raise exception
77 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");79 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
80 }
81
82 root = document.object();
7883
79 try84 try
80 {85 {
@@ -88,23 +93,24 @@
88 }93 }
89}94}
9095
91// Load Json::JsonValue into this object96// Load QJsonObject into this object
92void Coordinate::SetJsonValue(Json::Value root) {97void Coordinate::SetJsonValue(QJsonObject root) {
9398
94 // Set data from Json (if key is found)99 // Set data from Json (if key is found)
95 if (!root["X"].isNull())100 if (!root["X"].isNull())
96 X = root["X"].asDouble();101 X = root["X"].toDouble();
97 if (!root["Y"].isNull())102 if (!root["Y"].isNull())
98 Y = root["Y"].asDouble();103 Y = root["Y"].toDouble();
99 if (!root["increasing"].isNull())104 if (!root["increasing"].isNull())
100 increasing = root["increasing"].asBool();105 increasing = root["increasing"].toBool();
101 if (!root["repeated"].isNull() && root["repeated"].isObject())106 if (!root["repeated"].isNull() && root["repeated"].isObject())
102 {107 {
103 if (!root["repeated"]["num"].isNull())108 const QJsonObject repeatedObject = root["repeated"].toObject();
104 repeated.num = root["repeated"]["num"].asInt();109 if (!root["repeated"].toObject()["num"].isNull())
105 if (!root["repeated"]["den"].isNull())110 repeated.num = repeatedObject["num"].toVariant().toInt();
106 repeated.den = root["repeated"]["den"].asInt();111 if (!root["repeated"].toObject()["den"].isNull())
112 repeated.den = repeatedObject["den"].toVariant().toInt();
107 }113 }
108 if (!root["delta"].isNull())114 if (!root["delta"].isNull())
109 delta = root["delta"].asDouble();115 delta = root["delta"].toDouble();
110}116}
111117
=== modified file 'src/DecklinkReader.cpp'
--- src/DecklinkReader.cpp 2015-08-24 06:05:48 +0000
+++ src/DecklinkReader.cpp 2015-10-04 15:21:00 +0000
@@ -249,12 +249,12 @@
249 return JsonValue().toStyledString();249 return JsonValue().toStyledString();
250}250}
251251
252// Generate Json::JsonValue for this object252// Generate QJsonObject for this object
253Json::Value DecklinkReader::JsonValue() {253QJsonObject DecklinkReader::JsonValue() {
254254
255 // Create root json object255 // Create root json object
256 Json::Value root = ReaderBase::JsonValue(); // get parent properties256 QJsonObject root = ReaderBase::JsonValue(); // get parent properties
257 root["type"] = "DecklinkReader";257 root.insert("type", QJsonValue("DecklinkReader"));
258258
259 // return JsonValue259 // return JsonValue
260 return root;260 return root;
@@ -264,12 +264,16 @@
264void DecklinkReader::SetJson(string value) throw(InvalidJSON) {264void DecklinkReader::SetJson(string value) throw(InvalidJSON) {
265265
266 // Parse JSON string into JSON objects266 // Parse JSON string into JSON objects
267 Json::Value root;267 QJsonObject root;
268 Json::Reader reader;268 QJsonParseError errors;
269 bool success = reader.parse( value, root );269
270 if (!success)270 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
271 if (errors.error != QJsonParseError::NoError) {
271 // Raise exception272 // Raise exception
272 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");273 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
274 }
275
276 root = document.object();
273277
274 try278 try
275 {279 {
@@ -283,8 +287,8 @@
283 }287 }
284}288}
285289
286// Load Json::JsonValue into this object290// Load QJsonObject into this object
287void DecklinkReader::SetJsonValue(Json::Value root) throw(InvalidFile) {291void DecklinkReader::SetJsonValue(QJsonObject root) throw(InvalidFile) {
288292
289 // Set parent data293 // Set parent data
290 ReaderBase::SetJsonValue(root);294 ReaderBase::SetJsonValue(root);
291295
=== modified file 'src/DummyReader.cpp'
--- src/DummyReader.cpp 2015-08-24 06:05:48 +0000
+++ src/DummyReader.cpp 2015-10-04 15:21:00 +0000
@@ -120,15 +120,16 @@
120// Generate JSON string of this object120// Generate JSON string of this object
121string DummyReader::Json() {121string DummyReader::Json() {
122122
123 // Return formatted string123 QJsonDocument document;
124 return JsonValue().toStyledString();124 document.setObject(JsonValue());
125 return document.toJson().constData();
125}126}
126127
127// Generate Json::JsonValue for this object128// Generate QJsonObject for this object
128Json::Value DummyReader::JsonValue() {129QJsonObject DummyReader::JsonValue() {
129130
130 // Create root json object131 // Create root json object
131 Json::Value root = ReaderBase::JsonValue(); // get parent properties132 QJsonObject root = ReaderBase::JsonValue(); // get parent properties
132 root["type"] = "DummyReader";133 root["type"] = "DummyReader";
133134
134 // return JsonValue135 // return JsonValue
@@ -139,12 +140,16 @@
139void DummyReader::SetJson(string value) throw(InvalidJSON) {140void DummyReader::SetJson(string value) throw(InvalidJSON) {
140141
141 // Parse JSON string into JSON objects142 // Parse JSON string into JSON objects
142 Json::Value root;143 QJsonObject root;
143 Json::Reader reader;144 QJsonParseError errors;
144 bool success = reader.parse( value, root );145
145 if (!success)146 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
147 if (errors.error != QJsonParseError::NoError) {
146 // Raise exception148 // Raise exception
147 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");149 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
150 }
151
152 root = document.object();
148153
149 try154 try
150 {155 {
@@ -158,8 +163,8 @@
158 }163 }
159}164}
160165
161// Load Json::JsonValue into this object166// Load QJsonObject into this object
162void DummyReader::SetJsonValue(Json::Value root) throw(InvalidFile) {167void DummyReader::SetJsonValue(QJsonObject root) throw(InvalidFile) {
163168
164 // Set parent data169 // Set parent data
165 ReaderBase::SetJsonValue(root);170 ReaderBase::SetJsonValue(root);
166171
=== modified file 'src/EffectBase.cpp'
--- src/EffectBase.cpp 2015-08-07 01:01:34 +0000
+++ src/EffectBase.cpp 2015-10-04 15:21:00 +0000
@@ -61,15 +61,16 @@
61// Generate JSON string of this object61// Generate JSON string of this object
62string EffectBase::Json() {62string EffectBase::Json() {
6363
64 // Return formatted string64 QJsonDocument document;
65 return JsonValue().toStyledString();65 document.setObject(JsonValue());
66 return document.toJson().constData();
66}67}
6768
68// Generate Json::JsonValue for this object69// Generate QJsonObject for this object
69Json::Value EffectBase::JsonValue() {70QJsonObject EffectBase::JsonValue() {
7071
71 // Create root json object72 // Create root json object
72 Json::Value root = ClipBase::JsonValue(); // get parent properties73 QJsonObject root = ClipBase::JsonValue(); // get parent properties
73 root["order"] = Order();74 root["order"] = Order();
7475
75 // return JsonValue76 // return JsonValue
@@ -80,12 +81,16 @@
80void EffectBase::SetJson(string value) throw(InvalidJSON) {81void EffectBase::SetJson(string value) throw(InvalidJSON) {
8182
82 // Parse JSON string into JSON objects83 // Parse JSON string into JSON objects
83 Json::Value root;84 QJsonObject root;
84 Json::Reader reader;85 QJsonParseError errors;
85 bool success = reader.parse( value, root );86
86 if (!success)87 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
88 if (errors.error != QJsonParseError::NoError) {
87 // Raise exception89 // Raise exception
88 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");90 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
91 }
92
93 root = document.object();
8994
90 try95 try
91 {96 {
@@ -99,29 +104,29 @@
99 }104 }
100}105}
101106
102// Load Json::JsonValue into this object107// Load QJsonObject into this object
103void EffectBase::SetJsonValue(Json::Value root) {108void EffectBase::SetJsonValue(const QJsonObject root) {
104109
105 // Set parent data110 // Set parent data
106 ClipBase::SetJsonValue(root);111 ClipBase::SetJsonValue(root);
107112
108 // Set data from Json (if key is found)113 // Set data from Json (if key is found)
109 if (!root["order"].isNull())114 if (!root["order"].isNull())
110 Order(root["order"].asInt());115 Order(root["order"].toVariant().toInt());
111}116}
112117
113// Generate Json::JsonValue for this object118// Generate QJsonObject for this object
114Json::Value EffectBase::JsonInfo() {119QJsonObject EffectBase::JsonInfo() {
115120
116 // Create root json object121 // Create root json object
117 Json::Value root;122 QJsonObject root;
118 root["name"] = info.name;123 root["name"] = info.name.c_str();
119 root["class_name"] = info.class_name;124 root["class_name"] = info.class_name.c_str();
120 root["short_name"] = info.short_name;125 root["short_name"] = info.short_name.c_str();
121 root["description"] = info.description;126 root["description"] = info.description.c_str();
122 root["has_video"] = info.has_video;127 root["has_video"] = info.has_video;
123 root["has_audio"] = info.has_audio;128 root["has_audio"] = info.has_audio;
124129
125 // return JsonValue130 // return JsonValue
126 return root;131 return root;
127}
128\ No newline at end of file132\ No newline at end of file
133}
129134
=== modified file 'src/EffectInfo.cpp'
--- src/EffectInfo.cpp 2015-08-17 03:58:07 +0000
+++ src/EffectInfo.cpp 2015-10-04 15:21:00 +0000
@@ -35,14 +35,16 @@
35string EffectInfo::Json() {35string EffectInfo::Json() {
3636
37 // Return formatted string37 // Return formatted string
38 return JsonValue().toStyledString();38 QJsonDocument document;
39 document.setArray(JsonValue());
40 return document.toJson().constData();
39}41}
4042
41// Generate Json::JsonValue for this object43// Generate Json::JsonValue for this object
42Json::Value EffectInfo::JsonValue() {44QJsonArray EffectInfo::JsonValue() {
4345
44 // Create root json object46 // Create root json object
45 Json::Value root;47 QJsonArray root;
4648
47 // Append info JSON from each supported effect49 // Append info JSON from each supported effect
48 root.append(Brightness().JsonInfo());50 root.append(Brightness().JsonInfo());
4951
=== modified file 'src/FFmpegReader.cpp'
--- src/FFmpegReader.cpp 2015-10-01 18:00:50 +0000
+++ src/FFmpegReader.cpp 2015-10-04 15:21:00 +0000
@@ -252,7 +252,9 @@
252 }252 }
253253
254 // Clear debug json254 // Clear debug json
255 debug_root.clear();255 while (!debug_root.isEmpty()) {
256 debug_root.removeFirst();
257 }
256258
257 // Close the video file259 // Close the video file
258 avformat_close_input(&pFormatCtx);260 avformat_close_input(&pFormatCtx);
@@ -1838,17 +1840,18 @@
1838// Generate JSON string of this object1840// Generate JSON string of this object
1839string FFmpegReader::Json() {1841string FFmpegReader::Json() {
18401842
1841 // Return formatted string1843 QJsonDocument document;
1842 return JsonValue().toStyledString();1844 document.setObject(JsonValue());
1845 return document.toJson().constData();
1843}1846}
18441847
1845// Generate Json::JsonValue for this object1848// Generate QJsonObject for this object
1846Json::Value FFmpegReader::JsonValue() {1849QJsonObject FFmpegReader::JsonValue() {
18471850
1848 // Create root json object1851 // Create root json object
1849 Json::Value root = ReaderBase::JsonValue(); // get parent properties1852 QJsonObject root = ReaderBase::JsonValue(); // get parent properties
1850 root["type"] = "FFmpegReader";1853 root["type"] = "FFmpegReader";
1851 root["path"] = path;1854 root["path"] = path.c_str();
18521855
1853 // return JsonValue1856 // return JsonValue
1854 return root;1857 return root;
@@ -1858,12 +1861,16 @@
1858void FFmpegReader::SetJson(string value) throw(InvalidJSON) {1861void FFmpegReader::SetJson(string value) throw(InvalidJSON) {
18591862
1860 // Parse JSON string into JSON objects1863 // Parse JSON string into JSON objects
1861 Json::Value root;1864 QJsonObject root;
1862 Json::Reader reader;1865 QJsonParseError errors;
1863 bool success = reader.parse( value, root );1866
1864 if (!success)1867 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
1868 if (errors.error != QJsonParseError::NoError) {
1865 // Raise exception1869 // Raise exception
1866 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");1870 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
1871 }
1872
1873 root = document.object();
18671874
1868 try1875 try
1869 {1876 {
@@ -1877,15 +1884,15 @@
1877 }1884 }
1878}1885}
18791886
1880// Load Json::JsonValue into this object1887// Load QJsonObject into this object
1881void FFmpegReader::SetJsonValue(Json::Value root) throw(InvalidFile) {1888void FFmpegReader::SetJsonValue(QJsonObject root) throw(InvalidFile) {
18821889
1883 // Set parent data1890 // Set parent data
1884 ReaderBase::SetJsonValue(root);1891 ReaderBase::SetJsonValue(root);
18851892
1886 // Set data from Json (if key is found)1893 // Set data from Json (if key is found)
1887 if (!root["path"].isNull())1894 if (!root["path"].isNull())
1888 path = root["path"].asString();1895 path = root["path"].toString().toLocal8Bit().constData();
18891896
1890 // Re-Open path, and re-init everything (if needed)1897 // Re-Open path, and re-init everything (if needed)
1891 if (is_open)1898 if (is_open)
18921899
=== modified file 'src/FrameMapper.cpp'
--- src/FrameMapper.cpp 2015-10-01 18:00:50 +0000
+++ src/FrameMapper.cpp 2015-10-04 15:21:00 +0000
@@ -538,18 +538,19 @@
538// Generate JSON string of this object538// Generate JSON string of this object
539string FrameMapper::Json() {539string FrameMapper::Json() {
540540
541 // Return formatted string541 QJsonDocument document;
542 return JsonValue().toStyledString();542 document.setObject(JsonValue());
543 return document.toJson().constData();
543}544}
544545
545// Generate Json::JsonValue for this object546// Generate QJsonObject for this object
546Json::Value FrameMapper::JsonValue() {547QJsonObject FrameMapper::JsonValue() {
547548
548 // Create root json object549 // Create root json object
549 Json::Value root = ReaderBase::JsonValue(); // get parent properties550 QJsonObject root = ReaderBase::JsonValue(); // get parent properties
550 root["type"] = "FrameMapper";551 root["type"] = "FrameMapper";
551552
552 // return JsonValue553 // return QJsonObject
553 return root;554 return root;
554}555}
555556
@@ -557,12 +558,16 @@
557void FrameMapper::SetJson(string value) throw(InvalidJSON) {558void FrameMapper::SetJson(string value) throw(InvalidJSON) {
558559
559 // Parse JSON string into JSON objects560 // Parse JSON string into JSON objects
560 Json::Value root;561 QJsonObject root;
561 Json::Reader reader;562 QJsonParseError errors;
562 bool success = reader.parse( value, root );563
563 if (!success)564 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
565 if (errors.error != QJsonParseError::NoError) {
564 // Raise exception566 // Raise exception
565 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");567 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
568 }
569
570 root = document.object();
566571
567 try572 try
568 {573 {
@@ -576,8 +581,8 @@
576 }581 }
577}582}
578583
579// Load Json::JsonValue into this object584// Load QJsonObject into this object
580void FrameMapper::SetJsonValue(Json::Value root) throw(InvalidFile) {585void FrameMapper::SetJsonValue(QJsonObject root) throw(InvalidFile) {
581586
582 // Set parent data587 // Set parent data
583 ReaderBase::SetJsonValue(root);588 ReaderBase::SetJsonValue(root);
584589
=== modified file 'src/ImageReader.cpp'
--- src/ImageReader.cpp 2015-09-29 03:05:50 +0000
+++ src/ImageReader.cpp 2015-10-04 15:21:00 +0000
@@ -123,19 +123,20 @@
123// Generate JSON string of this object123// Generate JSON string of this object
124string ImageReader::Json() {124string ImageReader::Json() {
125125
126 // Return formatted string126 QJsonDocument document;
127 return JsonValue().toStyledString();127 document.setObject(JsonValue());
128 return document.toJson().constData();
128}129}
129130
130// Generate Json::JsonValue for this object131// Generate QJsonObject for this object
131Json::Value ImageReader::JsonValue() {132QJsonObject ImageReader::JsonValue() {
132133
133 // Create root json object134 // Create root json object
134 Json::Value root = ReaderBase::JsonValue(); // get parent properties135 QJsonObject root = ReaderBase::JsonValue(); // get parent properties
135 root["type"] = "ImageReader";136 root["type"] = "ImageReader";
136 root["path"] = path;137 root["path"] = path.c_str();
137138
138 // return JsonValue139 // return QJsonObject
139 return root;140 return root;
140}141}
141142
@@ -143,12 +144,16 @@
143void ImageReader::SetJson(string value) throw(InvalidJSON) {144void ImageReader::SetJson(string value) throw(InvalidJSON) {
144145
145 // Parse JSON string into JSON objects146 // Parse JSON string into JSON objects
146 Json::Value root;147 QJsonObject root;
147 Json::Reader reader;148 QJsonParseError errors;
148 bool success = reader.parse( value, root );149
149 if (!success)150 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
151 if (errors.error != QJsonParseError::NoError) {
150 // Raise exception152 // Raise exception
151 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");153 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
154 }
155
156 root = document.object();
152157
153 try158 try
154 {159 {
@@ -162,15 +167,15 @@
162 }167 }
163}168}
164169
165// Load Json::JsonValue into this object170// Load QJsonObject into this object
166void ImageReader::SetJsonValue(Json::Value root) throw(InvalidFile) {171void ImageReader::SetJsonValue(QJsonObject root) throw(InvalidFile) {
167172
168 // Set parent data173 // Set parent data
169 ReaderBase::SetJsonValue(root);174 ReaderBase::SetJsonValue(root);
170175
171 // Set data from Json (if key is found)176 // Set data from Json (if key is found)
172 if (!root["path"].isNull())177 if (!root["path"].isNull())
173 path = root["path"].asString();178 path = root["path"].toString().toLocal8Bit().constData();
174179
175 // Re-Open path, and re-init everything (if needed)180 // Re-Open path, and re-init everything (if needed)
176 if (is_open)181 if (is_open)
177182
=== modified file 'src/KeyFrame.cpp'
--- src/KeyFrame.cpp 2015-10-02 23:22:10 +0000
+++ src/KeyFrame.cpp 2015-10-04 15:21:00 +0000
@@ -305,22 +305,23 @@
305// Generate JSON string of this object305// Generate JSON string of this object
306string Keyframe::Json() {306string Keyframe::Json() {
307307
308 // Return formatted string308 QJsonDocument document;
309 return JsonValue().toStyledString();309 document.setObject(JsonValue());
310 return document.toJson().constData();
310}311}
311312
312// Generate Json::JsonValue for this object313// Generate QJsonObject for this object
313Json::Value Keyframe::JsonValue() {314QJsonObject Keyframe::JsonValue() {
314315
315 // Create root json object316 // Create root json object
316 Json::Value root;317 QJsonObject root;
317 root["Points"] = Json::Value(Json::arrayValue);318 root["Points"] = QJsonArray();
318319
319 // loop through points, and find a matching coordinate320 // loop through points, and find a matching coordinate
320 for (int x = 0; x < Points.size(); x++) {321 for (int x = 0; x < Points.size(); x++) {
321 // Get each point322 // Get each point
322 Point existing_point = Points[x];323 Point existing_point = Points[x];
323 root["Points"].append(existing_point.JsonValue());324 root["Points"].toArray().append(existing_point.JsonValue());
324 }325 }
325326
326 // return JsonValue327 // return JsonValue
@@ -331,12 +332,16 @@
331void Keyframe::SetJson(string value) throw(InvalidJSON) {332void Keyframe::SetJson(string value) throw(InvalidJSON) {
332333
333 // Parse JSON string into JSON objects334 // Parse JSON string into JSON objects
334 Json::Value root;335 QJsonObject root;
335 Json::Reader reader;336 QJsonParseError errors;
336 bool success = reader.parse( value, root );337
337 if (!success)338 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
339 if (errors.error != QJsonParseError::NoError) {
338 // Raise exception340 // Raise exception
339 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");341 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
342 }
343
344 root = document.object();
340345
341 try346 try
342 {347 {
@@ -350,8 +355,8 @@
350 }355 }
351}356}
352357
353// Load Json::JsonValue into this object358// Load QJsonObject into this object
354void Keyframe::SetJsonValue(Json::Value root) {359void Keyframe::SetJsonValue(QJsonObject root) {
355360
356 // mark as dirty361 // mark as dirty
357 needs_update = true;362 needs_update = true;
@@ -361,9 +366,9 @@
361366
362 if (!root["Points"].isNull())367 if (!root["Points"].isNull())
363 // loop through points368 // loop through points
364 for (long int x = 0; x < root["Points"].size(); x++) {369 for (long int x = 0; x < root["Points"].toArray().size(); x++) {
365 // Get each point370 // Get each point
366 Json::Value existing_point = root["Points"][x];371 QJsonObject existing_point = root["Points"].toArray()[x].toObject();
367372
368 // Create Point373 // Create Point
369 Point p;374 Point p;
@@ -376,7 +381,7 @@
376 }381 }
377382
378 if (!root["Auto_Handle_Percentage"].isNull())383 if (!root["Auto_Handle_Percentage"].isNull())
379 Auto_Handle_Percentage = root["Auto_Handle_Percentage"].asBool();384 Auto_Handle_Percentage = root["Auto_Handle_Percentage"].toBool();
380}385}
381386
382// Get the fraction that represents how many times this value is repeated in the curve387// Get the fraction that represents how many times this value is repeated in the curve
383388
=== modified file 'src/Point.cpp'
--- src/Point.cpp 2015-02-21 09:10:38 +0000
+++ src/Point.cpp 2015-10-04 15:21:00 +0000
@@ -96,15 +96,16 @@
96// Generate JSON string of this object96// Generate JSON string of this object
97string Point::Json() {97string Point::Json() {
9898
99 // Return formatted string99 QJsonDocument document;
100 return JsonValue().toStyledString();100 document.setObject(JsonValue());
101 return document.toJson().constData();
101}102}
102103
103// Generate Json::JsonValue for this object104// Generate QJsonObject for this object
104Json::Value Point::JsonValue() {105QJsonObject Point::JsonValue() {
105106
106 // Create root json object107 // Create root json object
107 Json::Value root;108 QJsonObject root;
108 root["co"] = co.JsonValue();109 root["co"] = co.JsonValue();
109 if (interpolation == BEZIER) {110 if (interpolation == BEZIER) {
110 root["handle_left"] = handle_left.JsonValue();111 root["handle_left"] = handle_left.JsonValue();
@@ -121,12 +122,16 @@
121void Point::SetJson(string value) throw(InvalidJSON) {122void Point::SetJson(string value) throw(InvalidJSON) {
122123
123 // Parse JSON string into JSON objects124 // Parse JSON string into JSON objects
124 Json::Value root;125 QJsonObject root;
125 Json::Reader reader;126 QJsonParseError errors;
126 bool success = reader.parse( value, root );127
127 if (!success)128 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
129 if (errors.error != QJsonParseError::NoError) {
128 // Raise exception130 // Raise exception
129 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");131 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
132 }
133
134 root = document.object();
130135
131 try136 try
132 {137 {
@@ -140,18 +145,18 @@
140 }145 }
141}146}
142147
143// Load Json::JsonValue into this object148// Load QJsonObject into this object
144void Point::SetJsonValue(Json::Value root) {149void Point::SetJsonValue(const QJsonObject root) {
145150
146 if (!root["co"].isNull())151 if (!root["co"].isNull())
147 co.SetJsonValue(root["co"]); // update coordinate152 co.SetJsonValue(root["co"].toObject()); // update coordinate
148 if (!root["handle_left"].isNull())153 if (!root["handle_left"].isNull())
149 handle_left.SetJsonValue(root["handle_left"]); // update coordinate154 handle_left.SetJsonValue(root["handle_left"].toObject()); // update coordinate
150 if (!root["handle_right"].isNull())155 if (!root["handle_right"].isNull())
151 handle_right.SetJsonValue(root["handle_right"]); // update coordinate156 handle_right.SetJsonValue(root["handle_right"].toObject()); // update coordinate
152 if (!root["interpolation"].isNull())157 if (!root["interpolation"].isNull())
153 interpolation = (InterpolationType) root["interpolation"].asInt();158 interpolation = (InterpolationType) root["interpolation"].toVariant().toInt();
154 if (!root["handle_type"].isNull())159 if (!root["handle_type"].isNull())
155 handle_type = (HandleType) root["handle_type"].asInt();160 handle_type = (HandleType) root["handle_type"].toVariant().toInt();
156161
157}162}
158163
=== modified file 'src/Profiles.cpp'
--- src/Profiles.cpp 2014-07-11 21:52:14 +0000
+++ src/Profiles.cpp 2015-10-04 15:21:00 +0000
@@ -136,27 +136,28 @@
136// Generate JSON string of this object136// Generate JSON string of this object
137string Profile::Json() {137string Profile::Json() {
138138
139 // Return formatted string139 QJsonDocument document;
140 return JsonValue().toStyledString();140 document.setObject(JsonValue());
141 return document.toJson().constData();
141}142}
142143
143// Generate Json::JsonValue for this object144// Generate QJsonObject for this object
144Json::Value Profile::JsonValue() {145QJsonObject Profile::JsonValue() {
145146
146 // Create root json object147 // Create root json object
147 Json::Value root;148 QJsonObject root;
148 root["height"] = info.height;149 root["height"] = info.height;
149 root["width"] = info.width;150 root["width"] = info.width;
150 root["pixel_format"] = info.pixel_format;151 root["pixel_format"] = info.pixel_format;
151 root["fps"] = Json::Value(Json::objectValue);152 root["fps"] = QJsonObject();
152 root["fps"]["num"] = info.fps.num;153 root["fps"].toObject()["num"] = info.fps.num;
153 root["fps"]["den"] = info.fps.den;154 root["fps"].toObject()["den"] = info.fps.den;
154 root["pixel_ratio"] = Json::Value(Json::objectValue);155 root["pixel_ratio"] = QJsonObject();
155 root["pixel_ratio"]["num"] = info.pixel_ratio.num;156 root["pixel_ratio"].toObject()["num"] = info.pixel_ratio.num;
156 root["pixel_ratio"]["den"] = info.pixel_ratio.den;157 root["pixel_ratio"].toObject()["den"] = info.pixel_ratio.den;
157 root["display_ratio"] = Json::Value(Json::objectValue);158 root["display_ratio"] = QJsonObject();
158 root["display_ratio"]["num"] = info.display_ratio.num;159 root["display_ratio"].toObject()["num"] = info.display_ratio.num;
159 root["display_ratio"]["den"] = info.display_ratio.den;160 root["display_ratio"].toObject()["den"] = info.display_ratio.den;
160 root["interlaced_frame"] = info.interlaced_frame;161 root["interlaced_frame"] = info.interlaced_frame;
161162
162 // return JsonValue163 // return JsonValue
@@ -167,12 +168,16 @@
167void Profile::SetJson(string value) throw(InvalidJSON) {168void Profile::SetJson(string value) throw(InvalidJSON) {
168169
169 // Parse JSON string into JSON objects170 // Parse JSON string into JSON objects
170 Json::Value root;171 QJsonObject root;
171 Json::Reader reader;172 QJsonParseError errors;
172 bool success = reader.parse( value, root );173
173 if (!success)174 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
175 if (errors.error != QJsonParseError::NoError) {
174 // Raise exception176 // Raise exception
175 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");177 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
178 }
179
180 root = document.object();
176181
177 try182 try
178 {183 {
@@ -186,28 +191,31 @@
186 }191 }
187}192}
188193
189// Load Json::JsonValue into this object194// Load QJsonObject into this object
190void Profile::SetJsonValue(Json::Value root) {195void Profile::SetJsonValue(const QJsonObject root) {
191196
192 if (!root["height"].isNull())197 if (!root["height"].isNull())
193 info.height = root["height"].asInt();198 info.height = root["height"].toVariant().toInt();
194 if (!root["width"].isNull())199 if (!root["width"].isNull())
195 info.width = root["width"].asInt();200 info.width = root["width"].toVariant().toInt();
196 if (!root["pixel_format"].isNull())201 if (!root["pixel_format"].isNull())
197 info.pixel_format = root["pixel_format"].asInt();202 info.pixel_format = root["pixel_format"].toVariant().toInt();
198 if (!root["fps"].isNull()) {203 if (!root["fps"].isNull()) {
199 info.fps.num = root["fps"]["num"].asInt();204 const QJsonObject fpsObject = root["fps"].toObject();
200 info.fps.den = root["fps"]["den"].asInt();205 info.fps.num = fpsObject["num"].toVariant().toInt();
206 info.fps.den = fpsObject["den"].toVariant().toInt();
201 }207 }
202 if (!root["pixel_ratio"].isNull()) {208 if (!root["pixel_ratio"].isNull()) {
203 info.pixel_ratio.num = root["pixel_ratio"]["num"].asInt();209 const QJsonObject pixelRatioObject = root["pixel_ratio"].toObject();
204 info.pixel_ratio.den = root["pixel_ratio"]["den"].asInt();210 info.pixel_ratio.num = pixelRatioObject["num"].toVariant().toInt();
211 info.pixel_ratio.den = pixelRatioObject["den"].toVariant().toInt();
205 }212 }
206 if (!root["display_ratio"].isNull()) {213 if (!root["display_ratio"].isNull()) {
207 info.display_ratio.num = root["display_ratio"]["num"].asInt();214 const QJsonObject displayRatioObject = root["display_ratio"].toObject();
208 info.display_ratio.den = root["display_ratio"]["den"].asInt();215 info.display_ratio.num = displayRatioObject["num"].toVariant().toInt();
216 info.display_ratio.den = displayRatioObject["den"].toVariant().toInt();
209 }217 }
210 if (!root["interlaced_frame"].isNull())218 if (!root["interlaced_frame"].isNull())
211 info.interlaced_frame = root["interlaced_frame"].asBool();219 info.interlaced_frame = root["interlaced_frame"].toBool();
212220
213}221}
214222
=== modified file 'src/QtImageReader.cpp'
--- src/QtImageReader.cpp 2015-09-29 03:05:50 +0000
+++ src/QtImageReader.cpp 2015-10-04 15:21:00 +0000
@@ -123,16 +123,18 @@
123string QtImageReader::Json() {123string QtImageReader::Json() {
124124
125 // Return formatted string125 // Return formatted string
126 return JsonValue().toStyledString();126 QJsonDocument document;
127 document.setObject(JsonValue());
128 return document.toJson().constData();
127}129}
128130
129// Generate Json::JsonValue for this object131// Generate Json::JsonValue for this object
130Json::Value QtImageReader::JsonValue() {132QJsonObject QtImageReader::JsonValue() {
131133
132 // Create root json object134 // Create root json object
133 Json::Value root = ReaderBase::JsonValue(); // get parent properties135 QJsonObject root = ReaderBase::JsonValue(); // get parent properties
134 root["type"] = "QtImageReader";136 root["type"] = "QtImageReader";
135 root["path"] = path;137 root["path"] = path.c_str();
136138
137 // return JsonValue139 // return JsonValue
138 return root;140 return root;
@@ -141,13 +143,17 @@
141// Load JSON string into this object143// Load JSON string into this object
142void QtImageReader::SetJson(string value) throw(InvalidJSON) {144void QtImageReader::SetJson(string value) throw(InvalidJSON) {
143145
144 // Parse JSON string into JSON objects146 // Parse JSON string into JSON objects
145 Json::Value root;147 QJsonObject root;
146 Json::Reader reader;148 QJsonParseError errors;
147 bool success = reader.parse( value, root );149
148 if (!success)150 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
149 // Raise exception151 if (errors.error != QJsonParseError::NoError) {
150 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");152 // Raise exception
153 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
154 }
155
156 root = document.object();
151157
152 try158 try
153 {159 {
@@ -162,14 +168,14 @@
162}168}
163169
164// Load Json::JsonValue into this object170// Load Json::JsonValue into this object
165void QtImageReader::SetJsonValue(Json::Value root) throw(InvalidFile) {171void QtImageReader::SetJsonValue(QJsonObject root) throw(InvalidFile) {
166172
167 // Set parent data173 // Set parent data
168 ReaderBase::SetJsonValue(root);174 ReaderBase::SetJsonValue(root);
169175
170 // Set data from Json (if key is found)176 // Set data from Json (if key is found)
171 if (!root["path"].isNull())177 if (!root["path"].isNull())
172 path = root["path"].asString();178 path = root["path"].toString().toLocal8Bit().constData();
173179
174 // Re-Open path, and re-init everything (if needed)180 // Re-Open path, and re-init everything (if needed)
175 if (is_open)181 if (is_open)
176182
=== modified file 'src/ReaderBase.cpp'
--- src/ReaderBase.cpp 2015-09-29 03:05:50 +0000
+++ src/ReaderBase.cpp 2015-10-04 15:21:00 +0000
@@ -67,12 +67,14 @@
67string ReaderBase::OutputDebugJSON()67string ReaderBase::OutputDebugJSON()
68{68{
69 // Return formatted string69 // Return formatted string
70 return debug_root.toStyledString();70 QJsonDocument document;
71 document.setArray(debug_root);
72 return document.toJson().constData();
71}73}
7274
7375
74// Append debug information as JSON76// Append debug information as JSON
75void ReaderBase::AppendDebugItem(Json::Value debug_item)77void ReaderBase::AppendDebugItem(QJsonValue debug_item)
76{78{
77 // Append item to root array79 // Append item to root array
78 debug_root.append(debug_item);80 debug_root.append(debug_item);
@@ -90,8 +92,8 @@
90 // Don't do anything92 // Don't do anything
91 return;93 return;
9294
93 Json::Value debug_item;95 QJsonObject debug_item;
94 debug_item["method"] = method_name;96 debug_item["method"] = method_name.c_str();
9597
96 // Output to standard output98 // Output to standard output
97 #pragma omp critical (debug_output)99 #pragma omp critical (debug_output)
@@ -101,27 +103,27 @@
101103
102 // Add attributes to method JSON104 // Add attributes to method JSON
103 if (arg1_name.length() > 0) {105 if (arg1_name.length() > 0) {
104 debug_item[arg1_name] = arg1_value;106 debug_item[arg1_name.c_str()] = arg1_value;
105 cout << arg1_name << "=" << arg1_value;107 cout << arg1_name << "=" << arg1_value;
106 }108 }
107 if (arg2_name.length() > 0) {109 if (arg2_name.length() > 0) {
108 debug_item[arg2_name] = arg2_value;110 debug_item[arg2_name.c_str()] = arg2_value;
109 cout << ", " << arg2_name << "=" << arg2_value;111 cout << ", " << arg2_name << "=" << arg2_value;
110 }112 }
111 if (arg3_name.length() > 0) {113 if (arg3_name.length() > 0) {
112 debug_item[arg3_name] = arg3_value;114 debug_item[arg3_name.c_str()] = arg3_value;
113 cout << ", " << arg3_name << "=" << arg3_value;115 cout << ", " << arg3_name << "=" << arg3_value;
114 }116 }
115 if (arg4_name.length() > 0) {117 if (arg4_name.length() > 0) {
116 debug_item[arg4_name] = arg4_value;118 debug_item[arg4_name.c_str()] = arg4_value;
117 cout << ", " << arg4_name << "=" << arg4_value;119 cout << ", " << arg4_name << "=" << arg4_value;
118 }120 }
119 if (arg5_name.length() > 0) {121 if (arg5_name.length() > 0) {
120 debug_item[arg5_name] = arg5_value;122 debug_item[arg5_name.c_str()] = arg5_value;
121 cout << ", " << arg5_name << "=" << arg5_value;123 cout << ", " << arg5_name << "=" << arg5_value;
122 }124 }
123 if (arg6_name.length() > 0) {125 if (arg6_name.length() > 0) {
124 debug_item[arg6_name] = arg6_value;126 debug_item[arg6_name.c_str()] = arg6_value;
125 cout << ", " << arg6_name << "=" << arg6_value;127 cout << ", " << arg6_name << "=" << arg6_value;
126 }128 }
127129
@@ -129,7 +131,7 @@
129 cout << ")" << endl;131 cout << ")" << endl;
130132
131 // Append method to root array133 // Append method to root array
132 debug_root.append(debug_item);134 debug_root.append(QJsonValue(debug_item));
133 }135 }
134}136}
135137
@@ -174,128 +176,124 @@
174}176}
175177
176// Generate Json::JsonValue for this object178// Generate Json::JsonValue for this object
177Json::Value ReaderBase::JsonValue() {179QJsonObject ReaderBase::JsonValue() {
178180
179 // Create root json object181 // Create root json object
180 Json::Value root;182 QJsonObject root;
181 root["has_video"] = info.has_video;183 root["has_video"] = info.has_video;
182 root["has_audio"] = info.has_audio;184 root["has_audio"] = info.has_audio;
183 root["has_single_image"] = info.has_single_image;185 root["has_single_image"] = info.has_single_image;
184 root["duration"] = info.duration;186 root["duration"] = info.duration;
185 stringstream filesize_stream;187 root["file_size"] = info.file_size;
186 filesize_stream << info.file_size;
187 root["file_size"] = filesize_stream.str();
188 root["height"] = info.height;188 root["height"] = info.height;
189 root["width"] = info.width;189 root["width"] = info.width;
190 root["pixel_format"] = info.pixel_format;190 root["pixel_format"] = info.pixel_format;
191 root["fps"] = Json::Value(Json::objectValue);191 root["fps"] = QJsonObject();
192 root["fps"]["num"] = info.fps.num;192 root["fps"].toObject()["num"] = info.fps.num;
193 root["fps"]["den"] = info.fps.den;193 root["fps"].toObject()["den"] = info.fps.den;
194 root["video_bit_rate"] = info.video_bit_rate;194 root["video_bit_rate"] = info.video_bit_rate;
195 root["pixel_ratio"] = Json::Value(Json::objectValue);195 root["pixel_ratio"] = QJsonObject();
196 root["pixel_ratio"]["num"] = info.pixel_ratio.num;196 root["pixel_ratio"].toObject()["num"] = info.pixel_ratio.num;
197 root["pixel_ratio"]["den"] = info.pixel_ratio.den;197 root["pixel_ratio"].toObject()["den"] = info.pixel_ratio.den;
198 root["display_ratio"] = Json::Value(Json::objectValue);198 root["display_ratio"] = QJsonObject();
199 root["display_ratio"]["num"] = info.display_ratio.num;199 root["display_ratio"].toObject()["num"] = info.display_ratio.num;
200 root["display_ratio"]["den"] = info.display_ratio.den;200 root["display_ratio"].toObject()["den"] = info.display_ratio.den;
201 root["vcodec"] = info.vcodec;201 root["vcodec"] = info.vcodec.c_str();
202 stringstream video_length_stream;202 root["video_length"] = (long long) info.video_length;
203 video_length_stream << info.video_length;
204 root["video_length"] = video_length_stream.str();
205 root["video_stream_index"] = info.video_stream_index;203 root["video_stream_index"] = info.video_stream_index;
206 root["video_timebase"] = Json::Value(Json::objectValue);204 root["video_timebase"] = QJsonObject();
207 root["video_timebase"]["num"] = info.video_timebase.num;205 root["video_timebase"].toObject()["num"] = info.video_timebase.num;
208 root["video_timebase"]["den"] = info.video_timebase.den;206 root["video_timebase"].toObject()["den"] = info.video_timebase.den;
209 root["interlaced_frame"] = info.interlaced_frame;207 root["interlaced_frame"] = info.interlaced_frame;
210 root["top_field_first"] = info.top_field_first;208 root["top_field_first"] = info.top_field_first;
211 root["acodec"] = info.acodec;209 root["acodec"] = info.acodec.c_str();
212 root["audio_bit_rate"] = info.audio_bit_rate;210 root["audio_bit_rate"] = info.audio_bit_rate;
213 root["sample_rate"] = info.sample_rate;211 root["sample_rate"] = info.sample_rate;
214 root["channels"] = info.channels;212 root["channels"] = info.channels;
215 root["channel_layout"] = info.channel_layout;213 root["channel_layout"] = info.channel_layout;
216 root["audio_stream_index"] = info.audio_stream_index;214 root["audio_stream_index"] = info.audio_stream_index;
217 root["audio_timebase"] = Json::Value(Json::objectValue);215 root["audio_timebase"] = QJsonObject();
218 root["audio_timebase"]["num"] = info.audio_timebase.num;216 root["audio_timebase"].toObject()["num"] = info.audio_timebase.num;
219 root["audio_timebase"]["den"] = info.audio_timebase.den;217 root["audio_timebase"].toObject()["den"] = info.audio_timebase.den;
220218
221 // return JsonValue219 // return JsonValue
222 return root;220 return root;
223}221}
224222
225// Load Json::JsonValue into this object223// Load Json::JsonValue into this object
226void ReaderBase::SetJsonValue(Json::Value root) {224void ReaderBase::SetJsonValue(QJsonObject root) {
227225
228 // Set data from Json (if key is found)226 // Set data from Json (if key is found)
229 if (!root["has_video"].isNull())227 if (!root["has_video"].isNull())
230 info.has_video = root["has_video"].asBool();228 info.has_video = root["has_video"].toBool();
231 if (!root["has_audio"].isNull())229 if (!root["has_audio"].isNull())
232 info.has_audio = root["has_audio"].asBool();230 info.has_audio = root["has_audio"].toBool();
233 if (!root["has_single_image"].isNull())231 if (!root["has_single_image"].isNull())
234 info.has_single_image = root["has_single_image"].asBool();232 info.has_single_image = root["has_single_image"].toBool();
235 if (!root["duration"].isNull())233 if (!root["duration"].isNull())
236 info.duration = root["duration"].asDouble();234 info.duration = root["duration"].toDouble();
237 if (!root["file_size"].isNull())235 if (!root["file_size"].isNull())
238 info.file_size = atoll(root["file_size"].asString().c_str());236 info.file_size = root.value("file_size").toVariant().toLongLong();
239 if (!root["height"].isNull())237 if (!root["height"].isNull())
240 info.height = root["height"].asInt();238 info.height = root["height"].toInt();
241 if (!root["width"].isNull())239 if (!root["width"].isNull())
242 info.width = root["width"].asInt();240 info.width = root["width"].toInt();
243 if (!root["pixel_format"].isNull())241 if (!root["pixel_format"].isNull())
244 info.pixel_format = root["pixel_format"].asInt();242 info.pixel_format = root["pixel_format"].toInt();
245 if (!root["fps"].isNull() && root["fps"].isObject()) {243 if (!root["fps"].isNull() && root["fps"].isObject()) {
246 if (!root["fps"]["num"].isNull())244 if (!root["fps"].toObject()["num"].isNull())
247 info.fps.num = root["fps"]["num"].asInt();245 info.fps.num = root["fps"].toObject()["num"].toInt();
248 if (!root["fps"]["den"].isNull())246 if (!root["fps"].toObject()["den"].isNull())
249 info.fps.den = root["fps"]["den"].asInt();247 info.fps.den = root["fps"].toObject()["den"].toInt();
250 }248 }
251 if (!root["video_bit_rate"].isNull())249 if (!root["video_bit_rate"].isNull())
252 info.video_bit_rate = root["video_bit_rate"].asInt();250 info.video_bit_rate = root["video_bit_rate"].toInt();
253 if (!root["pixel_ratio"].isNull() && root["pixel_ratio"].isObject()) {251 if (!root["pixel_ratio"].isNull() && root["pixel_ratio"].isObject()) {
254 if (!root["pixel_ratio"]["num"].isNull())252 if (!root["pixel_ratio"].toObject()["num"].isNull())
255 info.pixel_ratio.num = root["pixel_ratio"]["num"].asInt();253 info.pixel_ratio.num = root["pixel_ratio"].toObject()["num"].toInt();
256 if (!root["pixel_ratio"]["den"].isNull())254 if (!root["pixel_ratio"].toObject()["den"].isNull())
257 info.pixel_ratio.den = root["pixel_ratio"]["den"].asInt();255 info.pixel_ratio.den = root["pixel_ratio"].toObject()["den"].toInt();
258 }256 }
259 if (!root["display_ratio"].isNull() && root["display_ratio"].isObject()) {257 if (!root["display_ratio"].isNull() && root["display_ratio"].isObject()) {
260 if (!root["display_ratio"]["num"].isNull())258 if (!root["display_ratio"].toObject()["num"].isNull())
261 info.display_ratio.num = root["display_ratio"]["num"].asInt();259 info.display_ratio.num = root["display_ratio"].toObject()["num"].toInt();
262 if (!root["display_ratio"]["den"].isNull())260 if (!root["display_ratio"].toObject()["den"].isNull())
263 info.display_ratio.den = root["display_ratio"]["den"].asInt();261 info.display_ratio.den = root["display_ratio"].toObject()["den"].toInt();
264 }262 }
265 if (!root["vcodec"].isNull())263 if (!root["vcodec"].isNull())
266 info.vcodec = root["vcodec"].asString();264 info.vcodec = root["vcodec"].toString().toLocal8Bit().constData();
267 if (!root["video_length"].isNull())265 if (!root["video_length"].isNull())
268 info.video_length = atoll(root["video_length"].asString().c_str());266 info.video_length = root.value("video_length").toVariant().toLongLong();
269 if (!root["video_stream_index"].isNull())267 if (!root["video_stream_index"].isNull())
270 info.video_stream_index = root["video_stream_index"].asInt();268 info.video_stream_index = root["video_stream_index"].toInt();
271 if (!root["video_timebase"].isNull() && root["video_timebase"].isObject()) {269 if (!root["video_timebase"].isNull() && root["video_timebase"].isObject()) {
272 if (!root["video_timebase"]["num"].isNull())270 if (!root["video_timebase"].toObject()["num"].isNull())
273 info.video_timebase.num = root["video_timebase"]["num"].asInt();271 info.video_timebase.num = root["video_timebase"].toObject()["num"].toInt();
274 if (!root["video_timebase"]["den"].isNull())272 if (!root["video_timebase"].toObject()["den"].isNull())
275 info.video_timebase.den = root["video_timebase"]["den"].asInt();273 info.video_timebase.den = root["video_timebase"].toObject()["den"].toInt();
276 }274 }
277 if (!root["interlaced_frame"].isNull())275 if (!root["interlaced_frame"].isNull())
278 info.interlaced_frame = root["interlaced_frame"].asBool();276 info.interlaced_frame = root["interlaced_frame"].toBool();
279 if (!root["top_field_first"].isNull())277 if (!root["top_field_first"].isNull())
280 info.top_field_first = root["top_field_first"].asBool();278 info.top_field_first = root["top_field_first"].toBool();
281 if (!root["acodec"].isNull())279 if (!root["acodec"].isNull())
282 info.acodec = root["acodec"].asString();280 info.acodec = root["acodec"].toString().toLocal8Bit().constData();
283281
284 if (!root["audio_bit_rate"].isNull())282 if (!root["audio_bit_rate"].isNull())
285 info.audio_bit_rate = root["audio_bit_rate"].asInt();283 info.audio_bit_rate = root["audio_bit_rate"].toInt();
286 if (!root["sample_rate"].isNull())284 if (!root["sample_rate"].isNull())
287 info.sample_rate = root["sample_rate"].asInt();285 info.sample_rate = root["sample_rate"].toInt();
288 if (!root["channels"].isNull())286 if (!root["channels"].isNull())
289 info.channels = root["channels"].asInt();287 info.channels = root["channels"].toInt();
290 if (!root["channel_layout"].isNull())288 if (!root["channel_layout"].isNull())
291 info.channel_layout = (ChannelLayout) root["channel_layout"].asInt();289 info.channel_layout = (ChannelLayout) root["channel_layout"].toInt();
292 if (!root["audio_stream_index"].isNull())290 if (!root["audio_stream_index"].isNull())
293 info.audio_stream_index = root["audio_stream_index"].asInt();291 info.audio_stream_index = root["audio_stream_index"].toInt();
294 if (!root["audio_timebase"].isNull() && root["audio_timebase"].isObject()) {292 if (!root["audio_timebase"].isNull() && root["audio_timebase"].isObject()) {
295 if (!root["audio_timebase"]["num"].isNull())293 if (!root["audio_timebase"].toObject()["num"].isNull())
296 info.audio_timebase.num = root["audio_timebase"]["num"].asInt();294 info.audio_timebase.num = root["audio_timebase"].toObject()["num"].toInt();
297 if (!root["audio_timebase"]["den"].isNull())295 if (!root["audio_timebase"].toObject()["den"].isNull())
298 info.audio_timebase.den = root["audio_timebase"]["den"].asInt();296 info.audio_timebase.den = root["audio_timebase"].toObject()["den"].toInt();
299 }297 }
300}298}
301299
302300
=== modified file 'src/TextReader.cpp'
--- src/TextReader.cpp 2015-08-24 06:05:48 +0000
+++ src/TextReader.cpp 2015-10-04 15:21:00 +0000
@@ -171,28 +171,29 @@
171// Generate JSON string of this object171// Generate JSON string of this object
172string TextReader::Json() {172string TextReader::Json() {
173173
174 // Return formatted string174 QJsonDocument document;
175 return JsonValue().toStyledString();175 document.setObject(JsonValue());
176 return document.toJson().constData();
176}177}
177178
178// Generate Json::JsonValue for this object179// Generate QJsonObject for this object
179Json::Value TextReader::JsonValue() {180QJsonObject TextReader::JsonValue() {
180181
181 // Create root json object182 // Create root json object
182 Json::Value root = ReaderBase::JsonValue(); // get parent properties183 QJsonObject root = ReaderBase::JsonValue(); // get parent properties
183 root["type"] = "TextReader";184 root["type"] = "TextReader";
184 root["width"] = width;185 root["width"] = width;
185 root["height"] = height;186 root["height"] = height;
186 root["x_offset"] = x_offset;187 root["x_offset"] = x_offset;
187 root["y_offset"] = y_offset;188 root["y_offset"] = y_offset;
188 root["text"] = text;189 root["text"] = text.c_str();
189 root["font"] = font;190 root["font"] = font.c_str();
190 root["size"] = size;191 root["size"] = size;
191 root["text_color"] = text_color;192 root["text_color"] = text_color.c_str();
192 root["background_color"] = background_color;193 root["background_color"] = background_color.c_str();
193 root["gravity"] = gravity;194 root["gravity"] = gravity;
194195
195 // return JsonValue196 // return QJsonObject
196 return root;197 return root;
197}198}
198199
@@ -200,12 +201,16 @@
200void TextReader::SetJson(string value) throw(InvalidJSON) {201void TextReader::SetJson(string value) throw(InvalidJSON) {
201202
202 // Parse JSON string into JSON objects203 // Parse JSON string into JSON objects
203 Json::Value root;204 QJsonObject root;
204 Json::Reader reader;205 QJsonParseError errors;
205 bool success = reader.parse( value, root );206
206 if (!success)207 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
208 if (errors.error != QJsonParseError::NoError) {
207 // Raise exception209 // Raise exception
208 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");210 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
211 }
212
213 root = document.object();
209214
210 try215 try
211 {216 {
@@ -219,33 +224,33 @@
219 }224 }
220}225}
221226
222// Load Json::JsonValue into this object227// Load QJsonObject into this object
223void TextReader::SetJsonValue(Json::Value root) throw(InvalidFile) {228void TextReader::SetJsonValue(const QJsonObject root) throw(InvalidFile) {
224229
225 // Set parent data230 // Set parent data
226 ReaderBase::SetJsonValue(root);231 ReaderBase::SetJsonValue(root);
227232
228 // Set data from Json (if key is found)233 // Set data from Json (if key is found)
229 if (!root["width"].isNull())234 if (!root["width"].isNull())
230 width = root["width"].asInt();235 width = root["width"].toVariant().toInt();
231 if (!root["height"].isNull())236 if (!root["height"].isNull())
232 height = root["height"].asInt();237 height = root["height"].toVariant().toInt();
233 if (!root["x_offset"].isNull())238 if (!root["x_offset"].isNull())
234 x_offset = root["x_offset"].asInt();239 x_offset = root["x_offset"].toVariant().toInt();
235 if (!root["y_offset"].isNull())240 if (!root["y_offset"].isNull())
236 y_offset = root["y_offset"].asInt();241 y_offset = root["y_offset"].toVariant().toInt();
237 if (!root["text"].isNull())242 if (!root["text"].isNull())
238 text = root["text"].asString();243 text = root["text"].toString().toLocal8Bit().constData();
239 if (!root["font"].isNull())244 if (!root["font"].isNull())
240 font = root["font"].asString();245 font = root["font"].toString().toLocal8Bit().constData();
241 if (!root["size"].isNull())246 if (!root["size"].isNull())
242 size = root["size"].asDouble();247 size = root["size"].toDouble();
243 if (!root["text_color"].isNull())248 if (!root["text_color"].isNull())
244 text_color = root["text_color"].asString();249 text_color = root["text_color"].toString().toLocal8Bit().constData();
245 if (!root["background_color"].isNull())250 if (!root["background_color"].isNull())
246 background_color = root["background_color"].asString();251 background_color = root["background_color"].toString().toLocal8Bit().constData();
247 if (!root["gravity"].isNull())252 if (!root["gravity"].isNull())
248 gravity = (GravityType) root["gravity"].asInt();253 gravity = (GravityType) root["gravity"].toVariant().toInt();
249254
250 // Re-Open path, and re-init everything (if needed)255 // Re-Open path, and re-init everything (if needed)
251 if (is_open)256 if (is_open)
252257
=== modified file 'src/Timeline.cpp'
--- src/Timeline.cpp 2015-08-25 04:49:45 +0000
+++ src/Timeline.cpp 2015-10-04 15:21:00 +0000
@@ -750,15 +750,16 @@
750// Generate JSON string of this object750// Generate JSON string of this object
751string Timeline::Json() {751string Timeline::Json() {
752752
753 // Return formatted string753 QJsonDocument document;
754 return JsonValue().toStyledString();754 document.setObject(JsonValue());
755 return document.toJson().constData();
755}756}
756757
757// Generate Json::JsonValue for this object758// Generate QJsonObject for this object
758Json::Value Timeline::JsonValue() {759QJsonObject Timeline::JsonValue() {
759760
760 // Create root json object761 // Create root json object
761 Json::Value root = ReaderBase::JsonValue(); // get parent properties762 QJsonObject root = ReaderBase::JsonValue(); // get parent properties
762 root["type"] = "Timeline";763 root["type"] = "Timeline";
763 root["viewport_scale"] = viewport_scale.JsonValue();764 root["viewport_scale"] = viewport_scale.JsonValue();
764 root["viewport_x"] = viewport_x.JsonValue();765 root["viewport_x"] = viewport_x.JsonValue();
@@ -766,7 +767,7 @@
766 root["color"] = color.JsonValue();767 root["color"] = color.JsonValue();
767768
768 // Add array of clips769 // Add array of clips
769 root["clips"] = Json::Value(Json::arrayValue);770 root["clips"] = QJsonArray();
770771
771 // Find Clips at this time772 // Find Clips at this time
772 list<Clip*>::iterator clip_itr;773 list<Clip*>::iterator clip_itr;
@@ -774,11 +775,11 @@
774 {775 {
775 // Get clip object from the iterator776 // Get clip object from the iterator
776 Clip *existing_clip = (*clip_itr);777 Clip *existing_clip = (*clip_itr);
777 root["clips"].append(existing_clip->JsonValue());778 root["clips"].toArray().append(existing_clip->JsonValue());
778 }779 }
779780
780 // Add array of effects781 // Add array of effects
781 root["effects"] = Json::Value(Json::arrayValue);782 root["effects"] = QJsonArray();
782783
783 // loop through effects784 // loop through effects
784 list<EffectBase*>::iterator effect_itr;785 list<EffectBase*>::iterator effect_itr;
@@ -786,7 +787,7 @@
786 {787 {
787 // Get clip object from the iterator788 // Get clip object from the iterator
788 EffectBase *existing_effect = (*effect_itr);789 EffectBase *existing_effect = (*effect_itr);
789 root["effects"].append(existing_effect->JsonValue());790 root["effects"].toArray().append(existing_effect->JsonValue());
790 }791 }
791792
792 // return JsonValue793 // return JsonValue
@@ -797,12 +798,16 @@
797void Timeline::SetJson(string value) throw(InvalidJSON) {798void Timeline::SetJson(string value) throw(InvalidJSON) {
798799
799 // Parse JSON string into JSON objects800 // Parse JSON string into JSON objects
800 Json::Value root;801 QJsonObject root;
801 Json::Reader reader;802 QJsonParseError errors;
802 bool success = reader.parse( value, root );803
803 if (!success)804 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
805 if (errors.error != QJsonParseError::NoError) {
804 // Raise exception806 // Raise exception
805 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");807 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
808 }
809
810 root = document.object();
806811
807 try812 try
808 {813 {
@@ -816,8 +821,8 @@
816 }821 }
817}822}
818823
819// Load Json::JsonValue into this object824// Load QJsonObject into this object
820void Timeline::SetJsonValue(Json::Value root) throw(InvalidFile, ReaderClosed) {825void Timeline::SetJsonValue(QJsonObject root) throw(InvalidFile, ReaderClosed) {
821826
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)
823 Close();828 Close();
@@ -830,9 +835,9 @@
830 clips.clear();835 clips.clear();
831836
832 // loop through clips837 // loop through clips
833 for (int x = 0; x < root["clips"].size(); x++) {838 for (int x = 0; x < root["clips"].toArray().size(); x++) {
834 // Get each clip839 // Get each clip
835 Json::Value existing_clip = root["clips"][x];840 QJsonObject existing_clip = root["clips"].toArray()[x].toObject();
836841
837 // Create Clip842 // Create Clip
838 Clip *c = new Clip();843 Clip *c = new Clip();
@@ -850,25 +855,25 @@
850 effects.clear();855 effects.clear();
851856
852 // loop through effects857 // loop through effects
853 for (int x = 0; x < root["effects"].size(); x++) {858 for (int x = 0; x < root["effects"].toArray().size(); x++) {
854 // Get each effect859 // Get each effect
855 Json::Value existing_effect = root["effects"][x];860 QJsonObject existing_effect = root["effects"].toArray()[x].toObject();
856861
857 // Create Effect862 // Create Effect
858 EffectBase *e = NULL;863 EffectBase *e = NULL;
859864
860 if (!existing_effect["type"].isNull())865 if (!existing_effect["type"].isNull())
861 // Init the matching effect object866 // Init the matching effect object
862 if (existing_effect["type"].asString() == "ChromaKey")867 if (existing_effect["type"].toString() == "ChromaKey")
863 e = new ChromaKey();868 e = new ChromaKey();
864869
865 else if (existing_effect["type"].asString() == "Deinterlace")870 else if (existing_effect["type"].toString() == "Deinterlace")
866 e = new Deinterlace();871 e = new Deinterlace();
867872
868 else if (existing_effect["type"].asString() == "Mask")873 else if (existing_effect["type"].toString() == "Mask")
869 e = new Mask();874 e = new Mask();
870875
871 else if (existing_effect["type"].asString() == "Negate")876 else if (existing_effect["type"].toString() == "Negate")
872 e = new Negate();877 e = new Negate();
873878
874 // Load Json into Effect879 // Load Json into Effect
@@ -887,20 +892,24 @@
887 final_cache.Clear();892 final_cache.Clear();
888893
889 // Parse JSON string into JSON objects894 // Parse JSON string into JSON objects
890 Json::Value root;895 QJsonArray root;
891 Json::Reader reader;896 QJsonParseError errors;
892 bool success = reader.parse( value, root );897
893 if (!success || !root.isArray())898 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
899 if (errors.error != QJsonParseError::NoError) {
894 // Raise exception900 // Raise exception
895 throw InvalidJSON("JSON could not be parsed (or is invalid).", "");901 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
902 }
903
904 root = document.array();
896905
897 try906 try
898 {907 {
899 // Process the JSON change array, loop through each item908 // Process the JSON change array, loop through each item
900 for (int x = 0; x < root.size(); x++) {909 for (int x = 0; x < root.size(); x++) {
901 // Get each change910 // Get each change
902 Json::Value change = root[x];911 QJsonObject change = root[x].toObject();
903 string root_key = change["key"][(uint)0].asString();912 QString root_key = change["key"].toArray()[0].toString();
904913
905 // Process each type of change914 // Process each type of change
906 if (root_key == "clips")915 if (root_key == "clips")
@@ -928,23 +937,23 @@
928}937}
929938
930// Apply JSON diff to clips939// Apply JSON diff to clips
931void Timeline::apply_json_to_clips(Json::Value change) throw(InvalidJSONKey) {940void Timeline::apply_json_to_clips(QJsonObject change) throw(InvalidJSONKey) {
932941
933 // Get key and type of change942 // Get key and type of change
934 string change_type = change["type"].asString();943 QString change_type = change["type"].toString();
935 string clip_id = "";944 QString clip_id;
936 Clip *existing_clip = NULL;945 Clip *existing_clip = NULL;
937946
938 // Find id of clip (if any)947 // Find id of clip (if any)
939 for (int x = 0; x < change["key"].size(); x++) {948 for (int x = 0; x < change["key"].toArray().size(); x++) {
940 // Get each change949 // Get each change
941 Json::Value key_part = change["key"][x];950 QJsonValue key_part = change["key"].toArray()[x];
942951
943 if (key_part.isObject()) {952 if (key_part.isObject()) {
944 // Check for id953 // Check for id
945 if (!key_part["id"].isNull()) {954 if (!key_part.toObject()["id"].isNull()) {
946 // Set the id955 // Set the id
947 clip_id = key_part["id"].asString();956 clip_id = key_part.toObject()["id"].toString();
948957
949 // Find matching clip in timeline (if any)958 // Find matching clip in timeline (if any)
950 list<Clip*>::iterator clip_itr;959 list<Clip*>::iterator clip_itr;
@@ -952,7 +961,7 @@
952 {961 {
953 // Get clip object from the iterator962 // Get clip object from the iterator
954 Clip *c = (*clip_itr);963 Clip *c = (*clip_itr);
955 if (c->Id() == clip_id) {964 if (c->Id().c_str() == clip_id) {
956 existing_clip = c;965 existing_clip = c;
957 break; // clip found, exit loop966 break; // clip found, exit loop
958 }967 }
@@ -964,18 +973,18 @@
964973
965 // Check for a more specific key (targetting this clip's effects)974 // Check for a more specific key (targetting this clip's effects)
966 // For example: ["clips", {"id:123}, "effects", {"id":432}]975 // For example: ["clips", {"id:123}, "effects", {"id":432}]
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")
968 {977 {
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)
970 EffectBase *existing_effect = NULL;979 EffectBase *existing_effect = NULL;
971 Json::Value key_part = change["key"][3];
972980
973 if (key_part.isObject()) {981 if (change["key"].toArray()[3].isObject()) {
982 QJsonObject key_part = change["key"].toArray()[3].toObject();
974 // Check for id983 // Check for id
975 if (!key_part["id"].isNull())984 if (!key_part["id"].isNull())
976 {985 {
977 // Set the id986 // Set the id
978 string effect_id = key_part["id"].asString();987 string effect_id = key_part["id"].toString().toLocal8Bit().constData();
979988
980 // Find matching effect in timeline (if any)989 // Find matching effect in timeline (if any)
981 list<EffectBase*>::iterator effect_itr;990 list<EffectBase*>::iterator effect_itr;
@@ -1000,14 +1009,14 @@
10001009
1001 // Create new clip1010 // Create new clip
1002 Clip *clip = new Clip();1011 Clip *clip = new Clip();
1003 clip->SetJsonValue(change["value"]); // Set properties of new clip from JSON1012 clip->SetJsonValue(change["value"].toObject()); // Set properties of new clip from JSON
1004 AddClip(clip); // Add clip to timeline1013 AddClip(clip); // Add clip to timeline
10051014
1006 } else if (change_type == "update") {1015 } else if (change_type == "update") {
10071016
1008 // Update existing clip1017 // Update existing clip
1009 if (existing_clip)1018 if (existing_clip)
1010 existing_clip->SetJsonValue(change["value"]); // Update clip properties from JSON1019 existing_clip->SetJsonValue(change["value"].toObject()); // Update clip properties from JSON
10111020
1012 } else if (change_type == "delete") {1021 } else if (change_type == "delete") {
10131022
@@ -1020,23 +1029,21 @@
1020}1029}
10211030
1022// Apply JSON diff to effects1031// Apply JSON diff to effects
1023void Timeline::apply_json_to_effects(Json::Value change) throw(InvalidJSONKey) {1032void Timeline::apply_json_to_effects(QJsonObject change) throw(InvalidJSONKey) {
10241033
1025 // Get key and type of change1034 // Get key and type of change
1026 string change_type = change["type"].asString();1035 string change_type = change["type"].toString().toLocal8Bit().constData();
1027 EffectBase *existing_effect = NULL;1036 EffectBase *existing_effect = NULL;
10281037
1029 // Find id of an effect (if any)1038 // Find id of an effect (if any)
1030 for (int x = 0; x < change["key"].size(); x++) {1039 for (int x = 0; x < change["key"].toArray().size(); x++) {
1031 // Get each change1040 if (change["key"].toArray()[x].isObject()) {
1032 Json::Value key_part = change["key"][x];1041 QJsonObject key_part = change["key"].toArray()[x].toObject();
1033
1034 if (key_part.isObject()) {
1035 // Check for id1042 // Check for id
1036 if (!key_part["id"].isNull())1043 if (!key_part["id"].isNull())
1037 {1044 {
1038 // Set the id1045 // Set the id
1039 string effect_id = key_part["id"].asString();1046 string effect_id = key_part["id"].toString().toLocal8Bit().constData();
10401047
1041 // Find matching effect in timeline (if any)1048 // Find matching effect in timeline (if any)
1042 list<EffectBase*>::iterator effect_itr;1049 list<EffectBase*>::iterator effect_itr;
@@ -1044,7 +1051,7 @@
1044 {1051 {
1045 // Get effect object from the iterator1052 // Get effect object from the iterator
1046 EffectBase *e = (*effect_itr);1053 EffectBase *e = (*effect_itr);
1047 if (e->Id() == effect_id) {1054 if (e->Id().c_str() == effect_id) {
1048 existing_effect = e;1055 existing_effect = e;
1049 break; // effect found, exit loop1056 break; // effect found, exit loop
1050 }1057 }
@@ -1061,16 +1068,16 @@
1061}1068}
10621069
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)
1064void Timeline::apply_json_to_effects(Json::Value change, EffectBase* existing_effect) throw(InvalidJSONKey) {1071void Timeline::apply_json_to_effects(QJsonObject change, EffectBase* existing_effect) throw(InvalidJSONKey) {
10651072
1066 // Get key and type of change1073 // Get key and type of change
1067 string change_type = change["type"].asString();1074 string change_type = change["type"].toString().toLocal8Bit().constData();
10681075
1069 // Determine type of change operation1076 // Determine type of change operation
1070 if (change_type == "insert") {1077 if (change_type == "insert") {
10711078
1072 // Determine type of effect1079 // Determine type of effect
1073 string effect_type = change["value"]["type"].asString();1080 QString effect_type = change["value"].toObject()["type"].toString();
10741081
1075 // Create Effect1082 // Create Effect
1076 EffectBase *e = NULL;1083 EffectBase *e = NULL;
@@ -1089,7 +1096,7 @@
1089 e = new Negate();1096 e = new Negate();
10901097
1091 // Load Json into Effect1098 // Load Json into Effect
1092 e->SetJsonValue(change["value"]);1099 e->SetJsonValue(change["value"].toObject());
10931100
1094 // Add Effect to Timeline1101 // Add Effect to Timeline
1095 AddEffect(e);1102 AddEffect(e);
@@ -1098,7 +1105,7 @@
10981105
1099 // Update existing effect1106 // Update existing effect
1100 if (existing_effect)1107 if (existing_effect)
1101 existing_effect->SetJsonValue(change["value"]); // Update effect properties from JSON1108 existing_effect->SetJsonValue(change["value"].toObject()); // Update effect properties from JSON
11021109
1103 } else if (change_type == "delete") {1110 } else if (change_type == "delete") {
11041111
@@ -1110,11 +1117,11 @@
1110}1117}
11111118
1112// Apply JSON diff to timeline properties1119// Apply JSON diff to timeline properties
1113void Timeline::apply_json_to_timeline(Json::Value change) throw(InvalidJSONKey) {1120void Timeline::apply_json_to_timeline(QJsonObject change) throw(InvalidJSONKey) {
11141121
1115 // Get key and type of change1122 // Get key and type of change
1116 string change_type = change["type"].asString();1123 QString change_type = change["type"].toString();
1117 string root_key = change["key"][(uint)0].asString();1124 QString root_key = change["key"].toArray()[0].toString();
11181125
1119 // Determine type of change operation1126 // Determine type of change operation
1120 if (change_type == "insert" || change_type == "update") {1127 if (change_type == "insert" || change_type == "update") {
@@ -1123,36 +1130,38 @@
1123 // Check for valid property1130 // Check for valid property
1124 if (root_key == "color")1131 if (root_key == "color")
1125 // Set color1132 // Set color
1126 color.SetJsonValue(change["value"]);1133 color.SetJsonValue(change["value"].toObject());
1127 else if (root_key == "viewport_scale")1134 else if (root_key == "viewport_scale")
1128 // Set viewport scale1135 // Set viewport scale
1129 viewport_scale.SetJsonValue(change["value"]);1136 viewport_scale.SetJsonValue(change["value"].toObject());
1130 else if (root_key == "viewport_x")1137 else if (root_key == "viewport_x")
1131 // Set viewport x offset1138 // Set viewport x offset
1132 viewport_x.SetJsonValue(change["value"]);1139 viewport_x.SetJsonValue(change["value"].toObject());
1133 else if (root_key == "viewport_y")1140 else if (root_key == "viewport_y")
1134 // Set viewport y offset1141 // Set viewport y offset
1135 viewport_y.SetJsonValue(change["value"]);1142 viewport_y.SetJsonValue(change["value"].toObject());
1136 else if (root_key == "width")1143 else if (root_key == "width")
1137 // Set width1144 // Set width
1138 info.width = change["value"].asInt();1145 info.width = change["value"].toInt();
1139 else if (root_key == "height")1146 else if (root_key == "height")
1140 // Set height1147 // Set height
1141 info.height = change["value"].asInt();1148 info.height = change["value"].toInt();
1142 else if (root_key == "fps" && change["key"][(uint)1].asString() == "num")1149 else if (root_key == "fps" && change["key"].toArray()[1].toString() == "num")
1143 // Set fps.num1150 // Set fps.num
1144 info.fps.num = change["value"].asInt();1151 info.fps.num = change["value"].toInt();
1145 else if (root_key == "fps" && change["key"][(uint)1].asString() == "den")1152 else if (root_key == "fps" && change["key"].toArray()[1].toString() == "den")
1146 // Set fps.den1153 // Set fps.den
1147 info.fps.den = change["value"].asInt();1154 info.fps.den = change["value"].toInt();
11481155
1149 else1156 else {
1150
1151 // Error parsing JSON (or missing keys)1157 // Error parsing JSON (or missing keys)
1152 throw InvalidJSONKey("JSON change key is invalid", change.toStyledString());1158 QJsonDocument document;
11531159 document.setObject(change);
11541160 throw InvalidJSONKey("JSON change key is invalid", document.toJson().constData());
1155 } else if (change["type"].asString() == "delete") {1161 }
1162
1163
1164 } else if (change["type"].toString() == "delete") {
11561165
1157 // DELETE / RESET1166 // DELETE / RESET
1158 // Reset the following properties (since we can't delete them)1167 // Reset the following properties (since we can't delete them)
@@ -1168,9 +1177,12 @@
1168 viewport_x = Keyframe(0.0);1177 viewport_x = Keyframe(0.0);
1169 else if (root_key == "viewport_y")1178 else if (root_key == "viewport_y")
1170 viewport_y = Keyframe(0.0);1179 viewport_y = Keyframe(0.0);
1171 else1180 else {
1172 // Error parsing JSON (or missing keys)1181 // Error parsing JSON (or missing keys)
1173 throw InvalidJSONKey("JSON change key is invalid", change.toStyledString());1182 QJsonDocument document;
1183 document.setObject(change);
1184 throw InvalidJSONKey("JSON change key is invalid", document.toJson().constData());
1185 }
11741186
1175 }1187 }
11761188
11771189
=== modified file 'src/WriterBase.cpp'
--- src/WriterBase.cpp 2015-09-29 03:05:50 +0000
+++ src/WriterBase.cpp 2015-10-04 15:21:00 +0000
@@ -67,11 +67,13 @@
67string WriterBase::OutputDebugJSON()67string WriterBase::OutputDebugJSON()
68{68{
69 // Return formatted string69 // Return formatted string
70 return debug_root.toStyledString();70 QJsonDocument document;
71 document.setArray(debug_root);
72 return document.toJson().constData();
71}73}
7274
73// Append debug information as JSON75// Append debug information as JSON
74void WriterBase::AppendDebugItem(Json::Value debug_item)76void WriterBase::AppendDebugItem(QJsonValue debug_item)
75{77{
76 // Append item to root array78 // Append item to root array
77 debug_root.append(debug_item);79 debug_root.append(debug_item);
@@ -89,8 +91,8 @@
89 // Don't do anything91 // Don't do anything
90 return;92 return;
9193
92 Json::Value debug_item;94 QJsonObject debug_item;
93 debug_item["method"] = method_name;95 debug_item["method"] = method_name.c_str();
9496
95 // Output to standard output97 // Output to standard output
96 cout << fixed << setprecision(4);98 cout << fixed << setprecision(4);
@@ -98,27 +100,27 @@
98100
99 // Add attributes to method JSON101 // Add attributes to method JSON
100 if (arg1_name.length() > 0) {102 if (arg1_name.length() > 0) {
101 debug_item[arg1_name] = arg1_value;103 debug_item[arg1_name.c_str()] = arg1_value;
102 cout << arg1_name << "=" << arg1_value;104 cout << arg1_name << "=" << arg1_value;
103 }105 }
104 if (arg2_name.length() > 0) {106 if (arg2_name.length() > 0) {
105 debug_item[arg2_name] = arg2_value;107 debug_item[arg2_name.c_str()] = arg2_value;
106 cout << ", " << arg2_name << "=" << arg2_value;108 cout << ", " << arg2_name << "=" << arg2_value;
107 }109 }
108 if (arg3_name.length() > 0) {110 if (arg3_name.length() > 0) {
109 debug_item[arg3_name] = arg3_value;111 debug_item[arg3_name.c_str()] = arg3_value;
110 cout << ", " << arg3_name << "=" << arg3_value;112 cout << ", " << arg3_name << "=" << arg3_value;
111 }113 }
112 if (arg4_name.length() > 0) {114 if (arg4_name.length() > 0) {
113 debug_item[arg4_name] = arg4_value;115 debug_item[arg4_name.c_str()] = arg4_value;
114 cout << ", " << arg4_name << "=" << arg4_value;116 cout << ", " << arg4_name << "=" << arg4_value;
115 }117 }
116 if (arg5_name.length() > 0) {118 if (arg5_name.length() > 0) {
117 debug_item[arg5_name] = arg5_value;119 debug_item[arg5_name.c_str()] = arg5_value;
118 cout << ", " << arg5_name << "=" << arg5_value;120 cout << ", " << arg5_name << "=" << arg5_value;
119 }121 }
120 if (arg6_name.length() > 0) {122 if (arg6_name.length() > 0) {
121 debug_item[arg6_name] = arg6_value;123 debug_item[arg6_name.c_str()] = arg6_value;
122 cout << ", " << arg6_name << "=" << arg6_value;124 cout << ", " << arg6_name << "=" << arg6_value;
123 }125 }
124126
@@ -126,7 +128,7 @@
126 cout << ")" << endl;128 cout << ")" << endl;
127129
128 // Append method to root array130 // Append method to root array
129 debug_root.append(debug_item);131 debug_root.append(QJsonValue(debug_item));
130}132}
131133
132// This method copy's the info struct of a reader, and sets the writer with the same info134// This method copy's the info struct of a reader, and sets the writer with the same info
@@ -208,53 +210,51 @@
208string WriterBase::Json() {210string WriterBase::Json() {
209211
210 // Return formatted string212 // Return formatted string
211 return JsonValue().toStyledString();213 QJsonDocument document;
214 document.setObject(JsonValue());
215 return document.toJson().constData();
212}216}
213217
214// Generate Json::JsonValue for this object218// Generate QJsonObject for this object
215Json::Value WriterBase::JsonValue() {219QJsonObject WriterBase::JsonValue() {
216220
217 // Create root json object221 // Create root json object
218 Json::Value root;222 QJsonObject root;
219 root["has_video"] = info.has_video;223 root["has_video"] = info.has_video;
220 root["has_audio"] = info.has_audio;224 root["has_audio"] = info.has_audio;
221 root["has_single_image"] = info.has_single_image;225 root["has_single_image"] = info.has_single_image;
222 root["duration"] = info.duration;226 root["duration"] = info.duration;
223 stringstream filesize_stream;227 root["file_size"] = info.file_size;
224 filesize_stream << info.file_size;
225 root["file_size"] = filesize_stream.str();
226 root["height"] = info.height;228 root["height"] = info.height;
227 root["width"] = info.width;229 root["width"] = info.width;
228 root["pixel_format"] = info.pixel_format;230 root["pixel_format"] = info.pixel_format;
229 root["fps"] = Json::Value(Json::objectValue);231 root["fps"] = QJsonObject();
230 root["fps"]["num"] = info.fps.num;232 root["fps"].toObject()["num"] = info.fps.num;
231 root["fps"]["den"] = info.fps.den;233 root["fps"].toObject()["den"] = info.fps.den;
232 root["video_bit_rate"] = info.video_bit_rate;234 root["video_bit_rate"] = info.video_bit_rate;
233 root["pixel_ratio"] = Json::Value(Json::objectValue);235 root["pixel_ratio"] = QJsonObject();
234 root["pixel_ratio"]["num"] = info.pixel_ratio.num;236 root["pixel_ratio"].toObject()["num"] = info.pixel_ratio.num;
235 root["pixel_ratio"]["den"] = info.pixel_ratio.den;237 root["pixel_ratio"].toObject()["den"] = info.pixel_ratio.den;
236 root["display_ratio"] = Json::Value(Json::objectValue);238 root["display_ratio"] = QJsonObject();
237 root["display_ratio"]["num"] = info.display_ratio.num;239 root["display_ratio"].toObject()["num"] = info.display_ratio.num;
238 root["display_ratio"]["den"] = info.display_ratio.den;240 root["display_ratio"].toObject()["den"] = info.display_ratio.den;
239 root["vcodec"] = info.vcodec;241 root["vcodec"] = info.vcodec.c_str();
240 stringstream video_length_stream;242 root["video_length"] = (long long) info.video_length;
241 video_length_stream << info.video_length;
242 root["video_length"] = video_length_stream.str();
243 root["video_stream_index"] = info.video_stream_index;243 root["video_stream_index"] = info.video_stream_index;
244 root["video_timebase"] = Json::Value(Json::objectValue);244 root["video_timebase"] = QJsonObject();
245 root["video_timebase"]["num"] = info.video_timebase.num;245 root["video_timebase"].toObject()["num"] = info.video_timebase.num;
246 root["video_timebase"]["den"] = info.video_timebase.den;246 root["video_timebase"].toObject()["den"] = info.video_timebase.den;
247 root["interlaced_frame"] = info.interlaced_frame;247 root["interlaced_frame"] = info.interlaced_frame;
248 root["top_field_first"] = info.top_field_first;248 root["top_field_first"] = info.top_field_first;
249 root["acodec"] = info.acodec;249 root["acodec"] = info.acodec.c_str();
250 root["audio_bit_rate"] = info.audio_bit_rate;250 root["audio_bit_rate"] = info.audio_bit_rate;
251 root["sample_rate"] = info.sample_rate;251 root["sample_rate"] = info.sample_rate;
252 root["channels"] = info.channels;252 root["channels"] = info.channels;
253 root["channel_layout"] = info.channel_layout;253 root["channel_layout"] = info.channel_layout;
254 root["audio_stream_index"] = info.audio_stream_index;254 root["audio_stream_index"] = info.audio_stream_index;
255 root["audio_timebase"] = Json::Value(Json::objectValue);255 root["audio_timebase"] = QJsonObject();
256 root["audio_timebase"]["num"] = info.audio_timebase.num;256 root["audio_timebase"].toObject()["num"] = info.audio_timebase.num;
257 root["audio_timebase"]["den"] = info.audio_timebase.den;257 root["audio_timebase"].toObject()["den"] = info.audio_timebase.den;
258258
259 // return JsonValue259 // return JsonValue
260 return root;260 return root;
@@ -264,12 +264,16 @@
264void WriterBase::SetJson(string value) throw(InvalidJSON) {264void WriterBase::SetJson(string value) throw(InvalidJSON) {
265265
266 // Parse JSON string into JSON objects266 // Parse JSON string into JSON objects
267 Json::Value root;267 QJsonObject root;
268 Json::Reader reader;268 QJsonParseError errors;
269 bool success = reader.parse( value, root );269
270 if (!success)270 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
271 if (errors.error != QJsonParseError::NoError) {
271 // Raise exception272 // Raise exception
272 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");273 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
274 }
275
276 root = document.object();
273277
274 try278 try
275 {279 {
@@ -284,78 +288,78 @@
284}288}
285289
286// Load Json::JsonValue into this object290// Load Json::JsonValue into this object
287void WriterBase::SetJsonValue(Json::Value root) {291void WriterBase::SetJsonValue(QJsonObject root) {
288292
289 // Set data from Json (if key is found)293 // Set data from Json (if key is found)
290 if (!root["has_video"].isNull())294 if (!root["has_video"].isNull())
291 info.has_video = root["has_video"].asBool();295 info.has_video = root["has_video"].toBool();
292 if (!root["has_audio"].isNull())296 if (!root["has_audio"].isNull())
293 info.has_audio = root["has_audio"].asBool();297 info.has_audio = root["has_audio"].toBool();
294 if (!root["has_single_image"].isNull())298 if (!root["has_single_image"].isNull())
295 info.has_single_image = root["has_single_image"].asBool();299 info.has_single_image = root["has_single_image"].toBool();
296 if (!root["duration"].isNull())300 if (!root["duration"].isNull())
297 info.duration = root["duration"].asDouble();301 info.duration = root["duration"].toDouble();
298 if (!root["file_size"].isNull())302 if (!root["file_size"].isNull())
299 info.file_size = (long long) root["file_size"].asUInt();303 info.file_size = root.value("file_size").toVariant().toLongLong();
300 if (!root["height"].isNull())304 if (!root["height"].isNull())
301 info.height = root["height"].asInt();305 info.height = root["height"].toInt();
302 if (!root["width"].isNull())306 if (!root["width"].isNull())
303 info.width = root["width"].asInt();307 info.width = root["width"].toInt();
304 if (!root["pixel_format"].isNull())308 if (!root["pixel_format"].isNull())
305 info.pixel_format = root["pixel_format"].asInt();309 info.pixel_format = root["pixel_format"].toInt();
306 if (!root["fps"].isNull() && root["fps"].isObject()) {310 if (!root["fps"].isNull() && root["fps"].isObject()) {
307 if (!root["fps"]["num"].isNull())311 if (!root["fps"].toObject()["num"].isNull())
308 info.fps.num = root["fps"]["num"].asInt();312 info.fps.num = root["fps"].toObject()["num"].toInt();
309 if (!root["fps"]["den"].isNull())313 if (!root["fps"].toObject()["den"].isNull())
310 info.fps.den = root["fps"]["den"].asInt();314 info.fps.den = root["fps"].toObject()["den"].toInt();
311 }315 }
312 if (!root["video_bit_rate"].isNull())316 if (!root["video_bit_rate"].isNull())
313 info.video_bit_rate = root["video_bit_rate"].asInt();317 info.video_bit_rate = root["video_bit_rate"].toInt();
314 if (!root["pixel_ratio"].isNull() && root["pixel_ratio"].isObject()) {318 if (!root["pixel_ratio"].isNull() && root["pixel_ratio"].isObject()) {
315 if (!root["pixel_ratio"]["num"].isNull())319 if (!root["pixel_ratio"].toObject()["num"].isNull())
316 info.pixel_ratio.num = root["pixel_ratio"]["num"].asInt();320 info.pixel_ratio.num = root["pixel_ratio"].toObject()["num"].toInt();
317 if (!root["pixel_ratio"]["den"].isNull())321 if (!root["pixel_ratio"].toObject()["den"].isNull())
318 info.pixel_ratio.den = root["pixel_ratio"]["den"].asInt();322 info.pixel_ratio.den = root["pixel_ratio"].toObject()["den"].toInt();
319 }323 }
320 if (!root["display_ratio"].isNull() && root["display_ratio"].isObject()) {324 if (!root["display_ratio"].isNull() && root["display_ratio"].isObject()) {
321 if (!root["display_ratio"]["num"].isNull())325 if (!root["display_ratio"].toObject()["num"].isNull())
322 info.display_ratio.num = root["display_ratio"]["num"].asInt();326 info.display_ratio.num = root["display_ratio"].toObject()["num"].toInt();
323 if (!root["display_ratio"]["den"].isNull())327 if (!root["display_ratio"].toObject()["den"].isNull())
324 info.display_ratio.den = root["display_ratio"]["den"].asInt();328 info.display_ratio.den = root["display_ratio"].toObject()["den"].toInt();
325 }329 }
326 if (!root["vcodec"].isNull())330 if (!root["vcodec"].isNull())
327 info.vcodec = root["vcodec"].asString();331 info.vcodec = root["vcodec"].toString().toLocal8Bit().constData();
328 if (!root["video_length"].isNull())332 if (!root["video_length"].isNull())
329 info.video_length = (long int) root["video_length"].asUInt();333 info.video_length = root.value("video_length").toVariant().toLongLong();
330 if (!root["video_stream_index"].isNull())334 if (!root["video_stream_index"].isNull())
331 info.video_stream_index = root["video_stream_index"].asInt();335 info.video_stream_index = root["video_stream_index"].toInt();
332 if (!root["video_timebase"].isNull() && root["video_timebase"].isObject()) {336 if (!root["video_timebase"].isNull() && root["video_timebase"].isObject()) {
333 if (!root["video_timebase"]["num"].isNull())337 if (!root["video_timebase"].toObject()["num"].isNull())
334 info.video_timebase.num = root["video_timebase"]["num"].asInt();338 info.video_timebase.num = root["video_timebase"].toObject()["num"].toInt();
335 if (!root["video_timebase"]["den"].isNull())339 if (!root["video_timebase"].toObject()["den"].isNull())
336 info.video_timebase.den = root["video_timebase"]["den"].asInt();340 info.video_timebase.den = root["video_timebase"].toObject()["den"].toInt();
337 }341 }
338 if (!root["interlaced_frame"].isNull())342 if (!root["interlaced_frame"].isNull())
339 info.interlaced_frame = root["interlaced_frame"].asBool();343 info.interlaced_frame = root["interlaced_frame"].toBool();
340 if (!root["top_field_first"].isNull())344 if (!root["top_field_first"].isNull())
341 info.top_field_first = root["top_field_first"].asBool();345 info.top_field_first = root["top_field_first"].toBool();
342 if (!root["acodec"].isNull())346 if (!root["acodec"].isNull())
343 info.acodec = root["acodec"].asString();347 info.acodec = root["acodec"].toString().toLocal8Bit().constData();
344348
345 if (!root["audio_bit_rate"].isNull())349 if (!root["audio_bit_rate"].isNull())
346 info.audio_bit_rate = root["audio_bit_rate"].asInt();350 info.audio_bit_rate = root["audio_bit_rate"].toInt();
347 if (!root["sample_rate"].isNull())351 if (!root["sample_rate"].isNull())
348 info.sample_rate = root["sample_rate"].asInt();352 info.sample_rate = root["sample_rate"].toInt();
349 if (!root["channels"].isNull())353 if (!root["channels"].isNull())
350 info.channels = root["channels"].asInt();354 info.channels = root["channels"].toInt();
351 if (!root["channel_layout"].isNull())355 if (!root["channel_layout"].isNull())
352 info.channel_layout = (ChannelLayout) root["channel_layout"].asInt();356 info.channel_layout = (ChannelLayout) root["channel_layout"].toInt();
353 if (!root["audio_stream_index"].isNull())357 if (!root["audio_stream_index"].isNull())
354 info.audio_stream_index = root["audio_stream_index"].asInt();358 info.audio_stream_index = root["audio_stream_index"].toInt();
355 if (!root["audio_timebase"].isNull() && root["audio_timebase"].isObject()) {359 if (!root["audio_timebase"].isNull() && root["audio_timebase"].isObject()) {
356 if (!root["audio_timebase"]["num"].isNull())360 if (!root["audio_timebase"].toObject()["num"].isNull())
357 info.audio_timebase.num = root["audio_timebase"]["num"].asInt();361 info.audio_timebase.num = root["audio_timebase"].toObject()["num"].toInt();
358 if (!root["audio_timebase"]["den"].isNull())362 if (!root["audio_timebase"].toObject()["den"].isNull())
359 info.audio_timebase.den = root["audio_timebase"]["den"].asInt();363 info.audio_timebase.den = root["audio_timebase"].toObject()["den"].toInt();
360 }364 }
361}365}
362366
=== modified file 'src/effects/Brightness.cpp'
--- src/effects/Brightness.cpp 2015-10-02 23:22:10 +0000
+++ src/effects/Brightness.cpp 2015-10-04 15:21:00 +0000
@@ -117,19 +117,21 @@
117string Brightness::Json() {117string Brightness::Json() {
118118
119 // Return formatted string119 // Return formatted string
120 return JsonValue().toStyledString();120 QJsonDocument document;
121 document.setObject(JsonValue());
122 return document.toJson().constData();
121}123}
122124
123// Generate Json::JsonValue for this object125// Generate QJsonObject for this object
124Json::Value Brightness::JsonValue() {126QJsonObject Brightness::JsonValue() {
125127
126 // Create root json object128 // Create root json object
127 Json::Value root = EffectBase::JsonValue(); // get parent properties129 QJsonObject root = EffectBase::JsonValue(); // get parent properties
128 root["type"] = info.class_name;130 root["type"] = info.class_name.c_str();
129 root["brightness"] = brightness.JsonValue();131 root["brightness"] = brightness.JsonValue();
130 root["contrast"] = contrast.JsonValue();132 root["contrast"] = contrast.JsonValue();
131133
132 // return JsonValue134 // return QJsonObject
133 return root;135 return root;
134}136}
135137
@@ -137,12 +139,16 @@
137void Brightness::SetJson(string value) throw(InvalidJSON) {139void Brightness::SetJson(string value) throw(InvalidJSON) {
138140
139 // Parse JSON string into JSON objects141 // Parse JSON string into JSON objects
140 Json::Value root;142 QJsonObject root;
141 Json::Reader reader;143 QJsonParseError errors;
142 bool success = reader.parse( value, root );144
143 if (!success)145 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
144 // Raise exception146 if (errors.error != QJsonParseError::NoError) {
145 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");147 // Raise exception
148 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
149 }
150
151 root = document.object();
146152
147 try153 try
148 {154 {
@@ -156,17 +162,17 @@
156 }162 }
157}163}
158164
159// Load Json::JsonValue into this object165// Load QJsonObject into this object
160void Brightness::SetJsonValue(Json::Value root) {166void Brightness::SetJsonValue(QJsonObject root) {
161167
162 // Set parent data168 // Set parent data
163 EffectBase::SetJsonValue(root);169 EffectBase::SetJsonValue(root);
164170
165 // Set data from Json (if key is found)171 // Set data from Json (if key is found)
166 if (!root["brightness"].isNull())172 if (!root["brightness"].isNull())
167 brightness.SetJsonValue(root["brightness"]);173 brightness.SetJsonValue(root["brightness"].toObject());
168 if (!root["contrast"].isNull())174 if (!root["contrast"].isNull())
169 contrast.SetJsonValue(root["contrast"]);175 contrast.SetJsonValue(root["contrast"].toObject());
170}176}
171177
172// Get all properties for a specific frame178// Get all properties for a specific frame
@@ -176,7 +182,7 @@
176 Point requested_point(requested_frame, requested_frame);182 Point requested_point(requested_frame, requested_frame);
177183
178 // Generate JSON properties list184 // Generate JSON properties list
179 Json::Value root;185 QJsonObject root;
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);
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);
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);
@@ -189,6 +195,8 @@
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);
190196
191 // Return formatted string197 // Return formatted string
192 return root.toStyledString();198 QJsonDocument document;
199 document.setObject(root);
200 return document.toJson().constData();
193}201}
194202
195203
=== modified file 'src/effects/ChromaKey.cpp'
--- src/effects/ChromaKey.cpp 2015-10-02 23:22:10 +0000
+++ src/effects/ChromaKey.cpp 2015-10-04 15:21:00 +0000
@@ -101,15 +101,17 @@
101string ChromaKey::Json() {101string ChromaKey::Json() {
102102
103 // Return formatted string103 // Return formatted string
104 return JsonValue().toStyledString();104 QJsonDocument document;
105 document.setObject(JsonValue());
106 return document.toJson().constData();
105}107}
106108
107// Generate Json::JsonValue for this object109// Generate Json::JsonValue for this object
108Json::Value ChromaKey::JsonValue() {110QJsonObject ChromaKey::JsonValue() {
109111
110 // Create root json object112 // Create root json object
111 Json::Value root = EffectBase::JsonValue(); // get parent properties113 QJsonObject root = EffectBase::JsonValue(); // get parent properties
112 root["type"] = info.class_name;114 root["type"] = info.class_name.c_str();
113 root["color"] = color.JsonValue();115 root["color"] = color.JsonValue();
114 root["fuzz"] = fuzz.JsonValue();116 root["fuzz"] = fuzz.JsonValue();
115117
@@ -121,12 +123,16 @@
121void ChromaKey::SetJson(string value) throw(InvalidJSON) {123void ChromaKey::SetJson(string value) throw(InvalidJSON) {
122124
123 // Parse JSON string into JSON objects125 // Parse JSON string into JSON objects
124 Json::Value root;126 QJsonObject root;
125 Json::Reader reader;127 QJsonParseError errors;
126 bool success = reader.parse( value, root );128
127 if (!success)129 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
130 if (errors.error != QJsonParseError::NoError) {
128 // Raise exception131 // Raise exception
129 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");132 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
133 }
134
135 root = document.object();
130136
131 try137 try
132 {138 {
@@ -140,17 +146,17 @@
140 }146 }
141}147}
142148
143// Load Json::JsonValue into this object149// Load QJsonObject into this object
144void ChromaKey::SetJsonValue(Json::Value root) {150void ChromaKey::SetJsonValue(QJsonObject root) {
145151
146 // Set parent data152 // Set parent data
147 EffectBase::SetJsonValue(root);153 EffectBase::SetJsonValue(root);
148154
149 // Set data from Json (if key is found)155 // Set data from Json (if key is found)
150 if (!root["color"].isNull())156 if (!root["color"].isNull())
151 color.SetJsonValue(root["color"]);157 color.SetJsonValue(root["color"].toObject());
152 if (!root["fuzz"].isNull())158 if (!root["fuzz"].isNull())
153 fuzz.SetJsonValue(root["fuzz"]);159 fuzz.SetJsonValue(root["fuzz"].toObject());
154}160}
155161
156// Get all properties for a specific frame162// Get all properties for a specific frame
@@ -160,7 +166,7 @@
160 Point requested_point(requested_frame, requested_frame);166 Point requested_point(requested_frame, requested_frame);
161167
162 // Generate JSON properties list168 // Generate JSON properties list
163 Json::Value root;169 QJsonObject root;
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);
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);
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);
@@ -170,11 +176,13 @@
170176
171 // Keyframes177 // Keyframes
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);
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);
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);
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);
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);
177183
178 // Return formatted string184 // Return formatted string
179 return root.toStyledString();185 QJsonDocument document;
186 document.setObject(root);
187 return document.toJson().constData();
180}188}
181189
=== modified file 'src/effects/Deinterlace.cpp'
--- src/effects/Deinterlace.cpp 2015-10-02 23:22:10 +0000
+++ src/effects/Deinterlace.cpp 2015-10-04 15:21:00 +0000
@@ -96,15 +96,17 @@
96string Deinterlace::Json() {96string Deinterlace::Json() {
9797
98 // Return formatted string98 // Return formatted string
99 return JsonValue().toStyledString();99 QJsonDocument document;
100 document.setObject(JsonValue());
101 return document.toJson().constData();
100}102}
101103
102// Generate Json::JsonValue for this object104// Generate Json::JsonValue for this object
103Json::Value Deinterlace::JsonValue() {105QJsonObject Deinterlace::JsonValue() {
104106
105 // Create root json object107 // Create root json object
106 Json::Value root = EffectBase::JsonValue(); // get parent properties108 QJsonObject root = EffectBase::JsonValue(); // get parent properties
107 root["type"] = info.class_name;109 root["type"] = info.class_name.c_str();
108 root["isOdd"] = isOdd;110 root["isOdd"] = isOdd;
109111
110 // return JsonValue112 // return JsonValue
@@ -115,12 +117,16 @@
115void Deinterlace::SetJson(string value) throw(InvalidJSON) {117void Deinterlace::SetJson(string value) throw(InvalidJSON) {
116118
117 // Parse JSON string into JSON objects119 // Parse JSON string into JSON objects
118 Json::Value root;120 QJsonObject root;
119 Json::Reader reader;121 QJsonParseError errors;
120 bool success = reader.parse( value, root );122
121 if (!success)123 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
124 if (errors.error != QJsonParseError::NoError) {
122 // Raise exception125 // Raise exception
123 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");126 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
127 }
128
129 root = document.object();
124130
125 try131 try
126 {132 {
@@ -134,15 +140,15 @@
134 }140 }
135}141}
136142
137// Load Json::JsonValue into this object143// Load QJsonObject into this object
138void Deinterlace::SetJsonValue(Json::Value root) {144void Deinterlace::SetJsonValue(QJsonObject root) {
139145
140 // Set parent data146 // Set parent data
141 EffectBase::SetJsonValue(root);147 EffectBase::SetJsonValue(root);
142148
143 // Set data from Json (if key is found)149 // Set data from Json (if key is found)
144 if (!root["isOdd"].isNull())150 if (!root["isOdd"].isNull())
145 isOdd = root["isOdd"].asBool();151 isOdd = root["isOdd"].toBool();
146}152}
147153
148// Get all properties for a specific frame154// Get all properties for a specific frame
@@ -152,7 +158,7 @@
152 Point requested_point(requested_frame, requested_frame);158 Point requested_point(requested_frame, requested_frame);
153159
154 // Generate JSON properties list160 // Generate JSON properties list
155 Json::Value root;161 QJsonObject root;
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);
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);
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);
@@ -162,9 +168,11 @@
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);
163169
164 // Add Is Odd Frame choices (dropdown style)170 // Add Is Odd Frame choices (dropdown style)
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));
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));
167173
168 // Return formatted string174 // Return formatted string
169 return root.toStyledString();175 QJsonDocument document;
176 document.setObject(root);
177 return document.toJson().constData();
170}178}
171179
=== modified file 'src/effects/Mask.cpp'
--- src/effects/Mask.cpp 2015-10-02 23:22:10 +0000
+++ src/effects/Mask.cpp 2015-10-04 15:21:00 +0000
@@ -159,21 +159,23 @@
159string Mask::Json() {159string Mask::Json() {
160160
161 // Return formatted string161 // Return formatted string
162 return JsonValue().toStyledString();162 QJsonDocument document;
163 document.setObject(JsonValue());
164 return document.toJson().constData();
163}165}
164166
165// Generate Json::JsonValue for this object167// Generate Json::JsonValue for this object
166Json::Value Mask::JsonValue() {168QJsonObject Mask::JsonValue() {
167169
168 // Create root json object170 // Create root json object
169 Json::Value root = EffectBase::JsonValue(); // get parent properties171 QJsonObject root = EffectBase::JsonValue(); // get parent properties
170 root["type"] = info.class_name;172 root["type"] = info.class_name.c_str();
171 root["brightness"] = brightness.JsonValue();173 root["brightness"] = brightness.JsonValue();
172 root["contrast"] = contrast.JsonValue();174 root["contrast"] = contrast.JsonValue();
173 if (reader)175 if (reader)
174 root["reader"] = reader->JsonValue();176 root["reader"] = reader->JsonValue();
175 else177 else
176 root["reader"] = Json::objectValue;178 root["reader"] = QJsonObject();
177 root["replace_image"] = replace_image;179 root["replace_image"] = replace_image;
178180
179 // return JsonValue181 // return JsonValue
@@ -184,12 +186,16 @@
184void Mask::SetJson(string value) throw(InvalidJSON) {186void Mask::SetJson(string value) throw(InvalidJSON) {
185187
186 // Parse JSON string into JSON objects188 // Parse JSON string into JSON objects
187 Json::Value root;189 QJsonObject root;
188 Json::Reader reader;190 QJsonParseError errors;
189 bool success = reader.parse( value, root );191
190 if (!success)192 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
193 if (errors.error != QJsonParseError::NoError) {
191 // Raise exception194 // Raise exception
192 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");195 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
196 }
197
198 root = document.object();
193199
194 try200 try
195 {201 {
@@ -204,22 +210,22 @@
204}210}
205211
206// Load Json::JsonValue into this object212// Load Json::JsonValue into this object
207void Mask::SetJsonValue(Json::Value root) {213void Mask::SetJsonValue(QJsonObject root) {
208214
209 // Set parent data215 // Set parent data
210 EffectBase::SetJsonValue(root);216 EffectBase::SetJsonValue(root);
211217
212 // Set data from Json (if key is found)218 // Set data from Json (if key is found)
213 if (!root["replace_image"].isNull())219 if (!root["replace_image"].isNull())
214 replace_image = root["replace_image"].asBool();220 replace_image = root["replace_image"].toBool();
215 if (!root["brightness"].isNull())221 if (!root["brightness"].isNull())
216 brightness.SetJsonValue(root["brightness"]);222 brightness.SetJsonValue(root["brightness"].toObject());
217 if (!root["contrast"].isNull())223 if (!root["contrast"].isNull())
218 contrast.SetJsonValue(root["contrast"]);224 contrast.SetJsonValue(root["contrast"].toObject());
219 if (!root["reader"].isNull()) // does Json contain a reader?225 if (!root["reader"].isNull()) // does Json contain a reader?
220 {226 {
221227
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'?
223 {229 {
224 // Close previous reader (if any)230 // Close previous reader (if any)
225 if (reader)231 if (reader)
@@ -231,31 +237,31 @@
231 }237 }
232238
233 // Create new reader (and load properties)239 // Create new reader (and load properties)
234 string type = root["reader"]["type"].asString();240 string type = root["reader"].toObject()["type"].toString().toLocal8Bit().constData();
235241
236 if (type == "FFmpegReader") {242 if (type == "FFmpegReader") {
237243
238 // Create new reader244 // Create new reader
239 reader = new FFmpegReader(root["reader"]["path"].asString());245 reader = new FFmpegReader(root["reader"].toObject()["path"].toString().toLocal8Bit().constData());
240 reader->SetJsonValue(root["reader"]);246 reader->SetJsonValue(root["reader"].toObject());
241247
242 } else if (type == "ImageReader") {248 } else if (type == "ImageReader") {
243249
244 // Create new reader250 // Create new reader
245 reader = new ImageReader(root["reader"]["path"].asString());251 reader = new ImageReader(root["reader"].toObject()["path"].toString().toLocal8Bit().constData());
246 reader->SetJsonValue(root["reader"]);252 reader->SetJsonValue(root["reader"].toObject());
247253
248 } else if (type == "QtImageReader") {254 } else if (type == "QtImageReader") {
249255
250 // Create new reader256 // Create new reader
251 reader = new QtImageReader(root["reader"]["path"].asString());257 reader = new QtImageReader(root["reader"].toObject()["path"].toString().toLocal8Bit().constData());
252 reader->SetJsonValue(root["reader"]);258 reader->SetJsonValue(root["reader"].toObject());
253259
254 } else if (type == "ChunkReader") {260 } else if (type == "ChunkReader") {
255261
256 // Create new reader262 // Create new reader
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());
258 reader->SetJsonValue(root["reader"]);264 reader->SetJsonValue(root["reader"].toObject());
259265
260 }266 }
261267
@@ -271,7 +277,7 @@
271 Point requested_point(requested_frame, requested_frame);277 Point requested_point(requested_frame, requested_frame);
272278
273 // Generate JSON properties list279 // Generate JSON properties list
274 Json::Value root;280 QJsonObject root;
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);
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);
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);
@@ -281,14 +287,16 @@
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);
282288
283 // Add replace_image choices (dropdown style)289 // Add replace_image choices (dropdown style)
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));
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));
286292
287 // Keyframes293 // Keyframes
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);
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);
290296
291 // Return formatted string297 // Return formatted string
292 return root.toStyledString();298 QJsonDocument document;
299 document.setObject(root);
300 return document.toJson().constData();
293}301}
294302
295303
=== modified file 'src/effects/Negate.cpp'
--- src/effects/Negate.cpp 2015-08-24 06:05:48 +0000
+++ src/effects/Negate.cpp 2015-10-04 15:21:00 +0000
@@ -58,15 +58,17 @@
58string Negate::Json() {58string Negate::Json() {
5959
60 // Return formatted string60 // Return formatted string
61 return JsonValue().toStyledString();61 QJsonDocument document;
62 document.setObject(JsonValue());
63 return document.toJson().constData();
62}64}
6365
64// Generate Json::JsonValue for this object66// Generate Json::JsonValue for this object
65Json::Value Negate::JsonValue() {67QJsonObject Negate::JsonValue() {
6668
67 // Create root json object69 // Create root json object
68 Json::Value root = EffectBase::JsonValue(); // get parent properties70 QJsonObject root = EffectBase::JsonValue(); // get parent properties
69 root["type"] = info.class_name;71 root["type"] = info.class_name.c_str();
7072
71 // return JsonValue73 // return JsonValue
72 return root;74 return root;
@@ -76,12 +78,16 @@
76void Negate::SetJson(string value) throw(InvalidJSON) {78void Negate::SetJson(string value) throw(InvalidJSON) {
7779
78 // Parse JSON string into JSON objects80 // Parse JSON string into JSON objects
79 Json::Value root;81 QJsonObject root;
80 Json::Reader reader;82 QJsonParseError errors;
81 bool success = reader.parse( value, root );83
82 if (!success)84 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
85 if (errors.error != QJsonParseError::NoError) {
83 // Raise exception86 // Raise exception
84 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");87 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
88 }
89
90 root = document.object();
8591
86 try92 try
87 {93 {
@@ -95,8 +101,8 @@
95 }101 }
96}102}
97103
98// Load Json::JsonValue into this object104// Load QJsonObject into this object
99void Negate::SetJsonValue(Json::Value root) {105void Negate::SetJsonValue(QJsonObject root) {
100106
101 // Set parent data107 // Set parent data
102 EffectBase::SetJsonValue(root);108 EffectBase::SetJsonValue(root);
@@ -110,7 +116,7 @@
110 Point requested_point(requested_frame, requested_frame);116 Point requested_point(requested_frame, requested_frame);
111117
112 // Generate JSON properties list118 // Generate JSON properties list
113 Json::Value root;119 QJsonObject root;
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);
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);
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);
@@ -119,5 +125,7 @@
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);
120126
121 // Return formatted string127 // Return formatted string
122 return root.toStyledString();128 QJsonDocument document;
129 document.setObject(root);
130 return document.toJson().constData();
123}131}
124132
=== modified file 'src/effects/Saturation.cpp'
--- src/effects/Saturation.cpp 2015-10-02 23:22:10 +0000
+++ src/effects/Saturation.cpp 2015-10-04 15:21:00 +0000
@@ -120,15 +120,17 @@
120string Saturation::Json() {120string Saturation::Json() {
121121
122 // Return formatted string122 // Return formatted string
123 return JsonValue().toStyledString();123 QJsonDocument document;
124 document.setObject(JsonValue());
125 return document.toJson().constData();
124}126}
125127
126// Generate Json::JsonValue for this object128// Generate Json::JsonValue for this object
127Json::Value Saturation::JsonValue() {129QJsonObject Saturation::JsonValue() {
128130
129 // Create root json object131 // Create root json object
130 Json::Value root = EffectBase::JsonValue(); // get parent properties132 QJsonObject root = EffectBase::JsonValue(); // get parent properties
131 root["type"] = info.class_name;133 root["type"] = info.class_name.c_str();
132 root["saturation"] = saturation.JsonValue();134 root["saturation"] = saturation.JsonValue();
133135
134 // return JsonValue136 // return JsonValue
@@ -139,12 +141,16 @@
139void Saturation::SetJson(string value) throw(InvalidJSON) {141void Saturation::SetJson(string value) throw(InvalidJSON) {
140142
141 // Parse JSON string into JSON objects143 // Parse JSON string into JSON objects
142 Json::Value root;144 QJsonObject root;
143 Json::Reader reader;145 QJsonParseError errors;
144 bool success = reader.parse( value, root );146
145 if (!success)147 QJsonDocument document = QJsonDocument::fromJson(QByteArray(value.c_str()), &errors);
146 // Raise exception148 if (errors.error != QJsonParseError::NoError) {
147 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");149 // Raise exception
150 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
151 }
152
153 root = document.object();
148154
149 try155 try
150 {156 {
@@ -159,14 +165,14 @@
159}165}
160166
161// Load Json::JsonValue into this object167// Load Json::JsonValue into this object
162void Saturation::SetJsonValue(Json::Value root) {168void Saturation::SetJsonValue(QJsonObject root) {
163169
164 // Set parent data170 // Set parent data
165 EffectBase::SetJsonValue(root);171 EffectBase::SetJsonValue(root);
166172
167 // Set data from Json (if key is found)173 // Set data from Json (if key is found)
168 if (!root["saturation"].isNull())174 if (!root["saturation"].isNull())
169 saturation.SetJsonValue(root["saturation"]);175 saturation.SetJsonValue(root["saturation"].toObject());
170}176}
171177
172// Get all properties for a specific frame178// Get all properties for a specific frame
@@ -176,7 +182,7 @@
176 Point requested_point(requested_frame, requested_frame);182 Point requested_point(requested_frame, requested_frame);
177183
178 // Generate JSON properties list184 // Generate JSON properties list
179 Json::Value root;185 QJsonObject root;
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);
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);
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);
@@ -188,6 +194,8 @@
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);
189195
190 // Return formatted string196 // Return formatted string
191 return root.toStyledString();197 QJsonDocument document;
198 document.setObject(root);
199 return document.toJson().constData();
192}200}
193201
194202
=== modified file 'tests/Clip_Tests.cpp'
--- tests/Clip_Tests.cpp 2015-09-29 03:17:29 +0000
+++ tests/Clip_Tests.cpp 2015-10-04 15:21:00 +0000
@@ -109,18 +109,19 @@
109 string properties = c1.PropertiesJSON(1);109 string properties = c1.PropertiesJSON(1);
110110
111 // Parse JSON string into JSON objects111 // Parse JSON string into JSON objects
112 Json::Value root;112 QJsonParseError error;
113 Json::Reader reader;113 QJsonDocument rootDocument = QJsonDocument::fromJson(properties.c_str(), &error);
114 bool success = reader.parse( properties, root );114 if (error.error != QJsonParseError::NoError)
115 if (!success)
116 // Raise exception115 // Raise exception
117 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");116 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
118117
118 QJsonObject root = rootDocument.object();
119
119 try120 try
120 {121 {
121 // Check for specific things122 // Check for specific things
122 CHECK_CLOSE(1.0f, root["alpha"]["value"].asDouble(), 0.01);123 CHECK_CLOSE(1.0f, root["alpha"].toObject()["value"].toDouble(), 0.01);
123 CHECK_EQUAL(true, root["alpha"]["keyframe"].asBool());124 CHECK_EQUAL(true, root["alpha"].toObject()["keyframe"].toBool());
124125
125 }126 }
126 catch (exception e)127 catch (exception e)
@@ -134,17 +135,18 @@
134 properties = c1.PropertiesJSON(250);135 properties = c1.PropertiesJSON(250);
135136
136 // Parse JSON string into JSON objects137 // Parse JSON string into JSON objects
137 root.clear();138 rootDocument = QJsonDocument::fromJson(properties.c_str(), &error);
138 success = reader.parse( properties, root );139 if (error.error != QJsonParseError::NoError)
139 if (!success)
140 // Raise exception140 // Raise exception
141 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");141 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
142142
143 root = rootDocument.object();
144
143 try145 try
144 {146 {
145 // Check for specific things147 // Check for specific things
146 CHECK_CLOSE(0.5f, root["alpha"]["value"].asDouble(), 0.01);148 CHECK_CLOSE(0.5f, root["alpha"].toObject()["value"].toDouble(), 0.01);
147 CHECK_EQUAL(false, root["alpha"]["keyframe"].asBool());149 CHECK_EQUAL(false, root["alpha"].toObject()["keyframe"].toBool());
148150
149 }151 }
150 catch (exception e)152 catch (exception e)
@@ -158,16 +160,17 @@
158 properties = c1.PropertiesJSON(250); // again160 properties = c1.PropertiesJSON(250); // again
159161
160 // Parse JSON string into JSON objects162 // Parse JSON string into JSON objects
161 root.clear();163 rootDocument = QJsonDocument::fromJson(properties.c_str(), &error);
162 success = reader.parse( properties, root );164 if (error.error != QJsonParseError::NoError)
163 if (!success)
164 // Raise exception165 // Raise exception
165 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");166 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
166167
168 root = rootDocument.object();
169
167 try170 try
168 {171 {
169 // Check for specific things172 // Check for specific things
170 CHECK_EQUAL(false, root["alpha"]["keyframe"].asBool());173 CHECK_EQUAL(false, root["alpha"].toObject()["keyframe"].toBool());
171174
172 }175 }
173 catch (exception e)176 catch (exception e)
@@ -181,17 +184,18 @@
181 properties = c1.PropertiesJSON(500);184 properties = c1.PropertiesJSON(500);
182185
183 // Parse JSON string into JSON objects186 // Parse JSON string into JSON objects
184 root.clear();187 rootDocument = QJsonDocument::fromJson(properties.c_str(), &error);
185 success = reader.parse( properties, root );188 if (error.error != QJsonParseError::NoError)
186 if (!success)
187 // Raise exception189 // Raise exception
188 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");190 throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
189191
192 root = rootDocument.object();
193
190 try194 try
191 {195 {
192 // Check for specific things196 // Check for specific things
193 CHECK_CLOSE(0.0f, root["alpha"]["value"].asDouble(), 0.00001);197 CHECK_CLOSE(0.0f, root["alpha"].toObject()["value"].toDouble(), 0.00001);
194 CHECK_EQUAL(true, root["alpha"]["keyframe"].asBool());198 CHECK_EQUAL(true, root["alpha"].toObject()["keyframe"].toBool());
195199
196 }200 }
197 catch (exception e)201 catch (exception e)
198202
=== modified file 'tests/ReaderBase_Tests.cpp'
--- tests/ReaderBase_Tests.cpp 2015-08-24 06:05:48 +0000
+++ tests/ReaderBase_Tests.cpp 2015-10-04 15:21:00 +0000
@@ -46,8 +46,8 @@
46 void Open() { };46 void Open() { };
47 string Json() { };47 string Json() { };
48 void SetJson(string value) throw(InvalidJSON) { };48 void SetJson(string value) throw(InvalidJSON) { };
49 Json::Value JsonValue() { };49 QJsonObject JsonValue() { };
50 void SetJsonValue(Json::Value root) { };50 void SetJsonValue(QJsonObject root) { };
51 bool IsOpen() { return true; };51 bool IsOpen() { return true; };
52 };52 };
5353
5454
=== removed directory 'thirdparty'
=== removed directory 'thirdparty/jsoncpp'
=== removed file 'thirdparty/jsoncpp/LICENSE'
--- thirdparty/jsoncpp/LICENSE 2013-08-01 18:45:09 +0000
+++ thirdparty/jsoncpp/LICENSE 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1The json-cpp library and this documentation are in Public Domain.
20
=== removed directory 'thirdparty/jsoncpp/include'
=== removed directory 'thirdparty/jsoncpp/include/json'
=== removed file 'thirdparty/jsoncpp/include/json/autolink.h'
--- thirdparty/jsoncpp/include/json/autolink.h 2013-07-31 21:18:54 +0000
+++ thirdparty/jsoncpp/include/json/autolink.h 1970-01-01 00:00:00 +0000
@@ -1,19 +0,0 @@
1#ifndef JSON_AUTOLINK_H_INCLUDED
2# define JSON_AUTOLINK_H_INCLUDED
3
4# include "config.h"
5
6# ifdef JSON_IN_CPPTL
7# include <cpptl/cpptl_autolink.h>
8# endif
9
10# if !defined(JSON_NO_AUTOLINK) && !defined(JSON_DLL_BUILD) && !defined(JSON_IN_CPPTL)
11# define CPPTL_AUTOLINK_NAME "json"
12# undef CPPTL_AUTOLINK_DLL
13# ifdef JSON_DLL
14# define CPPTL_AUTOLINK_DLL
15# endif
16# include "autolink.h"
17# endif
18
19#endif // JSON_AUTOLINK_H_INCLUDED
200
=== removed file 'thirdparty/jsoncpp/include/json/config.h'
--- thirdparty/jsoncpp/include/json/config.h 2013-07-31 21:18:54 +0000
+++ thirdparty/jsoncpp/include/json/config.h 1970-01-01 00:00:00 +0000
@@ -1,43 +0,0 @@
1#ifndef JSON_CONFIG_H_INCLUDED
2# define JSON_CONFIG_H_INCLUDED
3
4/// If defined, indicates that json library is embedded in CppTL library.
5//# define JSON_IN_CPPTL 1
6
7/// If defined, indicates that json may leverage CppTL library
8//# define JSON_USE_CPPTL 1
9/// If defined, indicates that cpptl vector based map should be used instead of std::map
10/// as Value container.
11//# define JSON_USE_CPPTL_SMALLMAP 1
12/// If defined, indicates that Json specific container should be used
13/// (hash table & simple deque container with customizable allocator).
14/// THIS FEATURE IS STILL EXPERIMENTAL!
15//# define JSON_VALUE_USE_INTERNAL_MAP 1
16/// Force usage of standard new/malloc based allocator instead of memory pool based allocator.
17/// The memory pools allocator used optimization (initializing Value and ValueInternalLink
18/// as if it was a POD) that may cause some validation tool to report errors.
19/// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined.
20//# define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1
21
22/// If defined, indicates that Json use exception to report invalid type manipulation
23/// instead of C assert macro.
24# define JSON_USE_EXCEPTION 1
25
26# ifdef JSON_IN_CPPTL
27# include <cpptl/config.h>
28# ifndef JSON_USE_CPPTL
29# define JSON_USE_CPPTL 1
30# endif
31# endif
32
33# ifdef JSON_IN_CPPTL
34# define JSON_API CPPTL_API
35# elif defined(JSON_DLL_BUILD)
36# define JSON_API __declspec(dllexport)
37# elif defined(JSON_DLL)
38# define JSON_API __declspec(dllimport)
39# else
40# define JSON_API
41# endif
42
43#endif // JSON_CONFIG_H_INCLUDED
440
=== removed file 'thirdparty/jsoncpp/include/json/features.h'
--- thirdparty/jsoncpp/include/json/features.h 2013-09-10 04:32:16 +0000
+++ thirdparty/jsoncpp/include/json/features.h 1970-01-01 00:00:00 +0000
@@ -1,42 +0,0 @@
1#ifndef CPPTL_JSON_FEATURES_H_INCLUDED
2# define CPPTL_JSON_FEATURES_H_INCLUDED
3
4# include "forwards.h"
5
6namespace Json {
7
8 /** @brief Configuration passed to reader and writer.
9 * This configuration object can be used to force the Reader or Writer
10 * to behave in a standard conforming way.
11 */
12 class JSON_API Features
13 {
14 public:
15 /** @brief A configuration that allows all features and assumes all strings are UTF-8.
16 * - C & C++ comments are allowed
17 * - Root object can be any JSON value
18 * - Assumes Value strings are encoded in UTF-8
19 */
20 static Features all();
21
22 /** @brief A configuration that is strictly compatible with the JSON specification.
23 * - Comments are forbidden.
24 * - Root object must be either an array or an object value.
25 * - Assumes Value strings are encoded in UTF-8
26 */
27 static Features strictMode();
28
29 /** @brief Initialize the configuration like JsonConfig::allFeatures;
30 */
31 Features();
32
33 /// \c true if comments are allowed. Default: \c true.
34 bool allowComments_;
35
36 /// \c true if root must be either an array or an object value. Default: \c false.
37 bool strictRoot_;
38 };
39
40} // namespace Json
41
42#endif // CPPTL_JSON_FEATURES_H_INCLUDED
430
=== removed file 'thirdparty/jsoncpp/include/json/forwards.h'
--- thirdparty/jsoncpp/include/json/forwards.h 2013-07-31 21:18:54 +0000
+++ thirdparty/jsoncpp/include/json/forwards.h 1970-01-01 00:00:00 +0000
@@ -1,39 +0,0 @@
1#ifndef JSON_FORWARDS_H_INCLUDED
2# define JSON_FORWARDS_H_INCLUDED
3
4# include "config.h"
5
6namespace Json {
7
8 // writer.h
9 class FastWriter;
10 class StyledWriter;
11
12 // reader.h
13 class Reader;
14
15 // features.h
16 class Features;
17
18 // value.h
19 typedef int Int;
20 typedef unsigned int UInt;
21 class StaticString;
22 class Path;
23 class PathArgument;
24 class Value;
25 class ValueIteratorBase;
26 class ValueIterator;
27 class ValueConstIterator;
28#ifdef JSON_VALUE_USE_INTERNAL_MAP
29 class ValueAllocator;
30 class ValueMapAllocator;
31 class ValueInternalLink;
32 class ValueInternalArray;
33 class ValueInternalMap;
34#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP
35
36} // namespace Json
37
38
39#endif // JSON_FORWARDS_H_INCLUDED
400
=== removed file 'thirdparty/jsoncpp/include/json/json.h'
--- thirdparty/jsoncpp/include/json/json.h 2013-07-31 21:18:54 +0000
+++ thirdparty/jsoncpp/include/json/json.h 1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
1#ifndef JSON_JSON_H_INCLUDED
2# define JSON_JSON_H_INCLUDED
3
4# include "autolink.h"
5# include "value.h"
6# include "reader.h"
7# include "writer.h"
8# include "features.h"
9
10#endif // JSON_JSON_H_INCLUDED
110
=== removed file 'thirdparty/jsoncpp/include/json/reader.h'
--- thirdparty/jsoncpp/include/json/reader.h 2013-09-10 04:32:16 +0000
+++ thirdparty/jsoncpp/include/json/reader.h 1970-01-01 00:00:00 +0000
@@ -1,196 +0,0 @@
1#ifndef CPPTL_JSON_READER_H_INCLUDED
2# define CPPTL_JSON_READER_H_INCLUDED
3
4# include "features.h"
5# include "value.h"
6# include <deque>
7# include <stack>
8# include <string>
9# include <iostream>
10
11namespace Json {
12
13 /** @brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a Value.
14 *
15 */
16 class JSON_API Reader
17 {
18 public:
19 typedef char Char;
20 typedef const Char *Location;
21
22 /** @brief Constructs a Reader allowing all features
23 * for parsing.
24 */
25 Reader();
26
27 /** @brief Constructs a Reader allowing the specified feature set
28 * for parsing.
29 */
30 Reader( const Features &features );
31
32 /** @brief Read a Value from a <a HREF="http://www.json.org">JSON</a> document.
33 * \param document UTF-8 encoded string containing the document to read.
34 * \param root [out] Contains the root value of the document if it was
35 * successfully parsed.
36 * \param collectComments \c true to collect comment and allow writing them back during
37 * serialization, \c false to discard comments.
38 * This parameter is ignored if Features::allowComments_
39 * is \c false.
40 * \return \c true if the document was successfully parsed, \c false if an error occurred.
41 */
42 bool parse( const std::string &document,
43 Value &root,
44 bool collectComments = true );
45
46 /** @brief Read a Value from a <a HREF="http://www.json.org">JSON</a> document.
47 * \param document UTF-8 encoded string containing the document to read.
48 * \param root [out] Contains the root value of the document if it was
49 * successfully parsed.
50 * \param collectComments \c true to collect comment and allow writing them back during
51 * serialization, \c false to discard comments.
52 * This parameter is ignored if Features::allowComments_
53 * is \c false.
54 * \return \c true if the document was successfully parsed, \c false if an error occurred.
55 */
56 bool parse( const char *beginDoc, const char *endDoc,
57 Value &root,
58 bool collectComments = true );
59
60 /// @brief Parse from input stream.
61 /// \see Json::operator>>(std::istream&, Json::Value&).
62 bool parse( std::istream &is,
63 Value &root,
64 bool collectComments = true );
65
66 /** @brief Returns a user friendly string that list errors in the parsed document.
67 * \return Formatted error message with the list of errors with their location in
68 * the parsed document. An empty string is returned if no error occurred
69 * during parsing.
70 */
71 std::string getFormatedErrorMessages() const;
72
73 private:
74 enum TokenType
75 {
76 tokenEndOfStream = 0,
77 tokenObjectBegin,
78 tokenObjectEnd,
79 tokenArrayBegin,
80 tokenArrayEnd,
81 tokenString,
82 tokenNumber,
83 tokenTrue,
84 tokenFalse,
85 tokenNull,
86 tokenArraySeparator,
87 tokenMemberSeparator,
88 tokenComment,
89 tokenError
90 };
91
92 class Token
93 {
94 public:
95 TokenType type_;
96 Location start_;
97 Location end_;
98 };
99
100 class ErrorInfo
101 {
102 public:
103 Token token_;
104 std::string message_;
105 Location extra_;
106 };
107
108 typedef std::deque<ErrorInfo> Errors;
109
110 bool expectToken( TokenType type, Token &token, const char *message );
111 bool readToken( Token &token );
112 void skipSpaces();
113 bool match( Location pattern,
114 int patternLength );
115 bool readComment();
116 bool readCStyleComment();
117 bool readCppStyleComment();
118 bool readString();
119 void readNumber();
120 bool readValue();
121 bool readObject( Token &token );
122 bool readArray( Token &token );
123 bool decodeNumber( Token &token );
124 bool decodeString( Token &token );
125 bool decodeString( Token &token, std::string &decoded );
126 bool decodeDouble( Token &token );
127 bool decodeUnicodeCodePoint( Token &token,
128 Location &current,
129 Location end,
130 unsigned int &unicode );
131 bool decodeUnicodeEscapeSequence( Token &token,
132 Location &current,
133 Location end,
134 unsigned int &unicode );
135 bool addError( const std::string &message,
136 Token &token,
137 Location extra = 0 );
138 bool recoverFromError( TokenType skipUntilToken );
139 bool addErrorAndRecover( const std::string &message,
140 Token &token,
141 TokenType skipUntilToken );
142 void skipUntilSpace();
143 Value &currentValue();
144 Char getNextChar();
145 void getLocationLineAndColumn( Location location,
146 int &line,
147 int &column ) const;
148 std::string getLocationLineAndColumn( Location location ) const;
149 void addComment( Location begin,
150 Location end,
151 CommentPlacement placement );
152 void skipCommentTokens( Token &token );
153
154 typedef std::stack<Value *> Nodes;
155 Nodes nodes_;
156 Errors errors_;
157 std::string document_;
158 Location begin_;
159 Location end_;
160 Location current_;
161 Location lastValueEnd_;
162 Value *lastValue_;
163 std::string commentsBefore_;
164 Features features_;
165 bool collectComments_;
166 };
167
168 /** @brief Read from 'sin' into 'root'.
169
170 Always keep comments from the input JSON.
171
172 This can be used to read a file into a particular sub-object.
173 For example:
174 \code
175 Json::Value root;
176 cin >> root["dir"]["file"];
177 cout << root;
178 \endcode
179 Result:
180 \verbatim
181 {
182 "dir": {
183 "file": {
184 // The input stream JSON would be nested here.
185 }
186 }
187 }
188 \endverbatim
189 \throw std::exception on parse error.
190 \see Json::operator<<()
191 */
192 std::istream& operator>>( std::istream&, Value& );
193
194} // namespace Json
195
196#endif // CPPTL_JSON_READER_H_INCLUDED
1970
=== removed file 'thirdparty/jsoncpp/include/json/value.h'
--- thirdparty/jsoncpp/include/json/value.h 2013-09-10 04:32:16 +0000
+++ thirdparty/jsoncpp/include/json/value.h 1970-01-01 00:00:00 +0000
@@ -1,1069 +0,0 @@
1#ifndef CPPTL_JSON_H_INCLUDED
2# define CPPTL_JSON_H_INCLUDED
3
4# include "forwards.h"
5# include <string>
6# include <vector>
7
8# ifndef JSON_USE_CPPTL_SMALLMAP
9# include <map>
10# else
11# include <cpptl/smallmap.h>
12# endif
13# ifdef JSON_USE_CPPTL
14# include <cpptl/forwards.h>
15# endif
16
17/** @brief JSON (JavaScript Object Notation).
18 */
19namespace Json {
20
21 /** @brief Type of the value held by a Value object.
22 */
23 enum ValueType
24 {
25 nullValue = 0, ///< 'null' value
26 intValue, ///< signed integer value
27 uintValue, ///< unsigned integer value
28 realValue, ///< double value
29 stringValue, ///< UTF-8 string value
30 booleanValue, ///< bool value
31 arrayValue, ///< array value (ordered list)
32 objectValue ///< object value (collection of name/value pairs).
33 };
34
35 enum CommentPlacement
36 {
37 commentBefore = 0, ///< a comment placed on the line before a value
38 commentAfterOnSameLine, ///< a comment just after a value on the same line
39 commentAfter, ///< a comment on the line after a value (only make sense for root value)
40 numberOfCommentPlacement
41 };
42
43//# ifdef JSON_USE_CPPTL
44// typedef CppTL::AnyEnumerator<const char *> EnumMemberNames;
45// typedef CppTL::AnyEnumerator<const Value &> EnumValues;
46//# endif
47
48 /** @brief Lightweight wrapper to tag static string.
49 *
50 * Value constructor and objectValue member assignement takes advantage of the
51 * StaticString and avoid the cost of string duplication when storing the
52 * string or the member name.
53 *
54 * Example of usage:
55 * \code
56 * Json::Value aValue( StaticString("some text") );
57 * Json::Value object;
58 * static const StaticString code("code");
59 * object[code] = 1234;
60 * \endcode
61 */
62 class JSON_API StaticString
63 {
64 public:
65 explicit StaticString( const char *czstring )
66 : str_( czstring )
67 {
68 }
69
70 operator const char *() const
71 {
72 return str_;
73 }
74
75 const char *c_str() const
76 {
77 return str_;
78 }
79
80 private:
81 const char *str_;
82 };
83
84 /** @brief Represents a <a HREF="http://www.json.org">JSON</a> value.
85 *
86 * This class is a discriminated union wrapper that can represents a:
87 * - signed integer [range: Value::minInt - Value::maxInt]
88 * - unsigned integer (range: 0 - Value::maxUInt)
89 * - double
90 * - UTF-8 string
91 * - boolean
92 * - 'null'
93 * - an ordered list of Value
94 * - collection of name/value pairs (javascript object)
95 *
96 * The type of the held value is represented by a #ValueType and
97 * can be obtained using type().
98 *
99 * values of an #objectValue or #arrayValue can be accessed using operator[]() methods.
100 * Non const methods will automatically create the a #nullValue element
101 * if it does not exist.
102 * The sequence of an #arrayValue will be automatically resize and initialized
103 * with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.
104 *
105 * The get() methods can be used to obtanis default value in the case the required element
106 * does not exist.
107 *
108 * It is possible to iterate over the list of a #objectValue values using
109 * the getMemberNames() method.
110 */
111 class JSON_API Value
112 {
113 friend class ValueIteratorBase;
114# ifdef JSON_VALUE_USE_INTERNAL_MAP
115 friend class ValueInternalLink;
116 friend class ValueInternalMap;
117# endif
118 public:
119 typedef std::vector<std::string> Members;
120 typedef ValueIterator iterator;
121 typedef ValueConstIterator const_iterator;
122 typedef Json::UInt UInt;
123 typedef Json::Int Int;
124 typedef UInt ArrayIndex;
125
126 static const Value null;
127 static const Int minInt;
128 static const Int maxInt;
129 static const UInt maxUInt;
130
131 private:
132#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
133# ifndef JSON_VALUE_USE_INTERNAL_MAP
134 class CZString
135 {
136 public:
137 enum DuplicationPolicy
138 {
139 noDuplication = 0,
140 duplicate,
141 duplicateOnCopy
142 };
143 CZString( int index );
144 CZString( const char *cstr, DuplicationPolicy allocate );
145 CZString( const CZString &other );
146 ~CZString();
147 CZString &operator =( const CZString &other );
148 bool operator<( const CZString &other ) const;
149 bool operator==( const CZString &other ) const;
150 int index() const;
151 const char *c_str() const;
152 bool isStaticString() const;
153 private:
154 void swap( CZString &other );
155 const char *cstr_;
156 int index_;
157 };
158
159 public:
160# ifndef JSON_USE_CPPTL_SMALLMAP
161 typedef std::map<CZString, Value> ObjectValues;
162# else
163 typedef CppTL::SmallMap<CZString, Value> ObjectValues;
164# endif // ifndef JSON_USE_CPPTL_SMALLMAP
165# endif // ifndef JSON_VALUE_USE_INTERNAL_MAP
166#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
167
168 public:
169 /** @brief Create a default Value of the given type.
170
171 This is a very useful constructor.
172 To create an empty array, pass arrayValue.
173 To create an empty object, pass objectValue.
174 Another Value can then be set to this one by assignment.
175 This is useful since clear() and resize() will not alter types.
176
177 Examples:
178 \code
179 Json::Value null_value; // null
180 Json::Value arr_value(Json::arrayValue); // []
181 Json::Value obj_value(Json::objectValue); // {}
182 \endcode
183 */
184 Value( ValueType type = nullValue );
185 Value( Int value );
186 Value( UInt value );
187 Value( double value );
188 Value( const char *value );
189 Value( const char *beginValue, const char *endValue );
190 /** @brief Constructs a value from a static string.
191
192 * Like other value string constructor but do not duplicate the string for
193 * internal storage. The given string must remain alive after the call to this
194 * constructor.
195 * Example of usage:
196 * \code
197 * Json::Value aValue( StaticString("some text") );
198 * \endcode
199 */
200 Value( const StaticString &value );
201 Value( const std::string &value );
202# ifdef JSON_USE_CPPTL
203 Value( const CppTL::ConstString &value );
204# endif
205 Value( bool value );
206 Value( const Value &other );
207 ~Value();
208
209 Value &operator=( const Value &other );
210 /// Swap values.
211 /// \note Currently, comments are intentionally not swapped, for
212 /// both logic and efficiency.
213 void swap( Value &other );
214
215 ValueType type() const;
216
217 bool operator <( const Value &other ) const;
218 bool operator <=( const Value &other ) const;
219 bool operator >=( const Value &other ) const;
220 bool operator >( const Value &other ) const;
221
222 bool operator ==( const Value &other ) const;
223 bool operator !=( const Value &other ) const;
224
225 int compare( const Value &other );
226
227 const char *asCString() const;
228 std::string asString() const;
229# ifdef JSON_USE_CPPTL
230 CppTL::ConstString asConstString() const;
231# endif
232 Int asInt() const;
233 UInt asUInt() const;
234 double asDouble() const;
235 bool asBool() const;
236
237 bool isNull() const;
238 bool isBool() const;
239 bool isInt() const;
240 bool isUInt() const;
241 bool isIntegral() const;
242 bool isDouble() const;
243 bool isNumeric() const;
244 bool isString() const;
245 bool isArray() const;
246 bool isObject() const;
247
248 bool isConvertibleTo( ValueType other ) const;
249
250 /// Number of values in array or object
251 UInt size() const;
252
253 /// @brief Return true if empty array, empty object, or null;
254 /// otherwise, false.
255 bool empty() const;
256
257 /// Return isNull()
258 bool operator!() const;
259
260 /// Remove all object members and array elements.
261 /// \pre type() is arrayValue, objectValue, or nullValue
262 /// \post type() is unchanged
263 void clear();
264
265 /// Resize the array to size elements.
266 /// New elements are initialized to null.
267 /// May only be called on nullValue or arrayValue.
268 /// \pre type() is arrayValue or nullValue
269 /// \post type() is arrayValue
270 void resize( UInt size );
271
272 /// Access an array element (zero based index ).
273 /// If the array contains less than index element, then null value are inserted
274 /// in the array so that its size is index+1.
275 /// (You may need to say 'value[0u]' to get your compiler to distinguish
276 /// this from the operator[] which takes a string.)
277 Value &operator[]( UInt index );
278 /// Access an array element (zero based index )
279 /// (You may need to say 'value[0u]' to get your compiler to distinguish
280 /// this from the operator[] which takes a string.)
281 const Value &operator[]( UInt index ) const;
282 /// If the array contains at least index+1 elements, returns the element value,
283 /// otherwise returns defaultValue.
284 Value get( UInt index,
285 const Value &defaultValue ) const;
286 /// Return true if index < size().
287 bool isValidIndex( UInt index ) const;
288 /// @brief Append value to array at the end.
289 ///
290 /// Equivalent to jsonvalue[jsonvalue.size()] = value;
291 Value &append( const Value &value );
292
293 /// Access an object value by name, create a null member if it does not exist.
294 Value &operator[]( const char *key );
295 /// Access an object value by name, returns null if there is no member with that name.
296 const Value &operator[]( const char *key ) const;
297 /// Access an object value by name, create a null member if it does not exist.
298 Value &operator[]( const std::string &key );
299 /// Access an object value by name, returns null if there is no member with that name.
300 const Value &operator[]( const std::string &key ) const;
301 /** @brief Access an object value by name, create a null member if it does not exist.
302
303 * If the object as no entry for that name, then the member name used to store
304 * the new entry is not duplicated.
305 * Example of use:
306 * \code
307 * Json::Value object;
308 * static const StaticString code("code");
309 * object[code] = 1234;
310 * \endcode
311 */
312 Value &operator[]( const StaticString &key );
313# ifdef JSON_USE_CPPTL
314 /// Access an object value by name, create a null member if it does not exist.
315 Value &operator[]( const CppTL::ConstString &key );
316 /// Access an object value by name, returns null if there is no member with that name.
317 const Value &operator[]( const CppTL::ConstString &key ) const;
318# endif
319 /// Return the member named key if it exist, defaultValue otherwise.
320 Value get( const char *key,
321 const Value &defaultValue ) const;
322 /// Return the member named key if it exist, defaultValue otherwise.
323 Value get( const std::string &key,
324 const Value &defaultValue ) const;
325# ifdef JSON_USE_CPPTL
326 /// Return the member named key if it exist, defaultValue otherwise.
327 Value get( const CppTL::ConstString &key,
328 const Value &defaultValue ) const;
329# endif
330 /// @brief Remove and return the named member.
331 ///
332 /// Do nothing if it did not exist.
333 /// \return the removed Value, or null.
334 /// \pre type() is objectValue or nullValue
335 /// \post type() is unchanged
336 Value removeMember( const char* key );
337 /// Same as removeMember(const char*)
338 Value removeMember( const std::string &key );
339
340 /// Return true if the object has a member named key.
341 bool isMember( const char *key ) const;
342 /// Return true if the object has a member named key.
343 bool isMember( const std::string &key ) const;
344# ifdef JSON_USE_CPPTL
345 /// Return true if the object has a member named key.
346 bool isMember( const CppTL::ConstString &key ) const;
347# endif
348
349 /// @brief Return a list of the member names.
350 ///
351 /// If null, return an empty list.
352 /// \pre type() is objectValue or nullValue
353 /// \post if type() was nullValue, it remains nullValue
354 Members getMemberNames() const;
355
356//# ifdef JSON_USE_CPPTL
357// EnumMemberNames enumMemberNames() const;
358// EnumValues enumValues() const;
359//# endif
360
361 /// Comments must be //... or /* ... */
362 void setComment( const char *comment,
363 CommentPlacement placement );
364 /// Comments must be //... or /* ... */
365 void setComment( const std::string &comment,
366 CommentPlacement placement );
367 bool hasComment( CommentPlacement placement ) const;
368 /// Include delimiters and embedded newlines.
369 std::string getComment( CommentPlacement placement ) const;
370
371 std::string toStyledString() const;
372
373 const_iterator begin() const;
374 const_iterator end() const;
375
376 iterator begin();
377 iterator end();
378
379 private:
380 Value &resolveReference( const char *key,
381 bool isStatic );
382
383# ifdef JSON_VALUE_USE_INTERNAL_MAP
384 inline bool isItemAvailable() const
385 {
386 return itemIsUsed_ == 0;
387 }
388
389 inline void setItemUsed( bool isUsed = true )
390 {
391 itemIsUsed_ = isUsed ? 1 : 0;
392 }
393
394 inline bool isMemberNameStatic() const
395 {
396 return memberNameIsStatic_ == 0;
397 }
398
399 inline void setMemberNameIsStatic( bool isStatic )
400 {
401 memberNameIsStatic_ = isStatic ? 1 : 0;
402 }
403# endif // # ifdef JSON_VALUE_USE_INTERNAL_MAP
404
405 private:
406 struct CommentInfo
407 {
408 CommentInfo();
409 ~CommentInfo();
410
411 void setComment( const char *text );
412
413 char *comment_;
414 };
415
416 //struct MemberNamesTransform
417 //{
418 // typedef const char *result_type;
419 // const char *operator()( const CZString &name ) const
420 // {
421 // return name.c_str();
422 // }
423 //};
424
425 union ValueHolder
426 {
427 Int int_;
428 UInt uint_;
429 double real_;
430 bool bool_;
431 char *string_;
432# ifdef JSON_VALUE_USE_INTERNAL_MAP
433 ValueInternalArray *array_;
434 ValueInternalMap *map_;
435#else
436 ObjectValues *map_;
437# endif
438 } value_;
439 ValueType type_ : 8;
440 int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.
441# ifdef JSON_VALUE_USE_INTERNAL_MAP
442 unsigned int itemIsUsed_ : 1; // used by the ValueInternalMap container.
443 int memberNameIsStatic_ : 1; // used by the ValueInternalMap container.
444# endif
445 CommentInfo *comments_;
446 };
447
448
449 /** @brief Experimental and untested: represents an element of the "path" to access a node.
450 */
451 class PathArgument
452 {
453 public:
454 friend class Path;
455
456 PathArgument();
457 PathArgument( UInt index );
458 PathArgument( const char *key );
459 PathArgument( const std::string &key );
460
461 private:
462 enum Kind
463 {
464 kindNone = 0,
465 kindIndex,
466 kindKey
467 };
468 std::string key_;
469 UInt index_;
470 Kind kind_;
471 };
472
473 /** @brief Experimental and untested: represents a "path" to access a node.
474 *
475 * Syntax:
476 * - "." => root node
477 * - ".[n]" => elements at index 'n' of root node (an array value)
478 * - ".name" => member named 'name' of root node (an object value)
479 * - ".name1.name2.name3"
480 * - ".[0][1][2].name1[3]"
481 * - ".%" => member name is provided as parameter
482 * - ".[%]" => index is provied as parameter
483 */
484 class Path
485 {
486 public:
487 Path( const std::string &path,
488 const PathArgument &a1 = PathArgument(),
489 const PathArgument &a2 = PathArgument(),
490 const PathArgument &a3 = PathArgument(),
491 const PathArgument &a4 = PathArgument(),
492 const PathArgument &a5 = PathArgument() );
493
494 const Value &resolve( const Value &root ) const;
495 Value resolve( const Value &root,
496 const Value &defaultValue ) const;
497 /// Creates the "path" to access the specified node and returns a reference on the node.
498 Value &make( Value &root ) const;
499
500 private:
501 typedef std::vector<const PathArgument *> InArgs;
502 typedef std::vector<PathArgument> Args;
503
504 void makePath( const std::string &path,
505 const InArgs &in );
506 void addPathInArg( const std::string &path,
507 const InArgs &in,
508 InArgs::const_iterator &itInArg,
509 PathArgument::Kind kind );
510 void invalidPath( const std::string &path,
511 int location );
512
513 Args args_;
514 };
515
516 /** @brief Experimental do not use: Allocator to customize member name and string value memory management done by Value.
517 *
518 * - makeMemberName() and releaseMemberName() are called to respectively duplicate and
519 * free an Json::objectValue member name.
520 * - duplicateStringValue() and releaseStringValue() are called similarly to
521 * duplicate and free a Json::stringValue value.
522 */
523 class ValueAllocator
524 {
525 public:
526 enum { unknown = (unsigned)-1 };
527
528 virtual ~ValueAllocator();
529
530 virtual char *makeMemberName( const char *memberName ) = 0;
531 virtual void releaseMemberName( char *memberName ) = 0;
532 virtual char *duplicateStringValue( const char *value,
533 unsigned int length = unknown ) = 0;
534 virtual void releaseStringValue( char *value ) = 0;
535 };
536
537#ifdef JSON_VALUE_USE_INTERNAL_MAP
538 /** @brief Allocator to customize Value internal map.
539 * Below is an example of a simple implementation (default implementation actually
540 * use memory pool for speed).
541 * \code
542 class DefaultValueMapAllocator : public ValueMapAllocator
543 {
544 public: // overridden from ValueMapAllocator
545 virtual ValueInternalMap *newMap()
546 {
547 return new ValueInternalMap();
548 }
549
550 virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )
551 {
552 return new ValueInternalMap( other );
553 }
554
555 virtual void destructMap( ValueInternalMap *map )
556 {
557 delete map;
558 }
559
560 virtual ValueInternalLink *allocateMapBuckets( unsigned int size )
561 {
562 return new ValueInternalLink[size];
563 }
564
565 virtual void releaseMapBuckets( ValueInternalLink *links )
566 {
567 delete [] links;
568 }
569
570 virtual ValueInternalLink *allocateMapLink()
571 {
572 return new ValueInternalLink();
573 }
574
575 virtual void releaseMapLink( ValueInternalLink *link )
576 {
577 delete link;
578 }
579 };
580 * \endcode
581 */
582 class JSON_API ValueMapAllocator
583 {
584 public:
585 virtual ~ValueMapAllocator();
586 virtual ValueInternalMap *newMap() = 0;
587 virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other ) = 0;
588 virtual void destructMap( ValueInternalMap *map ) = 0;
589 virtual ValueInternalLink *allocateMapBuckets( unsigned int size ) = 0;
590 virtual void releaseMapBuckets( ValueInternalLink *links ) = 0;
591 virtual ValueInternalLink *allocateMapLink() = 0;
592 virtual void releaseMapLink( ValueInternalLink *link ) = 0;
593 };
594
595 /** @brief ValueInternalMap hash-map bucket chain link (for internal use only).
596 * \internal previous_ & next_ allows for bidirectional traversal.
597 */
598 class JSON_API ValueInternalLink
599 {
600 public:
601 enum { itemPerLink = 6 }; // sizeof(ValueInternalLink) = 128 on 32 bits architecture.
602 enum InternalFlags {
603 flagAvailable = 0,
604 flagUsed = 1
605 };
606
607 ValueInternalLink();
608
609 ~ValueInternalLink();
610
611 Value items_[itemPerLink];
612 char *keys_[itemPerLink];
613 ValueInternalLink *previous_;
614 ValueInternalLink *next_;
615 };
616
617
618 /** @brief A linked page based hash-table implementation used internally by Value.
619 * \internal ValueInternalMap is a tradional bucket based hash-table, with a linked
620 * list in each bucket to handle collision. There is an addional twist in that
621 * each node of the collision linked list is a page containing a fixed amount of
622 * value. This provides a better compromise between memory usage and speed.
623 *
624 * Each bucket is made up of a chained list of ValueInternalLink. The last
625 * link of a given bucket can be found in the 'previous_' field of the following bucket.
626 * The last link of the last bucket is stored in tailLink_ as it has no following bucket.
627 * Only the last link of a bucket may contains 'available' item. The last link always
628 * contains at least one element unless is it the bucket one very first link.
629 */
630 class JSON_API ValueInternalMap
631 {
632 friend class ValueIteratorBase;
633 friend class Value;
634 public:
635 typedef unsigned int HashKey;
636 typedef unsigned int BucketIndex;
637
638# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
639 struct IteratorState
640 {
641 IteratorState()
642 : map_(0)
643 , link_(0)
644 , itemIndex_(0)
645 , bucketIndex_(0)
646 {
647 }
648 ValueInternalMap *map_;
649 ValueInternalLink *link_;
650 BucketIndex itemIndex_;
651 BucketIndex bucketIndex_;
652 };
653# endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
654
655 ValueInternalMap();
656 ValueInternalMap( const ValueInternalMap &other );
657 ValueInternalMap &operator =( const ValueInternalMap &other );
658 ~ValueInternalMap();
659
660 void swap( ValueInternalMap &other );
661
662 BucketIndex size() const;
663
664 void clear();
665
666 bool reserveDelta( BucketIndex growth );
667
668 bool reserve( BucketIndex newItemCount );
669
670 const Value *find( const char *key ) const;
671
672 Value *find( const char *key );
673
674 Value &resolveReference( const char *key,
675 bool isStatic );
676
677 void remove( const char *key );
678
679 void doActualRemove( ValueInternalLink *link,
680 BucketIndex index,
681 BucketIndex bucketIndex );
682
683 ValueInternalLink *&getLastLinkInBucket( BucketIndex bucketIndex );
684
685 Value &setNewItem( const char *key,
686 bool isStatic,
687 ValueInternalLink *link,
688 BucketIndex index );
689
690 Value &unsafeAdd( const char *key,
691 bool isStatic,
692 HashKey hashedKey );
693
694 HashKey hash( const char *key ) const;
695
696 int compare( const ValueInternalMap &other ) const;
697
698 private:
699 void makeBeginIterator( IteratorState &it ) const;
700 void makeEndIterator( IteratorState &it ) const;
701 static bool equals( const IteratorState &x, const IteratorState &other );
702 static void increment( IteratorState &iterator );
703 static void incrementBucket( IteratorState &iterator );
704 static void decrement( IteratorState &iterator );
705 static const char *key( const IteratorState &iterator );
706 static const char *key( const IteratorState &iterator, bool &isStatic );
707 static Value &value( const IteratorState &iterator );
708 static int distance( const IteratorState &x, const IteratorState &y );
709
710 private:
711 ValueInternalLink *buckets_;
712 ValueInternalLink *tailLink_;
713 BucketIndex bucketsSize_;
714 BucketIndex itemCount_;
715 };
716
717 /** @brief A simplified deque implementation used internally by Value.
718 * \internal
719 * It is based on a list of fixed "page", each page contains a fixed number of items.
720 * Instead of using a linked-list, a array of pointer is used for fast item look-up.
721 * Look-up for an element is as follow:
722 * - compute page index: pageIndex = itemIndex / itemsPerPage
723 * - look-up item in page: pages_[pageIndex][itemIndex % itemsPerPage]
724 *
725 * Insertion is amortized constant time (only the array containing the index of pointers
726 * need to be reallocated when items are appended).
727 */
728 class JSON_API ValueInternalArray
729 {
730 friend class Value;
731 friend class ValueIteratorBase;
732 public:
733 enum { itemsPerPage = 8 }; // should be a power of 2 for fast divide and modulo.
734 typedef Value::ArrayIndex ArrayIndex;
735 typedef unsigned int PageIndex;
736
737# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
738 struct IteratorState // Must be a POD
739 {
740 IteratorState()
741 : array_(0)
742 , currentPageIndex_(0)
743 , currentItemIndex_(0)
744 {
745 }
746 ValueInternalArray *array_;
747 Value **currentPageIndex_;
748 unsigned int currentItemIndex_;
749 };
750# endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
751
752 ValueInternalArray();
753 ValueInternalArray( const ValueInternalArray &other );
754 ValueInternalArray &operator =( const ValueInternalArray &other );
755 ~ValueInternalArray();
756 void swap( ValueInternalArray &other );
757
758 void clear();
759 void resize( ArrayIndex newSize );
760
761 Value &resolveReference( ArrayIndex index );
762
763 Value *find( ArrayIndex index ) const;
764
765 ArrayIndex size() const;
766
767 int compare( const ValueInternalArray &other ) const;
768
769 private:
770 static bool equals( const IteratorState &x, const IteratorState &other );
771 static void increment( IteratorState &iterator );
772 static void decrement( IteratorState &iterator );
773 static Value &dereference( const IteratorState &iterator );
774 static Value &unsafeDereference( const IteratorState &iterator );
775 static int distance( const IteratorState &x, const IteratorState &y );
776 static ArrayIndex indexOf( const IteratorState &iterator );
777 void makeBeginIterator( IteratorState &it ) const;
778 void makeEndIterator( IteratorState &it ) const;
779 void makeIterator( IteratorState &it, ArrayIndex index ) const;
780
781 void makeIndexValid( ArrayIndex index );
782
783 Value **pages_;
784 ArrayIndex size_;
785 PageIndex pageCount_;
786 };
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches