Isis 3 Programmer Reference
PvlToken.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include "PvlToken.h"
8 #include "IException.h"
9 #include "IString.h"
10 #include "Message.h"
11 
12 using namespace std;
13 namespace Isis {
19  PvlToken::PvlToken(const QString &k) {
20  setKey(k);
21  valueClear();
22  }
23 
25  PvlToken::PvlToken() {
26  valueClear();
27  }
28 
30  PvlToken::~PvlToken() {
31  m_key.clear();
32  valueClear();
33  }
34 
40  void PvlToken::setKey(const QString &k) {
41  m_key = k;
42  };
43 
49  QString PvlToken::key() const {
50  return m_key;
51  };
52 
58  QString PvlToken::keyUpper() const {
59  return m_key.toUpper();
60  }
61 
63  void PvlToken::valueClear() {
64  m_value.clear();
65  }
66 
72  int PvlToken::valueSize() const {
73  return m_value.size();
74  }
75 
82  void PvlToken::addValue(const QString &v) {
83  m_value.push_back(v);
84  }
85 
95  QString PvlToken::value(const int index) const {
96  if((index < 0) || (index >= (int) m_value.size())) {
97  QString message = Isis::Message::ArraySubscriptNotInRange(index);
98  throw IException(IException::Programmer, message, _FILEINFO_);
99  }
100  return m_value[index];
101  }
102 
112  QString PvlToken::valueUpper(int index) const {
113  if((index < 0) || (index >= (int) m_value.size())) {
114  QString message = Isis::Message::ArraySubscriptNotInRange(index);
115  throw IException(IException::Programmer, message, _FILEINFO_);
116  }
117 
118  return m_value[index].toUpper();
119  }
120 } // end namespace isis
Isis::IException
Isis exception class.
Definition: IException.h:91
std
Namespace for the standard library.
Isis::Message::ArraySubscriptNotInRange
QString ArraySubscriptNotInRange(int index)
This error should be used when an Isis object or application is checking array bounds and the legal r...
Definition: ArraySubscriptNotInRange.cpp:31
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16