Isis 3 Programmer Reference
PvlFormat.h
Go to the documentation of this file.
1 #ifndef PvlFormat_h
2 #define PvlFormat_h
3 
25 #include <map>
26 #include <string>
27 
28 #include "Pvl.h"
29 
30 #include "PvlKeyword.h"
31 
32 namespace Isis {
33 
35  enum KeywordType { NoTypeKeyword,
36  StringKeyword,
37  BoolKeyword,
38  IntegerKeyword,
39  RealKeyword,
40  OctalKeyword,
41  HexKeyword,
42  BinaryKeyword,
43  EnumKeyword
44  };
45 
54  inline KeywordType toKeywordType(const QString type) {
55 
56  QString t(type);
57  t = t.remove(QRegExp("[\\w_-\"'")).toUpper();
58 
59  if(t == "STRING") return StringKeyword;
60  else if(t == "BOOL") return BoolKeyword;
61  else if(t == "INTEGER") return IntegerKeyword;
62  else if(t == "REAL") return RealKeyword;
63  else if(t == "OCTAL") return OctalKeyword;
64  else if(t == "HEX") return HexKeyword;
65  else if(t == "BINARY") return BinaryKeyword;
66  else if(t == "ENUM") return EnumKeyword;
67  return NoTypeKeyword;
68  }
69 
124  class PvlFormat {
125 
126  public:
127 
128  PvlFormat();
129  PvlFormat(const QString &file);
130  PvlFormat(Pvl &keymap);
131  virtual ~PvlFormat() {};
132 
133  void add(const QString &file);
134  void add(Pvl &keymap);
135 
143  void setCharLimit(const unsigned int limit) {
144  m_charLimit = limit;
145  };
146 
154  unsigned int charLimit() const {
155  return m_charLimit;
156  };
157 
158  virtual QString formatValue(const PvlKeyword &keyword,
159  int valueIndex = 0);
160  virtual QString formatName(const PvlKeyword &keyword);
161  virtual QString formatEnd(const QString name,
162  const PvlKeyword &keyword);
163  virtual QString formatEOL() {
164  return "\n";
165  }
166 
167  virtual KeywordType type(const PvlKeyword &keyword);
168  virtual int accuracy(const PvlKeyword &keyword);
169 
170  protected:
171 
172  virtual QString addQuotes(const QString value);
173  bool isSingleUnit(const PvlKeyword &keyword);
174 
175  QString m_keywordMapFile;
176  Pvl m_keywordMap;
177 
179  unsigned int m_charLimit;
180 
181  private:
182  void init();
183  };
184 };
185 
186 #endif
187 
Formats a Pvl name value pair to Isis standards.
Definition: PvlFormat.h:124
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:143
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:154
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:323
KeywordType toKeywordType(const QString type)
Convert a string representing a type of keyword to the corresponding enumeration. ...
Definition: PvlFormat.h:54
A single keyword-value pair.
Definition: PvlKeyword.h:98
Container for cube-like labels.
Definition: Pvl.h:135
KeywordType
The different types of keywords that can be formatted.
Definition: PvlFormat.h:35
unsigned int m_charLimit
Maximum number of characters on a single line of a keyword value.
Definition: PvlFormat.h:179
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
void init()
Clears all PvlFormat data.
Definition: PvlFormat.cpp:72