wmi

git clone git://oldgit.suckless.org/wmi/
Log | Files | Refs | LICENSE

loader.h (1466B)


      1 // Copyright (c) 2003 - 2009 Anselm R Garbe <anselm@garbe.us>
      2 // See LICENSE for license details.
      3 
      4 #ifndef __LOADER_H
      5 #define __LOADER_H
      6 
      7 #include "wmi.h"
      8 
      9 #include <list>
     10 #include <string>
     11 #include <map>
     12 
     13 typedef map<string, string, less<string> > MSettings;
     14 
     15 /**
     16  * Loads and saves settings.
     17  */
     18 class Loader
     19 {
     20 
     21 public:
     22 
     23     /** Constructs a new settings manager instance.  */
     24     Loader();
     25 
     26     ~Loader();
     27 
     28     /**
     29      * (Re)loads settings. Returns <code>true</code> on success. 
     30      * The settings file has following grammar:
     31      * <key>=<value>
     32      * whitespaces (' ', '\t') are ignored by default (escape using "...")
     33      * '\' is escape character for escaping from '"', '=', '#', '\n', '\'
     34      * @param settings the settings to set
     35      * @param filename the filename to load from
     36      * @param suppressWarning suppresses warn messages to stderr
     37      * @param caseSensitive reads keys case sensitive
     38      * if file couldn't be loaded
     39      */
     40     static bool load(MSettings *settings, string path,
     41                      bool suppressWarning = false,
     42                      bool caseSensitive = false);
     43 
     44     /** Saves settings. Returns <code>true</code> on success. */
     45     static bool saveSettings(MSettings *settings, string path);
     46 
     47     /** Saves content to the file specified by path. */
     48     static bool saveFile(string path, string content);
     49 
     50     /** Prints all settings to stdout. */
     51     static void print(MSettings *settings);
     52 
     53 };
     54 
     55 #endif // __LOADER_H