Isis Developer Reference
Isis::LabelTranslationManager Class Referenceabstract

Allows applications to translate simple text files. More...

#include <LabelTranslationManager.h>

Inheritance diagram for Isis::LabelTranslationManager:
Inheritance graph
Collaboration diagram for Isis::LabelTranslationManager:
Collaboration graph

Public Member Functions

 LabelTranslationManager ()
 Constructs a default LabelTranslationManager.
 
 LabelTranslationManager (const QString &transFile)
 Constructs a LabelTranslationManager with a given translation table.
 
 LabelTranslationManager (std::istream &transStrm)
 Constructs and initializes a LabelTranslationManager object.
 
virtual ~LabelTranslationManager ()
 Destroys the LabelTranslationManager object.
 
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.
 
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.
 
QString Translate (const QString translationGroupName, const QString inputKeyValue="") const
 Translates a single output value from the given translation group name and input value.
 
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 PvlContainerCreateContainer (const QString translationGroupName, Pvl &pvl)
 Creates all parent PVL containers for an output keyword.
 
PvlTranslationTable ()
 Protected accessor for pvl translation table passed into class.
 
const PvlTranslationTable () 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 PvlGroupfindTranslationGroup (const QString translationGroupName) const
 Searches for translation group with the given name.
 

Detailed Description

Allows applications to translate simple text files.

This class allows the translation of text files which can be parsed by the Pvl class.

Author
2017-01-11 Jeannie Backer

Constructor & Destructor Documentation

◆ LabelTranslationManager() [1/3]

Isis::LabelTranslationManager::LabelTranslationManager ( )

Constructs a default LabelTranslationManager.

◆ LabelTranslationManager() [2/3]

Isis::LabelTranslationManager::LabelTranslationManager ( const QString & transFile)

Constructs a LabelTranslationManager with a given translation table.

Parameters
transfileThe translation table file.

References Isis::PvlTranslationTable::AddTable().

◆ LabelTranslationManager() [3/3]

Isis::LabelTranslationManager::LabelTranslationManager ( std::istream & transStrm)

Constructs and initializes a LabelTranslationManager object.

Parameters
transStrmA stream containing the tranlation table to be used to tranlate keywords in the input label.

References Isis::PvlTranslationTable::AddTable().

◆ ~LabelTranslationManager()

Isis::LabelTranslationManager::~LabelTranslationManager ( )
virtual

Destroys the LabelTranslationManager object.

Member Function Documentation

◆ AddTable() [1/2]

void Isis::PvlTranslationTable::AddTable ( const QString & transFile)
inherited

Adds the contents of a translation table to the searchable groups/keys.

Parameters
transFileThe name of the translation file to be added.

References Isis::Pvl::read().

◆ AddTable() [2/2]

void Isis::PvlTranslationTable::AddTable ( std::istream & transStm)
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.

Parameters
transStmThe stream to be added.
Exceptions
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 LabelTranslationManager(), LabelTranslationManager(), Isis::PvlTranslationTable::PvlTranslationTable(), Isis::XmlToPvlTranslationManager::XmlToPvlTranslationManager(), Isis::XmlToPvlTranslationManager::XmlToPvlTranslationManager(), Isis::XmlToPvlTranslationManager::XmlToPvlTranslationManager(), and Isis::XmlToPvlTranslationManager::XmlToPvlTranslationManager().

◆ Auto()

void Isis::LabelTranslationManager::Auto ( Pvl & outputLabel)
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.

Parameters
outputLabelThe PVL to add the translated keywords to.

Reimplemented in Isis::PvlToPvlTranslationManager, and Isis::XmlToPvlTranslationManager.

References CreateContainer(), DoTranslation(), Isis::PvlObject::group(), Isis::PvlObject::groups(), Isis::PvlTranslationTable::IsAuto(), Isis::PvlTranslationTable::IsOptional(), and Isis::PvlTranslationTable::TranslationTable().

◆ CreateContainer()

PvlContainer * Isis::LabelTranslationManager::CreateContainer ( const QString translationGroupName,
Pvl & pvl )
protectedvirtual

