SkottieJson.h 631 B

12345678910111213141516171819202122232425262728293031323334
  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. #ifndef SkottieJson_DEFINED
  8. #define SkottieJson_DEFINED
  9. #include "include/core/SkRefCnt.h"
  10. #include "src/utils/SkJSON.h"
  11. class SkData;
  12. class SkStream;
  13. class SkString;
  14. namespace skottie {
  15. template <typename T>
  16. bool Parse(const skjson::Value&, T*);
  17. template <typename T>
  18. T ParseDefault(const skjson::Value& v, const T& defaultValue) {
  19. T res;
  20. if (!Parse<T>(v, &res)) {
  21. res = defaultValue;
  22. }
  23. return res;
  24. }
  25. } // namespace skottie
  26. #endif // SkottieJson_DEFINED