| 1 | /* |
| 2 | * Copyright 2018 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SkottieJson_DEFINED |
| 9 | #define SkottieJson_DEFINED |
| 10 | |
| 11 | #include "include/core/SkRefCnt.h" |
| 12 | #include "src/utils/SkJSON.h" |
| 13 | |
| 14 | class SkData; |
| 15 | class SkStream; |
| 16 | class SkString; |
| 17 | |
| 18 | namespace skottie { |
| 19 | |
| 20 | template <typename T> |
| 21 | bool Parse(const skjson::Value&, T*); |
| 22 | |
| 23 | template <typename T> |
| 24 | T ParseDefault(const skjson::Value& v, const T& defaultValue) { |
| 25 | T res; |
| 26 | if (!Parse<T>(v, &res)) { |
| 27 | res = defaultValue; |
| 28 | } |
| 29 | return res; |
| 30 | } |
| 31 | |
| 32 | } // namespace skottie |
| 33 | |
| 34 | #endif // SkottieJson_DEFINED |
| 35 | |