]> cygwin.com Git - cygwin-apps/setup.git/blob - UserSettings.h
Also run stratum 'z' perpetual preremove scripts
[cygwin-apps/setup.git] / UserSettings.h
1 /* UserSettings.h
2
3 Copyright (c) 2009, Christopher Faylor
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 A copy of the GNU General Public License can be found at http://www.gnu.org
11 */
12
13 #ifndef SETUP_USERSETTINGS_H
14 #define SETUP_USERSETTINGS_H
15
16 #include <string>
17 #include "io_stream.h"
18
19 class UserSettings
20 {
21 private:
22 struct Element
23 {
24 const char *key;
25 const char *value;
26 } **table;
27 ssize_t table_len;
28
29 std::string filename;
30 std::string cwd;
31
32 public:
33 static class UserSettings *global;
34 UserSettings ();
35 static UserSettings& instance() {return *global;}
36
37 const char *get (const char *);
38 unsigned int get_index (const char *key);
39 io_stream *open (const char *); // opens an iostream you can write to set the value of key
40 const char *set (const char *, const char *);
41 const char *set (const char *key, const std::string val) {return set (key, val.c_str ());}
42 void load (std::string local_dir);
43 void save ();
44
45 private:
46 void extend_table (ssize_t);
47 io_stream *open_settings (const char *, std::string&);
48
49 };
50
51 #endif // SETUP_USERSETTINGS_H
This page took 0.036336 seconds and 5 git commands to generate.