Isis Developer Reference
Isis::PvlFlatMap Class Reference

Provides a flat map of PvlKeywords. More...

#include <PvlFlatMap.h>

Inheritance diagram for Isis::PvlFlatMap:
Inheritance graph
Collaboration diagram for Isis::PvlFlatMap:
Collaboration graph

Public Types

typedef QMap< QString, PvlKeyword >::const_iterator ConstPvlFlatMapIterator
 A const iterator for the underling QMap that PvlFlatMap is built on.
 
typedef QMap< QString, PvlKeyword >::iterator PvlFlatMapIterator
 An iterator for the underlying QMap that PvlFlatMap is built on.
 

Public Member Functions

 PvlFlatMap ()
 Default constructor.
 
 PvlFlatMap (const PvlFlatMap &other)
 Constructs a PvlFlatMap from another PvlFlatMap object.
 
 PvlFlatMap (const PvlFlatMap &pmap1, const PvlFlatMap &pmap2)
 Constructs a PvlFlatMap from two PvlFlatMap objects.
 
 PvlFlatMap (const PvlObject &pvl, const PvlConstraints &constraints=PvlConstraints())
 Constructs a PvlFlatMap (with constraints) from a PvlObject.
 
 PvlFlatMap (const PvlContainer &pvl, const PvlConstraints &constraints=PvlConstraints())
 Constructs a PvlFlatMap (with constraints) from the keywords in a PvlContainer (i.e PvlObject or PvlGroup).
 
virtual ~PvlFlatMap ()
 Destructor.
 
bool exists (const QString &key) const
 Determines whether a given keyword exists in the PvlFlatMap.
 
int count (const QString &key) const
 Returns the number of values associated with a given keyword.
 
bool isNull (const QString &key, const int index=0) const
 Determines if the value of a keyword is Null.
 
void add (const QString &key, const QString &value)
 Adds PvlKeyword with the given name and value to the PvlFlatMap.
 
void add (const PvlKeyword &keyword)
 Adds the given PvlKeyword to the PvlFlatMap.
 
void append (const PvlKeyword &key)
 Appends the given PvlKeyword's values to the PvlFlatMap.
 
void append (const QString &key, const QString &value)
 Appends a the given keyword and value to the PvlFlatMap.
 
bool erase (const QString &key)
 Erases a keyword from the PvlFlatMap.
 
QString get (const QString &key, const int &index=0) const
 Gets the value of a keyword in the PvlFlatMap.
 
QString get (const QString &key, const QString &defValue, const int &index=0) const
 Gets the value of a keyword in the PvlFlatMap.
 
QString operator() (const QString &name) const
 Gets the first value of a keyword in the PvlFlatMap.
 
QStringList allValues (const QString &key) const
 Gets all the values associated with a keyword in the PvlFlatMap.
 
PvlKeyword keyword (const QString &key) const
 Finds a keyword in the PvlFlatMap.
 
int merge (const PvlFlatMap &other)
 Adds the keywords from another PvlFlatMap.
 

Static Public Member Functions

static QStringList keywordValues (const PvlKeyword &keyword)
 Gets all of a PvlKeyword's values.
 

Detailed Description

Provides a flat map of PvlKeywords.

This class provides a very fast convenient way to store PVL keywords for applications that require extensive use of them. It is intended to provide a much easier interface to ISIS Pvl structures that represents them as a single flat lookup table.

Note that if you use the methods provided in this class, then the keywords names will be converted to lowercase to provide a consistent interface. One could choose to use the Qt QMap interface directly (which is the base class of this class) to use a case sensitive map. Restricting use to add() and get() methods provides the case insensitive representation.

Author
2012-07-15 Kris Becker

Member Typedef Documentation

◆ ConstPvlFlatMapIterator

typedef QMap<QString,PvlKeyword>::const_iterator Isis::PvlFlatMap::ConstPvlFlatMapIterator

A const iterator for the underling QMap that PvlFlatMap is built on.

◆ PvlFlatMapIterator

An iterator for the underlying QMap that PvlFlatMap is built on.

Constructor & Destructor Documentation

◆ PvlFlatMap() [1/5]

Isis::PvlFlatMap::PvlFlatMap ( )

Default constructor.

◆ PvlFlatMap() [2/5]

Isis::PvlFlatMap::PvlFlatMap ( const PvlFlatMap & other)

