H3D API  2.4.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
INIFile.h
Go to the documentation of this file.
1 // Copyright 2004-2019, SenseGraphics AB
3 //
4 // This file is part of H3D API.
5 //
6 // H3D API is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // H3D API is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with H3D API; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // A commercial license is also available. Please contact us at
21 // www.sensegraphics.com for more information.
22 //
24 //
26 
27 #ifndef __INIFILE_H__
28 #define __INIFILE_H__
29 
30 #include <string>
31 #include <iostream>
32 #include <map>
33 #include <H3D/H3DApi.h>
34 
35 namespace H3D {
36 
37  class H3DAPI_API INIFile {
38  public:
39  // Constructor.
40  INIFile( const std::string &file );
41 
42  // Constructor.
43  INIFile( std::istream& in );
44 
45  // Get a value as a string.
46  std::string get( std::string group,
47  std::string name ) const;
48 
49  // Get a value as a boolean
50  bool getBoolean( std::string group,
51  std::string name ) const;
52 
53  // Check if a value exists.
54  bool hasOption( std::string group,
55  std::string name ) const;
56 
57  private:
58  void parseStream( std::istream &is );
59 
60  void parseLine( std::string line,
61  std::string group,
62  unsigned count );
63 
64  std::map<std::string, std::map<std::string, std::string> > parsed_;
65  };
66 
67 }
68 
69 #endif
Base header file that handles all configuration related settings.
H3D API namespace.
Definition: Anchor.h:38