USGS

Isis 3.0 Developer's Reference (API)

Home

PvlFormat.h

Go to the documentation of this file.
00001 #ifndef PvlFormat_h
00002 #define PvlFormat_h
00003 
00025 #include <map>
00026 #include <string>
00027 
00028 #include "Pvl.h"
00029 
00030 #include "PvlKeyword.h"
00031 
00032 namespace Isis {
00033 
00035   enum KeywordType { NoTypeKeyword,
00036                      StringKeyword,
00037                      BoolKeyword,
00038                      IntegerKeyword,
00039                      RealKeyword,
00040                      OctalKeyword,
00041                      HexKeyword,
00042                      BinaryKeyword,
00043                      EnumKeyword
00044                    };
00045 
00054   inline KeywordType ToKeywordType(const QString type) {
00055 
00056     QString t(type);
00057     t = t.remove(QRegExp("[\\w_-\"'")).toUpper();
00058 
00059     if(t == "STRING") return StringKeyword;
00060     else if(t == "BOOL") return BoolKeyword;
00061     else if(t == "INTEGER") return IntegerKeyword;
00062     else if(t == "REAL") return RealKeyword;
00063     else if(t == "OCTAL") return OctalKeyword;
00064     else if(t == "HEX") return HexKeyword;
00065     else if(t == "BINARY") return BinaryKeyword;
00066     else if(t == "ENUM") return EnumKeyword;
00067     return NoTypeKeyword;
00068   }
00069 
00119   class PvlFormat {
00120 
00121     public:
00122 
00123       PvlFormat();
00124       PvlFormat(const QString &file);
00125       PvlFormat(Pvl &keymap);
00126       virtual ~PvlFormat() {};
00127 
00128       void Add(const QString &file);
00129       void Add(Pvl &keymap);
00130 
00138       void SetCharLimit(const unsigned int limit) {
00139         p_charLimit = limit;
00140       };
00141 
00149       unsigned int CharLimit() const {
00150         return p_charLimit;
00151       };
00152 
00153       virtual QString FormatValue(const PvlKeyword &keyword,
00154                                       int valueIndex = 0);
00155       virtual QString FormatName(const PvlKeyword &keyword);
00156       virtual QString FormatEnd(const QString name,
00157                                     const PvlKeyword &keyword);
00158       virtual QString FormatEOL() {
00159         return "\n";
00160       }
00161 
00162       virtual KeywordType Type(const PvlKeyword &keyword);
00163       virtual int Accuracy(const PvlKeyword &keyword);
00164 
00165     protected:
00166 
00167       virtual QString AddQuotes(const QString value);
00168       bool IsSingleUnit(const PvlKeyword &keyword);
00169 
00170       QString p_keywordMapFile;
00171       Pvl p_keywordMap;
00172 
00174       unsigned int p_charLimit;
00175 
00176     private:
00177       void Init();
00178   };
00179 };
00180 
00181 #endif
00182