Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
Saver Class Reference

#include <elm/json/Saver.h>

+ Inheritance diagram for Saver:

Public Member Functions

 Saver (io::OutStream &out=io::out)
 
 Saver (StringBuffer &buf)
 
 Saver (sys::Path &path)
 
 ~Saver (void)
 
void close (void)
 
bool isReadable (void) const
 
void setReadable (bool read)
 
string getIndent (void) const
 
void setIndent (string i)
 
void beginObject (void)
 
void endObject (void)
 
void beginArray (void)
 
void endArray (void)
 
void addField (string id)
 
void put (void)
 
void put (const char *val)
 
void put (cstring val)
 
void put (string val)
 
void put (t::uint64 val)
 
void put (t::int64 val)
 
void put (int val)
 
void put (double val)
 
void put (bool val)
 
virtual void write (bool x) override
 
virtual void write (char c) override
 
virtual void write (signed char x) override
 
virtual void write (unsigned char x) override
 
virtual void write (short x) override
 
virtual void write (unsigned short x) override
 
virtual void write (int x) override
 
virtual void write (unsigned int x) override
 
virtual void write (long x) override
 
virtual void write (unsigned long x) override
 
virtual void write (long long int x) override
 
virtual void write (long long unsigned int x) override
 
virtual void write (float x) override
 
virtual void write (double x) override
 
virtual void write (long double x) override
 
virtual void write (const char *s) override
 
virtual void write (cstring x) override
 
virtual void write (const string &x) override
 
virtual void key (cstring x) override
 
virtual void key (const string &x) override
 
virtual void beginMap () override
 
virtual void endMap () override
 
virtual void beginList () override
 
virtual void endList () override
 
- Public Member Functions inherited from StructuredOutput
virtual ~StructuredOutput ()
 
void key (const char *x)
 

Detailed Description

Object dedicated to write a JSON file. When this object is created, a first level object must be created where the user can add pairs of (key, value) with addField() and put methods. A value may be null, a boolean, an integer, a float, a string, an array or a new object. An object is started with beginObject() and anded by endObject(). An array is made of several values (possibly of different types), is started by beginArray() and ended by endArray().

Constructor & Destructor Documentation

◆ Saver() [1/3]

Saver ( io::OutStream out = io::out)

References Output::setStream().

◆ Saver() [2/3]

◆ Saver() [3/3]

◆ ~Saver()

~Saver ( void  )

References Saver::close().

Member Function Documentation

◆ addField()

void addField ( string  id)
inline

References Saver::key().

◆ beginArray()

void beginArray ( void  )
inline

References Saver::beginList().

◆ beginList()

void beginList ( )
overridevirtual

Begin an array. Only allowed inside an array or in a field.

Implements StructuredOutput.

References Vector< T, E, A >::push().

Referenced by Saver::beginArray().

◆ beginMap()

void beginMap ( )
overridevirtual

Begin an object. Only allowed at the beginning of the output, after adding an object or inside an array.

Implements StructuredOutput.

References Vector< T, E, A >::push().

Referenced by Saver::beginObject().

◆ beginObject()

void beginObject ( void  )
inline

References Saver::beginMap().

◆ close()

void close ( void  )

Close the JSON output.

References Output::flush().

Referenced by Saver::~Saver().

◆ endArray()

void endArray ( void  )
inline

References Saver::endList().

◆ endList()

void endList ( )
overridevirtual

End an array. Only allowed inside an array.

Implements StructuredOutput.

References Vector< T, E, A >::pop().

Referenced by Saver::endArray().

◆ endMap()

void endMap ( )
overridevirtual

End an object. Only allowed inside an object.

Implements StructuredOutput.

References Vector< T, E, A >::pop().

Referenced by Saver::endObject().

◆ endObject()

void endObject ( void  )
inline

References Saver::endMap().

◆ getIndent()

string getIndent ( void  ) const
inline

Get the indentation string.

Returns
Indentation string.

◆ isReadable()

bool isReadable ( void  ) const
inline

Test if the saver will generate human readable JSON output.

