aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/skottie/src/SkottieJson.h
blob: 98ee25a3ce292a38fdc317e5acd071e3f5e8c534 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
 * Copyright 2018 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkottieJson_DEFINED
#define SkottieJson_DEFINED

#include "SkJSON.h"
#include "SkRefCnt.h"

class SkData;
class SkStream;
class SkString;

namespace skottie {

template <typename T>
bool Parse(const skjson::Value&, T*);

template <typename T>
T ParseDefault(const skjson::Value& v, const T& defaultValue) {
    T res;
    if (!Parse<T>(v, &res)) {
        res = defaultValue;
    }
    return res;
}

} // namespace skottie

#endif // SkottieJson_DEFINED