Skip to content

Commit

Permalink
Merge pull request #396 from ferdnyc/json-parsing
Browse files Browse the repository at this point in the history
Behind-the-scenes code tidying for Json data handling
  • Loading branch information
jonoomph committed Feb 27, 2020
2 parents 4ddf775 + 8ea7449 commit 4f591c7
Show file tree
Hide file tree
Showing 82 changed files with 532 additions and 938 deletions.
6 changes: 3 additions & 3 deletions include/CacheBase.h
Expand Up @@ -110,9 +110,9 @@ namespace openshot {

/// Get and Set JSON methods
virtual std::string Json() = 0; ///< Generate JSON string of this object
virtual void SetJson(std::string value) = 0; ///< Load JSON string into this object
virtual Json::Value JsonValue() = 0; ///< Generate Json::JsonValue for this object
virtual void SetJsonValue(Json::Value root) = 0; ///< Load Json::JsonValue into this object
virtual void SetJson(const std::string value) = 0; ///< Load JSON string into this object
virtual Json::Value JsonValue() = 0; ///< Generate Json::Value for this object
virtual void SetJsonValue(const Json::Value root) = 0; ///< Load Json::Value into this object
virtual ~CacheBase() = default;

};
Expand Down
6 changes: 3 additions & 3 deletions include/CacheDisk.h
Expand Up @@ -129,9 +129,9 @@ namespace openshot {

/// Get and Set JSON methods
std::string Json(); ///< Generate JSON string of this object
void SetJson(std::string value); ///< Load JSON string into this object
Json::Value JsonValue(); ///< Generate Json::JsonValue for this object
void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object
void SetJson(const std::string value); ///< Load JSON string into this object
Json::Value JsonValue(); ///< Generate Json::Value for this object
void SetJsonValue(const Json::Value root); ///< Load Json::Value into this object
};

}
Expand Down
6 changes: 3 additions & 3 deletions include/CacheMemory.h
Expand Up @@ -111,9 +111,9 @@ namespace openshot {

/// Get and Set JSON methods
std::string Json(); ///< Generate JSON string of this object
void SetJson(std::string value); ///< Load JSON string into this object
Json::Value JsonValue(); ///< Generate Json::JsonValue for this object
void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object
void SetJson(const std::string value); ///< Load JSON string into this object
Json::Value JsonValue(); ///< Generate Json::Value for this object
void SetJsonValue(const Json::Value root); ///< Load Json::Value into this object
};

}
Expand Down
8 changes: 4 additions & 4 deletions include/ChunkReader.h
Expand Up @@ -157,10 +157,10 @@ namespace openshot
std::string Name() { return "ChunkReader"; };

/// Get and Set JSON methods
std::string Json(); ///< Generate JSON string of this object
void SetJson(std::string value); ///< Load JSON string into this object
Json::Value JsonValue(); ///< Generate Json::JsonValue for this object
void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object
std::string Json() const override; ///< Generate JSON string of this object
void SetJson(const std::string value); ///< Load JSON string into this object
Json::Value JsonValue() const override; ///< Generate Json::Value for this object
void SetJsonValue(const Json::Value root); ///< Load Json::Value into this object

