configfile.h
Go to the documentation of this file.
1 /*****************************************************************
2  *
3  * This file is part of the GMAPPING project
4  *
5  * GMAPPING Copyright (c) 2004 Giorgio Grisetti,
6  * Cyrill Stachniss, and Wolfram Burgard
7  *
8  * This software is licensed under the 3-Clause BSD License
9  * and is copyrighted by Giorgio Grisetti, Cyrill Stachniss,
10  * and Wolfram Burgard.
11  *
12  * Further information on this license can be found at:
13  * https://opensource.org/licenses/BSD-3-Clause
14  *
15  * GMAPPING is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied
17  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18  * PURPOSE.
19  *
20  *****************************************************************/
21 
22 
23 #ifndef CONFIGFILE_H
24 #define CONFIGFILE_H
25 
26 #include <iostream>
27 #include <string>
28 #include <map>
29 #include <gmapping/configfile/configfile_export.h>
30 
31 namespace GMapping{
32 
33 class CONFIGFILE_EXPORT AutoVal {
34 public:
35  AutoVal() {};
36  explicit AutoVal(const std::string&);
37  explicit AutoVal(double);
38  explicit AutoVal(int);
39  explicit AutoVal(unsigned int);
40  explicit AutoVal(bool);
41  explicit AutoVal(const char*);
42 
43  AutoVal(const AutoVal&);
44  AutoVal& operator=(const AutoVal&);
45 
46  AutoVal& operator=(double);
47  AutoVal& operator=(int);
48  AutoVal& operator=(unsigned int);
49  AutoVal& operator=(bool);
50  AutoVal& operator=(const std::string&);
51 
52 public:
53  operator std::string() const;
54  operator double() const;
55  operator int() const;
56  operator unsigned int() const;
57  operator bool() const;
58 
59 protected:
60  std::string toLower(const std::string& source) const;
61 
62 private:
63  std::string m_value;
64 };
65 
66 class CONFIGFILE_EXPORT ConfigFile {
67  std::map<std::string,AutoVal> m_content;
68 
69 public:
70  ConfigFile();
71  ConfigFile(const std::string& configFile);
72  ConfigFile(const char* configFile);
73 
74  bool read(const std::string& configFile);
75  bool read(const char* configFile);
76 
77 
78  const AutoVal& value(const std::string& section,
79  const std::string& entry) const;
80 
81  const AutoVal& value(const std::string& section,
82  const std::string& entry,
83  double def);
84 
85  const AutoVal& value(const std::string& section,
86  const std::string& entry,
87  const char* def);
88 
89  const AutoVal& value(const std::string& section,
90  const std::string& entry,
91  bool def);
92 
93  const AutoVal& value(const std::string& section,
94  const std::string& entry,
95  int def);
96 
97  const AutoVal& value(const std::string& section,
98  const std::string& entry,
99  unsigned int def);
100 
101  const AutoVal& value(const std::string& section,
102  const std::string& entry,
103  const std::string& def);
104 
105  void dumpValues(std::ostream& out);
106 
107 
108  protected:
109  std::string trim(const std::string& source, char const* delims = " \t\r\n") const;
110  std::string truncate(const std::string& source, const char* atChar) const;
111  std::string toLower(const std::string& source) const;
112  void insertValue(const std::string& section, const std::string& entry, const std::string& thevalue );
113 };
114 
115 };
116 
117 #endif
std::map< std::string, AutoVal > m_content
Definition: configfile.h:67
std::string m_value
Definition: configfile.h:63
rl read(is)


openslam_gmapping
Author(s): Cyrill Stachniss, Udo Frese, Giorgio Grisetti, Wolfram Burgard
autogenerated on Mon Feb 28 2022 22:59:20