Constructs a PvlFlatMap from another PvlFlatMap object.

Parameters
otherThe PvlFlatMap to copy

References merge().

◆ PvlFlatMap() [3/5]

Isis::PvlFlatMap::PvlFlatMap ( const PvlFlatMap & pmap1,
const PvlFlatMap & pmap2 )

Constructs a PvlFlatMap from two PvlFlatMap objects.

This constructor creates a PvlFlatMap from the contents of two PvlFlatMap objects. The constructed PvlFlatMap contains the first PvlFlatMap's contents followed by the second PvlFlatMap's contents.

If there are keywords of the same in both maps, then the last loaded keyword in pmap2 will overwrite any previous values.

See also
merge()
Parameters
pmap1The first PvlFlatMap
pmap2The second PvlFlatMap

References merge().

◆ PvlFlatMap() [4/5]

Isis::PvlFlatMap::PvlFlatMap ( const PvlObject & pvl,
const PvlConstraints & constraints = PvlConstraints() )

Constructs a PvlFlatMap (with constraints) from a PvlObject.

This Constructor creates a PvlFlatMap from a PvlObject according to any constraints passed to the constructor. If no PvlConstraints object is provided, the PvlFlatMap will be created from all the objects and groups within the passed PvlObject.

See also
loadObject()
Parameters
pvlThe PvlObject to use for creating the PvlFlatMap
constraintsThe PvlConstraints that determine which Pvl objects/groups are included or excluded in the constructed PvlFlatMap

◆ PvlFlatMap() [5/5]

Isis::PvlFlatMap::PvlFlatMap ( const PvlContainer & pvl,
const PvlConstraints & constraints = PvlConstraints() )

Constructs a PvlFlatMap (with constraints) from the keywords in a PvlContainer (i.e PvlObject or PvlGroup).

This constructor creates a PvlFlatMap from a PvlGroup object according to any constraints passed to the constructor. If no PvlConstraints object is provided, the PvlFlatMap will be created from all of the objects and groups within the passed PvlContainer.

See also
loadKeywords()
Parameters
pvlThe PvlContainer to use for creating the PvlFlatMap
constraintsThe PvlConstraints that determine which Pvl objects/groups are included or excluded in the constructed PvlFlatMap

◆ ~PvlFlatMap()

Isis::PvlFlatMap::~PvlFlatMap ( )
virtual

Destructor.

Member Function Documentation

◆ add() [1/2]

void Isis::PvlFlatMap::add ( const PvlKeyword & key)

Adds the given PvlKeyword to the PvlFlatMap.

This will overwrite any existing keyword in the map keyword with the same name.

Parameters
keyThe PvlKeyword to add to the map.

References Isis::PvlKeyword::name().

◆ add() [2/2]

void Isis::PvlFlatMap::add ( const QString & key,
const QString & value )

Adds PvlKeyword with the given name and value to the PvlFlatMap.

This will overwrite any existing keyword in the map with the same name.

Parameters
keyThe name of the keyword to add
valueThe value of the added keyword

References add().

Referenced by add(), and merge().

◆ allValues()

QStringList Isis::PvlFlatMap::allValues ( const QString & key) const

Gets all the values associated with a keyword in the PvlFlatMap.

If the keyword does not exist, an empty QStringList is returned.

Parameters
keyThe name of the keyword
Returns
QStringList The list of values associated with the keyword

References keywordValues().

Referenced by Isis::Strategy::composite(), Isis::Strategy::importGeometry(), Isis::Strategy::propagateKeys(), and Isis::Strategy::translateKeywordArgs().

◆ append() [1/2]

void Isis::PvlFlatMap::append ( const PvlKeyword & key)

Appends the given PvlKeyword's values to the PvlFlatMap.

If the keyword already exists in the PvlFlatMap, the values of the provided keyword are appended to the keyword's list of values in the map.

Parameters
keyA PvlKeyword to append to the map.

References append(), exists(), Isis::PvlKeyword::name(), and Isis::PvlKeyword::size().

Referenced by append(), and append().

◆ append() [2/2]

void Isis::PvlFlatMap::append ( const QString & key,
const QString & value )

Appends a the given keyword and value to the PvlFlatMap.

If the keyword already exists in the PvlFlatMap, the provided value is appended to the keyword's list of values in the map.

