source: OGRE/trunk/ogrenew/OgreMain/include/OgreConfigFile.h @ 657

Revision 657, 4.3 KB checked in by mattausch, 19 years ago (diff)

added ogre dependencies and patched ogre sources

RevLine 
[657]1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25#ifndef __ConfigFile_H__
26#define __ConfigFile_H__
27
28#include "OgrePrerequisites.h"
29
30#include "OgreString.h"
31#include "OgreStringVector.h"
32#include "OgreIteratorWrappers.h"
33#include "OgreDataStream.h"
34
35namespace Ogre {
36
37    /** Class for quickly loading settings from a text file.
38        @remarks
39            This class is designed to quickly parse a simple file containing
40            key/value pairs, mainly for use in configuration settings.
41        @par
42            This is a very simplified approach, no multiple values per key
43            are allowed, no grouping or context is being kept etc.
44        @par
45            By default the key/values pairs are tokenised based on a
46            separator of Tab, the colon (:) or equals (=) character. Each
47            key - value pair must end in a carriage return.
48        @par
49            Settings can be optionally grouped in sections, using a header
50            beforehand of the form [SectionName].
51    */
52    class _OgreExport ConfigFile
53    {
54    public:
55
56        ConfigFile();
57        virtual ~ConfigFile();
58        /// load from a filename (not using resource group locations)
59        void load(const String& filename, const String& separators = "\t:=", bool trimWhitespace = true);
60        /// load from a filename (using resource group locations)
61        void load(const String& filename, const String& resourceGroup, const String& separators = "\t:=", bool trimWhitespace = true);
62        /// load from a data stream
63        void load(const DataStreamPtr& stream, const String& separators = "\t:=", bool trimWhitespace = true);
64                /// load from a filename (not using resource group locations)
65                void loadDirect(const String& filename, const String& separators = "\t:=", bool trimWhitespace = true);
66                /// load from a filename (using resource group locations)
67                void loadFromResourceSystem(const String& filename, const String& resourceGroup, const String& separators = "\t:=", bool trimWhitespace = true);
68
69        /** Gets the first setting from the file with the named key.
70        @param key The name of the setting
71        @param section The name of the section it must be in (if any)
72        */
73        String getSetting(const String& key, const String& section = StringUtil::BLANK) const;
74        /** Gets all settings from the file with the named key. */
75        StringVector getMultiSetting(const String& key, const String& section = StringUtil::BLANK) const;
76
77        typedef std::multimap<String, String> SettingsMultiMap;
78        typedef MapIterator<SettingsMultiMap> SettingsIterator;
79        /** Gets an iterator for stepping through all the keys / values in the file. */
80        typedef std::map<String, SettingsMultiMap*> SettingsBySection;
81        typedef MapIterator<SettingsBySection> SectionIterator;
82        /** Get an iterator over all the available sections in the config file */
83        SectionIterator getSectionIterator(void);
84        /** Get an iterator over all the available settings in a section */
85        SettingsIterator getSettingsIterator(const String& section = StringUtil::BLANK);
86
87
88       
89        /** Clear the settings */
90        void clear(void);
91    protected:
92        SettingsBySection mSettings;
93    };
94
95}
96
97
98#endif
Note: See TracBrowser for help on using the repository browser.