]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/prefconf.cpp
Fixed wxAtomicInc/Dec() to not use asm/atomic.h header on Linux - it's kernel interna...
[wxWidgets.git] / src / palmos / prefconf.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/prefconf.cpp
3 // Purpose: wxPrefConfig implementation
4 // Author: Wlodzimierz ABX Skiba
5 // Modified by:
6 // Created: 28.12.2004
7 // RCS-ID: $Id$
8 // Copyright: (c) Wlodzimierz Skiba
9 // License: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #ifndef WX_PRECOMP
20 #include "wx/string.h"
21 #endif //WX_PRECOMP
22
23 #if wxUSE_CONFIG && wxUSE_CONFIG_NATIVE
24
25 #include "wx/config.h"
26
27 // ============================================================================
28 // implementation
29 // ============================================================================
30
31 /*
32
33 http://www.palmos.com/dev/support/docs/protein_books/System_Management/PreferenceConcepts.html
34
35 This wxPrefConfig class is a wxConfig wrapper around PalmOS Preferences
36 functionality. Preferences allow to write any structure into its database so
37 wxPrefConfig writes there all entries of single group into one Preference.
38 To optimize read/write operations value of preference is cached. Cache is filled
39 after each change of the path (including using path to group names in all
40 operations) and it is flushed on destructor, any path change on or purpose
41 with Flush().
42
43 Meaning of styles:
44
45 wxCONFIG_USE_LOCAL_FILE => store config in "saved" preferences database
46 (not to be backed up during a HotSync operation)
47 wxCONFIG_USE_GLOBAL_FILE => store config in "unsaved" preferences database
48 (backed up during a HotSync operation)
49
50
51 Each Preference is an array of chars. First unsigned char describes
52 number N of chars used for Preference size. Next N chars (string) contains
53 length of rest of Preference. Preference consists in serie of entries which
54 should be read in loop until in reaches end of Preference.
55
56 Each entry is an set of chars with following structure:
57 1. name (null terminated)
58 2. type (single char): b,s,g,l,d (see value)
59 3. value
60 - for type="b" (bool) it os "0" or "1"
61 - for type="s" (string) it is null terminated set of chars
62 - for type="g" (subgroup) as for "s" but string is converted to
63 uint16_t for id parameter of ::PrefGetAppPreferences()
64 - for type="l" (long) as for "s" but string is converted to long
65 - for type="d" (double) as for "s" but string is converted to double
66 - otherwise it is ""
67
68 So all together first Read in group needs 3 reading from Preference:
69 1. take the length N of length
70 2. take the length M of the group content
71 3. take the group content
72 and all it is in single Preference to not overload Preferences database.
73 As long as each next Read/Write is performed in the same group then none
74 access to Preferences is performed. Flushing needs only single writing to
75 databease because all 3 parts of Preference can be prepared in memory.
76
77 NOTE: wxPrefConfig can read/write only its own entries. It is impossible to
78 know structures of Preferences of other non wxW applications.
79
80 */
81
82 // ----------------------------------------------------------------------------
83 // ctor/dtor
84 // ----------------------------------------------------------------------------
85 IMPLEMENT_ABSTRACT_CLASS(wxPrefConfig, wxConfigBase)
86
87 wxPrefConfig::wxPrefConfig(const wxString& appName, const wxString& vendorName,
88 const wxString& strLocal, const wxString& strGlobal,
89 long style)
90 : wxConfigBase(appName, vendorName, strLocal, strGlobal, style)
91 {
92 }
93
94 // ----------------------------------------------------------------------------
95 // path management
96 // ----------------------------------------------------------------------------
97
98 void wxPrefConfig::SetPath(const wxString& strPath)
99 {
100 }
101
102 // ----------------------------------------------------------------------------
103 // enumeration (works only with current group)
104 // ----------------------------------------------------------------------------
105
106 bool wxPrefConfig::GetFirstGroup(wxString& str, long& lIndex) const
107 {
108 }
109
110 bool wxPrefConfig::GetNextGroup(wxString& str, long& lIndex) const
111 {
112 /* TODO */
113 return false;
114 }
115
116 bool wxPrefConfig::GetFirstEntry(wxString& str, long& lIndex) const
117 {
118 /* TODO */
119 return false;
120 }
121
122 bool wxPrefConfig::GetNextEntry(wxString& str, long& lIndex) const
123 {
124 /* TODO */
125 return false;
126 }
127
128 size_t wxPrefConfig::GetNumberOfEntries(bool WXUNUSED(bRecursive)) const
129 {
130 /* TODO */
131 return 0;
132 }
133
134 size_t wxPrefConfig::GetNumberOfGroups(bool WXUNUSED(bRecursive)) const
135 {
136 /* TODO */
137 return 0;
138 }
139
140 // ----------------------------------------------------------------------------
141 // tests for existence
142 // ----------------------------------------------------------------------------
143
144 bool wxPrefConfig::HasGroup(const wxString& key) const
145 {
146 /* TODO */
147 return false;
148 }
149
150 bool wxPrefConfig::HasEntry(const wxString& key) const
151 {
152 /* TODO */
153 return false;
154 }
155
156 wxConfigBase::EntryType wxPrefConfig::GetEntryType(const wxString& key) const
157 {
158 /* TODO */
159 return wxConfigBase::Type_Unknown;
160 }
161
162 // ----------------------------------------------------------------------------
163 // reading/writing
164 // ----------------------------------------------------------------------------
165
166 bool wxPrefConfig::DoReadString(const wxString& key, wxString *pStr) const
167 {
168 /* TODO */
169 return false;
170 }
171
172 // this exactly reproduces the string version above except for ExpandEnvVars(),
173 // we really should avoid this code duplication somehow...
174
175 bool wxPrefConfig::DoReadLong(const wxString& key, long *plResult) const
176 {
177 /* TODO */
178 return false;
179 }
180
181 bool DoReadBinary(const wxString& key, wxMemoryBuffer *buf) const
182 {
183 /* TODO */
184 return false;
185 }
186
187 bool wxPrefConfig::DoWriteString(const wxString& key, const wxString& szValue)
188 {
189 /* TODO */
190 return false;
191 }
192
193 bool wxPrefConfig::DoWriteLong(const wxString& key, long lValue)
194 {
195 /* TODO */
196 return false;
197 }
198
199 bool DoWriteBinary(const wxString& key, const wxMemoryBuffer& buf)
200 {
201 /* TODO */
202 return false;
203 }
204
205 // ----------------------------------------------------------------------------
206 // renaming
207 // ----------------------------------------------------------------------------
208
209 bool wxPrefConfig::RenameEntry(const wxString& oldName, const wxString& newName)
210 {
211 /* TODO */
212 return false;
213 }
214
215 bool wxPrefConfig::RenameGroup(const wxString& oldName, const wxString& newName)
216 {
217 /* TODO */
218 return false;
219 }
220
221 // ----------------------------------------------------------------------------
222 // deleting
223 // ----------------------------------------------------------------------------
224
225 bool wxPrefConfig::DeleteEntry(const wxString& value, bool bGroupIfEmptyAlso)
226 {
227 /* TODO */
228 return false;
229 }
230
231 bool wxPrefConfig::DeleteGroup(const wxString& key)
232 {
233 /* TODO */
234 return false;
235 }
236
237 bool wxPrefConfig::DeleteAll()
238 {
239 /* TODO */
240 return false;
241 }
242
243 #endif // wxUSE_CONFIG && wxUSE_CONFIG_NATIVE