CUGL 2.1
Cornell University Game Library
|
#include <CUJsonWriter.h>
Public Member Functions | |
void | writeJson (const std::shared_ptr< JsonValue > &json, bool format=true) |
void | writeJson (const JsonValue *json, bool format=true) |
Public Member Functions inherited from cugl::TextWriter | |
TextWriter () | |
~TextWriter () | |
bool | init (const std::string file) |
bool | init (const std::string file, unsigned int capacity) |
void | flush () |
void | close () |
void | write (char c) |
void | write (Uint8 b) |
void | write (Sint16 n) |
void | write (Uint16 n) |
void | write (Sint32 n) |
void | write (Uint32 n) |
void | write (Sint64 n) |
void | write (Uint64 n) |
void | write (bool b) |
void | write (float n) |
void | write (double n) |
void | write (const char *s) |
void | write (const std::string &s) |
void | writeLine (const char *s) |
void | writeLine (const std::string &s) |
Static Public Member Functions | |
static std::shared_ptr< JsonWriter > | alloc (const std::string file) |
static std::shared_ptr< JsonWriter > | alloc (const std::string file, unsigned int capacity) |
Static Public Member Functions inherited from cugl::TextWriter | |
static std::shared_ptr< TextWriter > | alloc (const std::string file) |
static std::shared_ptr< TextWriter > | alloc (const std::string file, unsigned int capacity) |
Additional Inherited Members | |
Protected Attributes inherited from cugl::TextWriter | |
std::string | _name |
SDL_RWops * | _stream |
char * | _cbuffer |
Uint32 | _capacity |
Sint32 | _bufoff |
Simple JSON extension to TextWriter.
This class not require that the entire file conform to JSON standards; it can write a JSON string embedded in a larger text file. This allows for maximum flexibility in encoding/decoding JSON data.
By default, this class (and every class in the io package) accesses the application save directory {
|
inlinestatic |
Returns a newly allocated writer for the given file.
The writer will have the default buffer capacity for writing chunks to the file.
If the file is a relative path, this reader will look for the file in the application save directory {
file | the path (absolute or relative) to the file |
|
inlinestatic |
Returns a newly allocated writer for the given file with the specified capacity.
If the file is a relative path, this reader will look for the file in the application save directory {
file | the path (absolute or relative) to the file |
capacity | the buffer capacity for reading chunks |
void cugl::JsonWriter::writeJson | ( | const JsonValue * | json, |
bool | format = true |
||
) |
Writes a JsonValue to the file, appending a newline at the end.
The JSON may either be pretty-printed or condensed depending on the value of format. By default, we pretty-print all JSON strings.
This method automatically flushes the buffer when done.
json | The JSON value to write |
format | Whether to pretty-print the JSON string |
|
inline |
Writes a JsonValue to the file, appending a newline at the end.
The JSON may either be pretty-printed or condensed depending on the value of format. By default, we pretty-print all JSON strings.
This method automatically flushes the buffer when done.
json | The JSON value to write |
format | Whether to pretty-print the JSON string |