USGS

Isis 3.0 Object Programmers' Reference

Home

Isis::PvlTranslationManager Class Reference
[Parsing]

#include <PvlTranslationManager.h>

Inheritance diagram for Isis::PvlTranslationManager:

Inheritance graph
[legend]
Collaboration diagram for Isis::PvlTranslationManager:

Collaboration graph
[legend]
List of all members.

Detailed Description

Allows applications to translate simple text files.

This class allows the translation of text files which can be parsed by the Pvl class.

Author:
2003-05-29 Stuart Sides

For internal use only.

History:
2003-09-03 Stuart Sides - Modified to work with new isis label format
History:
2003-09-25 Stuart Sides - Added the Translate member
History:
2005-02-15 Elizabeth Ribelin - Modified file to support Doxygen documentation
History:
2006-08-09 Brendan George - Modified to support Optional keyword translation
History:
2006-10-01 Stuart Sides - Fixed bug with Optional keyword. Non-optional keywords were being reported instantly.
History:
2006-11-16 Brendan George - Changed instances of "Foreign" to "Input" and "Native" to "Output"
History:
2007-06-22 Stuart Sides - Added ability to have more than one input location keyword for a translation. The first one found which contains the input keyword is used.
History:
2008-05-09 Steven Lambright - Added ability to change input label without re-reading the translation file.
History:
2008-07-10 Noah Hilt - Changed while loops to continue searching other groups if a group has been found, but the keyword does not exist in that group.
History:
2008-07-10 Steven Lambright - Changed to use new accessors
Todo:
2005-02-15 Stuart Sides - add coded example and implementation example to class documentation, and finish documentation

Definition at line 69 of file PvlTranslationManager.h.

Public Member Functions

 PvlTranslationManager (const std::string &transFile)
 PvlTranslationManager (Isis::Pvl &inputLabel, const std::string &transFile)
 Constructs and initializes a TranslationManager object.
 PvlTranslationManager (Isis::Pvl &inputLabel, std::istream &transStrm)
 Constructs and initializes a TranslationManager object.
 ~PvlTranslationManager ()
 Destroys the TranslationManager object.
std::string Translate (const std::string nName, int findex=0)
 Returns a translated value.
void Auto (Isis::Pvl &outputLabel)
std::string InputValue (const std::string nName, int findex=0)
 Returns the ith input value assiciated with the output name argument.
std::string InputUnits (const std::string nName, int findex=0)
 Returns the ith input units assiciated with the output name argument.
int InputSize (const std::string nName)
 Returns the number of values in foriegn keyword assiciated with the output name argument.
bool InputHasKeyword (const std::string nName)
 Indicates if the input keyword corresponding to the output name exists in the label.
void SetLabel (Isis::Pvl &lab)
std::string InputGroup (const std::string nName, const int inst=0) const
 Returns the input group name from the translation table corresponding to the output name argument.
std::string InputKeyword (const std::string nName) const
 Returns the input keyword name from the translation table corresponding to the output name argument.
std::string InputDefault (const std::string nName) const
 Returns the input default value from the translation table corresponding to the output name argument.
std::string Translate (const std::string nName, const std::string fValue="") const
 Translates the output name and input value.
void AddTable (std::istream &transStm)
 Adds the contents of a translation table to the searchable groups/keys Also performs a verification, to ensure that the translation table is valid.
void AddTable (const std::string &transFile)
 Adds the contents of a translation table to the searchable groups/keys.

Protected Member Functions

PvlTranslationTable ()
bool IsAuto (const std::string nName)
bool IsOptional (const std::string nName)
Isis::PvlKeywordOutputPosition (const std::string nName)
std::string OutputName (const std::string nName)

Private Member Functions

Isis::PvlKeyword Translate (const std::string nName, double dummy)
 Translate the requested output name to output values using the input name and values or default value.
Isis::PvlContainerGetContainer (const std::string &inputGroup)
Isis::PvlContainerCreateContainer (const std::string nName, Isis::Pvl &pvl)

Private Attributes

Isis::Pvl p_fLabel
 A Pvl object for the input label file.


Constructor & Destructor Documentation

Isis::PvlTranslationManager::PvlTranslationManager ( Isis::Pvl inputLabel,
const std::string &  transFile 
)

Constructs and initializes a TranslationManager object.

Parameters:
inputLabel The Pvl holding the input label.
transFile The translation file to be used to tranlate keywords in the input label.

Definition at line 43 of file PvlTranslationManager.cpp.

References Isis::PvlTranslationTable::AddTable(), and p_fLabel.

Isis::PvlTranslationManager::PvlTranslationManager ( Isis::Pvl inputLabel,
std::istream &  transStrm 
)

Constructs and initializes a TranslationManager object.

