Last change
on this file since 4767 was
4767,
checked in by bensch, 19 years ago
|
orxonox/trunk: ini-parser small cleanup char* → const char*
|
File size:
1.1 KB
|
Rev | Line | |
---|
[2064] | 1 | /*! |
---|
| 2 | \file ini_parser.h |
---|
| 3 | \brief A small ini file parser |
---|
[4597] | 4 | |
---|
[2064] | 5 | Can be used to find a defined [Section] in an ini file and get the VarName=Value entries |
---|
| 6 | */ |
---|
| 7 | |
---|
[3224] | 8 | #ifndef _INI_PARSER_H |
---|
| 9 | #define _INI_PARSER_H |
---|
[2064] | 10 | |
---|
[2066] | 11 | #include <stdio.h> |
---|
[2167] | 12 | #include <string.h> |
---|
[2066] | 13 | #include <stdlib.h> |
---|
[4597] | 14 | #include "base_object.h" |
---|
[2064] | 15 | |
---|
[4482] | 16 | #define PARSELINELENGHT 512 //!< how many chars to read at once |
---|
[2064] | 17 | |
---|
[2141] | 18 | //! ini-file parser |
---|
| 19 | /** |
---|
[4597] | 20 | This class can be used to load an initializer file and parse it's contents for variablename=value pairs. |
---|
[2141] | 21 | */ |
---|
[4597] | 22 | class IniParser : public BaseObject |
---|
| 23 | { |
---|
[2064] | 24 | public: |
---|
[4028] | 25 | IniParser (const char* filename); |
---|
[2064] | 26 | ~IniParser (); |
---|
[4597] | 27 | |
---|
[4767] | 28 | const char* getVar(const char* name, const char* section, const char* defvalue); |
---|
[4028] | 29 | int openFile(const char* name); |
---|
[4767] | 30 | int getSection( const char* section); |
---|
| 31 | int nextVar( const char* name, const char* value); |
---|
[4482] | 32 | |
---|
| 33 | private: |
---|
| 34 | FILE* stream; //!< A FileStream to be loaded |
---|
| 35 | bool bInSection; //!< if the requested parameter is in the section. |
---|
| 36 | char internbuf[PARSELINELENGHT]; //!< a buffer |
---|
| 37 | |
---|
[4597] | 38 | |
---|
[2064] | 39 | }; |
---|
| 40 | |
---|
[3224] | 41 | #endif /* _INI_PARSER_H */ |
---|
Note: See
TracBrowser
for help on using the repository browser.