JsonCpp project page | Classes | Namespace | JsonCpp home page

Classes | Public Member Functions | Protected Attributes | List of all members
Json::StreamWriter Class Referenceabstract

Usage: More...

`#include <json/writer.h>`

Inheritance diagram for Json::StreamWriter:
Collaboration diagram for Json::StreamWriter:

## Classes
class | Factory
| A simple abstract factory. More...

## Public Member Functions
| StreamWriter ()
virtual | ~StreamWriter ()
virtual int | write (Value const &root, OStream *sout)=0
| Write Value into document as configured in sub-class.

## Protected Attributes
OStream * | sout_

## Detailed Description

Usage:

using namespace Json;
void writeToStdout(StreamWriter::Factory const& factory, Value const& value)
{ std::unique_ptr<StreamWriter> const writer( factory.newStreamWriter());
writer->write(value, &std::cout);
std::cout << std::endl; // add lf and flush
}
Json::StreamWriter::Factory
A simple abstract factory.
Definition writer.h:59
Json::StreamWriter::Factory::newStreamWriter
virtual StreamWriter * newStreamWriter() const =0
Allocate a CharReader via operator new().
Json::Value
Represents a JSON value.
Definition value.h:207
Json
JSON (JavaScript Object Notation).
Definition allocator.h:16

Definition at line 42 of file writer.h.

## Constructor & Destructor Documentation

## ◆ StreamWriter()

Json::StreamWriter::StreamWriter | ( |  | ) |

Definition at line 1099 of file json_writer.cpp.

References sout_.

Referenced by Json::StreamWriter::Factory::newStreamWriter().

Here is the caller graph for this function:

## ◆ ~StreamWriter()

Json::StreamWriter::~StreamWriter | ( |  | ) |
| virtualdefault

## Member Function Documentation

## ◆ write()

virtual int Json::StreamWriter::write | ( | Value const & | root,
|  | OStream * | sout )
| pure virtual

Write Value into document as configured in sub-class.

Do not take ownership of sout, but maintain a reference during function.

Precondition
  sout != NULL

Returns
  zero on success (For now, we always return zero, so check the stream instead.)

Exceptions

  std::exception | possibly, depending on configuration

Referenced by Json::operator<<(), and Json::writeString().

Here is the caller graph for this function:

## Member Data Documentation

## ◆ sout_

OStream* Json::StreamWriter::sout_
| protected

Definition at line 44 of file writer.h.

Referenced by StreamWriter().

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

- include/json/writer.h
- src/lib_json/json_writer.cpp