Parameters:
inputLabel The Pvl holding the input label.
transStrm A stream containing the tranlation table to be used to tranlate keywords in the input label.

Definition at line 59 of file PvlTranslationManager.cpp.

References Isis::PvlTranslationTable::AddTable(), and p_fLabel.

Isis::PvlTranslationManager::~PvlTranslationManager (  )  [inline]

Destroys the TranslationManager object.

Definition at line 82 of file PvlTranslationManager.h.


Member Function Documentation

void Isis::PvlTranslationTable::AddTable ( const std::string &  transFile  )  [inherited]

Adds the contents of a translation table to the searchable groups/keys.

Parameters:
transFile The name of the translation file to be added.
Exceptions:
Isis::iException::Io 

Definition at line 77 of file PvlTranslationTable.cpp.

References _FILEINFO_, Isis::PvlTranslationTable::AddTable(), Isis::Filename::Expanded(), Isis::Message::FileOpen(), in, and Isis::iException::Message().

void Isis::PvlTranslationTable::AddTable ( std::istream &  transStm  )  [inherited]

Adds the contents of a translation table to the searchable groups/keys Also performs a verification, to ensure that the translation table is valid.

Parameters:
transStm The stream to be added.

Definition at line 100 of file PvlTranslationTable.cpp.

References Isis::PvlTranslationTable::p_trnsTbl.

Referenced by Isis::PvlTranslationTable::AddTable(), and PvlTranslationManager().

string Isis::PvlTranslationTable::InputDefault ( const std::string  nName  )  const [inherited]

Returns the input default value from the translation table corresponding to the output name argument.

Parameters:
nName The output name to be used to search the translation table.
Returns:
string The input default value
Exceptions:
Isis::iException::Programmer 

Definition at line 272 of file PvlTranslationTable.cpp.

References _FILEINFO_, Isis::PvlContainer::Filename(), Isis::PvlObject::FindGroup(), Isis::PvlObject::HasGroup(), Isis::PvlContainer::HasKeyword(), Isis::iException::Message(), and Isis::PvlTranslationTable::p_trnsTbl.

string Isis::PvlTranslationTable::InputGroup ( const std::string  nName,
const int  inst = 0 
) const [inherited]

Returns the input group name from the translation table corresponding to the output name argument.

Parameters:
nName The output name to be used to search the translation table.
inst The occurence number of the "InputGroup" keyword (first one is zero)
Returns:
string The input group name
Exceptions:
Isis::iException::Programmer 

Definition at line 211 of file PvlTranslationTable.cpp.

References _FILEINFO_, Isis::PvlContainer::Begin(), Isis::PvlContainer::End(), Isis::PvlContainer::Filename(), Isis::PvlObject::FindGroup(), Isis::PvlContainer::FindKeyword(), Isis::PvlObject::HasGroup(), Isis::PvlContainer::HasKeyword(), Isis::iException::Message(), Isis::PvlContainer::Name(), and Isis::PvlTranslationTable::p_trnsTbl.

Referenced by InputHasKeyword(), InputSize(), InputUnits(), InputValue(), and Translate().

bool Isis::PvlTranslationManager::InputHasKeyword ( const std::string  nName  ) 

Indicates if the input keyword corresponding to the output name exists in the label.

Parameters:
nName The output name used to identify the input keyword.

Definition at line 289 of file PvlTranslationManager.cpp.

References GetContainer(), Isis::PvlContainer::HasKeyword(), Isis::PvlTranslationTable::InputGroup(), and Isis::PvlTranslationTable::InputKeyword().

Referenced by Isis::ProcessImportPds::ExtractPdsProjection(), Isis::ProcessImportPds::IdentifySource(), Isis::ProcessImportPds::SetPdsFile(), and Isis::ProcessImportPds::TranslatePdsProjection().

string Isis::PvlTranslationTable::InputKeyword ( const std::string  nName  )  const [inherited]

Returns the input keyword name from the translation table corresponding to the output name argument.

Parameters:
nName The output name to be used to search the translation table.
Returns:
string The input keyword name
Exceptions:
Isis::iException::Programmer 

Definition at line 249 of file PvlTranslationTable.cpp.

References _FILEINFO_, Isis::PvlContainer::Filename(), Isis::PvlObject::FindGroup(), Isis::PvlObject::HasGroup(), Isis::PvlContainer::HasKeyword(), Isis::iException::Message(), and Isis::PvlTranslationTable::p_trnsTbl.

Referenced by InputHasKeyword(), InputSize(), InputUnits(), InputValue(), and Translate().

int Isis::PvlTranslationManager::InputSize ( const std::string  nName  ) 

Returns the number of values in foriegn keyword assiciated with the output name argument.

