Colobot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
profile.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
5  *
6  * This program 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 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program 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.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
25 #pragma once
26 
27 #include "common/singleton.h"
28 
29 #include <boost/property_tree/ptree.hpp>
30 #include <boost/filesystem.hpp>
31 #include <boost/algorithm/string/replace.hpp>
32 
33 #include <string>
34 #include <vector>
35 
36 namespace fs = boost::filesystem;
37 
38 
45 class CProfile : public CSingleton<CProfile>
46 {
47 public:
48  CProfile();
49  virtual ~CProfile();
50 
52  void SetUseCurrentDirectory(bool useCurrentDirectory);
53 
57  bool Init();
58 
62  bool Save();
63 
70  bool SetStringProperty(std::string section, std::string key, std::string value);
71 
78  bool GetStringProperty(std::string section, std::string key, std::string& buffer);
79 
86  bool SetIntProperty(std::string section, std::string key, int value);
87 
94  bool GetIntProperty(std::string section, std::string key, int &value);
95 
102  bool SetFloatProperty(std::string section, std::string key, float value);
103 
110  bool GetFloatProperty(std::string section, std::string key, float &value);
111 
117  std::vector< std::string > GetSection(std::string section, std::string key);
118 
119 private:
120  boost::property_tree::ptree m_propertyTree;
121  bool m_profileNeedSave;
122  bool m_useCurrentDirectory;
123 };
124 
127 {
128  return *CProfile::GetInstancePointer();
129 }
130 
CSingleton base class for singletons.
bool SetIntProperty(std::string section, std::string key, int value)
Definition: profile.cpp:165
void SetUseCurrentDirectory(bool useCurrentDirectory)
Definition: profile.cpp:52
Definition: singleton.h:30
bool Save()
Definition: profile.cpp:94
std::vector< std::string > GetSection(std::string section, std::string key)
Definition: profile.cpp:227
bool GetStringProperty(std::string section, std::string key, std::string &buffer)
Definition: profile.cpp:150
bool GetIntProperty(std::string section, std::string key, int &value)
Definition: profile.cpp:181
Class for loading profile (currently for loading ini config file)
Definition: profile.h:45
bool Init()
Definition: profile.cpp:57
bool SetFloatProperty(std::string section, std::string key, float value)
Definition: profile.cpp:196
CProfile & GetProfile()
Global function to get profile instance.
Definition: profile.h:126
bool GetFloatProperty(std::string section, std::string key, float &value)
Definition: profile.cpp:212
bool SetStringProperty(std::string section, std::string key, std::string value)
Definition: profile.cpp:134