Isis Developer Reference
|
Provides a flat map of PvlKeywords. More...
#include <PvlFlatMap.h>
Public Types | |
typedef QMap< QString, PvlKeyword >::const_iterator | ConstPvlFlatMapIterator |
A const iterator for the underling QMap that PvlFlatMap is built on. More... | |
typedef QMap< QString, PvlKeyword >::iterator | PvlFlatMapIterator |
An iterator for the underlying QMap that PvlFlatMap is built on. More... | |
Public Member Functions | |
PvlFlatMap () | |
Default constructor. More... | |
PvlFlatMap (const PvlFlatMap &other) | |
Constructs a PvlFlatMap from another PvlFlatMap object. More... | |
PvlFlatMap (const PvlFlatMap &pmap1, const PvlFlatMap &pmap2) | |
Constructs a PvlFlatMap from two PvlFlatMap objects. More... | |
PvlFlatMap (const PvlObject &pvl, const PvlConstraints &constraints=PvlConstraints()) | |
Constructs a PvlFlatMap (with constraints) from a PvlObject. More... | |
PvlFlatMap (const PvlContainer &pvl, const PvlConstraints &constraints=PvlConstraints()) | |
Constructs a PvlFlatMap (with constraints) from the keywords in a PvlContainer (i.e PvlObject or PvlGroup). More... | |
virtual | ~PvlFlatMap () |
Destructor. More... | |
bool | exists (const QString &key) const |
Determines whether a given keyword exists in the PvlFlatMap. More... | |
int | count (const QString &key) const |
Returns the number of values associated with a given keyword. More... | |
bool | isNull (const QString &key, const int index=0) const |
Determines if the value of a keyword is Null. More... | |
void | add (const QString &key, const QString &value) |
Adds PvlKeyword with the given name and value to the PvlFlatMap. More... | |
void | add (const PvlKeyword &keyword) |
Adds the given PvlKeyword to the PvlFlatMap. More... | |
void | append (const PvlKeyword &key) |
Appends the given PvlKeyword's values to the PvlFlatMap. More... | |
void | append (const QString &key, const QString &value) |
Appends a the given keyword and value to the PvlFlatMap. More... | |
bool | erase (const QString &key) |
Erases a keyword from the PvlFlatMap. More... | |
QString | get (const QString &key, const int &index=0) const |
Gets the value of a keyword in the PvlFlatMap. More... | |
QString | get (const QString &key, const QString &defValue, const int &index=0) const |
Gets the value of a keyword in the PvlFlatMap. More... | |
QString | operator() (const QString &name) const |
Gets the first value of a keyword in the PvlFlatMap. More... | |
QStringList | allValues (const QString &key) const |
Gets all the values associated with a keyword in the PvlFlatMap. More... | |
PvlKeyword | keyword (const QString &key) const |
Finds a keyword in the PvlFlatMap. More... | |
int | merge (const PvlFlatMap &other) |
Adds the keywords from another PvlFlatMap. More... | |
Static Public Member Functions | |
static QStringList | keywordValues (const PvlKeyword &keyword) |
Gets all of a PvlKeyword's values. More... | |
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.
typedef QMap<QString,PvlKeyword>::const_iterator Isis::PvlFlatMap::ConstPvlFlatMapIterator |
A const iterator for the underling QMap that PvlFlatMap is built on.
typedef QMap<QString,PvlKeyword>::iterator Isis::PvlFlatMap::PvlFlatMapIterator |
An iterator for the underlying QMap that PvlFlatMap is built on.
Isis::PvlFlatMap::PvlFlatMap | ( | ) |
Default constructor.
Isis::PvlFlatMap::PvlFlatMap | ( | const PvlFlatMap & | other | ) |
Constructs a PvlFlatMap from another PvlFlatMap object.
other | The PvlFlatMap to copy |
References merge().
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.
pmap1 | The first PvlFlatMap |
pmap2 | The second PvlFlatMap |
References merge().
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.
pvl | The PvlObject to use for creating the PvlFlatMap |
constraints | The PvlConstraints that determine which Pvl objects/groups are included or excluded in the constructed PvlFlatMap |
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.
pvl | The PvlContainer to use for creating the PvlFlatMap |
constraints | The PvlConstraints that determine which Pvl objects/groups are included or excluded in the constructed PvlFlatMap |
|
virtual |
Destructor.
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.
key | The PvlKeyword to add to the map. |
References Isis::PvlKeyword::name().
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.
key | The name of the keyword to add |
value | The value of the added keyword |
Referenced by merge().
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.
key | The name of the keyword |
References keywordValues().
Referenced by Isis::Strategy::composite(), Isis::Strategy::importGeometry(), Isis::Strategy::propagateKeys(), and Isis::Strategy::translateKeywordArgs().
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.
key | A PvlKeyword to append to the map. |
References exists(), Isis::PvlKeyword::name(), and Isis::PvlKeyword::size().
Referenced by append().
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.
key | The name of the keyword to be appended |
value | The value of the keyword to be appended |
References append().
int Isis::PvlFlatMap::count | ( | const QString & | key | ) | const |
bool Isis::PvlFlatMap::erase | ( | const QString & | key | ) |
Erases a keyword from the PvlFlatMap.
key | The keyword to erase |
bool Isis::PvlFlatMap::exists | ( | const QString & | key | ) | const |
Determines whether a given keyword exists in the PvlFlatMap.
key | The name of the keyword |
Referenced by append(), count(), Isis::Strategy::importGeometry(), isNull(), and Isis::Strategy::translateKeywordArgs().
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.
key | The name of the keyword |
index | The index of the value to get |
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(), Isis::Strategy::initProgress(), operator()(), Isis::Strategy::Strategy(), and Isis::Strategy::translateKeywordArgs().
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.
key | The name of the keyword |
defValue | The default value to return if the keyword does not exist |
index | The index of the value to get |
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.
key | The name of the keyword |
index | The index of the value associated with the keyword |
PvlKeyword Isis::PvlFlatMap::keyword | ( | const QString & | key | ) | const |
Finds a keyword in the PvlFlatMap.
key | The name of the keyword to find |
IException::Programmer | "Keyword does not exist" |
References _FILEINFO_, and Isis::IException::Programmer.
Referenced by count(), isNull(), and keywordValues().
|
static |
Gets all of a PvlKeyword's values.
(Helper method for PvlFlatMap::allValues)
keyword | The PvlKeyword to get values from |
References keyword(), and Isis::PvlKeyword::size().
Referenced by allValues().
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.
other | The PvlFlatMap to get keywords from |
References add().
Referenced by Isis::ShapeModelFactory::create(), and PvlFlatMap().
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.
name | The name of the keyword |
References get().