Isis Developer Reference
|
Allows applications to translate simple text files. More...
#include <PvlToXmlTranslationManager.h>
Public Member Functions | |
PvlToXmlTranslationManager (const QString &transFile) | |
Constructs and initializes a TranslationManager object from given the Pvl translation file. | |
PvlToXmlTranslationManager (Pvl &inputLabel, const QString &transFile) | |
Constructs and initializes a TranslationManager object. | |
virtual | ~PvlToXmlTranslationManager () |
Destroys the TranslationManager object. | |
virtual QString | Translate (QString translationGroupName, int inputIndex=0) |
Returns a translated value. | |
void | Auto (QDomDocument &outputLabel) |
Automatically translate all the output names found in the translation table. | |
void | Auto (Pvl &inputLabel, QDomDocument &outputLabel) |
Set the inputLabel and automatically translate all the output names found in the translation table. | |
virtual const PvlKeyword & | InputKeyword (const QString translationGroupName) const |
Uses the translation file group name to find the input label's PvlKeyword that corresponds to the InputKey value of the translation table and returns it, if found. | |
virtual bool | InputHasKeyword (const QString translationGroupName) |
Indicates if the input keyword corresponding to the output name exists in the label. | |
void | SetLabel (Pvl &inputLabel) |
Internalizes a Pvl formatted label for translation. | |
QString | Translate (const QString translationGroupName, const QString inputKeyValue="") const |
Translates a single output value from the given translation group name and input value. | |
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. | |
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. | |
Static Public Member Functions | |
static void | addElement (QDomElement &parent, QString name, QString value, QString units="") |
Add a QDomElement to the given parent with the indicated value and units. | |
static void | setElementValue (QDomElement &element, QString value, QString units="") |
Set the QDomElement's value, and units, if units != "". | |
static void | resetElementValue (QDomElement &element, QString value, QString units="") |
Reset the QDomElement's value, and units, if units != "". | |
Protected Member Functions | |
void | doTranslation (PvlGroup transGroup, QDomElement &parent) |
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 with the path given by the "InputPosition" keyword of the translation table. | |
virtual std::vector< std::pair< QString, int > > | validKeywords () const |
Returns a vector of valid keyword names and their sizes. | |
bool | checkDependencies (QDomElement element, PvlKeyword dependencies, bool isDebug) const |
QDomElement * | createParentElements (const QString translationGroupName, QDomElement &xml) |
Read the OutputPosition for the translation group name passed and create any parent elements specified by OutputPosition to prepare for translation. | |
void | addSiblings (PvlKeyword outputSiblings, QDomElement &parent) |
Take in outputSiblings PvlKeyword and turn each sibling into its corresponding QDomElement. | |
void | addAttributes (PvlKeyword something, QDomElement &parent) |
Take in the outputAttributes PvlKeyword and add each attribute to the appropriate element given as an argument. | |
virtual PvlKeyword | DoTranslation (const QString translationGroupName) |
Translate the requested output name to output values using the input name and values or default value. | |
virtual PvlContainer * | CreateContainer (const QString translationGroupName, Pvl &pvl) |
Creates all parent PVL containers for an output keyword. | |
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. | |
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 into Xml files.
Isis::PvlToXmlTranslationManager::PvlToXmlTranslationManager | ( | 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 tranlate keywords in the input label. |
Isis::PvlToXmlTranslationManager::PvlToXmlTranslationManager | ( | 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 tranlate keywords in the input label. |
|
virtual |
Destroys the TranslationManager object.
|
protected |
Take in the outputAttributes PvlKeyword and add each attribute to the appropriate element given as an argument.
outputAttributes | The PvlKeyword that holds the list of siblings |
element | QDomElement to be modified |
IException::Programmer | "Malformed output attribute [" + outputAttributes[i] + ]." |
References _FILEINFO_, Isis::LabelTranslationManager::parseSpecification(), and Isis::IException::Programmer.
Referenced by doTranslation().
|
static |
Add a QDomElement to the given parent with the indicated value and units.
parent | The parent QDomElement of the new element. |
name | The name of the new element. |
value | The value of the new element. |
units | A string containing the unit specification for the new element. |
References setElementValue().
|
protected |
Take in outputSiblings PvlKeyword and turn each sibling into its corresponding QDomElement.
Then add the QDomElement to the parent as a child.
outputSiblings | The PvlKeyword that holds the list of siblings |
parent | The parent QDomElement |
IException::Programmer | "Malformed OutputSibling [" + outputSiblings[i] + "]" |
References _FILEINFO_, Isis::LabelTranslationManager::parseSpecification(), Isis::IException::Programmer, and setElementValue().
Referenced by doTranslation().
|
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().
void Isis::PvlToXmlTranslationManager::Auto | ( | Pvl & | inputLabel, |
QDomDocument & | outputLabel ) |
Set the inputLabel and 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. If the output name is translated, store the translated key, value pairs in the QDomDocument.
inputLabel | The input Pvl label |
outputLabel | The output QDomDocument label |
References Auto().
|
virtualinherited |
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, and Isis::XmlToPvlTranslationManager.
References Isis::LabelTranslationManager::CreateContainer(), Isis::LabelTranslationManager::DoTranslation(), Isis::PvlObject::group(), Isis::PvlObject::groups(), Isis::PvlTranslationTable::IsAuto(), Isis::PvlTranslationTable::IsOptional(), and Isis::PvlTranslationTable::TranslationTable().
void Isis::PvlToXmlTranslationManager::Auto | ( | QDomDocument & | 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. If the output name is translated, store the translated key, value pairs in the QDomDocument.
outputLabel | A reference to the output QDomDocument label |
References createParentElements(), doTranslation(), Isis::PvlObject::group(), Isis::PvlObject::groups(), Isis::PvlTranslationTable::IsAuto(), Isis::PvlTranslationTable::IsOptional(), and Isis::PvlTranslationTable::TranslationTable().
Referenced by Auto().
|
protected |
|
protectedvirtualinherited |
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.
References Isis::PvlObject::addObject(), and Isis::PvlTranslationTable::OutputPosition().
Referenced by Isis::LabelTranslationManager::Auto(), and Isis::PvlToPvlTranslationManager::CreateContainer().
|
protected |
Read the OutputPosition for the translation group name passed and create any parent elements specified by OutputPosition to prepare for translation.
const | QString translationGroupName Name of the translation group we will grab OutputPosition from. |
QDomElement | &xmlRootElement The XML document root element to add to. |
References Isis::PvlTranslationTable::OutputPosition(), and Isis::LabelTranslationManager::parseSpecification().
Referenced by Auto().
|
protectedvirtualinherited |
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. |
@TODO output units
Reimplemented in Isis::PvlToPvlTranslationManager.
References Isis::LabelTranslationManager::Translate().
Referenced by Isis::LabelTranslationManager::Auto().
|
protected |
Translate the requested output name to output values using the input name and values or default value.
transGroupName | The output name used to identify the input keyword to be translated. |
parentElement | The element that is the parent of the new QDomElement, if a new element is created. If a new element is not created, then parentElement will have an attribute added to it. |
References addAttributes(), addSiblings(), GetContainer(), Isis::PvlTranslationTable::InputGroup(), Isis::PvlTranslationTable::InputKeywordName(), Isis::PvlTranslationTable::OutputName(), Isis::LabelTranslationManager::parseSpecification(), setElementValue(), and Isis::PvlTranslationTable::Translate().
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 with the path given by the "InputPosition" keyword of the translation table.
inputGroup | The InputPosition keyword |
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 Isis::PvlToPvlTranslationManager::DoTranslation(), doTranslation(), Isis::PvlToPvlTranslationManager::InputHasKeyword(), InputHasKeyword(), Isis::PvlToPvlTranslationManager::InputKeyword(), InputKeyword(), Isis::PvlToPvlTranslationManager::Translate(), and Translate().
|
virtual |
Indicates if the input keyword corresponding to the output name exists in the label.
transGroupName | The output name used to identify the input keyword. |
References GetContainer(), Isis::PvlTranslationTable::InputGroup(), and Isis::PvlTranslationTable::InputKeywordName().
|
virtual |
Uses the translation file group name to find the input label's PvlKeyword that corresponds to the InputKey value of the translation table and returns it, if found.
transGroupName | The name of the translation group for this InputKey. |
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 doTranslation(), Isis::PvlToPvlTranslationManager::InputHasKeyword(), InputHasKeyword(), Isis::PvlToPvlTranslationManager::InputKeyword(), InputKeyword(), Isis::PvlToPvlTranslationManager::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. |
References Isis::PvlTranslationTable::findTranslationGroup().
Referenced by Isis::LabelTranslationManager::Auto(), Isis::PvlToPvlTranslationManager::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. |
References Isis::PvlTranslationTable::findTranslationGroup().
Referenced by Isis::LabelTranslationManager::Auto(), Isis::PvlToPvlTranslationManager::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. |
References Isis::PvlTranslationTable::findTranslationGroup().
Referenced by Isis::PvlToPvlTranslationManager::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." |
References _FILEINFO_, Isis::PvlContainer::fileName(), Isis::PvlTranslationTable::findTranslationGroup(), and Isis::IException::Programmer.
Referenced by Isis::LabelTranslationManager::CreateContainer(), and 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 addAttributes(), addSiblings(), Isis::XmlToPvlTranslationManager::checkDependencies(), createParentElements(), and doTranslation().
|
static |
Reset the QDomElement's value, and units, if units != "".
element | The QDomElement whose value needs to be reset. |
value | The value to set. |
units | A string containing the unit specification. |
Referenced by Isis::ProcessExportPds4::identificationArea(), Isis::ProcessExportPds4::reorder(), Isis::ProcessExportPds4::StandardAllMapping(), and Isis::ProcessExportPds4::standardInstrument().
|
static |
Set the QDomElement's value, and units, if units != "".
element | The QDomElement whose value needs to be set. |
value | The value to set. |
units | A string containing the unit specification. |
Referenced by addElement(), Isis::ProcessExportPds4::addHistory(), addSiblings(), doTranslation(), Isis::ProcessExportPds4::fileAreaObservational(), Isis::ProcessExportPds4::translateBandBinSpectrumBinSet(), Isis::ProcessExportPds4::translateBandBinSpectrumUniform(), and Isis::ProcessExportPds4::WritePds4().
void Isis::PvlToXmlTranslationManager::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 Isis::PvlToPvlTranslationManager::DoTranslation(), doTranslation(), Isis::PvlToPvlTranslationManager::Translate(), Isis::XmlToPvlTranslationManager::Translate(), and Translate().
|
virtual |
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.
transGroupName | The output name used to identify the input keyword to be translated. |
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(), Isis::PvlToPvlTranslationManager::Auto(), Auto(), Isis::PvlToPvlTranslationManager::DoTranslation(), Isis::PvlToPvlTranslationManager::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.
|
protectedvirtual |
Returns a vector of valid keyword names and their sizes.
A size of -1 indicates that the keyword can be any size.
Reimplemented from Isis::PvlTranslationTable.
References validKeywords(), and Isis::PvlTranslationTable::validKeywords().
Referenced by validKeywords().