Main MRPT website > C++ reference for MRPT 1.5.6
config-files.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 /** \page config_file_format Configuration file format in MRPT
11  *
12 
13 # Description
14 
15 Plain text configuration files in MRPT follows a custom version of the [INI file](https://en.wikipedia.org/wiki/INI_file)
16 standard format, comprising "sections", "properties" (or "keys") with associated "values" and, optionally, comments.
17 
18 The following C++ classes are provided to read and write such files:
19 - mrpt::utils::CConfigFile: Access to physical files.
20 - mrpt::utils::CConfigFileMemory: Wrapper around a configuration file "in memory", without an associated physical file.
21 
22 See also:
23 - mrpt::utils::CConfigFileBase: The base, virtual class underlying the two classes above. Users normally
24  inkove the API exposed in this base class.
25 - mrpt::utils::CConfigFilePrefixer: A proxy class to manipulate an object of the two classes above such
26  that all accesses to sections and/or properties are *mapped* to modified versions of their names.
27 
28 
29 # Format specifications
30 
31 - There exists only one level of hierarchy, i.e. only "toplevel" sections exist, there is no support for nested sections.
32  A possible workaround to this limitation is using mrpt::utils::CConfigFilePrefixer.
33 - Sections are formatted like: `[section_name]`
34 - Key/values pair follow the format: `key = value`. Whitespaces are ignored before and after the `=` sign, up to the
35 first non-blank character of the value.
36 - API methods exist to read and write different elementary data types (`int`,`double`,`std::string`) and also
37  vectors, matrices and even `enum`s.
38 - Comments can be included in different formats:
39  - Lines starting with `;`. Example: `; Comment line`
40  - Lines starting with `#`. Example: `# Comment line`
41  - After a value, with `//`. Example: `key = value // Explanation of this value`
42  - An exception to the rule above is hard-coded to allow URLs, e.g. `key = http://www.google.com` is not considered to contain a comment.
43 - Preprocessor:
44  - Just like in C/C++, lines can be ended in a backslash (`\`) to mean "line continuation". [New in MRPT 1.5.0]
45  - C preprocessor-like `#define`s are available as `@define VARNAME VALUE`, then using variables as `${VARNAME}` or math expressions as `$eval{...}`. See the example below: [New in MRPT 1.5.0].
46  \code
47  @define MAXSPEED 10
48  @define MAXDIST $eval{exp(2*MAXSPEED)}
49  [test]
50  var1=${MAXSPEED}
51  var2=$eval{1+2*MAXSPEED}
52  \endcode
53 
54 # Examples
55 
56 There are dozens of examples in the subdirectory [MRPT/share/mrpt/config_files](https://github.com/MRPT/mrpt/tree/master/share/mrpt/config_files).
57 
58 */
59 



Page generated by Doxygen 1.8.14 for MRPT 1.5.6 Git: 4c65e8431 Tue Apr 24 08:18:17 2018 +0200 at lun oct 28 01:35:26 CET 2019