RigsofRods
Soft-body Physics Simulation
ConfigFile.h
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3  Copyright 2005-2012 Pierre-Michel Ricordel
4  Copyright 2007-2012 Thomas Fischer
5  Copyright 2013-2016 Petr Ohlidal
6 
7  For more information, see http://www.rigsofrods.org/
8 
9  Rigs of Rods is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License version 3, as
11  published by the Free Software Foundation.
12 
13  Rigs of Rods is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
28 #pragma once
29 
30 #include "Console.h"
31 
32 #include <Ogre.h>
33 
34 namespace RoR {
35 
37 class ConfigFile: public Ogre::ConfigFile
38 {
39 public:
40 
41  Ogre::ColourValue getColourValue(Ogre::String const& key, Ogre::ColourValue const& defaultValue = Ogre::ColourValue())
42  {
43  return this->getColourValue(key, Ogre::BLANKSTRING, defaultValue);
44  }
45 
46  Ogre::ColourValue getColourValue(Ogre::String const& key, Ogre::String const& section, Ogre::ColourValue const& defaultValue = Ogre::ColourValue());
47 
48  Ogre::Vector3 getVector3(Ogre::String const& key, Ogre::String const& section, Ogre::Vector3 const& defaultValue = Ogre::Vector3::ZERO);
49 
50  float getFloat(Ogre::String const& key, float defaultValue = 0.f)
51  {
52  return this->getFloat(key, Ogre::BLANKSTRING, defaultValue);
53  }
54 
55  float getFloat(Ogre::String const& key, Ogre::String const& section, float defaultValue = 0.f);
56 
57  bool getBool(Ogre::String const& key, bool defaultValue = false)
58  {
59  return this->getBool(key, Ogre::BLANKSTRING, defaultValue);
60  }
61 
62  bool getBool(Ogre::String const& key, Ogre::String const& section, bool defaultValue = false);
63 
64  int getInt(Ogre::String const& key, int defaultValue = 0)
65  {
66  return this->getInt(key, Ogre::BLANKSTRING, defaultValue);
67  }
68 
69  int getInt(Ogre::String const& key, Ogre::String const& section, int defaultValue = 0);
70 
71  Ogre::String getString(Ogre::String const& key, Ogre::String const& section, Ogre::String const& defaultValue = "");
72 
73  void SetString(Ogre::String key, Ogre::String value, Ogre::String section = Ogre::BLANKSTRING);
74 
75  bool HasSection(std::string const & name);
76 
77  void setLoggingInfo(std::string const & filename, Console::MessageArea area)
78  {
79  m_log_filename = filename;
80  m_log_area = area;
81  }
82 
83 private:
84  //Block access to Ogre::ConfigFile::getSetting() - not UTF8 safe!
85  Ogre::String getSetting(Ogre::String, Ogre::String);
86  Ogre::String getSetting(Ogre::String, Ogre::String, Ogre::String);
87 
88  void logMessage(std::string const & msg);
89 
90  // Logging info.
91  std::string m_log_filename;
93 };
94 
95 } // namespace RoR
RoR::ConfigFile::getInt
int getInt(Ogre::String const &key, int defaultValue=0)
Definition: ConfigFile.h:64
RoR::ConfigFile::logMessage
void logMessage(std::string const &msg)
Definition: ConfigFile.cpp:124
RoR::ConfigFile::SetString
void SetString(Ogre::String key, Ogre::String value, Ogre::String section=Ogre::BLANKSTRING)
Definition: ConfigFile.cpp:99
Console.h
RoR::ConfigFile::m_log_filename
std::string m_log_filename
Definition: ConfigFile.h:91
RoR::ConfigFile::getString
Ogre::String getString(Ogre::String const &key, Ogre::String const &section, Ogre::String const &defaultValue="")
Definition: ConfigFile.cpp:89
RoR::ConfigFile::getSetting
Ogre::String getSetting(Ogre::String, Ogre::String)
RoR::ConfigFile::getBool
bool getBool(Ogre::String const &key, bool defaultValue=false)
Definition: ConfigFile.h:57
RoR::ConfigFile::getFloat
float getFloat(Ogre::String const &key, float defaultValue=0.f)
Definition: ConfigFile.h:50
RoR::ConfigFile::HasSection
bool HasSection(std::string const &name)
Definition: ConfigFile.cpp:117
RoR::ConfigFile::m_log_area
Console::MessageArea m_log_area
Definition: ConfigFile.h:92
RoR::ConfigFile::getVector3
Ogre::Vector3 getVector3(Ogre::String const &key, Ogre::String const &section, Ogre::Vector3 const &defaultValue=Ogre::Vector3::ZERO)
Definition: ConfigFile.cpp:62
RoR::Console::CONSOLE_MSGTYPE_INFO
@ CONSOLE_MSGTYPE_INFO
Generic message.
Definition: Console.h:60
RoR::ConfigFile
Adds direct parsing of custom types.
Definition: ConfigFile.h:37
RoR::ConfigFile::getColourValue
Ogre::ColourValue getColourValue(Ogre::String const &key, Ogre::ColourValue const &defaultValue=Ogre::ColourValue())
Definition: ConfigFile.h:41
RoR
Definition: AppContext.h:36
RoR::ConfigFile::setLoggingInfo
void setLoggingInfo(std::string const &filename, Console::MessageArea area)
Definition: ConfigFile.h:77
RoR::Console::MessageArea
MessageArea
Definition: Console.h:58