casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | List of all members
casacore::JsonKVMap Class Reference

Class to hold a collection of JSON key:value pairs. More...

#include <JsonKVMap.h>

Inheritance diagram for casacore::JsonKVMap:

Public Types

typedef std::map< String,
JsonValue >::const_iterator 
const_iterator
 Define the iterator types. More...
 
typedef std::map< String,
JsonValue >::iterator 
iterator
 

Public Member Functions

 JsonKVMap ()
 Construct an empty map. More...
 
 JsonKVMap (const JsonKVMap &that)
 Copy constructor (copy semantics) More...
 
 ~JsonKVMap ()
 
JsonKVMapoperator= (const JsonKVMap &that)
 Assignment (copy semantics) More...
 
Bool isDefined (const String &name) const
 Is a key defined? More...
 
const JsonValueget (const String &name) const
 Get the value of a key. More...
 
Get the typed value of a key

Use the default if not existing.

Bool getBool (const String &name, Bool defVal) const
 
Int64 getInt (const String &name, Int64 defVal) const
 
double getDouble (const String &name, double defVal) const
 
DComplex getDComplex (const String &name, const DComplex &defVal) const
 
const StringgetString (const String &name, const String &defVal) const
 
Record toRecord () const
 Convert the map to a Record. More...
 

Show the contents of the object

void show (ostream &) const
 
ostream & operator<< (ostream &, const JsonKVMap &)
 

Detailed Description

Class to hold a collection of JSON key:value pairs.

Intended use:

Public interface

Review Status

Test programs:
tJsonKVMap

Synopsis

A JsonKVMap object is the result of a JSON file parsed by JsonParser. It is a map of name to a JsonValue object holding an arbitrary value (including a JsonKVMap for nested structs).

JsonKVMap has functions to test if a given field is present and to get its JsonValue. It also has functions to get a scalar value where a default value is used if the key is undefined.

JsonKVMap is derived from std::map, so all its functions are available. Iterators make standard iteration possible.

Motivation

JSON is a commonly used interchange format.

Definition at line 72 of file JsonKVMap.h.

Member Typedef Documentation

Define the iterator types.

Definition at line 76 of file JsonKVMap.h.

Definition at line 77 of file JsonKVMap.h.

Constructor & Destructor Documentation

casacore::JsonKVMap::JsonKVMap ( )

Construct an empty map.

casacore::JsonKVMap::JsonKVMap ( const JsonKVMap that)

Copy constructor (copy semantics)

casacore::JsonKVMap::~JsonKVMap ( )

Member Function Documentation

const JsonValue& casacore::JsonKVMap::get ( const String name) const

Get the value of a key.

An exception is thrown if undefined.

Bool casacore::JsonKVMap::getBool ( const String name,
Bool  defVal 
) const
DComplex casacore::JsonKVMap::getDComplex ( const String name,
const DComplex &  defVal 
) const
double casacore::JsonKVMap::getDouble ( const String name,
double  defVal 
) const
Int64 casacore::JsonKVMap::getInt ( const String name,
Int64  defVal 
) const
const String& casacore::JsonKVMap::getString ( const String name,
const String defVal 
) const
Bool casacore::JsonKVMap::isDefined ( const String name) const
inline

Is a key defined?

Definition at line 91 of file JsonKVMap.h.

JsonKVMap& casacore::JsonKVMap::operator= ( const JsonKVMap that)

Assignment (copy semantics)

void casacore::JsonKVMap::show ( ostream &  ) const
Record casacore::JsonKVMap::toRecord ( ) const

Convert the map to a Record.

Friends And Related Function Documentation

ostream& operator<< ( ostream &  ,
const JsonKVMap  
)
friend

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