Parameters:
nName The output name used to identify the input keyword.
Exceptions:
Isis::iException::Programmer 

Definition at line 255 of file PvlTranslationManager.cpp.

References _FILEINFO_, Isis::PvlContainer::Filename(), GetContainer(), Isis::PvlContainer::HasKeyword(), Isis::PvlTranslationTable::InputGroup(), Isis::PvlTranslationTable::InputKeyword(), Isis::iException::Message(), and Isis::PvlTranslationTable::TranslationTable().

string Isis::PvlTranslationManager::InputUnits ( const std::string  nName,
int  findex = 0 
)

Returns the ith input units assiciated with the output name argument.

Parameters:
nName The output name used to identify the input keyword.
findex The index into the input keyword array. Defaults to 0
Exceptions:
Isis::iException::Programmer 

Definition at line 216 of file PvlTranslationManager.cpp.

References _FILEINFO_, Isis::PvlContainer::Filename(), GetContainer(), Isis::PvlContainer::HasKeyword(), Isis::PvlTranslationTable::InputGroup(), Isis::PvlTranslationTable::InputKeyword(), Isis::iException::Message(), and Isis::PvlTranslationTable::TranslationTable().

Referenced by Isis::ProcessImportPds::ExtractPdsProjection().

string Isis::PvlTranslationManager::InputValue ( const std::string  nName,
int  findex = 0 
)

Returns the ith input value assiciated with the output name argument.

Parameters:
nName The output name used to identify the input keyword.
findex The index into the input keyword array. Defaults to 0
Exceptions:
Isis::iException::Programmer 

Definition at line 176 of file PvlTranslationManager.cpp.

References _FILEINFO_, Isis::PvlContainer::Filename(), GetContainer(), Isis::PvlContainer::HasKeyword(), Isis::PvlTranslationTable::InputGroup(), Isis::PvlTranslationTable::InputKeyword(), Isis::iException::Message(), and Isis::PvlTranslationTable::TranslationTable().

string Isis::PvlTranslationTable::Translate ( const std::string  nName,
const std::string  fValue = "" 
) const [inherited]

Translates the output name and input value.

Parameters:
nName The output name to be used to search the translation table.
fValue The input value to be translated
Returns:
string The translated string
Exceptions:
Isis::iException::Programmer 

Definition at line 151 of file PvlTranslationTable.cpp.

References _FILEINFO_, Isis::PvlContainer::Begin(), Isis::PvlContainer::End(), Isis::PvlContainer::Filename(), Isis::PvlObject::FindGroup(), Isis::PvlContainer::FindKeyword(), Isis::PvlObject::HasGroup(), Isis::PvlContainer::HasKeyword(), Isis::iException::Message(), and Isis::PvlTranslationTable::p_trnsTbl.

Referenced by Translate().

Isis::PvlKeyword Isis::PvlTranslationManager::Translate ( const std::string  nName,
double  dummy 
) [private]

Translate the requested output name to output values using the input name and values or default value.

Parameters:
nName The output name used to identify the input keyword to be translated.
dummy 
Returns:
Isis::PvlKeyword

Definition at line 111 of file PvlTranslationManager.cpp.

References Isis::PvlKeyword::AddValue(), GetContainer(), Isis::PvlContainer::HasKeyword(), Isis::PvlTranslationTable::InputGroup(), Isis::PvlTranslationTable::InputKeyword(), Isis::PvlTranslationTable::OutputName(), Isis::PvlKeyword::SetName(), and Isis::PvlTranslationTable::Translate().

string Isis::PvlTranslationManager::Translate ( const std::string  nName,
int  findex = 0 
)

Returns a translated value.

The output name is used to find the input group, keyword, default and tranlations in the translation table. If the keyword does not exist in the input label, the input default if available will be used as the input value. This input value is then used to search all of the translations. If a match is found the translated value is returned.

Parameters:
nName The output name used to identify the input keyword to be translated.
findex The index into the input keyword array. Defaults to 0
Returns:
string

Definition at line 82 of file PvlTranslationManager.cpp.

References GetContainer(), Isis::PvlContainer::HasKeyword(), Isis::PvlTranslationTable::InputGroup(), Isis::PvlTranslationTable::InputKeyword(), and Isis::PvlTranslationTable::Translate().

Referenced by Auto(), Isis::NaifStatus::CheckErrors(), Isis::ProcessImportPds::ExtractPdsProjection(), Isis::ObservationNumber::FindObservationTranslation(), and Isis::SerialNumber::FindSerialTranslation().


Member Data Documentation

Isis::Pvl Isis::PvlTranslationManager::p_fLabel [private]

A Pvl object for the input label file.

Definition at line 111 of file PvlTranslationManager.h.

Referenced by GetContainer(), PvlTranslationManager(), and SetLabel().


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