helayers::JsonWrapper Class Reference

A wrapper over a JSON tree and json I/O utils. More...

#include <JsonWrapper.h>

Public Member Functions

void init ()
 Initializes an empty object.
 
void load (const char *inBuf, int len)
 Loads json data from given char buffer. More...
 
void load (const std::string &in)
 Loads json data from given string. More...
 
void load (std::istream &in)
 Loads json data from given stream. More...
 
void loadFromBinary (std::istream &in)
 Loads json data from given stream in binary format. More...
 
void writeToBinary (std::ostream &out) const
 Write json data from given stream in binary format. More...
 
void clear ()
 Clears data (returns to uninitialized)
 
void print (std::ostream &out, bool pretty) const
 Prints json to out. More...
 
std::string getString (const std::string &key) const
 Retrieves a string value by key name, or a path containing several keys delimited by . More...
 
int getInt (const std::string &key) const
 Retrieves an integer value by key name, or a path containing several keys delimited by . More...
 
double getDouble (const std::string &key) const
 Retrieves an double value by key name, or a path containing several keys delimited by . More...
 
void setString (const std::string &key, const std::string &value)
 Sets a string value into a key name, or a path containing several keys delimited by . More...
 
void setInt (const std::string &key, int value)
 Sets an integer value into a key name, or a path containing several keys delimited by . More...
 
void setDouble (const std::string &key, double value)
 Sets a double value into a key name, or a path containing several keys delimited by . More...
 
std::string toString () const
 Returns a string containing this json data.
 
bool isInitialized () const
 Returns true if this object is initialized (was loaded).
 
JsonSubtree getRoot () const
 Returns JsonSubtree object with the subtree being the root of the JSON structure.
 

Detailed Description

A wrapper over a JSON tree and json I/O utils.

Member Function Documentation

◆ getDouble()

double helayers::JsonWrapper::getDouble ( const std::string &  key) const

Retrieves an double value by key name, or a path containing several keys delimited by .

Parameters
[in]keykey name or path delimited by .

◆ getInt()

int helayers::JsonWrapper::getInt ( const std::string &  key) const

Retrieves an integer value by key name, or a path containing several keys delimited by .

Parameters
[in]keykey name or path delimited by .

◆ getString()

string helayers::JsonWrapper::getString ( const std::string &  key) const

Retrieves a string value by key name, or a path containing several keys delimited by .

Parameters
[in]keykey name or path delimited by .

◆ load() [1/3]

void helayers::JsonWrapper::load ( const char *  inBuf,
int  len 
)

Loads json data from given char buffer.

Parameters
[in]inBufbuffer to read from
[in]lenlength of buffer

◆ load() [2/3]

void helayers::JsonWrapper::load ( const std::string &  in)

Loads json data from given string.

Parameters
[in]instring to read from

◆ load() [3/3]

void helayers::JsonWrapper::load ( std::istream &  in)

Loads json data from given stream.

Parameters
[in]instream to read from

◆ loadFromBinary()

void helayers::JsonWrapper::loadFromBinary ( std::istream &  in)

Loads json data from given stream in binary format.

Parameters
[in]instream to read from

◆ print()

void helayers::JsonWrapper::print ( std::ostream &  out,
bool  pretty 
) const

Prints json to out.

Parameters
[in]outstream to write to
[in]prettyflag indicating whether to add indentation

◆ setDouble()

void helayers::JsonWrapper::setDouble ( const std::string &  key,
double  value 
)

Sets a double value into a key name, or a path containing several keys delimited by .

Parameters
[in]keykey name or path delimited by .
[in]valuethe double value to put under the given key

◆ setInt()

void helayers::JsonWrapper::setInt ( const std::string &  key,
int  value 
)

Sets an integer value into a key name, or a path containing several keys delimited by .

Parameters
[in]keykey name or path delimited by .
[in]valuethe integer value to put under the given key

◆ setString()

void helayers::JsonWrapper::setString ( const std::string &  key,
const std::string &  value 
)

Sets a string value into a key name, or a path containing several keys delimited by .

Parameters
[in]keykey name or path delimited by .
[in]valuethe string value to put under the given key

◆ writeToBinary()

void helayers::JsonWrapper::writeToBinary ( std::ostream &  out) const

Write json data from given stream in binary format.

Parameters
[in]outstream to write to

The documentation for this class was generated from the following files:
  • /opt/IBM/FHE-distro/ML-HElib/src/helayers/hebase/utils/JsonWrapper.h
  • /opt/IBM/FHE-distro/ML-HElib/src/helayers/hebase/utils/JsonWrapper.cpp