NamedColumnsParser.h
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef NamedColumnsParser_h
00020 #define NamedColumnsParser_h
00021
00022
00023
00024
00025
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031
00032 #include <map>
00033 #include <string>
00034 #include <utils/common/StringTokenizer.h>
00035
00036
00037
00038
00039
00056 class NamedColumnsParser {
00057 public:
00062 NamedColumnsParser() throw();
00063
00064
00077 NamedColumnsParser(const std::string &def, const std::string &defDelim=";",
00078 const std::string &lineDelim=";", bool chomp=false,
00079 bool ignoreCase=true) throw();
00080
00081
00083 ~NamedColumnsParser() throw();
00084
00085
00097 void reinit(const std::string &def, const std::string &defDelim=";",
00098 const std::string &lineDelim=";", bool chomp=false,
00099 bool ignoreCase=true) throw();
00100
00101
00110 void parseLine(const std::string &line) throw();
00111
00112
00127 std::string get(const std::string &name,
00128 bool prune=false) const throw(UnknownElement, OutOfBoundsException);
00129
00130
00136 bool know(const std::string &name) const throw();
00137
00138
00139 private:
00152 void reinitMap(std::string def, const std::string &delim=";",
00153 bool chomp=false) throw();
00154
00155
00164 void checkPrune(std::string &str, bool prune) const throw();
00165
00166
00167 private:
00169 typedef std::map<std::string, size_t> PosMap;
00170
00172 PosMap myDefinitionsMap;
00173
00175 std::string myLineDelimiter;
00176
00178 StringTokenizer myLineParser;
00179
00181 bool myAmCaseInsensitive;
00182
00183 };
00184
00185
00186 #endif
00187
00188
00189