Colobot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
profile.h
Go to the documentation of this file.
1 // * This file is part of the COLOBOT source code
2 // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
3 // *
4 // * This program is free software: you can redistribute it and/or modify
5 // * it under the terms of the GNU General Public License as published by
6 // * the Free Software Foundation, either version 3 of the License, or
7 // * (at your option) any later version.
8 // *
9 // * This program is distributed in the hope that it will be useful,
10 // * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // * GNU General Public License for more details.
13 // *
14 // * You should have received a copy of the GNU General Public License
15 // * along with this program. If not, see http://www.gnu.org/licenses/.
16 
22 #pragma once
23 
24 #include "common/singleton.h"
25 
26 #include <boost/property_tree/ptree.hpp>
27 #include <boost/filesystem.hpp>
28 #include <boost/algorithm/string/replace.hpp>
29 
30 #include <string>
31 #include <vector>
32 
33 namespace fs = boost::filesystem;
34 
35 
42 class CProfile : public CSingleton<CProfile>
43 {
44 public:
45  CProfile();
46  virtual ~CProfile();
47 
51  bool InitCurrentDirectory();
52 
56  bool SaveCurrentDirectory();
57 
64  bool SetLocalProfileString(std::string section, std::string key, std::string value);
65 
72  bool GetLocalProfileString(std::string section, std::string key, std::string& buffer);
73 
80  bool SetLocalProfileInt(std::string section, std::string key, int value);
81 
88  bool GetLocalProfileInt(std::string section, std::string key, int &value);
89 
96  bool SetLocalProfileFloat(std::string section, std::string key, float value);
97 
104  bool GetLocalProfileFloat(std::string section, std::string key, float &value);
105 
111  std::vector< std::string > GetLocalProfileSection(std::string section, std::string key);
112 
116  void SetUserDir(std::string dir);
117 
124  std::string GetUserBasedPath(std::string dir, std::string default_dir);
125 
130  bool CopyFileToTemp(std::string filename);
131 
132 private:
133  boost::property_tree::ptree m_propertyTree;
134  bool m_profileNeedSave;
135  std::string m_userDirectory;
136 };
137 
140 {
141  return *CProfile::GetInstancePointer();
142 }
143 
bool SetLocalProfileFloat(std::string section, std::string key, float value)
Definition: profile.cpp:147
bool GetLocalProfileString(std::string section, std::string key, std::string &buffer)
Definition: profile.cpp:101
CSingleton base class for singletons.
bool SetLocalProfileString(std::string section, std::string key, std::string value)
Definition: profile.cpp:85
bool InitCurrentDirectory()
Definition: profile.cpp:46
bool CopyFileToTemp(std::string filename)
Definition: profile.cpp:230
Definition: singleton.h:27
bool GetLocalProfileFloat(std::string section, std::string key, float &value)
Definition: profile.cpp:163
bool SaveCurrentDirectory()
Definition: profile.cpp:64
void SetUserDir(std::string dir)
Definition: profile.cpp:202
bool SetLocalProfileInt(std::string section, std::string key, int value)
Definition: profile.cpp:116
std::string GetUserBasedPath(std::string dir, std::string default_dir)
Definition: profile.cpp:208
std::vector< std::string > GetLocalProfileSection(std::string section, std::string key)
Definition: profile.cpp:178
Class for loading profile (currently for loading ini config file)
Definition: profile.h:42
CProfile & GetProfile()
Global function to get profile instance.
Definition: profile.h:139
bool GetLocalProfileInt(std::string section, std::string key, int &value)
Definition: profile.cpp:132