diff options
author | Florin Malita <fmalita@chromium.org> | 2018-06-14 16:16:01 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-06-14 21:21:14 +0000 |
commit | 7d42c44cddee7b7a12fa7c59099e989995eabf3a (patch) | |
tree | 6e0d460c0a8fc7366ed76cc8f89f5c532d9d2678 /modules/skottie/src/SkottieJson.h | |
parent | 725d5ad257898c23ef27f4d7feaa545103932c03 (diff) |
[skottie] Switch to SkJSON
Convert to SkJSON APIs and remove RapidJSON dependency.
TBR=
Change-Id: I5b4fd78821a443326e3a5b370748d840b80ef279
Reviewed-on: https://skia-review.googlesource.com/134612
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'modules/skottie/src/SkottieJson.h')
-rw-r--r-- | modules/skottie/src/SkottieJson.h | 62 |
1 files changed, 10 insertions, 52 deletions
diff --git a/modules/skottie/src/SkottieJson.h b/modules/skottie/src/SkottieJson.h index 76e17c610e..98ee25a3ce 100644 --- a/modules/skottie/src/SkottieJson.h +++ b/modules/skottie/src/SkottieJson.h @@ -8,68 +8,26 @@ #ifndef SkottieJson_DEFINED #define SkottieJson_DEFINED +#include "SkJSON.h" #include "SkRefCnt.h" -#include "rapidjson/document.h" - class SkData; class SkStream; class SkString; namespace skottie { -namespace json { - -class ValueRef { -public: - ValueRef() : fValue(nullptr) {} - ValueRef(const rapidjson::Value& v) : fValue(v.IsNull() ? nullptr : &v) {} - - bool isNull() const { return !fValue; } - bool isObject() const { return fValue && fValue->IsObject(); } - bool isArray() const { return fValue && fValue->IsArray(); } - - template <typename T> - bool to(T*) const; +template <typename T> +bool Parse(const skjson::Value&, T*); - template <typename T> - T toDefault(const T& defaultValue) const { - T v; - if (!this->to<T>(&v)) { - v = defaultValue; - } - return v; +template <typename T> +T ParseDefault(const skjson::Value& v, const T& defaultValue) { + T res; + if (!Parse<T>(v, &res)) { + res = defaultValue; } - - size_t size() const; - ValueRef operator[](size_t i) const; - ValueRef operator[](const char* key) const; - - bool operator==(const ValueRef& other) const { return fValue == other.fValue; } - bool operator!=(const ValueRef& other) const { return !(*this == other); } - - const rapidjson::Value* begin() const; - const rapidjson::Value* end() const; - - SkString toString() const; - -private: - const rapidjson::Value* fValue; -}; - -// Container for the json DOM -class Document { -public: - explicit Document(SkStream*); - - ValueRef root() const { return fDocument; } - -private: - sk_sp<SkData> fData; // raw data - rapidjson::Document fDocument; // in-place json DOM -}; - -} // namespace json + return res; +} } // namespace skottie |