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
12using namespace std;
13namespace Isis {
19 PvlToken::PvlToken(const QString &k) {
20 setKey(k);
21 valueClear();
22 }
23
28
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
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 exception class.
Definition IException.h:91
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition IException.h:146
QString keyUpper() const
Returns the token keyword in all uppercase characters.
Definition PvlToken.cpp:58
~PvlToken()
Destroys the Token object.
Definition PvlToken.cpp:30
int valueSize() const
Returns the number of elements in the value-vector.
Definition PvlToken.cpp:72
QString valueUpper(const int index=0) const
Returns one element of the value-vector in uppercase.
Definition PvlToken.cpp:112
QString m_key
Storage for the keyword name.
Definition PvlToken.h:40
std::vector< QString > m_value
Vector storage for a list of values.
Definition PvlToken.h:41
void valueClear()
Removes all elements from the value-vector.
Definition PvlToken.cpp:63
QString key() const
Returns the token keyword.
Definition PvlToken.cpp:49
QString value(const int index=0) const
Returns one element of the value-vector.
Definition PvlToken.cpp:95
PvlToken()
Constructs a Token with NULL for both the keyword and value list.
Definition PvlToken.cpp:25
void addValue(const QString &v)
Adds a value to the value-vector.
Definition PvlToken.cpp:82
void setKey(const QString &k)
Set the token keyword.
Definition PvlToken.cpp:40
QString ArraySubscriptNotInRange(int index)
This error should be used when an Isis object or application is checking array bounds and the legal r...
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
Namespace for the standard library.