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