Isis 3.0 Developer's Reference (API) |
Home |
A single keyword-value pair. More...
#include <PvlKeyword.h>
Public Member Functions | |
PvlKeyword () | |
Constructs a blank PvlKeyword object. | |
PvlKeyword (const std::string &name) | |
Constructs a PvlKeyword object with a name. | |
PvlKeyword (const std::string &name, const Isis::iString value, const std::string unit="") | |
Constructs a PvlKeyword object with a name, value and units. | |
PvlKeyword (const PvlKeyword &other) | |
Copy constructor. | |
~PvlKeyword () | |
Destructs a PvlKeyword object. | |
void | SetName (const std::string &name) |
Sets the keyword name. | |
std::string | Name () const |
Returns the keyword name. | |
bool | IsNamed (const std::string &name) const |
Determines whether two PvlKeywords have the same name or not. | |
void | SetValue (const Isis::iString value, const std::string unit="") |
Sets new values. | |
void | SetUnits (const iString &units) |
Sets the unit of measure for all current values if any exist. | |
void | SetUnits (const iString &value, const iString &units) |
Sets the unit of measure for a given value. | |
PvlKeyword & | operator= (const Isis::iString value) |
Sets new values. | |
void | AddValue (const Isis::iString value, const std::string unit="") |
Adds a value with units. | |
PvlKeyword & | operator+= (const Isis::iString value) |
Adds a value. | |
int | Size () const |
Returns the number of values stored in this keyword. | |
bool | IsNull (const int index=0) const |
Decides whether a value is null or not at a given index. | |
void | Clear () |
Clears all values and units for this PvlKeyword object. | |
operator double () const | |
Returns the first value in this keyword converted to a double. | |
operator int () const | |
Returns the first value in this keyword converted to an integer. | |
operator Isis::BigInt () const | |
Returns the first value in this keyword converted to a BigInt. | |
operator std::string () const | |
Returns the first value in this keyword converted to a std::string. | |
operator QString () const | |
const Isis::iString & | operator[] (const int index) const |
Gets value for this object at specified index. | |
Isis::iString & | operator[] (const int index) |
Gets value for this object at specified index. | |
std::string | 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. | |
void | AddComment (const std::string &comment) |
Add a comment to the PvlKeyword. | |
void | AddCommentWrapped (const std::string &comment) |
Automatically wraps and adds long comments to the PvlKeyword. | |
void | AddComments (const std::vector< std::string > &comments) |
This method adds multiple comments at once by calling AddComments on each element in the vector. | |
int | Comments () const |
Returns the number of lines of comments associated with this keyword. | |
std::string | Comment (const int index) const |
Return a comment at the specified index. | |
void | ClearComments () |
Clears the current comments. | |
bool | operator== (const PvlKeyword &key) const |
Returns true of the keyword names match. | |
bool | operator!= (const PvlKeyword &key) const |
Returns true of the keyword names do not match. | |
bool | IsEquivalent (const std::string &string1, int index=0) const |
Checks to see if a value with a specified index is equivalent to another string. | |
void | SetWidth (int width) |
The width of the longest keyword name (for formatting). | |
void | SetIndent (int indent) |
Sets the indent level when outputted(for formatting). | |
int | Width () const |
Returns the current set longest keyword name. | |
int | Indent () const |
Returns the current indent level. | |
PvlKeyword & | operator= (Isis::PvlSequence &seq) |
Add values and units from a PvlSequence. | |
void | SetFormat (PvlFormat *formatter) |
Set the PvlFormatter used to format the keyword name and value(s). | |
PvlFormat * | GetFormat () |
Get the current PvlFormat or create one. | |
const PvlKeyword & | operator= (const PvlKeyword &other) |
This is an assignment operator. | |
void | ValidateKeyword (PvlKeyword &pvlKwrd, std::string psValueType="", PvlKeyword *pvlKwrdRange=NULL) |
Validate Keyword for type and required values. | |
Static Public Member Functions | |
static bool | StringEqual (const std::string &string1, const std::string &string2) |
Checks to see if two strings are equal. | |
static std::string | ReadLine (std::istream &is, bool insideComment) |
This method reads one line of data from the input stream. | |
static bool | ReadCleanKeyword (std::string keyword, std::vector< std::string > &keywordComments, std::string &keywordName, std::vector< std::pair< std::string, std::string > > &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). | |
static std::string | ReadValue (std::string &keyword, bool "eProblem) |
static std::string | ReadValue (std::string &keyword, bool "eProblem, const std::vector< std::pair< char, char > > &otherDelimiters) |
This method looks for a data element in the string. | |
Protected Member Functions | |
std::string | Reform (const std::string &value) const |
Checks if the value needs to be converted to PVL or iPVL and returns it in the correct format. | |
std::string | ToPvl (const std::string &value) const |
Converts a value to PVL format. | |
std::string | ToIPvl (const std::string &value) const |
Converts a value to iPVL format. | |
std::ostream & | WriteWithWrap (std::ostream &os, const std::string &textToWrite, int startColumn, PvlFormat &format) const |
Wraps output so that length doesn't exceed the character limit. | |
Protected Attributes | |
PvlFormat * | p_formatter |
Formatter object. | |
Friends | |
std::istream & | operator>> (std::istream &is, PvlKeyword &result) |
Read in a keyword. | |
std::ostream & | operator<< (std::ostream &os, const PvlKeyword &keyword) |
Write out the keyword. |
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 | ( | const std::string & | name | ) |
Isis::PvlKeyword::PvlKeyword | ( | const std::string & | name, | |
const Isis::iString | value, | |||
const std::string | 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. |
References AddValue(), and SetName().
Isis::PvlKeyword::PvlKeyword | ( | const PvlKeyword & | other | ) |
Copy constructor.
Isis::PvlKeyword::~PvlKeyword | ( | ) |
Destructs a PvlKeyword object.
void Isis::PvlKeyword::AddComment | ( | const std::string & | comment | ) |
Add a comment to the PvlKeyword.
comment | The new comment. |
Referenced by Isis::PvlContainer::AddComment(), AddComments(), AddCommentWrapped(), and Isis::ControlNetFileV0002::ToPvl().
void Isis::PvlKeyword::AddComments | ( | const std::vector< std::string > & | comments | ) |
This method adds multiple comments at once by calling AddComments on each element in the vector.
comments | Comments to associate with this keyword |
References AddComment().
Referenced by Isis::operator>>().
void Isis::PvlKeyword::AddCommentWrapped | ( | const std::string & | comment | ) |
Automatically wraps and adds long comments to the PvlKeyword.
comment | The new comment to add |
References AddComment(), and Isis::iString::Token().
void Isis::PvlKeyword::AddValue | ( | const Isis::iString | value, | |
const std::string | 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 string).
value | New value to be assigned. | |
unit | Units of measurement corresponding to the value. |
Referenced by Isis::PvlFormat::Add(), IsisAml::CommandLine(), operator+=(), operator=(), Isis::operator>>(), PvlKeyword(), Isis::Stretch::Save(), SetValue(), and Isis::Spice::storeValue().
void Isis::PvlKeyword::Clear | ( | ) |
Clears all values and units for this PvlKeyword object.
Referenced by operator=(), and SetValue().
void Isis::PvlKeyword::ClearComments | ( | ) |
Clears the current comments.
string 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_, Isis::Message::ArraySubscriptNotInRange(), Isis::iException::Message(), and Isis::iException::Programmer.
Referenced by Isis::PvlContainer::Comment(), and Isis::operator<<().
int Isis::PvlKeyword::Comments | ( | ) | const [inline] |
Returns the number of lines of comments associated with this keyword.
Referenced by Isis::PvlContainer::Comments(), and Isis::operator<<().
PvlFormat * Isis::PvlKeyword::GetFormat | ( | ) |
Get the current PvlFormat or create one.
References p_formatter.
Referenced by Isis::PvlContainer::GetFormat().
int Isis::PvlKeyword::Indent | ( | ) | const [inline] |
Returns the current indent level.
Referenced by Isis::PvlContainer::Indent(), and Isis::operator<<().
bool Isis::PvlKeyword::IsEquivalent | ( | const std::string & | string1, | |
int | index = 0 | |||
) | const |
Checks to see if a value with a specified index is equivalent to another string.
string1 | The string to compare the value to. | |
index | The index of the existing value. |
iException | ArraySubscriptNotInRange (index) Index out of bounds. |
References _FILEINFO_, Isis::Message::ArraySubscriptNotInRange(), Isis::iException::Message(), Isis::iException::Programmer, and StringEqual().
bool Isis::PvlKeyword::IsNamed | ( | const std::string & | name | ) | const [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 KernelDb::FindAll(), and 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_, Isis::Message::ArraySubscriptNotInRange(), Isis::iException::Message(), Isis::iException::Programmer, Size(), and StringEqual().
std::string Isis::PvlKeyword::Name | ( | ) | const [inline] |
Returns the keyword name.
Referenced by Isis::PvlFormat::Accuracy(), Isis::PvlFormat::Add(), Isis::ProcessMosaic::AddBandBinGroup(), Isis::PvlContainer::AddKeyword(), Isis::PvlTranslationTable::AddTable(), Isis::ControlMeasureLogData::ControlMeasureLogData(), Isis::PvlFormatPds::FormatName(), Isis::PvlFormat::FormatName(), Isis::PvlFormatPds::FormatValue(), Isis::PvlTranslationManager::InputKeyword(), IsNamed(), Isis::Preference::Load(), Isis::ProcessMosaic::MatchBandBinGroup(), Isis::PvlContainer::operator-=(), Isis::PvlFormat::Type(), Isis::PvlContainer::Type(), Isis::PvlContainer::ValidateAllKeywords(), ValidateKeyword(), and Isis::PvlContainer::ValidateRepeatOption().
Isis::PvlKeyword::operator double | ( | ) | const [inline] |
Returns the first value in this keyword converted to a double.
References operator[]().
Isis::PvlKeyword::operator int | ( | ) | const [inline] |
Returns the first value in this keyword converted to an integer.
References operator[]().
Isis::PvlKeyword::operator Isis::BigInt | ( | ) | const [inline] |
Returns the first value in this keyword converted to a BigInt.
References operator[]().
Isis::PvlKeyword::operator QString | ( | ) | const |
Isis::PvlKeyword::operator std::string | ( | ) | const [inline] |
Returns the first value in this keyword converted to a std::string.
References operator[]().
bool Isis::PvlKeyword::operator!= | ( | const PvlKeyword & | key | ) | const [inline] |
Returns true of the keyword names do not match.
key | The keyword to compare names with |
PvlKeyword & Isis::PvlKeyword::operator+= | ( | const Isis::iString | 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 string) to the array of values for this PvlKeyword object.
value | The new value. |
References AddValue().
Referenced by operator=().
const PvlKeyword & Isis::PvlKeyword::operator= | ( | const PvlKeyword & | other | ) |
This is an assignment operator.
References p_formatter, and SetName().
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 Clear(), operator+=(), size, and Isis::PvlSequence::Size().
PvlKeyword & Isis::PvlKeyword::operator= | ( | const Isis::iString | 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 string).
value | The value to be added. |
References AddValue(), and Clear().
bool Isis::PvlKeyword::operator== | ( | const PvlKeyword & | key | ) | const [inline] |
Returns true of the keyword names match.
key | The keyword to compare names with |
Isis::iString & Isis::PvlKeyword::operator[] | ( | const 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_, Isis::Message::ArraySubscriptNotInRange(), Isis::iException::Message(), and Isis::iException::Programmer.
const Isis::iString & Isis::PvlKeyword::operator[] | ( | const 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_, Isis::Message::ArraySubscriptNotInRange(), Isis::iException::Message(), and Isis::iException::Programmer.
Referenced by operator double(), operator int(), operator Isis::BigInt(), and operator std::string().
bool Isis::PvlKeyword::ReadCleanKeyword | ( | std::string | keyword, | |
std::vector< std::string > & | keywordComments, | |||
std::string & | keywordName, | |||
std::vector< std::pair< std::string, std::string > > & | keywordValues | |||
) | [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,...)" string | |
keywordComments | Output: Lines of data that are comments | |
keywordName | Output: Name of keyword | |
keywordValues | Output: vector< pair<Value, Units> > |
References _FILEINFO_, Isis::iException::Message(), Isis::iException::Pvl, ReadValue(), and Isis::iString::Trim().
Referenced by Isis::operator>>().
std::string Isis::PvlKeyword::ReadLine | ( | std::istream & | is, | |
bool | insideComment | |||
) | [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 |
References Isis::iString::Trim().
Referenced by Isis::operator>>().
std::string Isis::PvlKeyword::ReadValue | ( | std::string & | keyword, | |
bool & | quoteProblem, | |||
const std::vector< std::pair< char, char > > & | otherDelimiters | |||
) | [static] |
This method looks for a data element in the string.
A data element is a quoted string, a units value, or one value of an array (not including units). As an example, each value in the following string 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 string has an unclosed quote character |
References value.
std::string Isis::PvlKeyword::ReadValue | ( | std::string & | keyword, | |
bool & | quoteProblem | |||
) | [static] |
Referenced by ReadCleanKeyword().
string Isis::PvlKeyword::Reform | ( | const std::string & | value | ) | const [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(), g, Isis::Preference::Preferences(), ToIPvl(), ToPvl(), 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 |
References p_formatter.
Referenced by Isis::PvlContainer::SetFormat().
void Isis::PvlKeyword::SetIndent | ( | int | indent | ) | [inline] |
Sets the indent level when outputted(for formatting).
indent | The new indent |
Referenced by Isis::PvlContainer::SetIndent().
void Isis::PvlKeyword::SetName | ( | const std::string & | name | ) |
Sets the keyword name.
name | The new keyword name. |
References _FILEINFO_, Isis::iException::Message(), size, and Isis::iException::User.
Referenced by operator=(), Isis::operator>>(), Isis::PvlContainer::PvlContainer(), and PvlKeyword().
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_, ASSERT, Isis::iException::Message(), and Isis::iException::Programmer.
void Isis::PvlKeyword::SetUnits | ( | const iString & | units | ) |
Sets the unit of measure for all current values if any exist.
units | New units to be assigned. |
Referenced by Isis::ProcessMosaic::AddBandBinGroup().
void Isis::PvlKeyword::SetValue | ( | const Isis::iString | value, | |
const std::string | 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 string).
value | New value to be assigned. | |
unit | Units of measurement corresponding to the value. |
References AddValue(), and Clear().
Referenced by Isis::PvlContainer::SetName().
void Isis::PvlKeyword::SetWidth | ( | int | width | ) | [inline] |
The width of the longest keyword name (for formatting).
width | the new width |
int Isis::PvlKeyword::Size | ( | ) | const [inline] |
Returns the number of values stored in this keyword.
Referenced by Isis::PvlFormat::Accuracy(), Isis::PvlFormat::Add(), Isis::ProcessMosaic::AddBandBinGroup(), Isis::PvlTranslationTable::AddTable(), 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::ProcessMosaic::GetBandIndex(), Isis::Spice::HasKernels(), Isis::PvlTranslationTable::InputGroup(), Isis::PvlTranslationManager::InputKeyword(), IsNull(), Isis::PvlFormat::IsSingleUnit(), Isis::Stretch::Load(), Isis::LroWideAngleCamera::LroWideAngleCamera(), Isis::MarciCamera::MarciCamera(), Isis::ProcessMosaic::MatchBandBinGroup(), KernelDb::Matches(), Isis::operator<<(), Isis::SpectralPlotTool::refreshPlot(), Isis::ReseauDistortionMap::ReseauDistortionMap(), Isis::Spice::storeValue(), Isis::ThemisIrCamera::ThemisIrCamera(), Isis::ThemisVisCamera::ThemisVisCamera(), and ValidateKeyword().
bool Isis::PvlKeyword::StringEqual | ( | const std::string & | string1, | |
const std::string & | string2 | |||
) | [static] |
Checks to see if two strings are equal.
Each is converted to uppercase and removed of underscores and whitespaces.
string1 | The first string | |
string2 | The second string |
References Isis::iString::ConvertWhiteSpace(), Isis::iString::Remove(), s1, s2, and Isis::iString::UpCase().
Referenced by IsEquivalent(), IsNamed(), Isis::PvlContainer::IsNamed(), IsNull(), Isis::PvlFormat::IsSingleUnit(), Isis::PvlObject::operator==(), and Isis::PvlGroup::operator==().
string Isis::PvlKeyword::ToIPvl | ( | const std::string & | value | ) | const [protected] |
string Isis::PvlKeyword::ToPvl | ( | const std::string & | value | ) | const [protected] |
string 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_, Isis::Message::ArraySubscriptNotInRange(), Isis::iException::Message(), and Isis::iException::Programmer.
Referenced by Isis::ProcessMosaic::AddBandBinGroup(), 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(), and Isis::Cube::open().
void Isis::PvlKeyword::ValidateKeyword | ( | PvlKeyword & | pvlKwrd, | |
std::string | 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_, Isis::iString::DownCase(), Isis::iException::Message(), Name(), Size(), Isis::iString::ToDouble(), Isis::iString::ToInteger(), and Isis::iException::User.
Referenced by Isis::PvlContainer::ValidateAllKeywords(), and Isis::PvlContainer::ValidateRepeatOption().
int Isis::PvlKeyword::Width | ( | ) | const [inline] |
Returns the current set longest keyword name.
Referenced by Isis::operator<<().
ostream & Isis::PvlKeyword::WriteWithWrap | ( | std::ostream & | os, | |
const std::string & | textToWrite, | |||
int | startColumn, | |||
PvlFormat & | format | |||
) | const [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(), Isis::PvlFormat::FormatEOL(), and pos.
Referenced by Isis::operator<<().
std::ostream& operator<< | ( | std::ostream & | os, | |
const PvlKeyword & | keyword | |||
) | [friend] |
Write out the keyword.
os | The output stream. | |
keyword | The PvlKeyword object to output. |
std::istream& operator>> | ( | std::istream & | is, | |
PvlKeyword & | result | |||
) | [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) |
PvlFormat* Isis::PvlKeyword::p_formatter [protected] |
Formatter object.
Referenced by GetFormat(), Isis::operator<<(), operator=(), and SetFormat().