Isis Developer Reference
PvlFormat.h
Go to the documentation of this file.
1 #ifndef PvlFormat_h
2 #define PvlFormat_h
3 
8 /* SPDX-License-Identifier: CC0-1.0 */
9 #include <map>
10 #include <string>
11 
12 #include "Pvl.h"
13 
14 #include "PvlKeyword.h"
15 
16 namespace Isis {
17 
28  };
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 
Isis::EnumKeyword
@ EnumKeyword
Definition: PvlFormat.h:27
Isis::PvlFormat::m_keywordMap
Pvl m_keywordMap
Definition: PvlFormat.h:160
Isis::PvlKeyword::name
QString name() const
Returns the keyword name.
Definition: PvlKeyword.h:98
FileName.h
Isis::PvlFormat::~PvlFormat
virtual ~PvlFormat()
Definition: PvlFormat.h:115
Isis::StringKeyword
@ StringKeyword
Definition: PvlFormat.h:20
Isis::PvlKeyword
A single keyword-value pair.
Definition: PvlKeyword.h:82
Isis::PvlFormat::PvlFormat
PvlFormat()
Definition: PvlFormat.cpp:23
Isis::PvlFormat
Formats a Pvl name value pair to Isis standards.
Definition: PvlFormat.h:108
Isis::PvlFormat::formatEnd
virtual QString formatEnd(const QString name, const PvlKeyword &keyword)
Definition: PvlFormat.cpp:215
Isis::PvlFormat::m_charLimit
unsigned int m_charLimit
Maximum number of characters on a single line of a keyword value.
Definition: PvlFormat.h:163
Isis::PvlKeyword::addValue
void addValue(QString value, QString unit="")
Adds a value with units.
Definition: PvlKeyword.cpp:252
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::KeywordType
KeywordType
The different types of keywords that can be formatted.
Definition: PvlFormat.h:19
Isis::PvlFormat::add
void add(const QString &file)
Definition: PvlFormat.cpp:68
PvlFormat.h
Isis::BoolKeyword
@ BoolKeyword
Definition: PvlFormat.h:21
IString.h
Isis::PvlFormat::m_keywordMapFile
QString m_keywordMapFile
Definition: PvlFormat.h:159
Pvl.h
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::BinaryKeyword
@ BinaryKeyword
Definition: PvlFormat.h:26
Isis::toInt
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition: IString.cpp:93
Isis::PvlFormat::addQuotes
virtual QString addQuotes(const QString value)
Definition: PvlFormat.cpp:227
TextFile.h
Isis::toKeywordType
KeywordType toKeywordType(const QString type)
Convert a string representing a type of keyword to the corresponding enumeration.
Definition: PvlFormat.h:38
Isis::PvlFormat::accuracy
virtual int accuracy(const PvlKeyword &keyword)
Definition: PvlFormat.cpp:129
Isis::PvlFormat::type
virtual KeywordType type(const PvlKeyword &keyword)
Definition: PvlFormat.cpp:111
Isis::HexKeyword
@ HexKeyword
Definition: PvlFormat.h:25
Isis::OctalKeyword
@ OctalKeyword
Definition: PvlFormat.h:24
Isis::PvlFormat::formatEOL
virtual QString formatEOL()
Definition: PvlFormat.h:147
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::PvlFormat::setCharLimit
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
IException.h
std
Namespace for the standard library.
Isis::PvlFormat::formatName
virtual QString formatName(const PvlKeyword &keyword)
Definition: PvlFormat.cpp:204
Isis::RealKeyword
@ RealKeyword
Definition: PvlFormat.h:23
PvlKeyword.h
Isis::PvlKeyword::size
int size() const
Returns the number of values stored in this keyword.
Definition: PvlKeyword.h:125
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::PvlFormat::isSingleUnit
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
Isis::PvlContainer::keywords
int keywords() const
Returns the number of keywords contained in the PvlContainer.
Definition: PvlContainer.h:86
Isis::PvlFormat::formatValue
virtual QString formatValue(const PvlKeyword &keyword, int valueIndex=0)
Definition: PvlFormat.cpp:147
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::NoTypeKeyword
@ NoTypeKeyword
Definition: PvlFormat.h:19
Isis::PvlFormat::charLimit
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
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::IntegerKeyword
@ IntegerKeyword
Definition: PvlFormat.h:22
Message.h