Isis 3 Programmer Reference
|
Internalizes a translation table. More...
#include <PvlTranslationTable.h>
Public Member Functions | |
PvlTranslationTable (FileName transFile) | |
Constructs and initializes a PvlTranslationTable object. More... | |
PvlTranslationTable (std::istream &istr) | |
Constructs and initializes a PvlTranslationTable object. More... | |
PvlTranslationTable () | |
Construct an empty PvlTranslationTable. More... | |
virtual | ~PvlTranslationTable () |
Destroys the PvlTranslationTable object. 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... | |
QString | Translate (const QString translationGroupName, const QString inputKeyValue="") const |
Translates a single output value from the given translation group name and input value. 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 | |
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_trnsTbl |
Internalizes a translation table.
This class internalizes an Isis translation table and provides group/key searches and value translations. The group names listed are the output names used by applications to get the input names and values. There is only one level of groups and groups are not allowed to be nested. The Group names can NOT be repeated. OutputGroup is a comma delimited list of objects and/or groups in the input label. Traversing this list within the input label will lead to the correct level to find the input keyword. OutputKey is the keyword within the group which holds the information. OutputDefault is the value used if there is no value for the keyword. Translation is the output and corresponding input values. Translation may be repeated as needed. An example piece of a tranlation file:
Definition at line 106 of file PvlTranslationTable.h.
Isis::PvlTranslationTable::PvlTranslationTable | ( | FileName | transFile | ) |
Constructs and initializes a PvlTranslationTable object.
transFile | The translation file to be used. |
Definition at line 26 of file PvlTranslationTable.cpp.
References Isis::FileName::expanded().
Isis::PvlTranslationTable::PvlTranslationTable | ( | std::istream & | istr | ) |
Constructs and initializes a PvlTranslationTable object.
istr | The translation stream to be used to translate values |
Definition at line 36 of file PvlTranslationTable.cpp.
Isis::PvlTranslationTable::PvlTranslationTable | ( | ) |
Construct an empty PvlTranslationTable.
Definition at line 44 of file PvlTranslationTable.cpp.
|
virtual |
Destroys the PvlTranslationTable object.
Definition at line 51 of file PvlTranslationTable.cpp.
void Isis::PvlTranslationTable::AddTable | ( | const QString & | transFile | ) |
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 84 of file PvlTranslationTable.cpp.
References Isis::Pvl::read().
void Isis::PvlTranslationTable::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.
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 102 of file PvlTranslationTable.cpp.
References 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().
|
protected |
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 538 of file PvlTranslationTable.cpp.
References Isis::PvlContainer::fileName().
|
protected |
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 407 of file PvlTranslationTable.cpp.
References Isis::PvlContainer::hasKeyword().
Referenced by Isis::XmlToPvlTranslationManager::Translate().
QString Isis::PvlTranslationTable::InputDefault | ( | const QString | translationGroupName | ) | const |
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 382 of file PvlTranslationTable.cpp.
References Isis::PvlContainer::hasKeyword().
Referenced by Isis::XmlToPvlTranslationManager::Translate().
|
virtual |
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 285 of file PvlTranslationTable.cpp.
References Isis::PvlContainer::begin(), Isis::PvlContainer::end(), Isis::PvlContainer::findKeyword(), and Isis::PvlKeyword::size().
Referenced by Isis::PvlToPvlTranslationManager::DoTranslation(), Isis::PvlToXmlTranslationManager::doTranslation(), Isis::PvlToPvlTranslationManager::InputHasKeyword(), Isis::PvlToXmlTranslationManager::InputHasKeyword(), Isis::PvlToPvlTranslationManager::InputKeyword(), Isis::PvlToXmlTranslationManager::InputKeyword(), Isis::PvlToPvlTranslationManager::Translate(), and Isis::PvlToXmlTranslationManager::Translate().
|
virtual |
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 360 of file PvlTranslationTable.cpp.
References Isis::PvlContainer::hasKeyword().
Referenced by Isis::PvlToXmlTranslationManager::doTranslation(), Isis::PvlToPvlTranslationManager::InputHasKeyword(), Isis::PvlToXmlTranslationManager::InputHasKeyword(), Isis::PvlToPvlTranslationManager::InputKeyword(), Isis::PvlToXmlTranslationManager::InputKeyword(), Isis::PvlToPvlTranslationManager::Translate(), and Isis::PvlToXmlTranslationManager::Translate().
|
protected |
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 432 of file PvlTranslationTable.cpp.
References Isis::PvlContainer::hasKeyword().
Referenced by Isis::LabelTranslationManager::Auto(), Isis::PvlToPvlTranslationManager::Auto(), and Isis::PvlToXmlTranslationManager::Auto().
|
protected |
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 457 of file PvlTranslationTable.cpp.
References Isis::PvlContainer::hasKeyword().
Referenced by Isis::LabelTranslationManager::Auto(), Isis::PvlToPvlTranslationManager::Auto(), and Isis::PvlToXmlTranslationManager::Auto().
|
protected |
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 511 of file PvlTranslationTable.cpp.
References Isis::PvlContainer::hasKeyword().
Referenced by Isis::PvlToPvlTranslationManager::DoTranslation(), and Isis::PvlToXmlTranslationManager::doTranslation().
|
protected |
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 483 of file PvlTranslationTable.cpp.
References Isis::PvlContainer::hasKeyword().
Referenced by Isis::LabelTranslationManager::CreateContainer(), and Isis::PvlToXmlTranslationManager::createParentElements().
QString Isis::PvlTranslationTable::Translate | ( | const QString | translationGroupName, |
const QString | inputKeyValue = "" |
||
) | const |
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 216 of file PvlTranslationTable.cpp.
References Isis::PvlContainer::begin(), Isis::PvlContainer::end(), Isis::PvlContainer::fileName(), Isis::PvlContainer::findKeyword(), and Isis::PvlContainer::hasKeyword().
Referenced by Isis::PvlToPvlTranslationManager::DoTranslation(), Isis::PvlToXmlTranslationManager::doTranslation(), Isis::PvlToPvlTranslationManager::Translate(), Isis::XmlToPvlTranslationManager::Translate(), and Isis::PvlToXmlTranslationManager::Translate().
|
protected |
Protected accessor for pvl translation table passed into class.
This method returns a reference to the translation table member.
Definition at line 62 of file PvlTranslationTable.cpp.
Referenced by Isis::LabelTranslationManager::Auto(), Isis::PvlToPvlTranslationManager::Auto(), Isis::PvlToXmlTranslationManager::Auto(), Isis::PvlToPvlTranslationManager::DoTranslation(), Isis::PvlToPvlTranslationManager::InputKeyword(), Isis::PvlToXmlTranslationManager::InputKeyword(), and Isis::XmlToPvlTranslationManager::Translate().
|
protected |
Protected accessor for const pvl translation table passed into class.
This method returns a const reference to the translation table member.
Definition at line 74 of file PvlTranslationTable.cpp.
|
protectedvirtual |
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 179 of file PvlTranslationTable.cpp.
Referenced by Isis::PvlToXmlTranslationManager::validKeywords(), and Isis::XmlToPvlTranslationManager::validKeywords().