Isis Developer Reference
PvlFormat.h
Go to the documentation of this file.
1#ifndef PvlFormat_h
2#define PvlFormat_h
8/* SPDX-License-Identifier: CC0-1.0 */
9#include <map>
10#include <string>
11
12#include "Pvl.h"
13
14#include "PvlKeyword.h"
15
16namespace Isis {
17
29
38 inline KeywordType toKeywordType(const QString type) {
39
40 QString t(type);
41 t = t.remove(QRegExp("[\\w_-\"'")).toUpper();
42
43 if(t == "STRING") return StringKeyword;
44 else if(t == "BOOL") return BoolKeyword;
45 else if(t == "INTEGER") return IntegerKeyword;
46 else if(t == "REAL") return RealKeyword;
47 else if(t == "OCTAL") return OctalKeyword;
48 else if(t == "HEX") return HexKeyword;
49 else if(t == "BINARY") return BinaryKeyword;
50 else if(t == "ENUM") return EnumKeyword;
51 return NoTypeKeyword;
52 }
53
108 class PvlFormat {
109
110 public:
111
112 PvlFormat();
113 PvlFormat(const QString &file);
114 PvlFormat(Pvl &keymap);
115 virtual ~PvlFormat() {};
116
117 void add(const QString &file);
118 void add(Pvl &keymap);
119
127 void setCharLimit(const unsigned int limit) {
128 m_charLimit = limit;
129 };
130
138 unsigned int charLimit() const {
139 return m_charLimit;
140 };
141
142 virtual QString formatValue(const PvlKeyword &keyword,
143 int valueIndex = 0);
144 virtual QString formatName(const PvlKeyword &keyword);
145 virtual QString formatEnd(const QString name,
146 const PvlKeyword &keyword);
147 virtual QString formatEOL() {
148 return "\n";
149 }
150
151 virtual KeywordType type(const PvlKeyword &keyword);
152 virtual int accuracy(const PvlKeyword &keyword);
153
154 protected:
155
156 virtual QString addQuotes(const QString value);
157 bool isSingleUnit(const PvlKeyword &keyword);
158
161
163 unsigned int m_charLimit;
164
165 private:
166 void init();
167 };
168};
169
170#endif
171
Formats a Pvl name value pair to Isis standards.
Definition PvlFormat.h:108
QString m_keywordMapFile
Definition PvlFormat.h:159
virtual QString formatName(const PvlKeyword &keyword)
Definition PvlFormat.cpp:204
virtual int accuracy(const PvlKeyword &keyword)
Definition PvlFormat.cpp:129
unsigned int m_charLimit
Maximum number of characters on a single line of a keyword value.
Definition PvlFormat.h:163
virtual ~PvlFormat()
Definition PvlFormat.h:115
Pvl m_keywordMap
Definition PvlFormat.h:160
PvlFormat()
Definition PvlFormat.cpp:23
virtual QString addQuotes(const QString value)
Definition PvlFormat.cpp:227
void setCharLimit(const unsigned int limit)
Sets the maximum number of characters in a keyword value that can be printed to a line before it wrap...
Definition PvlFormat.h:127
virtual QString formatValue(const PvlKeyword &keyword, int valueIndex=0)
Definition PvlFormat.cpp:147
void add(const QString &file)
Definition PvlFormat.cpp:68
unsigned int charLimit() const
Retrieves the maximum number of characters in a keyword value that can be printed to a line before it...
Definition PvlFormat.h:138
virtual QString formatEnd(const QString name, const PvlKeyword &keyword)
Definition PvlFormat.cpp:215
virtual QString formatEOL()
Definition PvlFormat.h:147
bool isSingleUnit(const PvlKeyword &keyword)
Returns true if the units are the same for all value in the keyword otherwise it returns false.
Definition PvlFormat.cpp:307
virtual KeywordType type(const PvlKeyword &keyword)
Definition PvlFormat.cpp:111
Container for cube-like labels.
Definition Pvl.h:119
A single keyword-value pair.
Definition PvlKeyword.h:87
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
KeywordType
The different types of keywords that can be formatted.
Definition PvlFormat.h:19
@ BinaryKeyword
Definition PvlFormat.h:26
@ OctalKeyword
Definition PvlFormat.h:24
@ IntegerKeyword
Definition PvlFormat.h:22
@ BoolKeyword
Definition PvlFormat.h:21
@ RealKeyword
Definition PvlFormat.h:23
@ EnumKeyword
Definition PvlFormat.h:27
@ NoTypeKeyword
Definition PvlFormat.h:19
@ HexKeyword
Definition PvlFormat.h:25
@ StringKeyword
Definition PvlFormat.h:20
KeywordType toKeywordType(const QString type)
Convert a string representing a type of keyword to the corresponding enumeration.
Definition PvlFormat.h:38