]> cygwin.com Git - cygwin-apps/setup.git/blobdiff - UserSettings.h
Use solver to check for problems and produce a list of package transactions
[cygwin-apps/setup.git] / UserSettings.h
index e02e9a48697e480bb51d28a273cf4831ee43ec11..8f661cb27163fed48cb74f597064ae50e23a2585 100644 (file)
@@ -1,37 +1,50 @@
-/*
- * Copyright (c) 2003, Robert Collins.
- *
- *     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/
- *
- * Written by Robert Collins  <rbtcollins@hotmail.com>
- *
- */
-
-/* A collection of user-related settings */
-
-#ifndef _USERSETTINGS_H_
-#define _USERSETTINGS_H_
-
-#include <vector>
-
-class UserSetting;
-class UserSettings {
-  public:
-    static UserSettings &Instance();
-    void registerSetting(UserSetting &);
-    void deRegisterSetting(UserSetting &);
-  private:
-    static UserSettings Instance_;
-    typedef std::vector<UserSetting *> Settings;
-    void init();
-    int inited;
-    Settings settings;
+/*  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 (std::string);
+  static UserSettings& instance() {return *global;}
+
+  const char *get (const char *);
+  unsigned int get_index (const char *key);
+  io_stream *open (const char *);
+  const char *set (const char *, const char *);
+  const char *set (const char *key, const std::string val) {return set (key, val.c_str ());}
+  void save ();
+
+private:
+  void extend_table (ssize_t);
+  io_stream *open_settings (const char *, std::string&);
+
 };
 
-#endif /* _USERSETTINGS_H_ */
+#endif // SETUP_USERSETTINGS_H
This page took 0.021738 seconds and 5 git commands to generate.