forked from tstellar/cs510fly
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ConfigReader.h
27 lines (21 loc) · 986 Bytes
/
ConfigReader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "Ogre.h"
class ConfigReader {
Ogre::ConfigFile configFile;
mutable Ogre::ConfigFile::SectionIterator sectionIterator; // mutable because it's not const-correct ...
public:
ConfigReader(const Ogre::String& filename);
bool hasNextSection() const;
void advanceSection();
Ogre::String getSectionName() const;
Ogre::String get(const Ogre::String& name, const Ogre::String& dflt = Ogre::StringUtil::BLANK) const;
template<typename T>
T parse(const Ogre::String& name, T (* func)(const Ogre::String&), const T& dflt) const {
// Need to define this here so that the template can be instantiated. *grmbl*
const Ogre::ConfigFile::SettingsMultiMap * settings = sectionIterator.peekNextValue();
const Ogre::ConfigFile::SettingsMultiMap::const_iterator iter = settings->find(name);
if (iter == settings->end())
return dflt;
else
return func(iter->second);
}
};