Isis 3 Programmer Reference
|
Allows applications to translate simple text files. More...
#include <PvlToPvlTranslationManager.h>
Public Member Functions | |
PvlToPvlTranslationManager (const QString &transFile) | |
Constructs and initializes a TranslationManager object from given the Pvl translation file. More... | |
PvlToPvlTranslationManager (std::istream &transStrm) | |
Constructs and initializes a TranslationManager object from the given input stream. More... | |
PvlToPvlTranslationManager (Pvl &inputLabel, const QString &transFile) | |
Constructs and initializes a TranslationManager object. More... | |
PvlToPvlTranslationManager (Pvl &inputLabel, std::istream &transStrm) | |
Constructs and initializes a TranslationManager object. More... | |
virtual | ~PvlToPvlTranslationManager () |
Destroys the TranslationManager object. More... | |
virtual QString | Translate (QString translationGroupName, int findex=0) |
Returns a translated value. More... | |
void | Auto (Pvl &outputLabel) |
Automatically translate all the output names found in the translation table If a output name does not translate an error will be thrown by one of the support members Store the translated key, value pairs in the argument pvl. More... | |
void | Auto (Pvl &inputLabel, Pvl &outputLabel) |
Automatically translate all the output names found in the translation table If a output name does not translate an error will be thrown by one of the support members Store the translated key, value pairs in the argument pvl. More... | |
virtual const PvlKeyword & | InputKeyword (const QString translationGroupName) const |
Returns the ith input value associated with the output name argument. More... | |
virtual bool | InputHasKeyword (const QString translationGroupName) |
Indicates if the input keyword corresponding to the output name exists in the label. More... | |
void | SetLabel (Pvl &inputLabel) |
QString | Translate (const QString translationGroupName, const QString inputKeyValue="") const |
Translates a single output value from the given translation group name and input value. More... | |
virtual QStringList | parseSpecification (QString specification) const |
Parses and validates a dependency specification. More... | |
virtual PvlKeyword | InputGroup (const QString translationGroupName, const int inst=0) const |
Returns the input group name from the translation table corresponding to the output name argument. More... | |
virtual QString | InputKeywordName (const QString translationGroupName) const |
Returns the input keyword name from the translation table corresponding to the output name argument. More... | |
QString | InputDefault (const QString translationGroupName) const |
Returns the input default value from the translation table corresponding to the output name argument. More... | |
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. More... | |
void | AddTable (const QString &transFile) |
Adds the contents of a translation table to the searchable groups/keys. More... | |
Protected Member Functions | |
virtual PvlKeyword | DoTranslation (const QString translationGroupName) |
Translate the requested output name to output values using the input name and values or default value. More... | |
virtual const PvlContainer * | GetContainer (const PvlKeyword &inputGroup) const |
Return a container from the input label according tund. More... | |
virtual PvlContainer * | CreateContainer (const QString translationGroupName, Pvl &pvl) |
Create the requsted container and any containers above it and return a reference to the container. More... | |
Pvl & | TranslationTable () |
Protected accessor for pvl translation table passed into class. More... | |
const Pvl & | TranslationTable () const |
Protected accessor for const pvl translation table passed into class. More... | |
virtual std::vector< std::pair< QString, int > > | validKeywords () const |
Returns a vector of valid keyword names and their sizes. More... | |
bool | hasInputDefault (const QString translationGroupName) |
Determines whether the given group has a default input value. More... | |
bool | IsAuto (const QString translationGroupName) |
Determines whether the given group should be automatically translated. More... | |
bool | IsOptional (const QString translationGroupName) |
Determines whether the translation group is optional. More... | |
PvlKeyword | OutputPosition (const QString translationGroupName) |
Retrieves the OutputPosition PvlKeyword for the translation group with the given name. More... | |
QString | OutputName (const QString translationGroupName) |
Retrieves a string containing the value of the OutputName keyword for the translation group with the given name. More... | |
const PvlGroup & | findTranslationGroup (const QString translationGroupName) const |
Searches for translation group with the given name. More... | |
Private Attributes | |
Pvl | p_fLabel |
A Pvl object for the input label file. More... | |
Allows applications to translate simple text files.
This class allows the translation of text files which can be parsed by the Pvl class.
2003-09-03 Stuart Sides - Modified to work with new isis label format.
2003-09-25 Stuart Sides - Added the Translate member.
2005-02-15 Elizabeth Ribelin - Modified file to support Doxygen documentation.
2006-08-09 Brendan George - Modified to support Optional keyword translation.
2006-10-01 Stuart Sides - Fixed bug with Optional keyword. Non-optional keywords were being reported instantly.
2006-11-16 Brendan George - Changed instances of "Foreign" to "Input" and "Native" to "Output".
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.
2008-05-09 Steven Lambright - Added ability to change input label without re-reading the translation file.
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.
2008-07-10 Steven Lambright - Changed to use new accessors.
2010-01-04 Steven Lambright - Added InputKeyword method and removed InputSize, InputUnits, InputValue. Renamed private Translate() method to DoTranslation() to remove ambiguity with a parent method, instead of using a dummy parameter.
2017-01-11 Jeannie Backer - Moved several methods to a generic parent class, LabelTranslationManager. Fixes #4584.
2017-06-13 Adam Paquette - Changed PvlTranslationManager file name to PvlToPvlTranslationManager. Fixes #4901.
2018-01-10 Christopher Combs - Changed ProcessDataFilePointer call to reflect changes made to voy2isis. Fixes #4345, #4421.
2018-04-16 Jeannie Backer - Fixed indentation of history comments and brought code closer to coding standards.
Definition at line 80 of file PvlToPvlTranslationManager.h.
Isis::PvlToPvlTranslationManager::PvlToPvlTranslationManager | ( | const QString & | transFile | ) |
Constructs and initializes a TranslationManager object from given the Pvl translation file.
If this constructor is used, the user will need to set the input label before translating. This may be done by using SetLabel(Pvl inputLabel) or Auto(Pvl inputLabel, Pvl outputLabel).
transFile | The translation file to be used to translate keywords in the input label. |
Definition at line 46 of file PvlToPvlTranslationManager.cpp.
Isis::PvlToPvlTranslationManager::PvlToPvlTranslationManager | ( | std::istream & | transStrm | ) |
Constructs and initializes a TranslationManager object from the given input stream.
If this constructor is used, the user will need to set the input label before translating. This may be done by using SetLabel(Pvl inputLabel) or Auto(Pvl inputLabel, Pvl outputLabel).
transStrm | A stream containing the translation table to be used to translate keywords in the input label. |
Definition at line 59 of file PvlToPvlTranslationManager.cpp.
Isis::PvlToPvlTranslationManager::PvlToPvlTranslationManager | ( | Pvl & | inputLabel, |
const QString & | transFile | ||
) |
Constructs and initializes a TranslationManager object.
inputLabel | The Pvl holding the input label. |
transFile | The translation file to be used to translate keywords in the input label. |
Definition at line 72 of file PvlToPvlTranslationManager.cpp.
References p_fLabel.
Isis::PvlToPvlTranslationManager::PvlToPvlTranslationManager | ( | Pvl & | inputLabel, |
std::istream & | transStrm | ||
) |
Constructs and initializes a TranslationManager object.
inputLabel | The Pvl holding the input label. |
transStrm | A stream containing the translation table to be used to translate keywords in the input label. |
Definition at line 87 of file PvlToPvlTranslationManager.cpp.
References p_fLabel.
|
virtual |
Destroys the TranslationManager object.
Definition at line 95 of file PvlToPvlTranslationManager.cpp.
|
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.
transStm | The stream to be added. |
IException::User | - "Unable to find InputKey for group in translation file." |
IException::User | - "Keyword is not valid. Error in file." |
IException::User | - "Keyword does not have correct number of elements. Error in file." |
Definition at line 118 of file PvlTranslationTable.cpp.
References _FILEINFO_, Isis::PvlContainer::hasKeyword(), Isis::PvlContainer::keywords(), Isis::PvlContainer::name(), Isis::PvlKeyword::name(), and Isis::PvlKeyword::size().
Referenced by Isis::LabelTranslationManager::LabelTranslationManager(), and Isis::XmlToPvlTranslationManager::XmlToPvlTranslationManager().
|
inherited |
Adds the contents of a translation table to the searchable groups/keys.
transFile | The name of the translation file to be added. |
Definition at line 100 of file PvlTranslationTable.cpp.
References Isis::Pvl::read().
|
virtual |
Automatically translate all the output names found in the translation table If a output name does not translate an error will be thrown by one of the support members Store the translated key, value pairs in the argument pvl.
Reimplemented from Isis::LabelTranslationManager.
Definition at line 214 of file PvlToPvlTranslationManager.cpp.
References CreateContainer(), DoTranslation(), Isis::PvlObject::group(), Isis::PvlObject::groups(), Isis::PvlTranslationTable::IsAuto(), Isis::PvlTranslationTable::IsOptional(), Isis::PvlContainer::name(), and Isis::PvlTranslationTable::TranslationTable().
Referenced by Auto(), Isis::TiffImporter::convertProjection(), Isis::ProcessExportPds::StandardAllMapping(), Isis::ProcessExportPds::StandardImageImage(), Isis::ProcessExportPds::StandardJP2Image(), Isis::ProcessImportPds::TranslateIsis2BandBin(), Isis::ProcessImportPds::TranslateIsis2Instrument(), Isis::ProcessImportPds::TranslatePdsArchive(), Isis::ProcessImportPds::TranslatePdsBandBin(), and Isis::ProcessImportPds::TranslatePdsProjection().
Automatically translate all the output names found in the translation table If a output name does not translate an error will be thrown by one of the support members Store the translated key, value pairs in the argument pvl.
Definition at line 202 of file PvlToPvlTranslationManager.cpp.
|
protectedvirtual |
Create the requsted container and any containers above it and return a reference to the container.
List is a PvlKeyword with an array of container types and their names.
translationGroupName | The name of the PVL translation group used to identify the input/output keywords to be translated. Often, this is the same as the output keyword name. |
pvl | Pvl |
Reimplemented from Isis::LabelTranslationManager.
Definition at line 367 of file PvlToPvlTranslationManager.cpp.
References Isis::LabelTranslationManager::CreateContainer().
Referenced by Auto().
|
protectedvirtual |
Translate the requested output name to output values using the input name and values or default value.
Note: This is a protected method used when automatically translating
translationGroupName | The name of the PVL translation group used to identify the input/output keywords to be translated. Often, this is the same as the output keyword name. |
Reimplemented from Isis::LabelTranslationManager.
Definition at line 157 of file PvlToPvlTranslationManager.cpp.
References Isis::PvlKeyword::addValue(), Isis::PvlContainer::begin(), Isis::PvlContainer::end(), Isis::PvlObject::findGroup(), Isis::PvlContainer::findKeyword(), GetContainer(), Isis::PvlContainer::hasKeyword(), Isis::PvlTranslationTable::InputGroup(), Isis::PvlTranslationTable::OutputName(), Isis::PvlKeyword::setName(), Isis::PvlTranslationTable::Translate(), and Isis::PvlTranslationTable::TranslationTable().
Referenced by Auto().
|
protectedinherited |
Searches for translation group with the given name.
translationGroupName | The name of the PVL translation group used to identify the input/output keywords to be translated. Often, this is the same as the output keyword name. |
IException::Programmer | - "Unable to find translation group in file." |
Definition at line 554 of file PvlTranslationTable.cpp.
References _FILEINFO_, and Isis::PvlContainer::fileName().
|
protectedvirtual |
Return a container from the input label according tund.
Definition at line 318 of file PvlToPvlTranslationManager.cpp.
References Isis::PvlObject::findGroup(), Isis::PvlObject::findObject(), Isis::PvlObject::hasGroup(), Isis::PvlObject::hasObject(), p_fLabel, Isis::PvlKeyword::size(), and Isis::PvlKeyword::stringEqual().
Referenced by DoTranslation(), InputHasKeyword(), InputKeyword(), and Translate().
|
protectedinherited |
Determines whether the given group has a default input value.
This method returns true if the translation group contains a PvlKeyword with the name "InputDefault". Note: no value needs to be assigned to this keyword.
translationGroupName | The name of the PVL translation group used to identify the input/output keywords to be translated. Often, this is the same as the output keyword name. |
Definition at line 423 of file PvlTranslationTable.cpp.
References Isis::PvlContainer::hasKeyword().
Referenced by Isis::XmlToPvlTranslationManager::Translate().
|
inherited |
Returns the input default value from the translation table corresponding to the output name argument.
translationGroupName | The name of the PVL translation group used to identify the input/output keywords to be translated. Often, this is the same as the output keyword name. |
Definition at line 398 of file PvlTranslationTable.cpp.
References Isis::PvlContainer::hasKeyword().
Referenced by Isis::XmlToPvlTranslationManager::Translate().
|
virtualinherited |
Returns the input group name from the translation table corresponding to the output name argument.
translationGroupName | The name of the PVL translation group used to identify the input/output keywords to be translated. Often, this is the same as the output keyword name. |
inst | The occurence number of the "InputGroup" keyword (first one is zero) |
IException::Programmer | - "Keyword [InputPosition] cannot have a comma [,] in the value." |
Definition at line 301 of file PvlTranslationTable.cpp.
References _FILEINFO_, Isis::PvlContainer::begin(), Isis::PvlContainer::end(), Isis::PvlContainer::findKeyword(), and Isis::PvlKeyword::size().
Referenced by Isis::PvlToXmlTranslationManager::doTranslation(), DoTranslation(), Isis::PvlToXmlTranslationManager::InputHasKeyword(), InputHasKeyword(), Isis::PvlToXmlTranslationManager::InputKeyword(), InputKeyword(), Isis::PvlToXmlTranslationManager::Translate(), and Translate().
|
virtual |
Indicates if the input keyword corresponding to the output name exists in the label.
translationGroupName | The name of the PVL translation group used to identify the input/output keywords to be translated. Often, this is the same as the output keyword name. |
Definition at line 297 of file PvlToPvlTranslationManager.cpp.
References GetContainer(), Isis::PvlContainer::hasKeyword(), Isis::PvlTranslationTable::InputGroup(), and Isis::PvlTranslationTable::InputKeywordName().
Referenced by Isis::ProcessImportPds::ExtractPdsProjection(), Isis::ProcessImportPds::IdentifySource(), Isis::ProcessImportPds::ProcessLabel(), Isis::ProcessImportPds::ProcessSpecialPixels(), and Isis::ProcessImportPds::TranslatePdsProjection().
|
virtual |
Returns the ith input value associated with the output name argument.
translationGroupName | The name of the PVL translation group used to identify the input/output keywords to be translated. Often, this is the same as the output keyword name. |
findex | The index into the input keyword array. Defaults to 0 |
IException::Programmer |
Definition at line 246 of file PvlToPvlTranslationManager.cpp.
References _FILEINFO_, Isis::PvlContainer::fileName(), Isis::PvlContainer::findKeyword(), GetContainer(), Isis::PvlContainer::hasKeyword(), Isis::PvlTranslationTable::InputGroup(), Isis::PvlTranslationTable::InputKeywordName(), Isis::PvlKeyword::name(), Isis::IException::Programmer, Isis::PvlKeyword::size(), and Isis::PvlTranslationTable::TranslationTable().
Referenced by Isis::ProcessImportPds::ExtractPdsProjection(), Isis::ProcessImportPds::ProcessDataFilePointer(), and Isis::ProcessImportPds::ProcessPdsQubeLabel().
|
virtualinherited |
Returns the input keyword name from the translation table corresponding to the output name argument.
translationGroupName | The name of the PVL translation group used to identify the input/output keywords to be translated. Often, this is the same as the output keyword name. |
IException::Programmer |
Definition at line 376 of file PvlTranslationTable.cpp.
References Isis::PvlContainer::hasKeyword().
Referenced by Isis::PvlToXmlTranslationManager::doTranslation(), Isis::PvlToXmlTranslationManager::InputHasKeyword(), InputHasKeyword(), Isis::PvlToXmlTranslationManager::InputKeyword(), InputKeyword(), Isis::PvlToXmlTranslationManager::Translate(), and Translate().
|
protectedinherited |
Determines whether the given group should be automatically translated.
This method returns true if the translation group contains a PvlKeyword with the name "Auto". Note: no value is assigned to this keyword.
translationGroupName | The name of the PVL translation group used to identify the input/output keywords to be translated. Often, this is the same as the output keyword name. |
Definition at line 448 of file PvlTranslationTable.cpp.
References Isis::PvlContainer::hasKeyword().
Referenced by Isis::LabelTranslationManager::Auto(), Isis::PvlToXmlTranslationManager::Auto(), and Auto().
|
protectedinherited |
Determines whether the translation group is optional.
This method returns true if the translation group contains a PvlKeyword with the name "Optional". Note: no value is assigned to this keyword.
translationGroupName | The name of the PVL translation group used to identify the input/output keywords to be translated. Often, this is the same as the output keyword name. |
Definition at line 473 of file PvlTranslationTable.cpp.
References Isis::PvlContainer::hasKeyword().
Referenced by Isis::LabelTranslationManager::Auto(), Isis::PvlToXmlTranslationManager::Auto(), and Auto().
|
protectedinherited |
Retrieves a string containing the value of the OutputName keyword for the translation group with the given name.
translationGroupName | The name of the PVL translation group used to identify the input/output keywords to be translated. Often, this is the same as the output keyword name. |
Definition at line 527 of file PvlTranslationTable.cpp.
References Isis::PvlContainer::hasKeyword().
Referenced by Isis::PvlToXmlTranslationManager::doTranslation(), and DoTranslation().
|
protectedinherited |
Retrieves the OutputPosition PvlKeyword for the translation group with the given name.
translationGroupName | The name of the PVL translation group used to identify the input/output keywords to be translated. Often, this is the same as the output keyword name. |
IException::Programmer | - "Unable to find translation keyword [OutputPostion] in translation group in file." |
Definition at line 499 of file PvlTranslationTable.cpp.
References _FILEINFO_, and Isis::PvlContainer::hasKeyword().
Referenced by Isis::LabelTranslationManager::CreateContainer(), and Isis::PvlToXmlTranslationManager::createParentElements().
|
virtualinherited |
Parses and validates a dependency specification.
specification | The dependency specification string. |
IException::Programmer | "Malformed dependency specification." |
IException::Programmer | "Specification does not have two components separated by [@], the type of dependency and the name-value pair. |
IException::Programmer | "Dependency type specification is invalid. Valid types are [att] and [tag]" |
IException::Programmer | "Name-value specification does not have two components separated by [|]." |
Definition at line 187 of file LabelTranslationManager.cpp.
References _FILEINFO_, and Isis::IException::Programmer.
Referenced by Isis::PvlToXmlTranslationManager::addAttributes(), Isis::PvlToXmlTranslationManager::addSiblings(), Isis::XmlToPvlTranslationManager::checkDependencies(), Isis::PvlToXmlTranslationManager::createParentElements(), and Isis::PvlToXmlTranslationManager::doTranslation().
|
virtual |
Returns a translated value.
The output name is used to find the input group, keyword, default and translations in the translation table. If the keyword does not exist in the input label and an input default is available, then this default 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.
translationGroupName | The name of the PVL translation group used to identify the input/output keywords to be translated. Often, this is the same as the output keyword name. |
findex | The index into the input keyword array. Defaults to 0 |
Implements Isis::LabelTranslationManager.
Definition at line 122 of file PvlToPvlTranslationManager.cpp.
References GetContainer(), Isis::PvlContainer::hasKeyword(), Isis::PvlTranslationTable::InputGroup(), Isis::PvlTranslationTable::InputKeywordName(), and Isis::PvlTranslationTable::Translate().
Referenced by Isis::NaifStatus::CheckErrors(), Isis::ProcessImportPds::ExtractPdsProjection(), Isis::ObservationNumber::FindObservationTranslation(), Isis::SerialNumber::FindSerialTranslation(), Isis::ProcessImportPds::ProcessDataFilePointer(), Isis::ProcessImportPds::ProcessLabel(), Isis::ProcessImportPds::ProcessPdsCombinedSpectrumLabel(), Isis::ProcessImportPds::ProcessPdsImageLabel(), Isis::ProcessImportPds::ProcessPdsM3Label(), Isis::ProcessImportPds::ProcessPixelBitandType(), and Isis::ProcessImportPds::ProcessSpecialPixels().
|
inherited |
Translates a single output value from the given translation group name and input value.
translationGroupName | The name of the PVL translation group used to identify the input/output keywords to be translated. Often, this is the same as the output keyword name. |
inputKeyValue | The value to be translated, from the input keyword. |
IException::Programmer | - "No value or default value to translate for translation group." |
IException::Programmer | - "Unable to find translation value in file." |
Definition at line 232 of file PvlTranslationTable.cpp.
References _FILEINFO_, Isis::PvlContainer::begin(), Isis::PvlContainer::end(), Isis::PvlContainer::fileName(), Isis::PvlContainer::findKeyword(), and Isis::PvlContainer::hasKeyword().
Referenced by Isis::PvlToXmlTranslationManager::doTranslation(), DoTranslation(), Isis::PvlToXmlTranslationManager::Translate(), Translate(), and Isis::XmlToPvlTranslationManager::Translate().
|
protectedinherited |
Protected accessor for pvl translation table passed into class.
This method returns a reference to the translation table member.
Definition at line 78 of file PvlTranslationTable.cpp.
Referenced by Isis::LabelTranslationManager::Auto(), Isis::PvlToXmlTranslationManager::Auto(), Auto(), DoTranslation(), Isis::PvlToXmlTranslationManager::InputKeyword(), InputKeyword(), and Isis::XmlToPvlTranslationManager::Translate().
|
protectedinherited |
Protected accessor for const pvl translation table passed into class.
This method returns a const reference to the translation table member.
Definition at line 90 of file PvlTranslationTable.cpp.
|
protectedvirtualinherited |
Returns a vector of valid keyword names and their sizes.
A size of -1 indicates that the keyword can be any size.
Reimplemented in Isis::XmlToPvlTranslationManager, and Isis::PvlToXmlTranslationManager.
Definition at line 195 of file PvlTranslationTable.cpp.
Referenced by Isis::PvlToXmlTranslationManager::validKeywords(), and Isis::XmlToPvlTranslationManager::validKeywords().
|
private |
A Pvl object for the input label file.
Definition at line 115 of file PvlToPvlTranslationManager.h.
Referenced by Auto(), GetContainer(), and PvlToPvlTranslationManager().