Isis 3 Programmer Reference
|
Allows applications to translate simple text files. More...
#include <LabelTranslationManager.h>
Public Member Functions | |
LabelTranslationManager () | |
Constructs a default LabelTranslationManager. More... | |
LabelTranslationManager (const QString &transFile) | |
Constructs a LabelTranslationManager with a given translation table. More... | |
LabelTranslationManager (std::istream &transStrm) | |
Constructs and initializes a LabelTranslationManager object. More... | |
virtual | ~LabelTranslationManager () |
Destroys the LabelTranslationManager object. More... | |
virtual QString | Translate (QString translationGroupName, int findex=0)=0 |
virtual void | Auto (Pvl &outputLabel) |
Automatically translate all the output names tagged as Auto in the translation table If a output name does not translate an error will be thrown by one of the support members. 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... | |
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 | |
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 PvlContainer * | CreateContainer (const QString translationGroupName, Pvl &pvl) |
Creates all parent PVL containers for an output keyword. 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... | |
Allows applications to translate simple text files.
This class allows the translation of text files which can be parsed by the Pvl class.
2017-01-11 Jeannie Backer - Original Version. Code moved out of PvlTranslationManager to make a generic parent class. Fixes #4584.
2017-01-20 Jesse Mapel - Updated documentation and unit test. Fixes #4584.
2017-05-26 Cole Neubauer - Moved parseDependancy from children class. Fixes #5167.
2017-10-26 Kristin Berry - Modified parseSpecification to switch from parsing translation table dependency specifications of the form name:value to strings of the form name|value. Colons are now used for namespaces only.
Definition at line 59 of file LabelTranslationManager.h.
Isis::LabelTranslationManager::LabelTranslationManager | ( | ) |
Constructs a default LabelTranslationManager.
Definition at line 40 of file LabelTranslationManager.cpp.
Isis::LabelTranslationManager::LabelTranslationManager | ( | const QString & | transFile | ) |
Constructs a LabelTranslationManager with a given translation table.
transfile | The translation table file. |
Definition at line 50 of file LabelTranslationManager.cpp.
References Isis::PvlTranslationTable::AddTable().
Isis::LabelTranslationManager::LabelTranslationManager | ( | std::istream & | transStrm | ) |
Constructs and initializes a LabelTranslationManager object.
transStrm | A stream containing the tranlation table to be used to tranlate keywords in the input label. |
Definition at line 62 of file LabelTranslationManager.cpp.
References Isis::PvlTranslationTable::AddTable().
|
virtual |
Destroys the LabelTranslationManager object.
Definition at line 71 of file LabelTranslationManager.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 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 tagged as Auto in the translation table If a output name does not translate an error will be thrown by one of the support members.
The results of the translations will be stored in the outputLabel PVL based on the OutputPosition keywords in the translation table.
outputLabel | The PVL to add the translated keywords to. |
Reimplemented in Isis::PvlToPvlTranslationManager.
Definition at line 85 of file LabelTranslationManager.cpp.
References CreateContainer(), DoTranslation(), Isis::PvlObject::group(), Isis::PvlObject::groups(), Isis::PvlTranslationTable::IsAuto(), Isis::PvlTranslationTable::IsOptional(), Isis::PvlContainer::name(), and Isis::PvlTranslationTable::TranslationTable().
|
protectedvirtual |
Creates all parent PVL containers for an output keyword.
If any parent containers already exist then they will not be recreated.
translationGroupName | The name of the output keyword. The OutputPosition keyword in the translation group for translationGroupName will be used to determine which containers are made. |
pvl | The PVL file to create the containers in. |
Reimplemented in Isis::PvlToPvlTranslationManager.
Definition at line 115 of file LabelTranslationManager.cpp.
References Isis::PvlObject::addGroup(), Isis::PvlObject::addObject(), Isis::PvlObject::findGroup(), Isis::PvlObject::findObject(), Isis::PvlObject::hasGroup(), Isis::PvlObject::hasObject(), Isis::PvlTranslationTable::OutputPosition(), and Isis::PvlKeyword::size().
Referenced by Auto(), and Isis::PvlToPvlTranslationManager::CreateContainer().
|
protectedvirtual |
Translate the requested output name to output values using the input name and values or default value.
outputName | The output name used to identify the input keyword to be translated. |
output units
Reimplemented in Isis::PvlToPvlTranslationManager.
Definition at line 159 of file LabelTranslationManager.cpp.
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().
|
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(), Isis::PvlToPvlTranslationManager::DoTranslation(), Isis::PvlToXmlTranslationManager::InputHasKeyword(), Isis::PvlToPvlTranslationManager::InputHasKeyword(), Isis::PvlToXmlTranslationManager::InputKeyword(), Isis::PvlToPvlTranslationManager::InputKeyword(), Isis::PvlToXmlTranslationManager::Translate(), and Isis::PvlToPvlTranslationManager::Translate().
|
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(), Isis::PvlToPvlTranslationManager::InputHasKeyword(), Isis::PvlToXmlTranslationManager::InputKeyword(), Isis::PvlToPvlTranslationManager::InputKeyword(), Isis::PvlToXmlTranslationManager::Translate(), and Isis::PvlToPvlTranslationManager::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 Auto(), Isis::PvlToXmlTranslationManager::Auto(), and Isis::PvlToPvlTranslationManager::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 Auto(), Isis::PvlToXmlTranslationManager::Auto(), and Isis::PvlToPvlTranslationManager::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 Isis::PvlToPvlTranslationManager::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 CreateContainer(), and Isis::PvlToXmlTranslationManager::createParentElements().
|
virtual |
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().
|
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(), Isis::PvlToPvlTranslationManager::DoTranslation(), Isis::PvlToXmlTranslationManager::Translate(), Isis::PvlToPvlTranslationManager::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 Auto(), Isis::PvlToXmlTranslationManager::Auto(), Isis::PvlToPvlTranslationManager::Auto(), Isis::PvlToPvlTranslationManager::DoTranslation(), Isis::PvlToXmlTranslationManager::InputKeyword(), Isis::PvlToPvlTranslationManager::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().