Creates all parent PVL containers for an output keyword.

If any parent containers already exist then they will not be recreated.

Parameters
translationGroupNameThe name of the output keyword. The OutputPosition keyword in the translation group for translationGroupName will be used to determine which containers are made.
pvlThe PVL file to create the containers in.
Returns
PvlContainer The immediate parent container for translationGroupName.

Reimplemented in Isis::PvlToPvlTranslationManager.

References Isis::PvlObject::addObject(), and Isis::PvlTranslationTable::OutputPosition().

Referenced by Auto(), and Isis::PvlToPvlTranslationManager::CreateContainer().

◆ DoTranslation()

PvlKeyword Isis::LabelTranslationManager::DoTranslation ( const QString outputName)
protectedvirtual

Translate the requested output name to output values using the input name and values or default value.

Parameters
outputNameThe output name used to identify the input keyword to be translated.
Returns
PvlKeyword A keyword containing the output name and output value.

@TODO output units

Reimplemented in Isis::PvlToPvlTranslationManager.

References Translate().

Referenced by Auto().

◆ findTranslationGroup()

const PvlGroup & Isis::PvlTranslationTable::findTranslationGroup ( const QString translationGroupName) const
protectedinherited

Searches for translation group with the given name.

See also
PvlObject::findGroup()
Parameters
translationGroupNameThe 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.
Returns
const PvlGroup& The first PVL group with the given name.
Exceptions
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().

◆ hasInputDefault()

bool Isis::PvlTranslationTable::hasInputDefault ( const QString translationGroupName)
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.

Parameters
translationGroupNameThe 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.
Returns
bool Indicates whether the given group has an InputDefault keyword.

References Isis::PvlTranslationTable::findTranslationGroup().

Referenced by Isis::XmlToPvlTranslationManager::Translate().

◆ InputDefault()

QString Isis::PvlTranslationTable::InputDefault ( const QString translationGroupName) const
inherited

Returns the input default value from the translation table corresponding to the output name argument.

Parameters
translationGroupNameThe 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.
Returns
QString The input default value.

References Isis::PvlTranslationTable::findTranslationGroup().

Referenced by Isis::XmlToPvlTranslationManager::Translate().

◆ InputGroup()

PvlKeyword Isis::PvlTranslationTable::InputGroup ( const QString translationGroupName,
const int inst = 0 ) const
virtualinherited

Returns the input group name from the translation table corresponding to the output name argument.

Parameters
translationGroupNameThe 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.
instThe occurence number of the "InputGroup" keyword (first one is zero)
Returns
QString The input group name
Exceptions
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(), Isis::PvlToXmlTranslationManager::doTranslation(), Isis::PvlToPvlTranslationManager::InputHasKeyword(), Isis::PvlToXmlTranslationManager::InputHasKeyword(), Isis::PvlToPvlTranslationManager::InputKeyword(), Isis::PvlToXmlTranslationManager::InputKeyword(), Isis::PvlToPvlTranslationManager::Translate(), and Isis::PvlToXmlTranslationManager::Translate().

◆ InputKeywordName()

QString Isis::PvlTranslationTable::InputKeywordName ( const QString translationGroupName) const
virtualinherited

Returns the input keyword name from the translation table corresponding to the output name argument.

Parameters
translationGroupNameThe 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.
Returns
QString The input keyword name
Exceptions
IException::Programmer

References Isis::PvlTranslationTable::findTranslationGroup().

Referenced by Isis::PvlToXmlTranslationManager::doTranslation(), Isis::PvlToPvlTranslationManager::InputHasKeyword(), Isis::PvlToXmlTranslationManager::InputHasKeyword(), Isis::PvlToPvlTranslationManager::InputKeyword(), Isis::PvlToXmlTranslationManager::InputKeyword(), Isis::PvlToPvlTranslationManager::Translate(), and Isis::PvlToXmlTranslationManager::Translate().

◆ IsAuto()

bool Isis::PvlTranslationTable::IsAuto ( const QString translationGroupName)
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.

Parameters
translationGroupNameThe 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.
Returns
bool Indicates whether the given group has an Auto keyword.

