Flutter Engine
The Flutter Engine
|
#include <SkJSONWriter.h>
Public Types | |
enum class | Mode { kFast , kPretty } |
Public Member Functions | |
SkJSONWriter (SkWStream *stream, Mode mode=Mode::kFast) | |
~SkJSONWriter () | |
void | flush () |
void | appendName (const char *name) |
void | beginObject (const char *name=nullptr, bool multiline=true) |
void | endObject () |
void | beginArray (const char *name=nullptr, bool multiline=true) |
void | endArray () |
void | appendString (const char *value, size_t size) |
void | appendString (const SkString &value) |
template<class T , std::enable_if_t< std::is_same_v< T, std::string >, bool > = false> | |
void | appendString (const T &value) |
template<size_t N> | |
void | appendNString (char const (&value)[N]) |
void | appendCString (const char *value) |
void | appendPointer (const void *value) |
void | appendBool (bool value) |
void | appendS32 (int32_t value) |
void | appendS64 (int64_t value) |
void | appendU32 (uint32_t value) |
void | appendU64 (uint64_t value) |
void | appendFloat (float value) |
void | appendDouble (double value) |
void | appendFloatDigits (float value, int digits) |
void | appendDoubleDigits (double value, int digits) |
void | appendHexU32 (uint32_t value) |
void | appendHexU64 (uint64_t value) |
void | appendString (const char *name, const char *value, size_t size) |
void | appendString (const char *name, const SkString &value) |
template<class T , std::enable_if_t< std::is_same_v< T, std::string >, bool > = false> | |
void | appendString (const char *name, const T &value) |
template<size_t N> | |
void | appendNString (const char *name, char const (&value)[N]) |
void | appendCString (const char *name, const char *value) |
void | appendFloatDigits (const char *name, float value, int digits) |
void | appendDoubleDigits (const char *name, double value, int digits) |
Lightweight class for writing properly structured JSON data. No random-access, everything must be generated in-order. The resulting JSON is written directly to the SkWStream supplied at construction time. Output is buffered, so writing to disk (via an SkFILEWStream) is ideal.
There is a basic state machine to ensure that JSON is structured correctly, and to allow for (optional) pretty formatting.
This class adheres to the RFC-4627 usage of JSON (not ECMA-404). In other words, all JSON created with this class must have a top-level object or array. Free-floating values of other types are not considered valid.
Note that all error checking is in the form of asserts - invalid usage in a non-debug build will simply produce invalid JSON.
Definition at line 38 of file SkJSONWriter.h.
|
strong |
Definition at line 40 of file SkJSONWriter.h.
|
inline |
Construct a JSON writer that will serialize all the generated JSON to 'stream'.
Definition at line 57 of file SkJSONWriter.h.
|
inline |
Definition at line 68 of file SkJSONWriter.h.
|
inline |
Definition at line 229 of file SkJSONWriter.h.
|
inline |
Definition at line 273 of file SkJSONWriter.h.
|
inline |
Definition at line 224 of file SkJSONWriter.h.
|
inline |
Definition at line 242 of file SkJSONWriter.h.
|
inline |
Definition at line 301 of file SkJSONWriter.h.
|
inline |
Definition at line 247 of file SkJSONWriter.h.
|
inline |
Definition at line 241 of file SkJSONWriter.h.
|
inline |
Functions for adding named values of various types. These add a name field, so must be called between beginObject() and endObject().
Definition at line 297 of file SkJSONWriter.h.
|
inline |
Definition at line 243 of file SkJSONWriter.h.
|
inline |
Definition at line 251 of file SkJSONWriter.h.
void SkJSONWriter::appendHexU64 | ( | uint64_t | value | ) |
Definition at line 29 of file SkJSONWriter.cpp.
|
inline |
Append the name (key) portion of an object member. Must be called between beginObject() and endObject(). If you have both the name and value of an object member, you can simply call the two argument versions of the other append functions.
Definition at line 90 of file SkJSONWriter.h.
|
inline |
Definition at line 220 of file SkJSONWriter.h.
|
inline |
Definition at line 268 of file SkJSONWriter.h.
|
inline |
Definition at line 228 of file SkJSONWriter.h.
|
inline |
Definition at line 237 of file SkJSONWriter.h.
void SkJSONWriter::appendS64 | ( | int64_t | value | ) |
Definition at line 19 of file SkJSONWriter.cpp.
|
inline |
Definition at line 254 of file SkJSONWriter.h.
|
inline |
Definition at line 258 of file SkJSONWriter.h.
|
inline |
Definition at line 264 of file SkJSONWriter.h.
|
inline |
Functions for adding values of various types. The single argument versions add un-named values, so must be called either
Definition at line 176 of file SkJSONWriter.h.
|
inline |
Definition at line 212 of file SkJSONWriter.h.
|
inline |
Definition at line 217 of file SkJSONWriter.h.
|
inline |
Definition at line 239 of file SkJSONWriter.h.
void SkJSONWriter::appendU64 | ( | uint64_t | value | ) |
Definition at line 24 of file SkJSONWriter.cpp.
|
inline |
Adds a new array. A name must be supplied when called between beginObject() and endObject(). Calls to beginArray() must be balanced by corresponding calls to endArray(). By default, arrays are written out with one value per line (when in kPretty mode). This can be overridden for a particular array by passing false for multiline, this will keep the entire array on a single line. This can help with readability in some situations. In kFast mode, this parameter is ignored.
Definition at line 146 of file SkJSONWriter.h.
|
inline |
Adds a new object. A name must be supplied when called between beginObject() and endObject(). Calls to beginObject() must be balanced by corresponding calls to endObject(). By default, objects are written out with one named value per line (when in kPretty mode). This can be overridden for a particular object by passing false for multiline, this will keep the entire object on a single line. This can help with readability in some situations. In kFast mode, this parameter is ignored.
Definition at line 114 of file SkJSONWriter.h.
|
inline |
Ends an array that was previous started with beginArray().
Definition at line 158 of file SkJSONWriter.h.
|
inline |
Ends an object that was previously started with beginObject().
Definition at line 126 of file SkJSONWriter.h.
|
inline |
Force all buffered output to be flushed to the underlying stream.
Definition at line 78 of file SkJSONWriter.h.