File: 0003-Add-C-class-to-library.patch

package info (click to toggle)
libminini 1.4%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, trixie
  • size: 268 kB
  • sloc: ansic: 1,149; cpp: 307; makefile: 63; sh: 6
file content (307 lines) | stat: -rw-r--r-- 10,536 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
From 8487af1b891a223d88bb8e54eb4cd313bd2dda34 Mon Sep 17 00:00:00 2001
From: yangfl <yangfl@users.noreply.github.com>
Date: Wed, 31 Jul 2019 09:48:30 +0800
Subject: [PATCH 3/3] Add C++ class to library

---
 minIni-cxx.cc | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++
 minIni.h      |  84 +++++++++++++++++++++++++++++++++++-
 2 files changed, 198 insertions(+), 2 deletions(-)
 create mode 100644 minIni-cxx.cc

diff --git a/minIni-cxx.cc b/minIni-cxx.cc
new file mode 100644
index 0000000..173041f
--- /dev/null
+++ b/minIni-cxx.cc
@@ -0,0 +1,116 @@
+/*  minIni - Multi-Platform INI file parser, suitable for embedded systems
+ *
+ *  These routines are in part based on the article "Multiplatform .INI Files"
+ *  by Joseph J. Graf in the March 1994 issue of Dr. Dobb's Journal.
+ *
+ *  Copyright (c) CompuPhase, 2008-2020
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ *  use this file except in compliance with the License. You may obtain a copy
+ *  of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ *  License for the specific language governing permissions and limitations
+ *  under the License.
+ *
+ *  Version: $Id: minIni.c 53 2015-01-18 13:35:11Z thiadmer.riemersma@gmail.com $
+ */
+
+#if (defined _UNICODE || defined __UNICODE__ || defined UNICODE) && !defined INI_ANSIONLY
+# if !defined UNICODE   /* for Windows */
+#   define UNICODE
+# endif
+# if !defined _UNICODE  /* for C library */
+#   define _UNICODE
+# endif
+#endif
+
+#define MININI_IMPLEMENTATION 0
+#include "minIni.h"
+#if defined NDEBUG
+  #define assert(e)
+#else
+  #include <assert.h>
+#endif
+
+
+minIni::minIni(const std::string& filename) : iniFilename(filename)
+  { }
+
+bool minIni::getbool(const std::string& Section, const std::string& Key, bool DefValue) const
+  { return ini_getbool(Section.c_str(), Key.c_str(), int(DefValue), iniFilename.c_str()) != 0; }
+
+long minIni::getl(const std::string& Section, const std::string& Key, long DefValue) const
+  { return ini_getl(Section.c_str(), Key.c_str(), DefValue, iniFilename.c_str()); }
+
+int minIni::geti(const std::string& Section, const std::string& Key, int DefValue) const
+  { return static_cast<int>(this->getl(Section, Key, long(DefValue))); }
+
+std::string minIni::gets(const std::string& Section, const std::string& Key, const std::string& DefValue) const
+  {
+    char buffer[INI_BUFFERSIZE];
+    ini_gets(Section.c_str(), Key.c_str(), DefValue.c_str(), buffer, INI_BUFFERSIZE, iniFilename.c_str());
+    return buffer;
+  }
+
+std::string minIni::getsection(int idx) const
+  {
+    char buffer[INI_BUFFERSIZE];
+    ini_getsection(idx, buffer, INI_BUFFERSIZE, iniFilename.c_str());
+    return buffer;
+  }
+
+std::string minIni::getkey(const std::string& Section, int idx) const
+  {
+    char buffer[INI_BUFFERSIZE];
+    ini_getkey(Section.c_str(), idx, buffer, INI_BUFFERSIZE, iniFilename.c_str());
+    return buffer;
+  }
+
+bool minIni::hassection(const std::string& Section) const
+  { return ini_hassection(Section.c_str(), iniFilename.c_str()) != 0; }
+
+bool minIni::haskey(const std::string& Section, const std::string& Key) const
+  { return ini_haskey(Section.c_str(), Key.c_str(), iniFilename.c_str()) != 0; }
+
+#if defined INI_REAL
+INI_REAL minIni::getf(const std::string& Section, const std::string& Key, INI_REAL DefValue) const
+  { return ini_getf(Section.c_str(), Key.c_str(), DefValue, iniFilename.c_str()); }
+#endif
+
+#if ! defined INI_READONLY
+bool minIni::put(const std::string& Section, const std::string& Key, long Value)
+  { return ini_putl(Section.c_str(), Key.c_str(), Value, iniFilename.c_str()) != 0; }
+
+bool minIni::put(const std::string& Section, const std::string& Key, int Value)
+  { return ini_putl(Section.c_str(), Key.c_str(), (long)Value, iniFilename.c_str()) != 0; }
+
+bool minIni::put(const std::string& Section, const std::string& Key, bool Value)
+  { return ini_putl(Section.c_str(), Key.c_str(), (long)Value, iniFilename.c_str()) != 0; }
+
+bool minIni::put(const std::string& Section, const std::string& Key, const std::string& Value)
+  { return ini_puts(Section.c_str(), Key.c_str(), Value.c_str(), iniFilename.c_str()) != 0; }
+
+bool minIni::put(const std::string& Section, const std::string& Key, const char* Value)
+  { return ini_puts(Section.c_str(), Key.c_str(), Value, iniFilename.c_str()) != 0; }
+
+#if defined INI_REAL
+bool minIni::put(const std::string& Section, const std::string& Key, INI_REAL Value)
+  { return ini_putf(Section.c_str(), Key.c_str(), Value, iniFilename.c_str()) != 0; }
+#endif
+
+bool minIni::del(const std::string& Section, const std::string& Key)
+  { return ini_puts(Section.c_str(), Key.c_str(), 0, iniFilename.c_str()) != 0; }
+
+bool minIni::del(const std::string& Section)
+  { return ini_puts(Section.c_str(), 0, 0, iniFilename.c_str()) != 0; }
+#endif
+
+#if !defined INI_NOBROWSE
+bool minIni::browse(INI_CALLBACK Callback, void *UserData) const
+  { return ini_browse(Callback, UserData, iniFilename.c_str()) != 0; }
+#endif
diff --git a/minIni.h b/minIni.h
index b63451c..d82411a 100644
--- a/minIni.h
+++ b/minIni.h
@@ -76,84 +76,164 @@ int  ini_browse(INI_CALLBACK Callback, void *UserData, const mTCHAR *Filename);
   #include <string>
 
   /* The C++ class in minIni.h was contributed by Steven Van Ingelgem. */
