]> git.saurik.com Git - wxWidgets.git/blob - include/wx/config.h
*** empty log message ***
[wxWidgets.git] / include / wx / config.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name:
3 // Purpose:
4 // Author: Karsten Ballüder & Vadim Zeitlin
5 // Modified by:
6 // Created: 07.04.98 (adapted from appconf.h)
7 // RCS-ID: $Id$
8 // Copyright: (c) 1997 Karsten Ballüder Ballueder@usa.net
9 // Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
10 // Licence: wxWindows license
11 ///////////////////////////////////////////////////////////////////////////////
12
13 #ifndef _APPCONF_H
14 #define _APPCONF_H
15
16 // ----------------------------------------------------------------------------
17 // constants
18 // ----------------------------------------------------------------------------
19
20 /// shall we be case sensitive in parsing variable names?
21 #ifndef APPCONF_CASE_SENSITIVE
22 #define APPCONF_CASE_SENSITIVE FALSE
23 #endif
24
25 /// separates group and entry names
26 #ifndef APPCONF_PATH_SEPARATOR
27 #define APPCONF_PATH_SEPARATOR '/'
28 #endif
29
30 /// introduces immutable entries
31 #ifndef APPCONF_IMMUTABLE_PREFIX
32 #define APPCONF_IMMUTABLE_PREFIX '!'
33 #endif
34
35 /// should we use registry instead of configuration files under Win32?
36 #ifndef APPCONF_WIN32_NATIVE
37 #define APPCONF_WIN32_NATIVE TRUE
38 #endif
39
40 // ----------------------------------------------------------------------------
41 // global functions
42 // ----------------------------------------------------------------------------
43
44 /*
45 Replace environment variables ($SOMETHING) with their values. The format is
46 $VARNAME or ${VARNAME} where VARNAME contains alphanumeric characters and
47 '_' only. '$' must be escaped ('\$') in order to be taken literally.
48 */
49 wxString ExpandEnvVars(const wxString& str);
50
51 // ----------------------------------------------------------------------------
52 // abstract base class wxConfig which defines the interface for derived classes
53 //
54 // wxConfig organizes the items in a tree-like structure (modeled after the
55 // Unix/Dos filesystem). There are groups (directories) and keys (files).
56 // There is always one current group given by the current path.
57 //
58 // Keys are pairs "key_name = value" where value may be of string or integer
59 // (long) type (@@@ doubles and other types such as wxDate coming soon).
60 // ----------------------------------------------------------------------------
61 class wxConfig
62 {
63 public:
64 // ctor & virtual dtor
65 wxConfig() { }
66 virtual ~wxConfig();
67
68 // path management
69 // set current path: if the first character is '/', it's the absolute path,
70 // otherwise it's a relative path. '..' is supported. If the strPath
71 // doesn't exist it is created.
72 virtual void SetPath(const wxString& strPath) = 0;
73 // retrieve the current path (always as absolute path)
74 virtual const wxString& GetPath() const = 0;
75
76 // enumeration: all functions here return false when there are no more items.
77 // you must pass the same lIndex to GetNext and GetFirst (don't modify it)
78 // enumerate subgroups
79 virtual bool GetFirstGroup(wxString& str, long& lIndex) = 0;
80 virtual bool GetNextGroup (wxString& str, long& lIndex) = 0;
81 // enumerate entries
82 virtual bool GetFirstEntry(wxString& str, long& lIndex) = 0;
83 virtual bool GetNextEntry (wxString& str, long& lIndex) = 0;
84
85 // key access
86 // read a string or long value from the key. If the key is not
87 // found the default value is returned.
88 virtual const char *Read(const char *szKey,
89 const char *szDefault = NULL) const = 0;
90 virtual long Read(const char *szKey, long lDefault) const = 0;
91
92 // write the value (return true on success)
93 virtual bool Write(const char *szKey, const char *szValue) = 0;
94 virtual bool Write(const char *szKey, long lValue) = 0;
95 // permanently writes all changes
96 virtual bool Flush(bool bCurrentOnly = FALSE) = 0;
97
98 // delete entries/groups
99 // deletes the specified entry and the group it belongs to if
100 // it was the last key in it and the second parameter is true
101 virtual bool DeleteEntry(const char *szKey,
102 bool bDeleteGroupIfEmpty = TRUE) = 0;
103 // delete the group (with all subgroups)
104 virtual bool DeleteGroup(const char *szKey) = 0;
105 // delete the whole underlying object (disk file, registry key, ...)
106 // primarly for use by desinstallation routine.
107 virtual bool DeleteAll() = 0;
108
109 protected:
110 // true if environment variables are to be auto-expanded
111 bool m_bExpandEnvVars;
112 };
113
114 // ----------------------------------------------------------------------------
115 // functions to create different config implementations
116 // ----------------------------------------------------------------------------
117
118 wxConfig *CreateFileConfig(const wxString& strFile, bool bLocalOnly = FALSE);
119
120 #endif //_APPCONF_H
121