Isis 3 Programmer 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... | |
Private Member Functions | |
int | loadObject (const PvlObject &object, const PvlConstraints &constraints) |
Loads PvlObjects into the PvlFlatMap. More... | |
int | loadGroups (const PvlObject &object, const PvlConstraints &constraints) |
Loads PvlGroups into the PvlFlatMap. More... | |
int | loadGroup (const PvlGroup &group, const PvlConstraints &constraints) |
Loads a PvlGroup into the PvlFlatMap. More... | |
int | loadKeywords (const PvlContainer &pvl, const PvlConstraints &constraints) |
Loads PvlKeywords within a PvlContainer into the PvlFlatMap. 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.
2012-07-15 Kris Becker - Original version.
2015-03-18 Jeannie Backer - Brought class files closer to ISIS coding standards.
2015-03-20 Ian Humphrey - Updated documentation. Modified loadGroups() and added loadGroup() method to correctly load PvlGroups against PvlConstraints.
2016-02-28 Jeannie Backer - Moved from isisminer app to base class area. Brought closer to ISIS coding standards. Improved documentation. Created unit test. Fixes #2399
2016-02-28 Jeannie Backer - Changed readKeyListFile() to read the keylist in as an Isis::TextFile. References #2262
Definition at line 236 of file PvlFlatMap.h.
typedef QMap<QString,PvlKeyword>::const_iterator Isis::PvlFlatMap::ConstPvlFlatMapIterator |
A const iterator for the underling QMap that PvlFlatMap is built on.
Definition at line 240 of file PvlFlatMap.h.
typedef QMap<QString,PvlKeyword>::iterator Isis::PvlFlatMap::PvlFlatMapIterator |
An iterator for the underlying QMap that PvlFlatMap is built on.
Definition at line 242 of file PvlFlatMap.h.
Isis::PvlFlatMap::PvlFlatMap | ( | ) |
Default constructor.
Definition at line 360 of file PvlFlatMap.cpp.
Isis::PvlFlatMap::PvlFlatMap | ( | const PvlFlatMap & | other | ) |
Constructs a PvlFlatMap from another PvlFlatMap object.
other | The PvlFlatMap to copy |
Definition at line 369 of file PvlFlatMap.cpp.
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 |
Definition at line 390 of file PvlFlatMap.cpp.
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 |
Definition at line 411 of file PvlFlatMap.cpp.
References loadObject().
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 |
Definition at line 432 of file PvlFlatMap.cpp.
References loadKeywords().
|
virtual |
Destructor.
Definition at line 442 of file PvlFlatMap.cpp.
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 |
Definition at line 505 of file PvlFlatMap.cpp.
Referenced by loadKeywords(), and merge().
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. |
Definition at line 517 of file PvlFlatMap.cpp.
References Isis::PvlKeyword::name().
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 |
Definition at line 658 of file PvlFlatMap.cpp.
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. |
Definition at line 546 of file PvlFlatMap.cpp.
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 |
Definition at line 531 of file PvlFlatMap.cpp.
References append().
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.
key | The name of the keyword |
Definition at line 467 of file PvlFlatMap.cpp.
bool Isis::PvlFlatMap::erase | ( | const QString & | key | ) |
Erases a keyword from the PvlFlatMap.
key | The keyword to erase |
Definition at line 574 of file PvlFlatMap.cpp.
bool Isis::PvlFlatMap::exists | ( | const QString & | key | ) | const |
Determines whether a given keyword exists in the PvlFlatMap.
key | The name of the keyword |
Definition at line 453 of file PvlFlatMap.cpp.
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." |
Definition at line 593 of file PvlFlatMap.cpp.
References _FILEINFO_, Isis::IException::Programmer, and Isis::toString().
Referenced by Isis::Strategy::applyToIntersectedGeometry(), Isis::ShapeModelFactory::create(), Isis::Strategy::importGeometry(), Isis::Strategy::initProgress(), 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 |
Definition at line 621 of file PvlFlatMap.cpp.
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 |
Definition at line 487 of file PvlFlatMap.cpp.
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" |
Definition at line 677 of file PvlFlatMap.cpp.
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 |
Definition at line 719 of file PvlFlatMap.cpp.
References keyword(), and Isis::PvlKeyword::size().
Referenced by allValues().
|
private |
Loads a PvlGroup into the PvlFlatMap.
This method is the loadGroups() helper method that loads a PvlGroup into the PvlFlatMap according to any provided PvlConstraints. If the PvlGroup is to be excluded, none of its contained PvlKeywords will be loaded. If the PvlGroup is to be included, only it and any other included PvlGroups will be loaded. When a PvlGroup can be loaded, the group's PvlKeywords are loaded against any keyword constraints. Returns the number of PvlKeywords loaded from the PvlGroup.
group | The PvlGroup to load into the PvlFlatmap |
constraints | Any PvlConstraints that determine how the PvlGroup should be loaded |
Definition at line 835 of file PvlFlatMap.cpp.
References Isis::PvlConstraints::excludeSize(), Isis::PvlConstraints::includeSize(), Isis::PvlConstraints::isExcluded(), Isis::PvlConstraints::isIncluded(), loadKeywords(), and Isis::PvlContainer::name().
Referenced by loadGroups().
|
private |
Loads PvlGroups into the PvlFlatMap.
This method loads PvlGroups into the PvlFlatMap according to any provided PvlConstraints. This method iterates through a provided PvlObject and calls its helper method, loadGroup(), on each PvlGroup contained in the PvlObject. Returns the number of PvlKeywords loaded from the PvlGroups.
object | The PvlObject to load PvlGroups from |
constraints | Any PvlConstraints that determine how PvlGroups should be loaded |
Definition at line 805 of file PvlFlatMap.cpp.
References loadGroup().
Referenced by loadObject().
|
private |
Loads PvlKeywords within a PvlContainer into the PvlFlatMap.
This method loads the PvlKeywords within a PvlContainer according to any PvlConstraints given.
If there is more than one PvlKeyword with the same name, then the last loaded keyword will overwrite the previous.
If any keyword constraints exist, only the PvlKeywords included in the keyword constraints will be loaded into the PvlFlatMap. If no keyword constraints are given all PvlKeywords in the PvlContainer will be included in the PvlFlatMap.
Returns the number of PvlKeywords in the provided PvlContainer that are loaded into the PvlFlatMap.
pvl | The PvlContainer (i.e. PvlObject or PvlGroup) to load PvlKeywords from |
constraints | The keyword constraints that define which PvlKeyword will be loaded |
Definition at line 890 of file PvlFlatMap.cpp.
References add(), Isis::PvlContainer::begin(), Isis::PvlContainer::end(), Isis::PvlConstraints::isKeyInList(), and Isis::PvlConstraints::keyListSize().
Referenced by loadGroup(), loadObject(), and PvlFlatMap().
|
private |
Loads PvlObjects into the PvlFlatMap.
This method loads PvlObjects into the PvlFlatMap according to any provided PvlConstraints. If a PvlObject is to be excluded, none of its contained PvlObjects, PvlGroups, or PvlKeywords will be loaded. If the PvlObject is to be included, only it and any other included PvlObjects will be loaded. When PvlObject can be loaded, any contained PvlKeywords, PvlGroups, and PvlObjects will be loaded against any provided PvlConstraints. After finishing loading any PvlKeywords and PvlGroups contained in the PvlObject, this method will try to load subsequent PvlObjects. Returns the total number of PvlKeywords loaded into the PvlFlatMap
object | The PvlObject to load PvlKeywords, PvlGroups, and PvlObjects from |
constraints | Any PvlConstraints that define what is loaded into the PvlFlatMap |
Definition at line 747 of file PvlFlatMap.cpp.
References Isis::PvlConstraints::excludeSize(), Isis::PvlConstraints::includeSize(), Isis::PvlConstraints::isExcluded(), Isis::PvlConstraints::isIncluded(), loadGroups(), and loadKeywords().
Referenced by PvlFlatMap().
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 |
Definition at line 697 of file PvlFlatMap.cpp.
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 |
Definition at line 644 of file PvlFlatMap.cpp.