NamedColumnsParser.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // A parser to retrieve information from a table with known columns
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 #ifndef NamedColumnsParser_h
00020 #define NamedColumnsParser_h
00021 
00022 
00023 // ===========================================================================
00024 // included modules
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 // class definitions
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 

Generated on Wed May 5 00:06:32 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6