Returns
True if human readable output is generate, false else.

Referenced by Saver::key().

◆ key() [1/2]

void key ( const string id)
overridevirtual

Add a field. Only allowed inside an object.

Implements StructuredOutput.

References elm::_, Saver::isReadable(), and Vector< T, E, A >::push().

◆ key() [2/2]

void key ( cstring  id)
overridevirtual

Add a field. Only allowed inside an object.

Implements StructuredOutput.

References elm::_, Saver::isReadable(), and Vector< T, E, A >::push().

Referenced by Saver::addField().

◆ put() [1/9]

void put ( bool  val)
inline

References Saver::write().

◆ put() [2/9]

void put ( const char *  val)
inline

References Saver::put().

Referenced by Saver::put().

◆ put() [3/9]

void put ( cstring  val)
inline

References Saver::write().

◆ put() [4/9]

void put ( double  val)
inline

References Saver::write().

◆ put() [5/9]

void put ( int  val)
inline

References Saver::put().

Referenced by Saver::put().

◆ put() [6/9]

void put ( string  val)
inline

References Saver::write().

◆ put() [7/9]

void put ( t::int64  val)
inline

References Saver::write().

◆ put() [8/9]

void put ( t::uint64  val)
inline

References Saver::write().

◆ put() [9/9]

void put ( void  )

Put a null value.

References Vector< T, E, A >::pop().

◆ setIndent()

void setIndent ( string  i)
inline

Set the indentation string.

Parameters
iIdentation string (must be only composed of JSON blank characters).

◆ setReadable()

void setReadable ( bool  read)
inline

Set the human readable output option.

Parameters
readTrue for human readable output, false else.

References elm::io::read().

◆ write() [1/18]

void write ( bool  val)
overridevirtual

Put a boolean value.

Parameters
valValue to put.

Implements StructuredOutput.

References Vector< T, E, A >::pop().

Referenced by Saver::put(), and Saver::write().

◆ write() [2/18]

void write ( char  c)
overridevirtual

Put a character value.

Parameters
chrCharacter to put.

Implements StructuredOutput.

References Vector< T, E, A >::pop().

◆ write() [3/18]

void write ( const char *  str)
overridevirtual

Put a string value.

Parameters
strString to put.

Implements StructuredOutput.

References elm::str(), and Saver::write().

◆ write() [4/18]

void write ( const string val)
overridevirtual

Put a string value.

Parameters
valString to put.

Implements StructuredOutput.

References Vector< T, E, A >::pop().

◆ write() [5/18]

void write ( cstring  str)
overridevirtual

Put a string value.

Parameters
strString to put.

Implements StructuredOutput.

References Vector< T, E, A >::pop(), and elm::str().

◆ write() [6/18]

void write ( double  x)
overridevirtual

Implements StructuredOutput.

◆ write() [7/18]

void write ( float  x)
overridevirtual

Implements StructuredOutput.

◆ write() [8/18]

virtual void write ( int  x)
overridevirtual

Implements StructuredOutput.

◆ write() [9/18]

void write ( long double  x)
overridevirtual

Implements StructuredOutput.

◆ write() [10/18]

virtual void write ( long long int  x)
overridevirtual

Implements StructuredOutput.

◆ write() [11/18]

virtual void write ( long long unsigned int  x)
overridevirtual

Implements StructuredOutput.

◆ write() [12/18]

virtual void write ( long  x)
overridevirtual

Implements StructuredOutput.

◆ write() [13/18]

virtual void write ( short  x)
overridevirtual

Implements StructuredOutput.

◆ write() [14/18]

void write ( signed char  x)
overridevirtual

Implements StructuredOutput.

◆ write() [15/18]

void write ( unsigned char  x)
overridevirtual

Implements StructuredOutput.

◆ write() [16/18]

void write ( unsigned int  x)
overridevirtual

Implements StructuredOutput.

◆ write() [17/18]

void write ( unsigned long  x)
overridevirtual

Implements StructuredOutput.

◆ write() [18/18]

void write ( unsigned short  x)
overridevirtual

Implements StructuredOutput.


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