+#ifndef MININI_IMPLEMENTATION
+  #define MININI_IMPLEMENTATION 1
+#endif
   class minIni
   {
   public:
-    minIni(const std::string& filename) : iniFilename(filename)
-      { }
+    minIni(const std::string& filename)
+#if MININI_IMPLEMENTATION
+      : iniFilename(filename)
+       { }
+#else
+      ;
+#endif
 
     bool getbool(const std::string& Section, const std::string& Key, bool DefValue=false) const
+#if MININI_IMPLEMENTATION
       { return ini_getbool(Section.c_str(), Key.c_str(), int(DefValue), iniFilename.c_str()) != 0; }
+#else
+      ;
+#endif
 
     long getl(const std::string& Section, const std::string& Key, long DefValue=0) const
+#if MININI_IMPLEMENTATION
       { return ini_getl(Section.c_str(), Key.c_str(), DefValue, iniFilename.c_str()); }
+#else
+      ;
+#endif
 
     int geti(const std::string& Section, const std::string& Key, int DefValue=0) const
+#if MININI_IMPLEMENTATION
       { return static_cast<int>(this->getl(Section, Key, long(DefValue))); }
+#else
+      ;
+#endif
 
     std::string gets(const std::string& Section, const std::string& Key, const std::string& DefValue="") const
+#if MININI_IMPLEMENTATION
       {
         char buffer[INI_BUFFERSIZE];
         ini_gets(Section.c_str(), Key.c_str(), DefValue.c_str(), buffer, INI_BUFFERSIZE, iniFilename.c_str());
         return buffer;
       }
+#else
+      ;
+#endif
 
     std::string getsection(int idx) const
+#if MININI_IMPLEMENTATION
       {
         char buffer[INI_BUFFERSIZE];
         ini_getsection(idx, buffer, INI_BUFFERSIZE, iniFilename.c_str());
         return buffer;
       }
+#else
+      ;
+#endif
 
     std::string getkey(const std::string& Section, int idx) const
+#if MININI_IMPLEMENTATION
       {
         char buffer[INI_BUFFERSIZE];
         ini_getkey(Section.c_str(), idx, buffer, INI_BUFFERSIZE, iniFilename.c_str());
         return buffer;
       }
+#else
+      ;
+#endif
 
     bool hassection(const std::string& Section) const
+#if MININI_IMPLEMENTATION
       { return ini_hassection(Section.c_str(), iniFilename.c_str()) != 0; }
+#else
+      ;
+#endif
 
     bool haskey(const std::string& Section, const std::string& Key) const
+#if MININI_IMPLEMENTATION
       { return ini_haskey(Section.c_str(), Key.c_str(), iniFilename.c_str()) != 0; }
+#else
+      ;
+#endif
 
 #if defined INI_REAL
     INI_REAL getf(const std::string& Section, const std::string& Key, INI_REAL DefValue=0) const
+#if MININI_IMPLEMENTATION
       { return ini_getf(Section.c_str(), Key.c_str(), DefValue, iniFilename.c_str()); }
+#else
+      ;
+#endif
 #endif
 
 #if ! defined INI_READONLY
     bool put(const std::string& Section, const std::string& Key, long Value)
+#if MININI_IMPLEMENTATION
       { return ini_putl(Section.c_str(), Key.c_str(), Value, iniFilename.c_str()) != 0; }
+#else
+      ;
+#endif
 
     bool put(const std::string& Section, const std::string& Key, int Value)
+#if MININI_IMPLEMENTATION
       { return ini_putl(Section.c_str(), Key.c_str(), (long)Value, iniFilename.c_str()) != 0; }
+#else
+      ;
+#endif
 
     bool put(const std::string& Section, const std::string& Key, bool Value)
+#if MININI_IMPLEMENTATION
       { return ini_putl(Section.c_str(), Key.c_str(), (long)Value, iniFilename.c_str()) != 0; }
+#else
+      ;
+#endif
 
     bool put(const std::string& Section, const std::string& Key, const std::string& Value)
+#if MININI_IMPLEMENTATION
       { return ini_puts(Section.c_str(), Key.c_str(), Value.c_str(), iniFilename.c_str()) != 0; }
+#else
+      ;
+#endif
 
     bool put(const std::string& Section, const std::string& Key, const char* Value)
+#if MININI_IMPLEMENTATION
       { return ini_puts(Section.c_str(), Key.c_str(), Value, iniFilename.c_str()) != 0; }
+#else
+      ;
+#endif
 
 #if defined INI_REAL
     bool put(const std::string& Section, const std::string& Key, INI_REAL Value)
+#if MININI_IMPLEMENTATION
       { return ini_putf(Section.c_str(), Key.c_str(), Value, iniFilename.c_str()) != 0; }
+#else
+      ;
+#endif
 #endif
 
     bool del(const std::string& Section, const std::string& Key)
+#if MININI_IMPLEMENTATION
       { return ini_puts(Section.c_str(), Key.c_str(), 0, iniFilename.c_str()) != 0; }
+#else
+      ;
+#endif
 
     bool del(const std::string& Section)
+#if MININI_IMPLEMENTATION
       { return ini_puts(Section.c_str(), 0, 0, iniFilename.c_str()) != 0; }
+#else
+      ;
+#endif
 #endif
 
 #if !defined INI_NOBROWSE
     bool browse(INI_CALLBACK Callback, void *UserData) const
+#if MININI_IMPLEMENTATION
       { return ini_browse(Callback, UserData, iniFilename.c_str()) != 0; }
+#else
+      ;
+#endif
 #endif
 
   private:
-- 
2.35.1