Isis Developer Reference
PvlToXmlTranslationManager.h
Go to the documentation of this file.
1 #ifndef PvlToXmlTranslationManager_h
2 #define PvlToXmlTranslationManager_h
3 
8 /* SPDX-License-Identifier: CC0-1.0 */
10 
11 #include <string>
12 
13 #include <QDomDocument>
14 
15 #include "FileName.h"
16 #include "Pvl.h"
17 #include "PvlTokenizer.h"
18 
19 class QDomElement;
20 class QString;
21 
22 namespace Isis {
23  class Pvl;
24  class PvlContainer;
25  class PvlKeyword;
52  public:
53  PvlToXmlTranslationManager(const QString &transFile);
54 
55  PvlToXmlTranslationManager(Pvl &inputLabel,
56  const QString &transFile);
57 
59 
60  // Attempt to translate the requested output name to output value
61  // using the input name and value/default value
62  virtual QString Translate(QString translationGroupName, int inputIndex = 0);
63 
64  // Translate all translation table groups which contain "Auto"
65  void Auto(QDomDocument &outputLabel);
66  void Auto(Pvl &inputLabel, QDomDocument &outputLabel);
67 
68  // Return the ith input value associated with a output name
69  virtual const PvlKeyword &InputKeyword(const QString translationGroupName) const;
70 
71  // Return true if the input lable contains the translated group and key names
72  virtual bool InputHasKeyword(const QString translationGroupName);
73 
74  void SetLabel(Pvl &inputLabel);
75 
76  static void addElement(QDomElement &parent, QString name, QString value, QString units = "");
77  static void setElementValue(QDomElement &element, QString value, QString units = "");
78  static void resetElementValue(QDomElement &element, QString value, QString units = "");
79 
80 
81  protected:
82  void doTranslation(PvlGroup transGroup, QDomElement &parent);
83  virtual const PvlContainer *GetContainer(const PvlKeyword &inputGroup) const;
84 
85  virtual std::vector< std::pair<QString, int> > validKeywords() const;
86  bool checkDependencies(QDomElement element, PvlKeyword dependencies, bool isDebug) const;
87  QDomElement *createParentElements(const QString translationGroupName, QDomElement &xml);
88  void addSiblings(PvlKeyword outputSiblings, QDomElement &parent);
89  void addAttributes(PvlKeyword something, QDomElement &parent);
90 
91  private:
92  Pvl m_inputLabel;
93  };
94 };
95 
96 #endif
Isis::LabelTranslationManager::parseSpecification
virtual QStringList parseSpecification(QString specification) const
Parses and validates a dependency specification.
Definition: LabelTranslationManager.cpp:172
Isis::PvlToXmlTranslationManager::addSiblings
void addSiblings(PvlKeyword outputSiblings, QDomElement &parent)
Take in outputSiblings PvlKeyword and turn each sibling into its corresponding QDomElement.
Definition: PvlToXmlTranslationManager.cpp:438
Isis::PvlKeyword::name
QString name() const
Returns the keyword name.
Definition: PvlKeyword.h:98
FileName.h
Isis::PvlToXmlTranslationManager::checkDependencies
bool checkDependencies(QDomElement element, PvlKeyword dependencies, bool isDebug) const
Isis::PvlObject::findGroup
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:129
Isis::PvlObject::group
PvlGroup & group(const int index)
Return the group at the specified index.
Definition: PvlObject.cpp:452
Isis::PvlTranslationTable::validKeywords
virtual std::vector< std::pair< QString, int > > validKeywords() const
Returns a vector of valid keyword names and their sizes.
Definition: PvlTranslationTable.cpp:179
Isis::PvlObject
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:61
Isis::PvlKeyword
A single keyword-value pair.
Definition: PvlKeyword.h:82
Isis::PvlToXmlTranslationManager::addAttributes
void addAttributes(PvlKeyword something, QDomElement &parent)
Take in the outputAttributes PvlKeyword and add each attribute to the appropriate element given as an...
Definition: PvlToXmlTranslationManager.cpp:471
Isis::PvlToXmlTranslationManager::Translate
virtual QString Translate(QString translationGroupName, int inputIndex=0)
Returns a translated value.
Definition: PvlToXmlTranslationManager.cpp:104
Isis::PvlToXmlTranslationManager::doTranslation
void doTranslation(PvlGroup transGroup, QDomElement &parent)
Translate the requested output name to output values using the input name and values or default value...
Definition: PvlToXmlTranslationManager.cpp:133
PvlGroup.h
Isis::PvlObject::groups
int groups() const
Returns the number of groups contained.
Definition: PvlObject.h:75
Isis::PvlTranslationTable::OutputName
QString OutputName(const QString translationGroupName)
Retrieves a string containing the value of the OutputName keyword for the translation group with the ...
Definition: PvlTranslationTable.cpp:511
Isis::PvlObject::hasGroup
bool hasGroup(const QString &name) const
Returns a boolean value based on whether the object has the specified group or not.
Definition: PvlObject.h:210
Isis::PvlToXmlTranslationManager::addElement
static void addElement(QDomElement &parent, QString name, QString value, QString units="")
Add a QDomElement to the given parent with the indicated value and units.
Definition: PvlToXmlTranslationManager.cpp:498
Isis::PvlToXmlTranslationManager::validKeywords
virtual std::vector< std::pair< QString, int > > validKeywords() const
Returns a vector of valid keyword names and their sizes.
Definition: PvlToXmlTranslationManager.cpp:79
PvlTokenizer.h
Isis::PvlContainer::hasKeyword
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
Definition: PvlContainer.cpp:159
Isis::PvlToXmlTranslationManager::~PvlToXmlTranslationManager
virtual ~PvlToXmlTranslationManager()
Destroys the TranslationManager object.
Definition: PvlToXmlTranslationManager.cpp:57
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
QStringList
Isis::PvlToXmlTranslationManager::createParentElements
QDomElement * createParentElements(const QString translationGroupName, QDomElement &xml)
Read the OutputPosition for the translation group name passed and create any parent elements specifie...
Definition: PvlToXmlTranslationManager.cpp:378
IString.h
Isis::PvlToXmlTranslationManager::setElementValue
static void setElementValue(QDomElement &element, QString value, QString units="")
Set the QDomElement's value, and units, if units != "".
Definition: PvlToXmlTranslationManager.cpp:516
Isis::PvlGroup
Contains multiple PvlContainers.
Definition: PvlGroup.h:41
Pvl.h
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::PvlToXmlTranslationManager::InputHasKeyword
virtual bool InputHasKeyword(const QString translationGroupName)
Indicates if the input keyword corresponding to the output name exists in the label.
Definition: PvlToXmlTranslationManager.cpp:304
Isis::PvlToXmlTranslationManager
Allows applications to translate simple text files.
Definition: PvlToXmlTranslationManager.h:51
Isis::PvlToXmlTranslationManager::SetLabel
void SetLabel(Pvl &inputLabel)
Internalizes a Pvl formatted label for translation.
Definition: PvlToXmlTranslationManager.cpp:66
Isis::PvlToXmlTranslationManager::resetElementValue
static void resetElementValue(QDomElement &element, QString value, QString units="")
Reset the QDomElement's value, and units, if units != "".
Definition: PvlToXmlTranslationManager.cpp:536
Isis::PvlTranslationTable::OutputPosition
PvlKeyword OutputPosition(const QString translationGroupName)
Retrieves the OutputPosition PvlKeyword for the translation group with the given name.
Definition: PvlTranslationTable.cpp:483
Isis::LabelTranslationManager
Allows applications to translate simple text files.
Definition: LabelTranslationManager.h:43
Isis::PvlObject::findObject
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
Definition: PvlObject.h:274
Isis::PvlToXmlTranslationManager::PvlToXmlTranslationManager
PvlToXmlTranslationManager(const QString &transFile)
Constructs and initializes a TranslationManager object from given the Pvl translation file.
Definition: PvlToXmlTranslationManager.cpp:36
Isis::PvlContainer::fileName
QString fileName() const
Returns the filename used to initialise the Pvl object.
Definition: PvlContainer.h:232
PvlToXmlTranslationManager.h
Isis::PvlContainer::name
QString name() const
Returns the container name.
Definition: PvlContainer.h:63
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::PvlTranslationTable::Translate
QString Translate(const QString translationGroupName, const QString inputKeyValue="") const
Translates a single output value from the given translation group name and input value.
Definition: PvlTranslationTable.cpp:216
Isis::PvlObject::hasObject
bool hasObject(const QString &name) const
Returns a boolean value based on whether the object exists in the current PvlObject or not.
Definition: PvlObject.h:323
Isis::PvlTranslationTable::InputKeywordName
virtual QString InputKeywordName(const QString translationGroupName) const
Returns the input keyword name from the translation table corresponding to the output name argument.
Definition: PvlTranslationTable.cpp:360
Isis::PvlToXmlTranslationManager::GetContainer
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 tra...
Definition: PvlToXmlTranslationManager.cpp:330
PvlContainer.h
Isis::PvlTranslationTable::InputGroup
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.
Definition: PvlTranslationTable.cpp:285
Isis::PvlTranslationTable::IsAuto
bool IsAuto(const QString translationGroupName)
Determines whether the given group should be automatically translated.
Definition: PvlTranslationTable.cpp:432
IException.h
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
std
Namespace for the standard library.
PvlKeyword.h
Isis::PvlKeyword::size
int size() const
Returns the number of values stored in this keyword.
Definition: PvlKeyword.h:125
LabelTranslationManager.h
PvlObject.h
Isis::PvlTranslationTable::IsOptional
bool IsOptional(const QString translationGroupName)
Determines whether the translation group is optional.
Definition: PvlTranslationTable.cpp:457
Isis::PvlKeyword::unit
QString unit(const int index=0) const
Returns the units of measurement of the element of the array of values for the object at the specifie...
Definition: PvlKeyword.cpp:357
Isis::PvlContainer::findKeyword
PvlKeyword & findKeyword(const QString &name)
Find a keyword with a specified name.
Definition: PvlContainer.cpp:62
Isis::PvlToXmlTranslationManager::Auto
void Auto(QDomDocument &outputLabel)
Automatically translate all the output names found in the translation table.
Definition: PvlToXmlTranslationManager.cpp:221
Isis::PvlContainer
Contains more than one keyword-value pair.
Definition: PvlContainer.h:49
Isis::PvlKeyword::stringEqual
static bool stringEqual(const QString &string1, const QString &string2)
Checks to see if two QStrings are equal.
Definition: PvlKeyword.cpp:535
Isis::PvlToXmlTranslationManager::InputKeyword
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 Inp...
Definition: PvlToXmlTranslationManager.cpp:254
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Message.h
Isis::PvlTranslationTable::TranslationTable
Pvl & TranslationTable()
Protected accessor for pvl translation table passed into class.
Definition: PvlTranslationTable.cpp:62