Argo  1.0
A C++ library for handling JSON.
Public Member Functions | Static Public Member Functions | List of all members
argo::unparser Class Reference

Class to unparse json instances into JSON messages. More...

#include <unparser.hpp>

Public Member Functions

 unparser (writer &w, const char *space=" ", const char *newline="", const char *indent=" ", int indent_inc=0)
 
void unparse (const json &j, int indent_level=0)
 

Static Public Member Functions

static void unparse (std::ostream &o, const json &j, const char *space=" ", const char *newline="", const char *indent=" ", int indent_inc=0)
 
static void unparse (int fd, const json &j, const char *space=" ", const char *newline="", const char *indent=" ", int indent_inc=0)
 
static void unparse (FILE *s, const json &j, const char *space=" ", const char *newline="", const char *indent=" ", int indent_inc=0)
 
static void save (const json &j, const std::string &file_name, const char *space=" ", const char *newline="", const char *indent=" ", int indent_inc=0)
 

Detailed Description

Class to unparse json instances into JSON messages.

Class to unparse json instances into JSON messages. Various convenience methods are supplied for different IO models.

Definition at line 54 of file unparser.hpp.

Constructor & Destructor Documentation

unparser::unparser ( writer w,
const char *  space = " ",
const char *  newline = "",
const char *  indent = " ",
int  indent_inc = 0 
)

Construct a new unparser given a writer instance.

Parameters
wThe writer to use for output.
spaceWhat to print for the spacing around ":" and after ",".
newlineWhat to print for a newline after name/value pairs and array items.
indentWhat to print for indents after a newline.
indent_incHow much to increment by when indenting a new object or array. 1 == one indent string parameter value.
Exceptions
json_io_exceptionThrown in the case of a IO error whilst writing.

Definition at line 44 of file unparser.cpp.

Member Function Documentation

void unparser::save ( const json j,
const std::string &  file_name,
const char *  space = " ",
const char *  newline = "",
const char *  indent = " ",
int  indent_inc = 0 
)
static

Convenience method. Create a new file, write a single JSON message to it and then close it. See documentation for unparse to stream for other parameter details.

Exceptions
json_io_exceptionThrown in the case of a IO error whilst writing.

Definition at line 204 of file unparser.cpp.

void unparser::unparse ( std::ostream &  o,
const json j,
const char *  space = " ",
const char *  newline = "",
const char *  indent = " ",
int  indent_inc = 0 
)
static

Unparse a json instance to an ostream.

Parameters
oThe ostream to write to.
jThe json instance to write.
spaceWhat to print for the spacing around ":" and after ",".
newlineWhat to print for a newline after name/value pairs and array items.
indentWhat to print for indents after a newline.
indent_incHow much to increment by when indenting a new object or array. 1 == one indent string parameter value.
Exceptions
json_io_exceptionThrown in the case of a IO error whilst writing.

Definition at line 163 of file unparser.cpp.

void unparser::unparse ( int  fd,
const json j,
const char *  space = " ",
const char *  newline = "",
const char *  indent = " ",
int  indent_inc = 0 
)
static

Unparse a json instance to a POSIX file descriptor. See documentation for unparse to stream for other parameter details.

Exceptions
json_io_exceptionThrown in the case of a IO error whilst writing.

Definition at line 177 of file unparser.cpp.

void unparser::unparse ( FILE *  s,
const json j,
const char *  space = " ",
const char *  newline = "",
const char *  indent = " ",
int  indent_inc = 0 
)
static

Unparse a json instance to a stdio FILE. See documentation for unparse to stream for other parameter details.

Exceptions
json_io_exceptionThrown in the case of a IO error whilst writing.

Definition at line 191 of file unparser.cpp.

void unparser::unparse ( const json j,
int  indent_level = 0 
)

Unparse a single json instance.

Parameters
jThe json instance to output.
indent_levelThe indent level to start at (usually 0).
Exceptions
json_io_exceptionThrown in the case of a IO error whilst writing.

Definition at line 119 of file unparser.cpp.


The documentation for this class was generated from the following files: