Flutter Engine
The Flutter Engine
|
#include <SkJSON.h>
Public Types | |
enum class | Type { kNull , kBool , kNumber , kString , kArray , kObject } |
Public Member Functions | |
Type | getType () const |
template<typename T > | |
bool | is () const |
template<typename T > | |
const T & | as () const |
template<typename T > | |
operator const T * () const | |
SkString | toString () const |
const Value & | operator[] (const char *key) const |
Protected Types | |
enum class | Tag : uint8_t { kShortString = 0b00000000 , kNull = 0b00000001 , kBool = 0b00000010 , kInt = 0b00000011 , kFloat = 0b00000100 , kString = 0b00000101 , kArray = 0b00000110 , kObject = 0b00000111 } |
Protected Member Functions | |
void | init_tagged (Tag) |
void | init_tagged_pointer (Tag, void *) |
Tag | getTag () const |
template<typename T > | |
const T * | cast () const |
template<typename T > | |
T * | cast () |
template<typename T > | |
const T * | ptr () const |
Static Protected Attributes | |
static constexpr uint8_t | kTagMask = 0b00000111 |
A fast and likely non-conforming JSON parser.
Some known limitations/compromises:
– single-precision FP numbers
– missing string unescaping (no current users, could be easily added)
Values are opaque, fixed-size (64 bits), immutable records.
They can be converted to facade types for type-specific functionality.
E.g.:
if (v.is<ArrayValue>()) { for (const auto& item : v.as<ArrayValue>()) { if (const NumberValue* n = item) { printf("Found number: %f", **n); } } }
if (v.is<ObjectValue>()) { const StringValue* id = v.as<ObjectValue>()["id"]; if (id) { printf("Found object ID: %s", id->begin()); } else { printf("Missing object ID"); } }
|
strongprotected |
Enumerator | |
---|---|
kShortString | |
kNull | |
kBool | |
kInt | |
kFloat | |
kString | |
kArray | |
kObject |
Definition at line 131 of file SkJSON.h.
|
strong |
|
inlineprotected |
|
inline |
|
protected |
Definition at line 38 of file SkJSON.cpp.
|
protected |
Definition at line 45 of file SkJSON.cpp.
|
inline |
|
inline |
SkString Value::toString | ( | ) | const |
Definition at line 938 of file SkJSON.cpp.
|
inlinestaticconstexprprotected |