Parameters
keyThe name of the keyword to be appended
valueThe value of the keyword to be appended

References append().

◆ count()

int Isis::PvlFlatMap::count ( const QString & key) const

Returns the number of values associated with a given keyword.

If the keyword does not exist, this method returns 0.

Parameters
keyThe name of the keyword
Returns
int The number of values associated with the keyword.

References exists(), and keyword().

◆ erase()

bool Isis::PvlFlatMap::erase ( const QString & key)

Erases a keyword from the PvlFlatMap.

Parameters
keyThe keyword to erase
Returns
bool Indicates whether a keyword of the given name was found and succesfully erased.

◆ exists()

bool Isis::PvlFlatMap::exists ( const QString & key) const

Determines whether a given keyword exists in the PvlFlatMap.

Parameters
keyThe name of the keyword
Returns
bool True if the keyword exists in the PvlFlatMap

Referenced by append(), count(), Isis::Strategy::importGeometry(), isNull(), and Isis::Strategy::translateKeywordArgs().

◆ get() [1/2]

QString Isis::PvlFlatMap::get ( const QString & key,
const int & index = 0 ) const

Gets the value of a keyword in the PvlFlatMap.

By default, this method gets the first value associated with the passed keyword name. If the keyword does not exist, an exception is thrown.

Parameters
keyThe name of the keyword
indexThe index of the value to get
Returns
QString The keyword's value at the specified index
Exceptions
IException::Programmer"Keyword does not exist."
IException::Programmer"Index does not exist for the given keyword."

References _FILEINFO_, Isis::IException::Programmer, and Isis::toString().

Referenced by Isis::Strategy::applyToIntersectedGeometry(), Isis::ShapeModelFactory::create(), Isis::Strategy::importGeometry(), operator()(), and Isis::Strategy::translateKeywordArgs().

◆ get() [2/2]

QString Isis::PvlFlatMap::get ( const QString & key,
const QString & defValue,
const int & index = 0 ) const

Gets the value of a keyword in the PvlFlatMap.

By default, this method gets the first value associated with the passed keyword name. If the keyword does not exist, this method returns the QString specified in defValue.

Parameters
keyThe name of the keyword
defValueThe default value to return if the keyword does not exist
indexThe index of the value to get
Returns
QString The keyword's value

◆ isNull()

bool Isis::PvlFlatMap::isNull ( const QString & key,
const int index = 0 ) const

Determines if the value of a keyword is Null.

By default, this method checks the first value associated with the passed keyword. If the keyword does not exist, this method returns true.

Parameters
keyThe name of the keyword
indexThe index of the value associated with the keyword
Returns
bool True if the keyword's value at the given index is Null or if the keyword does not exist

References exists(), isNull(), and keyword().

Referenced by isNull().

◆ keyword()

PvlKeyword Isis::PvlFlatMap::keyword ( const QString & key) const

Finds a keyword in the PvlFlatMap.

Parameters
keyThe name of the keyword to find
Returns
PvlKeyword The found keyword
Exceptions
IException::Programmer"Keyword does not exist"

References _FILEINFO_, and Isis::IException::Programmer.

Referenced by count(), isNull(), and keywordValues().

◆ keywordValues()

QStringList Isis::PvlFlatMap::keywordValues ( const PvlKeyword & keyword)
static

Gets all of a PvlKeyword's values.

(Helper method for PvlFlatMap::allValues)

Parameters
keywordThe PvlKeyword to get values from
Returns
QStringList A list of the PvlKeyword's values

References keyword(), and Isis::PvlKeyword::size().

Referenced by allValues().

◆ merge()

int Isis::PvlFlatMap::merge ( const PvlFlatMap & other)

Adds the keywords from another PvlFlatMap.

If there are keywords of the same in both maps, then the last loaded keyword in the "other" map will overwrite any previous values.

Parameters
otherThe PvlFlatMap to get keywords from
Returns
int The number of keywords added

References add().

Referenced by Isis::ShapeModelFactory::create(), PvlFlatMap(), and PvlFlatMap().

◆ operator()()

QString Isis::PvlFlatMap::operator() ( const QString & name) const

Gets the first value of a keyword in the PvlFlatMap.

This method will get the first value of the keyword if the keyword has multiple values associated with it.

Parameters
nameThe name of the keyword
Returns
QString The value of the keyword

References get().


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