Isis 3 Developer 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 
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 
177 
179  unsigned int m_charLimit;
180 
181  private:
182  void init();
183  };
184 };
185 
186 #endif
187 
Definition: PvlFormat.h:43
Definition: PvlFormat.h:40
Definition: PvlFormat.h:37
virtual QString formatEnd(const QString name, const PvlKeyword &keyword)
Definition: PvlFormat.cpp:231
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
Definition: PvlFormat.h:41
virtual QString formatValue(const PvlKeyword &keyword, int valueIndex=0)
Definition: PvlFormat.cpp:163
Definition: PvlFormat.h:38
Definition: PvlFormat.h:36
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
virtual int accuracy(const PvlKeyword &keyword)
Definition: PvlFormat.cpp:145
PvlFormat()
Definition: PvlFormat.cpp:39
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
Definition: PvlFormat.h:42
KeywordType toKeywordType(const QString type)
Convert a string representing a type of keyword to the corresponding enumeration. ...
Definition: PvlFormat.h:54
QString m_keywordMapFile
Definition: PvlFormat.h:175
virtual QString formatName(const PvlKeyword &keyword)
Definition: PvlFormat.cpp:220
A single keyword-value pair.
Definition: PvlKeyword.h:98
Definition: PvlFormat.h:35
virtual QString formatEOL()
Definition: PvlFormat.h:163
virtual QString addQuotes(const QString value)
Definition: PvlFormat.cpp:243
Container for cube-like labels.
Definition: Pvl.h:135
KeywordType
The different types of keywords that can be formatted.
Definition: PvlFormat.h:35
virtual KeywordType type(const PvlKeyword &keyword)
Definition: PvlFormat.cpp:127
Pvl m_keywordMap
Definition: PvlFormat.h:176
unsigned int m_charLimit
Maximum number of characters on a single line of a keyword value.
Definition: PvlFormat.h:179
Definition: PvlFormat.h:39
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
void add(const QString &file)
Definition: PvlFormat.cpp:84
virtual ~PvlFormat()
Definition: PvlFormat.h:131