Commit f79117d2 authored by Makayla Shepherd's avatar Makayla Shepherd
Browse files

Renamed XmlTranslationManager to XmlToPvlTranslationManager. Fixes #4889.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@7722 41f8697f-d340-4b68-9986-7bafba869bb8
parent ffb9804d
Loading
Loading
Loading
Loading
+19 −19
Original line number Diff line number Diff line
@@ -35,13 +35,13 @@
#include "PvlGroup.h"
#include "PvlKeyword.h"
#include "PvlObject.h"
#include "XmlTranslationManager.h"
#include "XmlToPvlTranslationManager.h"

using namespace std;
namespace Isis {

  /**
   * Constructs and initializes an XmlTranslationManager object from the given
   * Constructs and initializes an XmlToPvlTranslationManager object from the given
   * 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(FileName inputLabel) or Auto(FileName inputLabel, Pvl 
@@ -50,13 +50,13 @@ namespace Isis {
   * @param transFile The translation file to be used to tranlate keywords in
   *                  the input label.
   */
  XmlTranslationManager::XmlTranslationManager(const QString &transFile) 
  XmlToPvlTranslationManager::XmlToPvlTranslationManager(const QString &transFile) 
      : LabelTranslationManager() {
    AddTable(transFile);
  }

  /**
   * Constructs and initializes an XmlTranslationManager object from the given 
   * Constructs and initializes an XmlToPvlTranslationManager 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(FileName 
   * inputLabel) or Auto(FileName inputLabel, Pvl outputLabel). 
@@ -65,14 +65,14 @@ namespace Isis {
   * @param transStrm A stream containing the tranlation table to be used to
   *                  tranlate keywords in the input label.
   */
  XmlTranslationManager::XmlTranslationManager(std::istream &transStrm)
  XmlToPvlTranslationManager::XmlToPvlTranslationManager(std::istream &transStrm)
      : LabelTranslationManager() {
    AddTable(transStrm);
  }


