![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
The FXJSON serializer loads or saves an FXVariant to a json text file. More...
#include <FXJSON.h>
Public Types | |
enum | Error { ErrOK, ErrSave, ErrLoad, ErrToken, ErrColon, ErrComma, ErrBracket, ErrBrace, ErrQuotes, ErrNumber, ErrEnd } |
enum | Flow { Stream, Compact, Pretty } |
enum | Direction { Stop = 0, Save = 1, Load = 2 } |
Public Member Functions | |
FXJSON () | |
Construct JSON serializer. | |
FXJSON (FXchar *data, FXuval sz=4096, Direction d=Load) | |
Construct JSON serializer and open for direction d. More... | |
FXbool | open (FXchar *data=NULL, FXuval size=4096, Direction d=Load) |
Open JSON stream for given direction d. More... | |
Direction | direction () const |
Return direction in effect. | |
FXuval | size () const |
Return size of parse buffer. | |
Error | load (FXVariant &variant) |
Load a variant from stream. More... | |
Error | save (const FXVariant &variant) |
Save a variant to stream. More... | |
FXint | getLine () const |
Return current line number. | |
FXint | getColumn () const |
Return current column number. | |
void | setNumericPrecision (FXint p) |
Floating point output precision control. | |
FXint | getNumericPrecision () const |
void | setNumericFormat (FXint f) |
Floating point output precision control. | |
FXint | getNumericFormat () const |
void | setOutputFlow (FXint f) |
Change output flow format (Stream, Compact, Pretty). More... | |
FXint | getOutputFlow () const |
void | setIndentation (FXint d) |
Change indentation level for pretty print flow, the amount of indentation applied for each level. | |
FXint | getIndentation () const |
void | setLineWrap (FXint w) |
Change column at which lines are wrapped. | |
FXint | getLineWrap () const |
virtual FXbool | fill () |
Fill buffer from file. More... | |
virtual FXbool | flush () |
Flush buffer to file. More... | |
virtual FXbool | close () |
Close stream and delete buffer, if owned. | |
virtual | ~FXJSON () |
Close JSON stream and clean up. | |
Static Public Member Functions | |
static const FXchar * | getError (Error err) |
Returns error code for given error. | |
Protected Attributes | |
FXchar * | begptr |
FXchar * | endptr |
FXchar * | sptr |
FXchar * | rptr |
FXchar * | wptr |
FXint | token |
FXint | column |
FXint | indent |
FXint | line |
FXint | wrap |
Direction | dir |
FXuchar | flow |
FXuchar | prec |
FXuchar | fmt |
FXuchar | dent |
FXbool | owns |
The FXJSON serializer loads or saves an FXVariant to a json text file.
Since FXVariant can contain an arbitrarily complex data structure, this provides applications with a convenient way to load and save state information in a well-defined and human-readable file format.
enum FX::FXJSON::Error |
enum FX::FXJSON::Flow |
Construct JSON serializer and open for direction d.
Use given buffer data of size sz, or allocate a local buffer.
|
virtual |
Fill buffer from file.
Return false if not open for reading, or fail to read from disk.
Reimplemented in FX::FXJSONFile.
|
virtual |
Flush buffer to file.
Return false if not open for writing, or if fail to write to disk.
Reimplemented in FX::FXJSONFile.
Load a variant from stream.
Return false if stream wasn't opened for loading, or syntax error.
Open JSON stream for given direction d.
Use given buffer data of size sz, or allocate a local buffer.
Save a variant to stream.
Return false if stream wasn't opened for saving, or disk was full.
|
inline |
Change output flow format (Stream, Compact, Pretty).
Stream is the most compact, but pretty much unreadable by humans; it aims to be compact. Compact is very human-readable while at the same time using minimum number of lines to represent the output. Pretty will print one item on each line, with indentation. It is very easily readable but produces large numbers of text lines.
![]() |