References Isis::PvlTranslationTable::findTranslationGroup().

Referenced by Auto(), Isis::PvlToPvlTranslationManager::Auto(), and Isis::PvlToXmlTranslationManager::Auto().

◆ IsOptional()

bool Isis::PvlTranslationTable::IsOptional ( const QString translationGroupName)
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.

Parameters
translationGroupNameThe 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.
Returns
bool Indicates whether the given group has an Optional keyword.

References Isis::PvlTranslationTable::findTranslationGroup().

Referenced by Auto(), Isis::PvlToPvlTranslationManager::Auto(), and Isis::PvlToXmlTranslationManager::Auto().

◆ OutputName()

QString Isis::PvlTranslationTable::OutputName ( const QString translationGroupName)
protectedinherited

Retrieves a string containing the value of the OutputName keyword for the translation group with the given name.

Parameters
translationGroupNameThe 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.
Returns
QString The value of the OutputName keyword from the given translation group.

References Isis::PvlTranslationTable::findTranslationGroup().

Referenced by Isis::PvlToPvlTranslationManager::DoTranslation(), and Isis::PvlToXmlTranslationManager::doTranslation().

◆ OutputPosition()

PvlKeyword Isis::PvlTranslationTable::OutputPosition ( const QString translationGroupName)
protectedinherited

Retrieves the OutputPosition PvlKeyword for the translation group with the given name.

Parameters
translationGroupNameThe 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.
Returns
PvlKeyword The OutputPosition keyword from the given translation group.
Exceptions
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 CreateContainer(), and Isis::PvlToXmlTranslationManager::createParentElements().

◆ parseSpecification()

QStringList Isis::LabelTranslationManager::parseSpecification ( QString specification) const
virtual

Parses and validates a dependency specification.

Parameters
specificationThe dependency specification string.
Returns
QStringList The dependency split into 3 components
  1. the type (att or tag)
  2. the name of what to check
  3. the value to check for
Exceptions
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().

◆ Translate() [1/2]

QString Isis::PvlTranslationTable::Translate ( const QString translationGroupName,
const QString inputKeyValue = "" ) const
inherited

Translates a single output value from the given translation group name and input value.

Parameters
translationGroupNameThe 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.
inputKeyValueThe value to be translated, from the input keyword.
Returns
QString The translated value, for the output keyword.
Exceptions
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(), Isis::PvlToXmlTranslationManager::doTranslation(), Isis::PvlToPvlTranslationManager::Translate(), Isis::XmlToPvlTranslationManager::Translate(), and Isis::PvlToXmlTranslationManager::Translate().

◆ Translate() [2/2]

virtual QString Isis::LabelTranslationManager::Translate ( QString translationGroupName,
int findex = 0 )
pure virtual

◆ TranslationTable() [1/2]

Pvl & Isis::PvlTranslationTable::TranslationTable ( )
protectedinherited

Protected accessor for pvl translation table passed into class.

This method returns a reference to the translation table member.

Returns
Pvl The translation table as a PVL object.

Referenced by Auto(), Isis::PvlToPvlTranslationManager::Auto(), Isis::PvlToXmlTranslationManager::Auto(), Isis::PvlToPvlTranslationManager::DoTranslation(), Isis::PvlToPvlTranslationManager::InputKeyword(), Isis::PvlToXmlTranslationManager::InputKeyword(), and Isis::XmlToPvlTranslationManager::Translate().

◆ TranslationTable() [2/2]

const Pvl & Isis::PvlTranslationTable::TranslationTable ( ) const
protectedinherited

Protected accessor for const pvl translation table passed into class.

This method returns a const reference to the translation table member.

Returns
Pvl The translation table as a PVL object.

◆ validKeywords()

vector< pair< QString, int > > Isis::PvlTranslationTable::validKeywords ( ) const
protectedvirtualinherited

Returns a vector of valid keyword names and their sizes.

A size of -1 indicates that the keyword can be any size.

Returns
vector<pair<QString,int>> A vector of valid keyword names and their sizes.

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().


The documentation for this class was generated from the following files: