ROLAND  0.70
Amstrad Emulator based on Caprice Source rewritten in C++.
prefs.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) by Fred Klaus *
3  * development@fkweb.de *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 #ifndef PREFS_H
21 #define PREFS_H
22 
23 #include "config.h"
24 #include <string>
25 #include <array>
26 #include <utility>
27 
28 #define PREFCOUNT 23
29 
31 class Prefs
32 {
33 
34  public:
35  enum PrefsArray {paKey = 0, paValue = 1};
36 
37  Prefs(bool autowrite = true, bool writealways = true);
38  ~Prefs();
39 
40  bool read();
41  bool write();
42 
43  bool set(const std::string & key, const std::string & value);
44  bool set(const std::string & key, int value);
45  bool set(const std::string & key, bool value);
46 
47  std::string getStr (const std::string & key) const;
48  std::string getPath(const std::string & key) const;
49  int getNum (const std::string & key) const;
50  bool getBool(const std::string & key) const;
51 
52 #ifdef _WIN32
53  static const char delim() {return '\\';}
54 #else
55  static char delim() {return '/';}
56 #endif
57 
58  private:
59 
60  bool mAutoWrite;
62  bool mRead;
63 
64  std::string mFilename;
65  std::string mNothing;
66  std::array<std::pair<std::string, std::string>, PREFCOUNT> mPrefs;
67  };
68 
69 #endif // PREFS_H
~Prefs()
Definition: prefs.cpp:100
bool mRead
Definition: prefs.h:62
#define PREFCOUNT
Definition: prefs.h:28
std::string mFilename
Definition: prefs.h:64
Definition: prefs.h:31
bool getBool(const std::string &key) const
Definition: prefs.cpp:248
bool mAutoWrite
Definition: prefs.h:60
Prefs(bool autowrite=true, bool writealways=true)
Definition: prefs.cpp:47
bool write()
Definition: prefs.cpp:142
std::string mNothing
Definition: prefs.h:65
int getNum(const std::string &key) const
Definition: prefs.cpp:235
std::string getStr(const std::string &key) const
Definition: prefs.cpp:202
std::array< std::pair< std::string, std::string >, 23 > mPrefs
Definition: prefs.h:66
bool mWriteAlways
Definition: prefs.h:61
Definition: prefs.h:35
Definition: prefs.h:35
std::string getPath(const std::string &key) const
Definition: prefs.cpp:211
static char delim()
Definition: prefs.h:55
bool read()
Definition: prefs.cpp:105
PrefsArray
Definition: prefs.h:35