Isis Developer Reference
|
A single keyword-value pair. More...
#include <PvlKeyword.h>
Public Member Functions | |
PvlKeyword () | |
Constructs a blank PvlKeyword object. More... | |
PvlKeyword (QString name) | |
Constructs a PvlKeyword object with a name. More... | |
PvlKeyword (QString name, QString value, QString unit="") | |
Constructs a PvlKeyword object with a name, value and units. More... | |
PvlKeyword (const PvlKeyword &other) | |
Copy constructor. More... | |
~PvlKeyword () | |
Destructs a PvlKeyword object. More... | |
void | setName (QString name) |
Sets the keyword name. More... | |
QString | name () const |
Returns the keyword name. More... | |
bool | isNamed (QString name) const |
Determines whether two PvlKeywords have the same name or not. More... | |
void | setValue (QString value, QString unit="") |
Sets new values. More... | |
void | setUnits (QString units) |
Sets the unit of measure for all current values if any exist. More... | |
void | setUnits (QString value, QString units) |
Sets the unit of measure for a given value. More... | |
PvlKeyword & | operator= (QString value) |
Sets new values. More... | |
void | addValue (QString value, QString unit="") |
Adds a value with units. More... | |
PvlKeyword & | operator+= (QString value) |
Adds a value. More... | |
int | size () const |
Returns the number of values stored in this keyword. More... | |
bool | isNull (const int index=0) const |
Decides whether a value is null or not at a given index. More... | |
void | clear () |
Clears all values and units for this PvlKeyword object. More... | |
operator double () const | |
Returns the first value in this keyword converted to a double. More... | |
operator int () const | |
Returns the first value in this keyword converted to an integer. More... | |
operator Isis::BigInt () const | |
Returns the first value in this keyword converted to a BigInt. More... | |
operator QString () const | |
const QString & | operator[] (int index) const |
Gets value for this object at specified index. More... | |
QString & | operator[] (int index) |
Gets value for this object at specified index. More... | |
QString | unit (const int index=0) const |
Returns the units of measurement of the element of the array of values for the object at the specified index. More... | |
void | addComment (QString comment) |
Add a comment to the PvlKeyword. More... | |
void | addCommentWrapped (QString comment) |
Automatically wraps and adds long comments to the PvlKeyword. More... | |
void | addComments (const std::vector< QString > &comments) |
This method adds multiple comments at once by calling AddComments on each element in the vector. More... | |
int | comments () const |
Returns the number of lines of comments associated with this keyword. More... | |
QString | comment (const int index) const |
Return a comment at the specified index. More... | |
void | clearComment () |
Clears the current comments. More... | |
bool | operator== (const PvlKeyword &key) const |
Returns true of the keyword names match. More... | |
bool | operator!= (const PvlKeyword &key) const |
Returns true of the keyword names do not match. More... | |
bool | isEquivalent (QString string1, int index=0) const |
Checks to see if a value with a specified index is equivalent to another QString. More... | |
void | setWidth (int width) |
The width of the longest keyword name (for formatting) More... | |
void | setIndent (int indent) |
Sets the indent level when outputted(for formatting) More... | |
int | width () const |
Returns the current set longest keyword name. More... | |
int | indent () const |
Returns the current indent level. More... | |
PvlKeyword & | operator= (Isis::PvlSequence &seq) |
Add values and units from a PvlSequence. More... | |
void | setFormat (PvlFormat *formatter) |
Set the PvlFormatter used to format the keyword name and value(s) More... | |
PvlFormat * | format () |
Get the current PvlFormat or create one. More... | |
const PvlKeyword & | operator= (const PvlKeyword &other) |
This is an assignment operator. More... | |
void | validateKeyword (PvlKeyword &pvlKwrd, QString psValueType="", PvlKeyword *pvlKwrdRange=NULL) |
Validate Keyword for type and required values. More... | |
Static Public Member Functions | |
static bool | stringEqual (const QString &string1, const QString &string2) |
Checks to see if two QStrings are equal. More... | |
static QString | readLine (std::istream &is, bool insideComment) |
This method reads one line of data from the input stream. More... | |
static bool | readCleanKeyword (QString keyword, std::vector< QString > &keywordComments, QString &keywordName, std::vector< std::pair< QString, QString > > &keywordValues) |
This reads a keyword compressed back to 1 line of data (excluding comments, which are included on separate lines of data before the keyword). More... | |
static QString | readValue (QString &keyword, bool "eProblem) |
static QString | readValue (QString &keyword, bool "eProblem, const std::vector< std::pair< char, char > > &otherDelimiters) |
This method looks for a data element in the QString. More... | |
Protected Member Functions | |
QString | reform (const QString &value) const |
Checks if the value needs to be converted to PVL or iPVL and returns it in the correct format. More... | |
QString | toPvl (const QString &value) const |
Converts a value to PVL format. More... | |
QString | toIPvl (const QString &value) const |
Converts a value to iPVL format. More... | |
std::ostream & | writeWithWrap (std::ostream &os, const QString &textToWrite, int startColumn, PvlFormat &format) const |
Wraps output so that length doesn't exceed the character limit. More... | |
Protected Attributes | |
PvlFormat * | m_formatter |
Formatter object. More... | |
Friends | |
std::istream & | operator>> (std::istream &is, PvlKeyword &result) |
Read in a keyword. More... | |
std::ostream & | operator<< (std::ostream &os, const PvlKeyword &keyword) |
Write out the keyword. More... | |
A single keyword-value pair.
This class is used to create a single PVL keyword-value pair. PvlContainer can combine PvlKeyword objects and organize them so they look clean on output.
Isis::PvlKeyword::PvlKeyword | ( | ) |
Constructs a blank PvlKeyword object.
Isis::PvlKeyword::PvlKeyword | ( | QString | name | ) |
Constructs a PvlKeyword object with a name.
name | The keyword name |
Isis::PvlKeyword::PvlKeyword | ( | QString | name, |
QString | value, | ||
QString | unit = "" |
||
) |
Constructs a PvlKeyword object with a name, value and units.
Defaults to unit="".
name | The keyword name. |
value | The keyword values. |
unit | The units the values are given in. |
Isis::PvlKeyword::PvlKeyword | ( | const PvlKeyword & | other | ) |
Copy constructor.
Isis::PvlKeyword::~PvlKeyword | ( | ) |
Destructs a PvlKeyword object.
void Isis::PvlKeyword::addComment | ( | QString | comment | ) |
Add a comment to the PvlKeyword.
comment | The new comment. |
Referenced by Isis::PvlContainer::addComment(), and Isis::ControlNetVersioner::toPvl().
void Isis::PvlKeyword::addComments | ( | const std::vector< QString > & | comments | ) |
This method adds multiple comments at once by calling AddComments on each element in the vector.
comments | Comments to associate with this keyword |
Referenced by Isis::operator>>().
void Isis::PvlKeyword::addCommentWrapped | ( | QString | comment | ) |
Automatically wraps and adds long comments to the PvlKeyword.
comment | The new comment to add |
References Isis::IString::Token().
void Isis::PvlKeyword::addValue | ( | QString | value, |
QString | unit = "" |
||
) |
Adds a value with units.
If no current value exists, this method sets the given value. Otherwise, it retains any current values and adds the value given to the array of values for this PvlKeyword object. Defaults to unit = "" (empty QString).
value | New value to be assigned. |
unit | Units of measurement corresponding to the value. |
Referenced by Isis::DbProfile::add(), Isis::PvlFormat::add(), Isis::ControlNetDiff::addUniqueMeasure(), Isis::ControlNetDiff::addUniquePoint(), IsisAml::CommandLine(), Isis::PvlToPvlTranslationManager::DoTranslation(), Isis::HiHistory::makekey(), Isis::ControlNetDiff::makeKeyword(), Isis::operator>>(), Isis::Stretch::Save(), and Isis::Spice::storeValue().
void Isis::PvlKeyword::clear | ( | ) |
Clears all values and units for this PvlKeyword object.
Referenced by Isis::PvlFormatPds::formatBinary(), and Isis::operator>>().
void Isis::PvlKeyword::clearComment | ( | ) |
Clears the current comments.
QString Isis::PvlKeyword::comment | ( | const int | index | ) | const |
Return a comment at the specified index.
index | The index of the comment. |
iException | ArraySubscriptNotInRange (index) Index out of bounds. |
References _FILEINFO_, and Isis::Message::ArraySubscriptNotInRange().
Referenced by Isis::PvlContainer::comment(), Isis::operator<<(), and Isis::pvlKeywordToJSON().
|
inline |
Returns the number of lines of comments associated with this keyword.
Referenced by Isis::PvlContainer::comments(), Isis::operator<<(), and Isis::pvlKeywordToJSON().
PvlFormat * Isis::PvlKeyword::format | ( | ) |
Get the current PvlFormat or create one.
Referenced by Isis::PvlContainer::format().
|
inline |
Returns the current indent level.
Referenced by Isis::PvlContainer::indent(), Isis::operator<<(), and setIndent().
bool Isis::PvlKeyword::isEquivalent | ( | QString | QString1, |
int | index = 0 |
||
) | const |
Checks to see if a value with a specified index is equivalent to another QString.
QString1 | The QString to compare the value to. |
index | The index of the existing value. |
iException | ArraySubscriptNotInRange (index) Index out of bounds. |
References _FILEINFO_, and Isis::Message::ArraySubscriptNotInRange().
Referenced by Isis::Blob::Find().
|
inline |
Determines whether two PvlKeywords have the same name or not.
name | The name of the keyword to compare with this one. |
References name(), and stringEqual().
Referenced by Isis::KernelDb::findAll(), and Isis::KernelDb::matches().
bool Isis::PvlKeyword::isNull | ( | const int | index = 0 | ) | const |
Decides whether a value is null or not at a given index.
Defaults to index = 0.
index | The value index |
References _FILEINFO_, and Isis::Message::ArraySubscriptNotInRange().
|
inline |
Returns the keyword name.
Referenced by Isis::PvlFormat::accuracy(), Isis::PvlFlatMap::add(), Isis::PvlFormat::add(), Isis::PvlContainer::addKeyword(), Isis::PvlTranslationTable::AddTable(), Isis::PvlFlatMap::append(), Isis::ControlNetDiff::compare(), Isis::Strategy::composite(), Isis::ControlMeasureLogData::ControlMeasureLogData(), Isis::ControlPointV0001::ControlPointV0001(), Isis::ControlPointV0002::ControlPointV0002(), Isis::PvlToXmlTranslationManager::doTranslation(), Isis::PvlFormat::formatName(), Isis::PvlFormatPds::formatName(), Isis::PvlFormatPds::formatValue(), Isis::PvlToPvlTranslationManager::InputKeyword(), Isis::PvlToXmlTranslationManager::InputKeyword(), isNamed(), Isis::Preference::Load(), Isis::PvlContainer::operator-=(), Isis::operator>>(), Isis::XmlToPvlTranslationManager::Translate(), Isis::PvlContainer::type(), Isis::PvlFormat::type(), Isis::PvlContainer::validateAllKeywords(), validateKeyword(), and Isis::PvlContainer::validateRepeatOption().
|
inline |
Returns the first value in this keyword converted to a double.
References Isis::toDouble().
|
inline |
Returns the first value in this keyword converted to an integer.
References Isis::toInt().
|
inline |
Returns the first value in this keyword converted to a BigInt.
References Isis::toBigInt().
Isis::PvlKeyword::operator QString | ( | ) | const |
|
inline |
Returns true of the keyword names do not match.
key | The keyword to compare names with |
PvlKeyword & Isis::PvlKeyword::operator+= | ( | QString | value | ) |
Adds a value.
Overwrites the '+=' operators to add a new value. Like addValue(), this method keeps any previously existing values and adds the new value with unit = "" (empty QString) to the array of values for this PvlKeyword object.
value | The new value. |
const PvlKeyword & Isis::PvlKeyword::operator= | ( | const PvlKeyword & | other | ) |
This is an assignment operator.
References m_formatter.
PvlKeyword & Isis::PvlKeyword::operator= | ( | Isis::PvlSequence & | seq | ) |
Add values and units from a PvlSequence.
(Clears current values and units)
seq | The PvlSequence to add from. |
References Isis::PvlSequence::Size().
PvlKeyword & Isis::PvlKeyword::operator= | ( | QString | value | ) |
Sets new values.
Overwrites the '=' operator to add a new value using addValue(). Like setValue(), this method clears any previously existing values and resets to the given value with unit = "" (empty QString).
value | The value to be added. |
|
inline |
Returns true of the keyword names match.
key | The keyword to compare names with |
References stringEqual().
QString & Isis::PvlKeyword::operator[] | ( | int | index | ) |
Gets value for this object at specified index.
Overrides the '[]' operator to return the element in the array of values at the specified index.
index | The index of the value. |
iException | ArraySubscriptNotInRange (index) Index out of bounds. |
References _FILEINFO_, and Isis::Message::ArraySubscriptNotInRange().
const QString & Isis::PvlKeyword::operator[] | ( | int | index | ) | const |
Gets value for this object at specified index.
Overrides the '[]' operator to return the element in the array of values at the specified index.
index | The index of the value. |
iException | ArraySubscriptNotInRange (index) Index out of bounds. |
References _FILEINFO_, and Isis::Message::ArraySubscriptNotInRange().
|
static |
This reads a keyword compressed back to 1 line of data (excluding comments, which are included on separate lines of data before the keyword).
Line concatenations must have already been handled. This returns the data of the keyword (if valid) and its status.
keyword | Pvl "#COMMENT\n//COMMENT\nKeyword = (Value1,Value2,...)" QString |
keywordComments | Output: Lines of data that are comments |
keywordName | Output: Name of keyword |
keywordValues | Output: vector< pair<Value, Units> > |
References _FILEINFO_.
|
static |
This method reads one line of data from the input stream.
All spaces, newlines, returns and tabs are trimmed from the result. Once a newline is encountered, if the line we read is blank, we keep reading. Once a line with data is encountered, that is the result. All newlines, spaces, returns and tabs are consumed past this line of data until the next different character (seeks to next valid data).
is | The stream to read from |
|
static |
|
static |
This method looks for a data element in the QString.
A data element is a quoted QString, a units value, or one value of an array (not including units). As an example, each value in the following QString is quoted:
'VALUE' '=' ('VALUE','VALUE', 'VALUE' '
')
The returned values of each of these elements is VALUE. Explicitly defined quotes (', ", <>) are stripped from the return value.
keyword | Input/Output: The keyword to get the next value from (DESTRUCTIVE) |
quoteProblem | Output: The QString has an unclosed quote character |
|
protected |
Checks if the value needs to be converted to PVL or iPVL and returns it in the correct format.
value | The value to be converted. |
References Isis::PvlObject::findGroup(), Isis::Preference::Preferences(), Isis::PvlObject::Traverse, and Isis::IString::UpCase().
void Isis::PvlKeyword::setFormat | ( | PvlFormat * | formatter | ) |
Set the PvlFormatter used to format the keyword name and value(s)
formatter | A pointer to the formatter to be used |
Referenced by Isis::PvlContainer::setFormat().
|
inline |
Sets the indent level when outputted(for formatting)
indent | The new indent |
References indent().
Referenced by Isis::PvlContainer::setIndent().
void Isis::PvlKeyword::setName | ( | QString | name | ) |
Sets the keyword name.
name | The new keyword name. |
References _FILEINFO_.
Referenced by Isis::Strategy::composite(), Isis::PvlToPvlTranslationManager::DoTranslation(), Isis::operator>>(), and Isis::PvlObject::PvlObject().
void Isis::PvlKeyword::setUnits | ( | QString | units | ) |
Sets the unit of measure for all current values if any exist.
units | New units to be assigned. |
void Isis::PvlKeyword::setUnits | ( | QString | value, |
QString | units | ||
) |
Sets the unit of measure for a given value.
value | The value to match |
units | New units to be assigned. |
Isis::iException::Programmer | - Given value must exist |
References _FILEINFO_, and ASSERT.
void Isis::PvlKeyword::setValue | ( | QString | value, |
QString | unit = "" |
||
) |
Sets new values.
If no current value exists, this method sets the given value to the PvlKeyword. Otherwise, it clears any existing values and resets to the value given using addValue(). Defaults to unit = "" (empty QString).
value | New value to be assigned. |
unit | Units of measurement corresponding to the value. |
Referenced by Isis::PvlObject::PvlObject(), Isis::PvlContainer::setName(), Isis::ProcessExportPds::StandardAllMapping(), Isis::ProcessMosaic::StartProcess(), and Isis::OverlapStatistics::toPvl().
|
inline |
The width of the longest keyword name (for formatting)
width | the new width |
References width().
|
inline |
Returns the number of values stored in this keyword.
Referenced by Isis::PvlFormat::accuracy(), Isis::PvlFormat::add(), Isis::PvlToXmlTranslationManager::addAttributes(), Isis::PvlToXmlTranslationManager::addSiblings(), Isis::PvlTranslationTable::AddTable(), Isis::PvlFlatMap::append(), Isis::Cube::attachSpiceFromIsd(), Isis::BundleObservationSolveSettings::BundleObservationSolveSettings(), Isis::XmlToPvlTranslationManager::checkDependencies(), Isis::ClipperNacRollingShutterCamera::ClipperNacRollingShutterCamera(), Isis::DbProfile::count(), Isis::LabelTranslationManager::CreateContainer(), Isis::PvlToXmlTranslationManager::createParentElements(), Isis::ProcessExportPds4::createUnitMap(), Isis::PvlFormatPds::formatBinary(), Isis::PvlFormatPds::formatBool(), Isis::PvlFormatPds::formatEnum(), Isis::PvlFormatPds::formatHex(), Isis::PvlFormatPds::formatInteger(), Isis::PvlFormatPds::formatReal(), Isis::PvlFormatPds::formatString(), Isis::PvlFormatPds::formatUnknown(), Isis::PvlFormat::formatValue(), Isis::CubeViewport::getAllWhatsThisInfo(), Isis::PvlToPvlTranslationManager::GetContainer(), Isis::PvlToXmlTranslationManager::GetContainer(), Isis::Spice::hasKernels(), Isis::PvlTranslationTable::InputGroup(), Isis::PvlToPvlTranslationManager::InputKeyword(), Isis::PvlToXmlTranslationManager::InputKeyword(), Isis::PvlFormat::isSingleUnit(), Isis::PvlFlatMap::keywordValues(), Isis::Stretch::Load(), Isis::SpiceRotation::LoadCache(), Isis::SpiceRotation::loadPCFromTable(), Isis::LroWideAngleCamera::LroWideAngleCamera(), Isis::MarciCamera::MarciCamera(), Isis::KernelDb::matches(), Isis::NewHorizonsLeisaCamera::NewHorizonsLeisaCamera(), Isis::NewHorizonsMvicFrameCamera::NewHorizonsMvicFrameCamera(), Isis::PvlSequence::operator+=(), Isis::operator<<(), Isis::PvlSequence::operator=(), Isis::pvlKeywordToJSON(), Isis::ReseauDistortionMap::ReseauDistortionMap(), Isis::LunarLambertEmpirical::SetPhotoLList(), Isis::LunarLambertEmpirical::SetPhotoPhaseCurveList(), Isis::LunarLambertEmpirical::SetPhotoPhaseList(), Isis::Spice::storeValue(), Isis::ThemisIrCamera::ThemisIrCamera(), Isis::ThemisVisCamera::ThemisVisCamera(), Isis::XmlToPvlTranslationManager::Translate(), Isis::ProcessExportPds4::translateBandBinSpectrumBinSet(), Isis::ProcessExportPds4::translateBandBinSpectrumUniform(), and validateKeyword().
|
static |
Checks to see if two QStrings are equal.
Each is converted to uppercase and removed of underscores and whitespaces.
QString1 | The first QString |
QString2 | The second QString |
References Isis::IString::ConvertWhiteSpace(), Isis::IString::Remove(), and Isis::IString::UpCase().
Referenced by Isis::PvlToPvlTranslationManager::GetContainer(), Isis::PvlToXmlTranslationManager::GetContainer(), Isis::PvlContainer::isNamed(), isNamed(), Isis::PvlFormat::isSingleUnit(), Isis::PvlGroup::operator==(), operator==(), and Isis::PvlObject::operator==().
|
protected |
Converts a value to iPVL format.
value | The value to be converted. |
|
protected |
Converts a value to PVL format.
value | The value to be converted. |
QString Isis::PvlKeyword::unit | ( | const int | index = 0 | ) | const |
Returns the units of measurement of the element of the array of values for the object at the specified index.
Defaults to index = 0.
index | The index of the unit. |
iException | ArraySubscriptNotInRange (index) Index out of bounds. |
References _FILEINFO_, and Isis::Message::ArraySubscriptNotInRange().
Referenced by Isis::PvlToXmlTranslationManager::doTranslation(), Isis::PvlFormatPds::formatBinary(), Isis::PvlFormatPds::formatEnum(), Isis::PvlFormatPds::formatHex(), Isis::PvlFormatPds::formatInteger(), Isis::PvlFormatPds::formatReal(), Isis::PvlFormatPds::formatString(), Isis::PvlFormatPds::formatUnknown(), Isis::PvlFormat::formatValue(), Isis::PvlFormat::isSingleUnit(), Isis::pvlKeywordToJSON(), Isis::ProcessExportPds::StandardAllMapping(), and Isis::ProcessExportPds4::translateBandBinSpectrumUniform().
void Isis::PvlKeyword::validateKeyword | ( | PvlKeyword & | pvlKwrd, |
QString | psValueType = "" , |
||
PvlKeyword * | pvlKwrdValue = NULL |
||
) |
Validate Keyword for type and required values.
Validate a Keyword, comparing against corresponding Template Keyword.
Template Keyword has the format: keyName = (valueType, optional/required, Values allowed separated by comma)
pvlKwrd | - Keyword to be validated |
psValueType | - Value Type (positive / negative) for numbers |
pvlKwrdValue | - Template Keyword __Value or __Range to validate keyword's value |
References _FILEINFO_, name(), size(), Isis::toDouble(), and Isis::toInt().
Referenced by Isis::PvlContainer::validateAllKeywords(), and Isis::PvlContainer::validateRepeatOption().
|
inline |
Returns the current set longest keyword name.
Referenced by Isis::operator<<(), and setWidth().
|
protected |
Wraps output so that length doesn't exceed the character limit.
By default, the character limit is set to 80, and can be changed with the method SetCharLimit. Used as a helper method for output of PvlKeyword.
os | Designated output stream |
textToWrite | The text to be written |
startColumn | The starting column after the "=" sign. |
endOfLine | The EOL character |
References Isis::PvlFormat::charLimit(), and Isis::PvlFormat::formatEOL().
Referenced by Isis::operator<<().
|
friend |
Write out the keyword.
os | The output stream. |
keyword | The PvlKeyword object to output. |
|
friend |
Read in a keyword.
http://pds.jpl.nasa.gov/tools/standards-reference.shtml
is | The input stream |
result | The keyword to read into (OUTPUT) |
|
protected |
Formatter object.
Referenced by Isis::operator<<(), and operator=().