/// Open the reader. This is required before you can access frames or data from the reader.
void Open();
Expand Down
12 changes: 6 additions & 6 deletions include/Clip.h
Expand Up @@ -187,18 +187,18 @@ namespace openshot {
openshot::ReaderBase* Reader();

/// Override End() method
float End(); ///< Get end position (in seconds) of clip (trim end of video), which can be affected by the time curve.
float End() const; ///< Get end position (in seconds) of clip (trim end of video), which can be affected by the time curve.
void End(float value) { end = value; } ///< Set end position (in seconds) of clip (trim end of video)

/// Get and Set JSON methods
std::string Json(); ///< Generate JSON string of this object
void SetJson(std::string value); ///< Load JSON string into this object
Json::Value JsonValue(); ///< Generate Json::JsonValue for this object
void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object
std::string Json() const override; ///< Generate JSON string of this object
void SetJson(const std::string value); ///< Load JSON string into this object
Json::Value JsonValue() const override; ///< Generate Json::Value for this object
void SetJsonValue(const Json::Value root); ///< Load Json::Value into this object

/// Get all properties for a specific frame (perfect for a UI to display the current state
/// of all properties at any time)
std::string PropertiesJSON(int64_t requested_frame);
std::string PropertiesJSON(int64_t requested_frame) const override;

/// @brief Remove an effect from the clip
/// @param effect Remove an effect from the clip.
Expand Down
26 changes: 13 additions & 13 deletions include/ClipBase.h
Expand Up @@ -56,10 +56,10 @@ namespace openshot {
std::string previous_properties; ///< This string contains the previous JSON properties

/// Generate JSON for a property
Json::Value add_property_json(std::string name, float value, std::string type, std::string memo, Keyframe* keyframe, float min_value, float max_value, bool readonly, int64_t requested_frame);
Json::Value add_property_json(std::string name, float value, std::string type, std::string memo, const Keyframe* keyframe, float min_value, float max_value, bool readonly, int64_t requested_frame) const;

/// Generate JSON choice for a property (dropdown properties)
Json::Value add_property_choice_json(std::string name, int value, int selected_value);
Json::Value add_property_choice_json(std::string name, int value, int selected_value) const;

public:

Expand All @@ -73,12 +73,12 @@ namespace openshot {
bool operator>= ( ClipBase& a) { return (Position() >= a.Position()); }

/// Get basic properties
std::string Id() { return id; } ///< Get the Id of this clip object
float Position() { return position; } ///< Get position on timeline (in seconds)
int Layer() { return layer; } ///< Get layer of clip on timeline (lower number is covered by higher numbers)
float Start() { return start; } ///< Get start position (in seconds) of clip (trim start of video)
float End() { return end; } ///< Get end position (in seconds) of clip (trim end of video)
float Duration() { return end - start; } ///< Get the length of this clip (in seconds)
std::string Id() const { return id; } ///< Get the Id of this clip object
float Position() const { return position; } ///< Get position on timeline (in seconds)
int Layer() const { return layer; } ///< Get layer of clip on timeline (lower number is covered by higher numbers)
float Start() const { return start; } ///< Get start position (in seconds) of clip (trim start of video)
float End() const { return end; } ///< Get end position (in seconds) of clip (trim end of video)
float Duration() const { return end - start; } ///< Get the length of this clip (in seconds)

/// Set basic properties
void Id(std::string value) { id = value; } ///> Set the Id of this clip object
Expand All @@ -88,14 +88,14 @@ namespace openshot {
void End(float value) { end = value; } ///< Set end position (in seconds) of clip (trim end of video)

/// Get and Set JSON methods
virtual std::string Json() = 0; ///< Generate JSON string of this object
virtual void SetJson(std::string value) = 0; ///< Load JSON string into this object
virtual Json::Value JsonValue() = 0; ///< Generate Json::JsonValue for this object
virtual void SetJsonValue(Json::Value root) = 0; ///< Load Json::JsonValue into this object
virtual std::string Json() const = 0; ///< Generate JSON string of this object
virtual void SetJson(const std::string value) = 0; ///< Load JSON string into this object
virtual Json::Value JsonValue() const = 0; ///< Generate Json::Value for this object
virtual void SetJsonValue(const Json::Value root) = 0; ///< Load Json::Value into this object

/// Get all properties for a specific frame (perfect for a UI to display the current state
/// of all properties at any time)
virtual std::string PropertiesJSON(int64_t requested_frame) = 0;
virtual std::string PropertiesJSON(int64_t requested_frame) const = 0;

virtual ~ClipBase() = default;
};
Expand Down
8 changes: 4 additions & 4 deletions include/Color.h
Expand Up @@ -69,10 +69,10 @@ namespace openshot {
static long GetDistance(long R1, long G1, long B1, long R2, long G2, long B2);

/// Get and Set JSON methods
std::string Json(); ///< Generate JSON string of this object
Json::Value JsonValue(); ///< Generate Json::JsonValue for this object
void SetJson(std::string value); ///< Load JSON string into this object
void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object
std::string Json() const; ///< Generate JSON string of this object
Json::Value JsonValue() const; ///< Generate Json::Value for this object
void SetJson(const std::string value); ///< Load JSON string into this object
void SetJsonValue(const Json::Value root); ///< Load Json::Value into this object
};


Expand Down
8 changes: 4 additions & 4 deletions include/Coordinate.h
Expand Up @@ -66,10 +66,10 @@ namespace openshot {
Coordinate(double x, double y);

/// Get and Set JSON methods
std::string Json(); ///< Generate JSON string of this object
Json::Value JsonValue(); ///< Generate Json::JsonValue for this object
void SetJson(std::string value); ///< Load JSON string into this object
void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object
std::string Json() const; ///< Generate JSON string of this object
Json::Value JsonValue() const; ///< Generate Json::Value for this object
void SetJson(const std::string value); ///< Load JSON string into this object
void SetJsonValue(const Json::Value root); ///< Load Json::Value into this object
};

}
Expand Down
8 changes: 4 additions & 4 deletions include/DecklinkReader.h
Expand Up @@ -118,10 +118,10 @@ namespace openshot
std::string Name() { return "DecklinkReader"; };

/// Get and Set JSON methods
std::string Json(); ///< Generate JSON string of this object
void SetJson(std::string value); ///< Load JSON string into this object
Json::Value JsonValue(); ///< Generate Json::JsonValue for this object
void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object
std::string Json() const override; ///< Generate JSON string of this object
void SetJson(const std::string value); ///< Load JSON string into this object
Json::Value JsonValue() const; ///< Generate Json::Value for this object
void SetJsonValue(const Json::Value root); ///< Load Json::Value into this object

/// Open device and video stream - which is called by the constructor automatically
void Open();
Expand Down
8 changes: 4 additions & 4 deletions include/DummyReader.h
Expand Up @@ -87,10 +87,10 @@ namespace openshot
std::string Name() { return "DummyReader"; };

/// Get and Set JSON methods
std::string Json(); ///< Generate JSON string of this object
void SetJson(std::string value); ///< Load JSON string into this object
Json::Value JsonValue(); ///< Generate Json::JsonValue for this object
void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object
std::string Json() const override; ///< Generate JSON string of this object
void SetJson(const std::string value); ///< Load JSON string into this object
Json::Value JsonValue() const override; ///< Generate Json::Value for this object
void SetJsonValue(const Json::Value root); ///< Load Json::Value into this object

/// Open File - which is called by the constructor automatically
void Open();
Expand Down
12 changes: 6 additions & 6 deletions include/EffectBase.h
Expand Up @@ -94,14 +94,14 @@ namespace openshot
void InitEffectInfo();

/// Get and Set JSON methods
virtual std::string Json() = 0; ///< Generate JSON string of this object
virtual void SetJson(std::string value) = 0; ///< Load JSON string into this object
virtual Json::Value JsonValue() = 0; ///< Generate Json::JsonValue for this object
virtual void SetJsonValue(Json::Value root) = 0; ///< Load Json::JsonValue into this object
Json::Value JsonInfo(); ///< Generate JSON object of meta data / info
virtual std::string Json() const = 0; ///< Generate JSON string of this object
virtual void SetJson(const std::string value) = 0; ///< Load JSON string into this object
virtual Json::Value JsonValue() const = 0; ///< Generate Json::Value for this object
virtual void SetJsonValue(const Json::Value root) = 0; ///< Load Json::Value into this object
Json::Value JsonInfo() const; ///< Generate JSON object of meta data / info

/// Get the order that this effect should be executed.
int Order() { return order; }
int Order() const { return order; }

/// Set the order that this effect should be executed.
void Order(int new_order) { order = new_order; }
Expand Down
2 changes: 1 addition & 1 deletion include/EffectInfo.h
Expand Up @@ -51,7 +51,7 @@ namespace openshot

/// JSON methods
static std::string Json(); ///< Generate JSON string of this object
static Json::Value JsonValue(); ///< Generate Json::JsonValue for this object
static Json::Value JsonValue(); ///< Generate Json::Value for this object

};

Expand Down
8 changes: 4 additions & 4 deletions include/FFmpegReader.h
Expand Up @@ -264,10 +264,10 @@ namespace openshot {
std::string Name() { return "FFmpegReader"; };

/// Get and Set JSON methods
std::string Json(); ///< Generate JSON string of this object
void SetJson(std::string value); ///< Load JSON string into this object
Json::Value JsonValue(); ///< Generate Json::JsonValue for this object
void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object
std::string Json() const override; ///< Generate JSON string of this object
void SetJson(const std::string value); ///< Load JSON string into this object
Json::Value JsonValue() const override; ///< Generate Json::Value for this object
void SetJsonValue(const Json::Value root); ///< Load Json::Value into this object

/// Open File - which is called by the constructor automatically
void Open();
Expand Down
8 changes: 4 additions & 4 deletions include/FrameMapper.h
Expand Up @@ -199,10 +199,10 @@ namespace openshot
std::string Name() { return "FrameMapper"; };

/// Get and Set JSON methods
std::string Json(); ///< Generate JSON string of this object
void SetJson(std::string value); ///< Load JSON string into this object
Json::Value JsonValue(); ///< Generate Json::JsonValue for this object
void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object
std::string Json() const override; ///< Generate JSON string of this object
void SetJson(const std::string value); ///< Load JSON string into this object
Json::Value JsonValue() const override; ///< Generate Json::Value for this object
void SetJsonValue(const Json::Value root); ///< Load Json::Value into this object

/// Open the internal reader
void Open();
Expand Down
8 changes: 4 additions & 4 deletions include/ImageReader.h
Expand Up @@ -106,10 +106,10 @@ namespace openshot
std::string Name() { return "ImageReader"; };

/// Get and Set JSON methods
std::string Json(); ///< Generate JSON string of this object
void SetJson(std::string value); ///< Load JSON string into this object
Json::Value JsonValue(); ///< Generate Json::JsonValue for this object
void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object
std::string Json() const override; ///< Generate JSON string of this object
void SetJson(const std::string value); ///< Load JSON string into this object
Json::Value JsonValue() const; ///< Generate Json::Value for this object
void SetJsonValue(const Json::Value root); ///< Load Json::Value into this object

/// Open File - which is called by the constructor automatically
void Open();
Expand Down
6 changes: 6 additions & 0 deletions include/Json.h
Expand Up @@ -31,6 +31,12 @@
#ifndef OPENSHOT_JSON_H
#define OPENSHOT_JSON_H

#include <string>
#include "json/json.h"
#include "Exceptions.h"

namespace openshot {
const Json::Value stringToJson(const std::string value);
}

#endif
6 changes: 3 additions & 3 deletions include/KeyFrame.h
Expand Up @@ -133,9 +133,9 @@ namespace openshot {

/// Get and Set JSON methods
std::string Json() const; ///< Generate JSON string of this object
Json::Value JsonValue() const; ///< Generate Json::JsonValue for this object
void SetJson(std::string value); ///< Load JSON string into this object
void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object
Json::Value JsonValue() const; ///< Generate Json::Value for this object
void SetJson(const std::string value); ///< Load JSON string into this object
void SetJsonValue(const Json::Value root); ///< Load Json::Value into this object

/// Remove a point by matching a coordinate
void RemovePoint(Point p);
Expand Down
8 changes: 4 additions & 4 deletions include/Point.h
Expand Up @@ -119,10 +119,10 @@ namespace openshot
void Initialize_RightHandle(float x, float y);

/// Get and Set JSON methods
std::string Json(); ///< Generate JSON string of this object
Json::Value JsonValue(); ///< Generate Json::JsonValue for this object
void SetJson(std::string value); ///< Load JSON string into this object
void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object
std::string Json() const; ///< Generate JSON string of this object
Json::Value JsonValue() const; ///< Generate Json::Value for this object
void SetJson(const std::string value); ///< Load JSON string into this object
void SetJsonValue(const Json::Value root); ///< Load Json::Value into this object

};

Expand Down
8 changes: 4 additions & 4 deletions include/Profiles.h
Expand Up @@ -90,10 +90,10 @@ namespace openshot
Profile(std::string path);

/// Get and Set JSON methods
std::string Json(); ///< Generate JSON string of this object
Json::Value JsonValue(); ///< Generate Json::JsonValue for this object
void SetJson(std::string value); ///< Load JSON string into this object
void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object
std::string Json() const; ///< Generate JSON string of this object
Json::Value JsonValue() const; ///< Generate Json::Value for this object
void SetJson(const std::string value); ///< Load JSON string into this object
void SetJsonValue(const Json::Value root); ///< Load Json::Value into this object
};

}
Expand Down
8 changes: 4 additions & 4 deletions include/QtHtmlReader.h
Expand Up @@ -131,10 +131,10 @@ namespace openshot
std::string Name() { return "QtHtmlReader"; };

