casacore
Public Types | Public Member Functions | List of all members
casacore::JsonKVMap Class Reference

More...

#include <JsonKVMap.h>

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

◆ const_iterator

Define the iterator types.

Definition at line 76 of file JsonKVMap.h.

◆ iterator

Definition at line 77 of file JsonKVMap.h.

Constructor & Destructor Documentation

◆ JsonKVMap() [1/2]

casacore::JsonKVMap::JsonKVMap ( )

Construct an empty map.

◆ JsonKVMap() [2/2]

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

Copy constructor (copy semantics)

◆ ~JsonKVMap()

casacore::JsonKVMap::~JsonKVMap ( )

Member Function Documentation

◆ get()

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

Get the value of a key.

An exception is thrown if undefined.

◆ getBool()

Bool casacore::JsonKVMap::getBool ( const String name,
Bool  defVal 
) const

◆ getDComplex()

DComplex casacore::JsonKVMap::getDComplex ( const String name,
const DComplex &  defVal 
) const

◆ getDouble()

double casacore::JsonKVMap::getDouble ( const String name,
double  defVal 
) const

◆ getInt()

Int64 casacore::JsonKVMap::getInt ( const String name,
Int64  defVal 
) const

◆ getString()

const String& casacore::JsonKVMap::getString ( const String name,
const String defVal 
) const

◆ isDefined()

Bool casacore::JsonKVMap::isDefined ( const String name) const
inline

Is a key defined?

Definition at line 91 of file JsonKVMap.h.

◆ operator=()

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

Assignment (copy semantics)

◆ show()

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

◆ toRecord()

Record casacore::JsonKVMap::toRecord ( ) const

Convert the map to a Record.

Friends And Related Function Documentation

◆ operator<<

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

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