summaryrefslogtreecommitdiff
path: root/platform/android/src/gson/json_primitive.hpp
blob: 5fc8a2b485b8f24b13db02f82be2214dff56e5db (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
35
36
37
38
39
#pragma once

#include <mapbox/geometry.hpp>
#include <mbgl/util/noncopyable.hpp>

#include <jni/jni.hpp>

namespace mbgl {
namespace android {
namespace gson {

class JsonPrimitive : private mbgl::util::noncopyable {
public:
    using value = mapbox::util::variant<mapbox::geometry::null_value_t, bool, uint64_t, int64_t, double, std::string>;

    static constexpr auto Name() { return "com/google/gson/JsonPrimitive"; };

    static value convert(JNIEnv&, jni::Object<JsonPrimitive>);

    static bool isBoolean(JNIEnv&, jni::Object<JsonPrimitive>);

    static bool isString(JNIEnv&, jni::Object<JsonPrimitive>);

    static bool isNumber(JNIEnv&, jni::Object<JsonPrimitive>);

    static bool getAsBoolean(JNIEnv&, jni::Object<JsonPrimitive>);

    static std::string getAsString(JNIEnv&, jni::Object<JsonPrimitive>);

    static double getAsDouble(JNIEnv&, jni::Object<JsonPrimitive>);

    static jni::Class<JsonPrimitive> javaClass;

    static void registerNative(jni::JNIEnv&);
};

} // namespace gson
} // namespace android
} // namespace mbgl