Isis Developer 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. | |
PvlToPvlTranslationManager (std::istream &transStrm) | |
Constructs and initializes a TranslationManager object from the given input stream. | |
PvlToPvlTranslationManager (Pvl &inputLabel, const QString &transFile) | |
Constructs and initializes a TranslationManager object. | |
PvlToPvlTranslationManager (Pvl &inputLabel, std::istream &transStrm) | |
Constructs and initializes a TranslationManager object. | |
virtual | ~PvlToPvlTranslationManager () |
Destroys the TranslationManager object. | |
virtual QString | Translate (QString translationGroupName, int findex=0) |
Returns a translated value. | |
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. | |
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. | |
virtual const PvlKeyword & | InputKeyword (const QString translationGroupName) const |
Returns the ith input value associated with the output name argument. | |
virtual bool | InputHasKeyword (const QString translationGroupName) |
Indicates if the input keyword corresponding to the output name exists in the label. | |
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. | |
virtual QStringList | parseSpecification (QString specification) const |
Parses and validates a dependency specification. | |
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. | |
virtual QString | InputKeywordName (const QString translationGroupName) const |
Returns the input keyword name from the translation table corresponding to the output name argument. | |
QString | InputDefault (const QString translationGroupName) const |
Returns the input default value from the translation table corresponding to the output name argument. | |
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 QString &transFile) |
Adds the contents of a translation table to the searchable groups/keys. | |
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. | |
virtual const PvlContainer * | GetContainer (const PvlKeyword &inputGroup) const |
Return a container from the input label according tund. | |
virtual PvlContainer * | CreateContainer (const QString translationGroupName, Pvl &pvl) |
Create the requsted container and any containers above it and return a reference to the container. | |
Pvl & | TranslationTable () |
Protected accessor for pvl translation table passed into class. | |
const Pvl & | TranslationTable () const |
Protected accessor for const pvl translation table passed into class. | |
virtual std::vector< std::pair< QString, int > > | validKeywords () const |
Returns a vector of valid keyword names and their sizes. | |
bool | hasInputDefault (const QString translationGroupName) |
Determines whether the given group has a default input value. | |
bool | IsAuto (const QString translationGroupName) |
Determines whether the given group should be automatically translated. | |
bool | IsOptional (const QString translationGroupName) |
Determines whether the translation group is optional. | |
PvlKeyword | OutputPosition (const QString translationGroupName) |
Retrieves the OutputPosition PvlKeyword for the translation group with the given name. | |
QString | OutputName (const QString translationGroupName) |
Retrieves a string containing the value of the OutputName keyword for the translation group with the given name. | |
const PvlGroup & | findTranslationGroup (const QString translationGroupName) const |
Searches for translation group with the given name. | |
Allows applications to translate simple text files.
This class allows the translation of text files which can be parsed by the Pvl class.
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. |
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. |
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. |
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. |
|
virtual |
Destroys the TranslationManager object.
|
inherited |
Adds the contents of a translation table to the searchable groups/keys.
transFile | The name of the translation file to be added. |
References Isis::Pvl::read().
|
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." |
References _FILEINFO_, Isis::PvlKeyword::name(), Isis::IException::User, and Isis::PvlTranslationTable::validKeywords().
Referenced by Isis::LabelTranslationManager::LabelTranslationManager(), Isis::LabelTranslationManager::LabelTranslationManager(), Isis::PvlTranslationTable::PvlTranslationTable(), Isis::XmlToPvlTranslationManager::XmlToPvlTranslationManager(), Isis::XmlToPvlTranslationManager::XmlToPvlTranslationManager(), Isis::XmlToPvlTranslationManager::XmlToPvlTranslationManager(), and Isis::XmlToPvlTranslationManager::XmlToPvlTranslationManager().
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.
References Auto().
|
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.
References CreateContainer(), DoTranslation(), Isis::PvlObject::group(), Isis::PvlObject::groups(), Isis::PvlTranslationTable::IsAuto(), Isis::PvlTranslationTable::IsOptional(), and Isis::PvlTranslationTable::TranslationTable().
Referenced by Auto().
|
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.
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.
References Isis::PvlKeyword::addValue(), Isis::PvlObject::findGroup(), GetContainer(), 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." |
References _FILEINFO_, Isis::PvlContainer::fileName(), Isis::PvlObject::findGroup(), Isis::PvlObject::hasGroup(), and Isis::IException::Programmer.
Referenced by Isis::PvlTranslationTable::hasInputDefault(), Isis::PvlTranslationTable::InputDefault(), Isis::PvlTranslationTable::InputGroup(), Isis::PvlTranslationTable::InputKeywordName(), Isis::PvlTranslationTable::IsAuto(), Isis::PvlTranslationTable::IsOptional(), Isis::PvlTranslationTable::OutputName(), Isis::PvlTranslationTable::OutputPosition(), and Isis::PvlTranslationTable::Translate().
|
protectedvirtual |
Return a container from the input label according tund.
References Isis::PvlObject::findObject(), 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. |
References Isis::PvlTranslationTable::findTranslationGroup().
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. |
References Isis::PvlTranslationTable::findTranslationGroup().
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." |
References _FILEINFO_, Isis::PvlTranslationTable::findTranslationGroup(), Isis::IException::Programmer, and Isis::PvlKeyword::size().
Referenced by DoTranslation(), Isis::PvlToXmlTranslationManager::doTranslation(), InputHasKeyword(), Isis::PvlToXmlTranslationManager::InputHasKeyword(), InputKeyword(), Isis::PvlToXmlTranslationManager::InputKeyword(), Translate(), and Isis::PvlToXmlTranslationManager::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. |
References GetContainer(), Isis::PvlTranslationTable::InputGroup(), and Isis::PvlTranslationTable::InputKeywordName().
|
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 |
References _FILEINFO_, Isis::PvlContainer::fileName(), GetContainer(), Isis::PvlTranslationTable::InputGroup(), Isis::PvlTranslationTable::InputKeywordName(), Isis::IException::Programmer, and Isis::PvlTranslationTable::TranslationTable().
|
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 |
References Isis::PvlTranslationTable::findTranslationGroup().
Referenced by Isis::PvlToXmlTranslationManager::doTranslation(), InputHasKeyword(), Isis::PvlToXmlTranslationManager::InputHasKeyword(), InputKeyword(), Isis::PvlToXmlTranslationManager::InputKeyword(), Translate(), and Isis::PvlToXmlTranslationManager::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. |
References Isis::PvlTranslationTable::findTranslationGroup().
Referenced by Isis::LabelTranslationManager::Auto(), Auto(), and Isis::PvlToXmlTranslationManager::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. |
References Isis::PvlTranslationTable::findTranslationGroup().
Referenced by Isis::LabelTranslationManager::Auto(), Auto(), and Isis::PvlToXmlTranslationManager::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. |
References Isis::PvlTranslationTable::findTranslationGroup().
Referenced by DoTranslation(), and Isis::PvlToXmlTranslationManager::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." |
References _FILEINFO_, Isis::PvlContainer::fileName(), Isis::PvlTranslationTable::findTranslationGroup(), and Isis::IException::Programmer.
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. @throws IException::Programmer "Dependency type specification is invalid. Valid types are [att] and [tag]" @throws IException::Programmer "Name-value specification does not have two components separated by [|]." |
References _FILEINFO_, and Isis::IException::Programmer.
Referenced by Isis::PvlToXmlTranslationManager::addAttributes(), Isis::PvlToXmlTranslationManager::addSiblings(), Isis::XmlToPvlTranslationManager::checkDependencies(), Isis::PvlToXmlTranslationManager::createParentElements(), and Isis::PvlToXmlTranslationManager::doTranslation().
void Isis::PvlToPvlTranslationManager::SetLabel | ( | Pvl & | inputLabel | ) |
|
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." |
References _FILEINFO_, Isis::PvlContainer::fileName(), Isis::PvlTranslationTable::findTranslationGroup(), and Isis::IException::Programmer.
Referenced by DoTranslation(), Isis::PvlToXmlTranslationManager::doTranslation(), Translate(), Isis::XmlToPvlTranslationManager::Translate(), and Isis::PvlToXmlTranslationManager::Translate().
|
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.
References GetContainer(), Isis::PvlTranslationTable::InputGroup(), Isis::PvlTranslationTable::InputKeywordName(), and Isis::PvlTranslationTable::Translate().
|
protectedinherited |
Protected accessor for pvl translation table passed into class.
This method returns a reference to the translation table member.
Referenced by Isis::LabelTranslationManager::Auto(), Auto(), Isis::PvlToXmlTranslationManager::Auto(), DoTranslation(), InputKeyword(), Isis::PvlToXmlTranslationManager::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.
|
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::PvlToXmlTranslationManager, and Isis::XmlToPvlTranslationManager.
References Isis::PvlTranslationTable::validKeywords().
Referenced by Isis::PvlTranslationTable::AddTable(), Isis::PvlToXmlTranslationManager::validKeywords(), Isis::PvlTranslationTable::validKeywords(), and Isis::XmlToPvlTranslationManager::validKeywords().