/// Get and Set JSON methods
std::string Json(); ///< Generate JSON string of this object
void SetJson(std::string value); ///< Load JSON string into this object
Json::Value JsonValue(); ///< Generate Json::JsonValue for this object
void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object
std::string Json() const override; ///< Generate JSON string of this object
void SetJson(const std::string value); ///< Load JSON string into this object
Json::Value JsonValue() const override; ///< Generate Json::Value for this object
void SetJsonValue(const Json::Value root); ///< Load Json::Value into this object

/// Open Reader - which is called by the constructor automatically
void Open();
Expand Down
8 changes: 4 additions & 4 deletions include/QtImageReader.h
Expand Up @@ -104,10 +104,10 @@ namespace openshot
std::string Name() { return "QtImageReader"; };

/// Get and Set JSON methods
std::string Json(); ///< Generate JSON string of this object
void SetJson(std::string value); ///< Load JSON string into this object
Json::Value JsonValue(); ///< Generate Json::JsonValue for this object
void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object
std::string Json() const override; ///< Generate JSON string of this object
void SetJson(const std::string value); ///< Load JSON string into this object
Json::Value JsonValue() const override; ///< Generate Json::Value for this object
void SetJsonValue(const Json::Value root); ///< Load Json::Value into this object

/// Open File - which is called by the constructor automatically
void Open();
Expand Down
8 changes: 4 additions & 4 deletions include/QtTextReader.h
Expand Up @@ -142,10 +142,10 @@ namespace openshot
std::string Name() { return "QtTextReader"; };

/// Get and Set JSON methods
std::string Json(); ///< Generate JSON string of this object
void SetJson(std::string value); ///< Load JSON string into this object
Json::Value JsonValue(); ///< Generate Json::JsonValue for this object
void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object
std::string Json() const override; ///< Generate JSON string of this object
void SetJson(const std::string value); ///< Load JSON string into this object
Json::Value JsonValue() const override; ///< Generate Json::Value for this object
void SetJsonValue(const Json::Value root); ///< Load Json::Value into this object

/// Open Reader - which is called by the constructor automatically
void Open();
Expand Down

0 comments on commit 4f591c7

Please sign in to comment.