-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserSettings.h
More file actions
51 lines (39 loc) · 1.27 KB
/
UserSettings.h
File metadata and controls
51 lines (39 loc) · 1.27 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* UserSettings.h
Copyright (c) 2009, Christopher Faylor
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
A copy of the GNU General Public License can be found at http://www.gnu.org
*/
#ifndef SETUP_USERSETTINGS_H
#define SETUP_USERSETTINGS_H
#include <string>
#include "io_stream.h"
class UserSettings
{
private:
struct Element
{
const char *key;
const char *value;
} **table;
ssize_t table_len;
std::string filename;
std::string cwd;
public:
static class UserSettings *global;
UserSettings ();
static UserSettings& instance() {return *global;}
const char *get (const char *);
unsigned int get_index (const char *key);
io_stream *open (const char *); // opens an iostream you can write to set the value of key
const char *set (const char *, const char *);
const char *set (const char *key, const std::string val) {return set (key, val.c_str ());}
void load (std::string local_dir);
void save ();
private:
void extend_table (ssize_t);
io_stream *open_settings (const char *, std::string&);
};
#endif // SETUP_USERSETTINGS_H