Loading...
Searching...
No Matches
casacore::JsonKVMap Class Reference
casa package (libcasa_casa) » Json_module

More...

`#include <JsonKVMap.h>`

## Public Types

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

## Public Member Functions

| JsonKVMap ()
| Construct an empty map.
| JsonKVMap (const JsonKVMap &that)
| Copy constructor (copy semantics).
| ~JsonKVMap ()
JsonKVMap & | operator= (const JsonKVMap &that)
| Assignment (copy semantics).
Bool | isDefined (const String &name) const
| Is a key defined?
const JsonValue & | get (const String &name) const
| Get the value of a key.
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 String & | getString (const String &name, const String &defVal) const
Record | toRecord () const
| Convert the map to a Record.

## 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 70 of file JsonKVMap.h.

## Member Typedef Documentation

## const_iterator

typedef std::map<String,JsonValue>::const_iterator casacore::JsonKVMap::const_iterator

Define the iterator types.

Definition at line 74 of file JsonKVMap.h.

## iterator

typedef std::map<String,JsonValue>::iterator casacore::JsonKVMap::iterator

Definition at line 75 of file JsonKVMap.h.

## Constructor & Destructor Documentation

## JsonKVMap() [1/2]

casacore::JsonKVMap::JsonKVMap | ( |  | ) |

Construct an empty map.

Referenced by JsonKVMap(), operator<<, and operator=().

## JsonKVMap() [2/2]

casacore::JsonKVMap::JsonKVMap | ( | const JsonKVMap & | that | ) |

Copy constructor (copy semantics).

References JsonKVMap().

## ~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.

References casacore::name().

## getBool()

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

References casacore::name().

## getDComplex()

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

References casacore::name().

## getDouble()

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

References casacore::name().

## getInt()

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

References casacore::name().

## getString()

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

References casacore::name().

## isDefined()

Bool casacore::JsonKVMap::isDefined | ( | const String & | name | ) | const

inline

Is a key defined?

Definition at line 89 of file JsonKVMap.h.

References casacore::name().

## operator=()

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

Assignment (copy semantics).

References JsonKVMap().

## show()

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

## toRecord()

Record casacore::JsonKVMap::toRecord | ( |  | ) | const

Convert the map to a Record.

References casacore::Record().

## Friends And Related Symbol Documentation

## operator<<

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

friend

References JsonKVMap().

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

- casa/Json/JsonKVMap.h