  /**
   * Constructs and initializes an XmlTranslationManager object from the given
   * Constructs and initializes an XmlToPvlTranslationManager object from the given
   * Pvl translation file and input label.
   *
   * @param inputLabel The Xml holding the input label.
@@ -80,7 +80,7 @@ namespace Isis {
   * @param transFile The translation file to be used to tranlate keywords in
   *                  the input label.
   */
  XmlTranslationManager::XmlTranslationManager(FileName &inputLabel,
  XmlToPvlTranslationManager::XmlToPvlTranslationManager(FileName &inputLabel,
                                               const QString &transFile)
      : LabelTranslationManager() {
    AddTable(transFile);
@@ -89,7 +89,7 @@ namespace Isis {


  /**
   * Constructs and initializes an XmlTranslationManager object from the given
   * Constructs and initializes an XmlToPvlTranslationManager object from the given
   * input stream and input label.
   *
   * @param inputLabel The Xml holding the input label.
@@ -97,7 +97,7 @@ namespace Isis {
   * @param transStrm A stream containing the tranlation table to be used to
   *                  tranlate keywords in the input label.
   */
  XmlTranslationManager::XmlTranslationManager(FileName &inputLabel, 
  XmlToPvlTranslationManager::XmlToPvlTranslationManager(FileName &inputLabel, 
                                               std::istream &transStrm)
      : LabelTranslationManager() {
    AddTable(transStrm);
@@ -106,9 +106,9 @@ namespace Isis {


  /**
   * Destroys the XmlTranslationManager object.
   * Destroys the XmlToPvlTranslationManager object.
   */
  XmlTranslationManager::~XmlTranslationManager() {
  XmlToPvlTranslationManager::~XmlToPvlTranslationManager() {
  }


@@ -117,7 +117,7 @@ namespace Isis {
   * 
   * @param inputLabel The input label file
   */
  void XmlTranslationManager::SetLabel(FileName &inputLabel) {
  void XmlToPvlTranslationManager::SetLabel(FileName &inputLabel) {
    parseFile(inputLabel);
  }

@@ -128,7 +128,7 @@ namespace Isis {
   * 
   * @return @b vector<pair<QString,int>> A vector of valid keyword names and their sizes.
   */
  vector< pair<QString, int> > XmlTranslationManager::validKeywords() const {
  vector< pair<QString, int> > XmlToPvlTranslationManager::validKeywords() const {

    vector< pair<QString, int> > validKeywords = PvlTranslationTable::validKeywords();
    validKeywords.push_back(pair<QString, int>("InputKeyAttribute",      -1));
@@ -167,7 +167,7 @@ namespace Isis {
   * @throws IException::Unknown "Could not find an input value or default value."
   * @throws IException::Unknown "Input element does not have the named attribute."
   */
  QString XmlTranslationManager::Translate(QString outputName, int index) {
  QString XmlToPvlTranslationManager::Translate(QString outputName, int index) {
    try {
    if (index != 0) {
      QString msg = "Cannot translate value at index [" + toString(index) +
@@ -354,7 +354,7 @@ namespace Isis {
   * 
   * @throws IException::Unknown "Parsing error, dependency type is not [att] or [tag]."
   */
  bool XmlTranslationManager::checkDependencies(QDomElement element,
  bool XmlToPvlTranslationManager::checkDependencies(QDomElement element,
                                                PvlKeyword dependencies,
                                                bool isDebug) const{

@@ -440,9 +440,9 @@ namespace Isis {
   * @throws IException::Unknown "Name-value specification does not have two
   *                              components separated by [:]."
   * 
   * @see XmlTranslationManager::checkDependencies
   * @see XmlToPvlTranslationManager::checkDependencies
   */
  QStringList XmlTranslationManager::parseDependency(QString specification) const {
  QStringList XmlToPvlTranslationManager::parseDependency(QString specification) const {

    QStringList parsedSpecification;

@@ -486,7 +486,7 @@ namespace Isis {
   * @param inputLabel The input label file to be translated.
   * @param outputLabel The output translated Pvl.
   */
  void XmlTranslationManager::Auto(FileName &inputLabel, Pvl &outputLabel) {
  void XmlToPvlTranslationManager::Auto(FileName &inputLabel, Pvl &outputLabel) {
    parseFile(inputLabel);
    Auto(outputLabel);
  }
@@ -500,7 +500,7 @@ namespace Isis {
   * @throws IException::Unknown "Could not open label file."
   * @throws IException::Unknown "XML read/parse error in file."
   */
  void XmlTranslationManager::parseFile(const FileName &xmlFileName) {
  void XmlToPvlTranslationManager::parseFile(const FileName &xmlFileName) {
     QFile xmlFile(xmlFileName.expanded());
     if ( !xmlFile.open(QIODevice::ReadOnly) ) {
       QString msg = "Could not open label file [" + xmlFileName.expanded() +
+10 −8
Original line number Diff line number Diff line
#ifndef XmlTranslationManager_h
#define XmlTranslationManager_h
#ifndef XmlToPvlTranslationManager_h
#define XmlToPvlTranslationManager_h
/**
 * @file
 * $Revision: 1.6 $
@@ -122,20 +122,22 @@ namespace Isis {
   *                          identifying input elements. Fixes #4584.
   *  @history 2017-01-18 Jesse Mapel - Updated documentation and error messages. Fixes #4584.
   *  @history 2017-01-25 Jesse Mapel - Created unit test. Fixes #4584.
   *  @history 2017-05-30 Makayla Shepherd - Renamed from XmlTranslationManager to 
   *                          XmlToPvlTranslationManager. Fixes #4889.
   */
  class XmlTranslationManager : public LabelTranslationManager {
  class XmlToPvlTranslationManager : public LabelTranslationManager {
    public:
      XmlTranslationManager(const QString &transFile);
      XmlToPvlTranslationManager(const QString &transFile);

      XmlTranslationManager(std::istream &transStrm);
      XmlToPvlTranslationManager(std::istream &transStrm);

      XmlTranslationManager(FileName &inputLabel,
      XmlToPvlTranslationManager(FileName &inputLabel,
                            const QString &transFile);

      XmlTranslationManager(FileName &inputLabel,
      XmlToPvlTranslationManager(FileName &inputLabel,
                            std::istream &transStrm);

      virtual ~XmlTranslationManager();
      virtual ~XmlToPvlTranslationManager();

      // Attempt to translate the requested output name to output value
      // using the input name and value/default value
+6 −6
Original line number Diff line number Diff line
#include <sstream>
#include "XmlTranslationManager.h"
#include "XmlToPvlTranslationManager.h"
#include "FileName.h"
#include "Preference.h"
#include "IException.h"
@@ -219,7 +219,7 @@ int main(void) {

    cout << "Testing string stream translation specification" << endl << endl;

    XmlTranslationManager transMgr(fLabel, trnsStrm);
    XmlToPvlTranslationManager transMgr(fLabel, trnsStrm);

    cout << "Testing Translate method" << endl << endl;
    cout << "Translation of InstrumentIfovWithUnits: " <<
@@ -231,7 +231,7 @@ int main(void) {
    cout << endl << outputLabel << endl << endl;

    cout << "Testing error throws" << endl << endl;
    XmlTranslationManager badTransMgr(fLabel, badTrnsStrm);
    XmlToPvlTranslationManager badTransMgr(fLabel, badTrnsStrm);

    try {
      transMgr.Translate("InstrumentIfovWithUnits", 2);
@@ -306,7 +306,7 @@ int main(void) {
    }

    try {
      XmlTranslationManager invalidTransMgr(fLabel, invalidTrnsStrm);
      XmlToPvlTranslationManager invalidTransMgr(fLabel, invalidTrnsStrm);
    }
    catch(IException &e) {
      e.print();
@@ -325,7 +325,7 @@ int main(void) {
      simpleTrans << "  OutputName = Version" << endl;
      simpleTrans << "  Translation = (*,*)" << endl;
      simpleTrans << "EndGroup" << endl;
      XmlTranslationManager nonExistantFileManager(nonExistantFile, simpleTrans);
      XmlToPvlTranslationManager nonExistantFileManager(nonExistantFile, simpleTrans);
    }
    catch(IException &e) {
      e.print();
@@ -344,7 +344,7 @@ int main(void) {
      simpleTrans << "  OutputName = Version" << endl;
      simpleTrans << "  Translation = (*,*)" << endl;
      simpleTrans << "EndGroup" << endl;
      XmlTranslationManager pvlTransFileManager(pvlFile, simpleTrans);
      XmlToPvlTranslationManager pvlTransFileManager(pvlFile, simpleTrans);
    }
    catch(IException &e) {
      e.print();
Loading