SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NamedColumnsParser.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // A parser to retrieve information from a table with known columns
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
11 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef NamedColumnsParser_h
22 #define NamedColumnsParser_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <map>
35 #include <string>
37 
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
59 public:
65 
66 
79  NamedColumnsParser(const std::string& def, const std::string& defDelim = ";",
80  const std::string& lineDelim = ";", bool chomp = false,
81  bool ignoreCase = true);
82 
83 
86 
87 
99  void reinit(const std::string& def, const std::string& defDelim = ";",
100  const std::string& lineDelim = ";", bool chomp = false,
101  bool ignoreCase = true);
102 
103 
112  void parseLine(const std::string& line);
113 
114 
129  std::string get(const std::string& name,
130  bool prune = false) const;
131 
132 
138  bool know(const std::string& name) const;
139 
140 
145  bool hasFullDefinition() const;
146 
147 
148 private:
161  void reinitMap(std::string def, const std::string& delim = ";",
162  bool chomp = false);
163 
164 
173  void checkPrune(std::string& str, bool prune) const;
174 
175 
176 private:
178  typedef std::map<std::string, size_t> PosMap;
179 
182 
184  std::string myLineDelimiter;
185 
188 
191 
192 };
193 
194 
195 #endif
196 
197 /****************************************************************************/
198