-
Notifications
You must be signed in to change notification settings - Fork 1
/
inifiles.cpp
955 lines (838 loc) · 22.6 KB
/
inifiles.cpp
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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
/*
Authors : Guru Kathiresan - [email protected] ,
FreePascal Team - http://www.freepascal.org
License :
Short Verion : wxVCL is distributed under Modified LGPL
(the same license used by FCL, LCL). In short,
this license allows you to use wxVCL in your application either
statically or dynamically linked (and keep your source code as
closed source) but you cannot sell wxVCL alone as a seperate
product or claim owner ship for it and when you make a change to
the wxVCL library (not your application code), you have to give
the changes (of the wxVCL library code) back to the community.
Long Version : The source code of wxVCL is distributed under the
Library GNU General Public License with the following modification:
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent modules,
and to copy and distribute the resulting executable under terms of your choice,
provided that you also meet, for each linked independent module, the terms
and conditions of the license of that module. An independent module is a module
which is not derived from or based on this library. If you modify this
library, you may extend this exception to your version of the library, but you are
not obligated to do so. If you do not wish to do so, delete this exception
statement from your version.
*/
#include "inifiles.h"
#include <wx/wx.h>
#include <wx/datetime.h>
#include "sysconst.h"
#include "strutils.h"
#include "sysutils.h"
#include "system.h"
#include "classes.h"
TIniFile::TIniFile(const wxString &FileName)
{
FFileName = FileName;
FFileBuffer = new TStringList;
if (FileExists(FileName))
{
LoadFromFile();
}
}
TIniFile::TIniFile(const wxString &StringContent, bool bStringContent)
{
wxUnusedVar(bStringContent);
FFileBuffer = new TStringList;
FFileBuffer->SetText(StringContent);
}
TIniFile::~TIniFile()
{
delete FFileBuffer;
}
bool TIniFile::ValueExists(const wxString &Section, const wxString &Ident)
{
if (IsStringEmpty(ReadString(Section, Ident, wxT(""))))
return false;
else
return true;
}
wxString TIniFile::GetName(const wxString &Line)
{
wxString result;
int I;
I = Pos(IniSeparator, Line);
if (I != 0)
result = Trim(Copy(Line, 0, I - 1));
else
result = EmptyStr;
return result;
}
wxString TIniFile::GetValue(const wxString &Line, const wxString &Name)
{
wxString result = EmptyStr;
int I;
int J;
if ((Line != EmptyStr) && (Name != EmptyStr))
{
I = Pos(Name, Line);
J = Pos(IniSeparator, Line);
if ((I != -1) && (J != -1) && (J > I))
result = Trim(Copy(Line, J + 1, MaxInt));
}
return result;
}
bool TIniFile::IsSection(const wxString &Line)
{
bool result = false;
wxString S;
if (Line != EmptyStr)
{
S = Trim(Line);
if ((S[0] == IniBrackets[0]) && (S[(unsigned int) Length(S) -
1] == IniBrackets[1]))
result = true;
}
return result;
}
int TIniFile::GetSectionIndex(const wxString &Section)
{
int result;
result = FFileBuffer->IndexOf(IniBrackets[0] + Section +
IniBrackets[1], true);
return result;
}
void TIniFile::LoadFromFile()
{
if (FileExists(FFileName) == false)
{
FFileBuffer->Clear();
return;
}
FFileBuffer->LoadFromFile(FFileName);
}
void TIniFile::SaveToFile()
{
FFileBuffer->SaveToFile(FFileName, true);
}
/* Read all Names of one Section */
void TIniFile::ReadSection(const wxString &Section, TStringList &Strings)
{
int I;
wxString N;
Strings.BeginUpdate();
Strings.Clear();
if (FFileBuffer->Count() > 0)
{
I = GetSectionIndex(Section);
if (I != -1)
{
++I;
while ((I < FFileBuffer->Count()) && !IsSection
(FFileBuffer->Item(I)))
{
N = GetName(FFileBuffer->Item(I));
if (N != EmptyStr)
Strings.Add(N);
++I;
}
}
}
}
/* Read all Sections of the Ini-File */
void TIniFile::ReadSections(TStringList &Strings)
{
long I;
wxString Section;
// Assert( !! Strings , SStringsUnassignedError );
Strings.BeginUpdate();
try
{
Strings.Clear();
if (FFileBuffer->Count() > 0)
{
I = 0;
while ((I < FFileBuffer->Count()))
{
if (IsSection(FFileBuffer->Item(I)))
{
Section = Trim(FFileBuffer->Item(I));
Delete(Section, 0, 1);
Delete(Section, Length(Section) - 1, 1);
Strings.Add(Trim(Section));
}
++I;
}
}
} /* ? *//* FINALLY */
catch (...)
{
Strings.EndUpdate();
}
}
/* Reads a String-Value of Ident in one Section.
The result is Default if
o Section doesn't exists
o Ident doesn't exists
o Ident doesn't have any assigned value */
wxString TIniFile::ReadString(const wxString &Section, const wxString &Ident,
const wxString &Default)
{
wxString result;
int I;
wxString V;
result = Default;
if (FFileBuffer->Count() > 0)
{
I = GetSectionIndex(Section);
if (I != -1)
{
++I;
while ((I < FFileBuffer->Count()) && !IsSection
(FFileBuffer->Item(I)))
{
wxString vName = GetName(FFileBuffer->Item(I));
if (vName.CmpNoCase(Ident) == 0)
{
V = GetValue(FFileBuffer->Item(I), Ident);
if (V != EmptyStr)
result = V;
return result;
}
++I;
}
}
}
return result;
}
/* Reads an Integer-Value of Ident in one Section */
long TIniFile::ReadInteger(const wxString &Section, const wxString &Ident,
long Default)
{
long result;
wxString IntStr;
IntStr = ReadString(Section, Ident, wxT(""));
// convert a Hex-Value
if ((Length(IntStr) > 2) && (IntStr.GetChar(1) == '0') &&
((IntStr.GetChar(2) == 'X') || (IntStr.GetChar(2) == 'x')))
IntStr = wxT("$") + Copy(IntStr, 3, MaxInt);
result = StrToIntDef(IntStr, Default);
return result;
}
/* Reads a Bool-Value of Ident in one Section */
bool TIniFile::ReadBool(const wxString &Section, const wxString &Ident,
bool Default)
{
bool result;
result = ReadInteger(Section, Ident, Ord(Default)) != 0;
return result;
}
float TIniFile::ReadFloat(const wxString &Section, const wxString &Ident,
float Default)
{
return StrToFloatDef(ReadString(Section, Ident, FloatToStr(Default)),
Default);
}
double TIniFile::ReadDouble(const wxString &Section, const wxString &Ident,
double Default)
{
return StrToDouble(ReadString(Section, Ident, DoubleToStr(Default)));
}
unsigned long TIniFile::ReadULong(const wxString &Section,
const wxString &Ident, unsigned long Default)
{
return StrToULong(ReadString(Section, Ident, ULongToStr(Default)));
}
wxLongLong TIniFile::ReadLongLong(const wxString &Section, const wxString &Ident,
wxLongLong Default)
{
wxString str = ReadString(Section, Ident, Default.ToString());
wxLongLong lng = StrToLongLong(str);
return lng;
}
long TIniFile::ReadLong(const wxString &Section, const wxString &Ident,
long Default)
{
return StrToLong(ReadString(Section, Ident, LongToStr(Default)));
}
wxDateTime TIniFile::ReadDateTime(const wxString &Section,
const wxString &Ident, wxDateTime Default)
{
return StrToDateTime(ReadString(Section, Ident, DateTimeToStr(Default)));
}
wxDateTime TIniFile::ReadULongDateTime(const wxString &Section,
const wxString &Ident, wxDateTime Default)
{
unsigned long WxTicks = ReadULong(Section, Ident, Default.GetTicks());
wxDateTime Result((time_t)WxTicks);
return Result;
}
wxDateTime TIniFile::ReadDate(const wxString &Section, const wxString &Ident,
wxDateTime Default)
{
wxLongLong ticks = ReadLongLong(Section, Ident, Default.GetTicks());
if (ticks == 0 || ticks == -1)
return Default;
wxDateTime result (ticks);
if (result.IsValid())
return result;
else
return Default;
}
wxDateTime TIniFile::ReadTime(const wxString &Section, const wxString &Ident,
wxDateTime Default)
{
long ticks = ReadLong(Section, Ident, Default.GetTicks());
if (ticks == 0)
return Default;
wxDateTime result (ticks);
if (result.IsValid())
return result;
else
return Default;
}
wxColour TIniFile::ReadColor(const wxString & Section, const wxString & Ident,
wxColour Default)
{
return StrToColor(ReadString(Section, Ident, ColorToStr(Default)));
}
wxFont TIniFile::ReadFont(const wxString & Section, const wxString & Ident,
wxFont Default)
{
return StrToFont(ReadString(Section, Ident, FontToStr(Default)));
}
wxPoint TIniFile::ReadPoint(const wxString & Section, const wxString & Ident,
wxPoint Default)
{
return StrToPoint(ReadString(Section, Ident, PointToStr(Default)));
}
wxRealPoint TIniFile::ReadRealPoint(const wxString & Section,
const wxString & Ident, wxRealPoint Default)
{
return StrToRealPoint(ReadString(Section, Ident, RealPointToStr(Default)));
}
wxRect TIniFile::ReadRect(const wxString & Section, const wxString & Ident,
wxRect Default)
{
return StrToRect(ReadString(Section, Ident, RectToStr(Default)));
}
wxSize TIniFile::ReadSize(const wxString & Section, const wxString & Ident,
wxSize Default)
{
return StrToSize(ReadString(Section, Ident, SizeToStr(Default)));
}
/* Reads all Names + Values of one Section */
void TIniFile::ReadSectionValues(const wxString &Section, TStringList &Strings)
{
wxString N;
wxString V;
int I;
// Assert( !! Strings , SStringsUnassignedError );
Strings.BeginUpdate();
try
{
Strings.Clear();
if (FFileBuffer->Count() > 0)
{
I = GetSectionIndex(Section);
if (I != -1)
{
++I;
while ((I < FFileBuffer->Count()) && !IsSection
(FFileBuffer->Item(I)))
{
N = GetName(FFileBuffer->Item(I));
if (N != EmptyStr)
{
V = GetValue(FFileBuffer->Item(I), N);
Strings.Add(N + IniSeparator + V);
}
++I;
}
}
}
} /* ? *//* FINALLY */
catch (...)
{
Strings.EndUpdate();
}
}
void TIniFile::ReadSectionNames(const wxString &Section, TStringList &Strings)
{
wxString N;
wxString V;
int I;
// Assert( !! Strings , SStringsUnassignedError );
Strings.BeginUpdate();
try
{
Strings.Clear();
if (FFileBuffer->Count() > 0)
{
I = GetSectionIndex(Section);
if (I != -1)
{
++I;
while ((I < FFileBuffer->Count()) && !IsSection
(FFileBuffer->Item(I)))
{
N = GetName(FFileBuffer->Item(I));
if (N != EmptyStr)
{
Strings.Add(N);
}
++I;
}
}
}
} /* ? *//* FINALLY */
catch (...)
{
Strings.EndUpdate();
}
}
void TIniFile::ReadSectionNamesValues(const wxString &Section,
TStringList &NameStrings, TStringList &ValueStrings)
{
wxString N;
wxString V;
int I;
// Assert( !! NameStrings , SStringsUnassignedError );
NameStrings.BeginUpdate();
try
{
NameStrings.Clear();
if (FFileBuffer->Count() > 0)
{
I = GetSectionIndex(Section);
if (I != -1)
{
++I;
while ((I < FFileBuffer->Count()) && !IsSection
(FFileBuffer->Item(I)))
{
N = GetName(FFileBuffer->Item(I));
V = GetValue(FFileBuffer->Item(I), N);
if (N != EmptyStr)
{
NameStrings.Add(N);
ValueStrings.Add(V);
}
++I;
}
}
}
} /* ? *//* FINALLY */
catch (...)
{
NameStrings.EndUpdate();
}
}
/* Writes a String-Value for Ident in one Section.
Note: If Section and/or Ident don't exist, they will be placed in the Ini-File */
void TIniFile::WriteString(const wxString &Section, const wxString &Ident,
const wxString &Value)
{
int I;
I = GetSectionIndex(Section);
// Section exists
if (I != -1)
{
++I;
while ((I < FFileBuffer->Count()) && !IsSection(FFileBuffer->Item(I)) &&
(GetName(FFileBuffer->Item(I)) != Ident))
++I;
// End of File or Ident doesn't exists in the Section
if ((I >= FFileBuffer->Count()) || IsSection(FFileBuffer->Item(I)))
{
if (Ident != EmptyStr)
FFileBuffer->Insert(I, Ident + IniSeparator + Value);
}
// Ident does exists in the section
else if (Ident != EmptyStr)
FFileBuffer->Item(I) = Ident + IniSeparator + Value;
}
// Section doesn't exists, so add new [Section] with Ident=Value
else
{
FFileBuffer->Add(EmptyStr);
FFileBuffer->Add(IniBrackets[0] + Section + IniBrackets[1]);
if (Ident != EmptyStr)
FFileBuffer->Add(Ident + IniSeparator + Value);
}
SaveToFile();
}
/* Writes an Integer-Value for Ident in one Section */
void TIniFile::WriteInteger(const wxString &Section, const wxString &Ident,
long Value)
{
WriteString(Section, Ident, IntToStr(Value));
}
/* Writes a Bool-Value for Ident in one Section */
void TIniFile::WriteBool(const wxString &Section, const wxString &Ident,
bool Value)
{
wxString StrValue;
if ((Value == true))
StrValue = wxT("1");
else
StrValue = wxT("0");
WriteString(Section, Ident, StrValue);
}
void TIniFile::WriteFloat(const wxString &Section, const wxString &Ident,
float Value)
{
WriteString(Section, Ident, FloatToStr(Value));
}
void TIniFile::WriteDouble(const wxString &Section, const wxString &Ident,
double Value)
{
WriteString(Section, Ident, DoubleToStr(Value));
}
void TIniFile::WriteULong(const wxString &Section, const wxString &Ident,
unsigned long Value)
{
WriteString(Section, Ident, ULongToStr(Value));
}
void TIniFile::WriteLong(const wxString &Section, const wxString &Ident,
long Value)
{
WriteString(Section, Ident, LongToStr(Value));
}
void TIniFile::WriteLongLong(const wxString &Section, const wxString &Ident,
wxLongLong Value)
{
WriteString(Section, Ident, Value.ToString());
}
void TIniFile::WriteDateTime(const wxString &Section, const wxString &Ident,
wxDateTime Value)
{
WriteString(Section, Ident, DateTimeToStr(Value));
}
void TIniFile::WriteULongDateTime(const wxString &Section,
const wxString &Ident, wxDateTime Value)
{
WriteULong(Section, Ident, Value.GetTicks());
}
void TIniFile::WriteDate(const wxString &Section, const wxString &Ident,
wxDateTime Value)
{
WriteLongLong(Section, Ident, Value.GetTicks());
}
void TIniFile::WriteTime(const wxString &Section, const wxString &Ident,
wxDateTime Value)
{
WriteLong(Section, Ident, Value.GetTicks());
}
void TIniFile::WriteDateSpan(const wxString & Section, const wxString & Ident,
wxDateSpan Value)
{
WriteString(Section, Ident, DateSpanToStr(Value));
}
void TIniFile::WriteColor(const wxString & Section, const wxString & Ident,
wxColour Value)
{
WriteString(Section, Ident, ColorToStr(Value));
}
void TIniFile::WriteFont(const wxString & Section, const wxString & Ident,
wxFont Value)
{
WriteString(Section, Ident, FontToStr(Value));
}
void TIniFile::WritePoint(const wxString & Section, const wxString & Ident,
wxPoint Value)
{
WriteString(Section, Ident, PointToStr(Value));
}
void TIniFile::WriteRealPoint(const wxString & Section, const wxString & Ident,
wxRealPoint Value)
{
WriteString(Section, Ident, RealPointToStr(Value));
}
void TIniFile::WriteRect(const wxString & Section, const wxString & Ident,
wxRect Value)
{
WriteString(Section, Ident, RectToStr(Value));
}
void TIniFile::WriteSize(const wxString & Section, const wxString & Ident,
wxSize Value)
{
WriteString(Section, Ident, SizeToStr(Value));
}
void TIniFile::WriteStringList(const wxString & Section, const wxString & Ident,
wxArrayString Value)
{
EraseSection(Section);
for (int i = 0; i < Value.GetCount(); i++)
{
this->WriteString(Section, wxString::Format("%s%d", Ident, i),Value.Item(i));
}
}
void TIniFile::WriteStringList(const wxString & Section, const wxString & Ident,
TStringList& Value)
{
EraseSection(Section);
for (int i = 0; i < Value.GetCount(); i++)
{
this->WriteString(Section, wxString::Format("%s%d", Ident, (i)),
Value.Item(i));
}
}
/* Deletes the Value of Ident in one Section.
Note: Only if Section and Ident exist, the Value of Ident will be set to NULL */
void TIniFile::DeleteKey(const wxString &Section, const wxString &Ident)
{
long I;
I = GetSectionIndex(Section);
if (I != -1)
{
++I;
while ((I < FFileBuffer->Count()) && !IsSection(FFileBuffer->Item(I)) &&
(GetName(FFileBuffer->Item(I)) != Ident))
++I;
// Ident does exists
if (!(I >= FFileBuffer->Count()) && !IsSection(FFileBuffer->Item(I)))
{
FFileBuffer->Delete(I);
SaveToFile();
}
}
}
/* Erases the whole Section from an Ini-File */
void TIniFile::EraseSection(const wxString &Section)
{
long I;
I = GetSectionIndex(Section);
if (I != -1)
{
// Delete Section-Header
FFileBuffer->Delete(I);
// Delete Section-Items
while ((I < FFileBuffer->Count()) && !IsSection(FFileBuffer->Item(I)))
FFileBuffer->Delete(I);
if (I > 0)
FFileBuffer->Insert(I, EmptyStr);
SaveToFile();
}
}
wxString TIniFile::FileName(void)
{
return FFileName;
}
void TIniFile::FileName(wxString FName)
{
FFileName = FName;
LoadFromFile();
}
bool WriteIntToIni(const wxString &FileName, const wxString &Section,
const wxString &Name, int Value)
{
TIniFile ini(FileName);
ini.WriteInteger(Section, Name, Value);
return true;
}
int ReadIntFromIni(const wxString &FileName, const wxString &Section,
const wxString &Name, int DefaultValue)
{
TIniFile ini(FileName);
return ini.ReadInteger(Section, Name, DefaultValue);
}
bool WriteBoolToIni(const wxString &FileName, const wxString &Section,
const wxString &Name, bool Value)
{
TIniFile ini(FileName);
ini.WriteBool(Section, Name, Value);
return true;
}
bool ReadBoolFromIni(const wxString &FileName, const wxString &Section,
const wxString &Name, bool DefaultValue)
{
TIniFile ini(FileName);
return ini.ReadBool(Section, Name, DefaultValue);
}
bool WriteLongToIni(const wxString &FileName, const wxString &Section,
const wxString &Name, long Value)
{
// fixme: Fix the Write function for Long
TIniFile ini(FileName);
ini.WriteLong(Section, Name, Value);
return true;
}
long ReadLongFromIni(const wxString &FileName, const wxString &Section,
const wxString &Name, long DefaultValue)
{
// fixme: Fix the Write function for Long
TIniFile ini(FileName);
return ini.ReadLong(Section, Name, DefaultValue);
}
bool WriteULongToIni(const wxString &FileName, const wxString &Section,
const wxString &Name, unsigned long Value)
{
// fixme: Fix the Write function for Long
TIniFile ini(FileName);
ini.WriteULong(Section, Name, Value);
return true;
}
unsigned long ReadULongFromIni(const wxString &FileName,
const wxString &Section, const wxString &Name, unsigned long DefaultValue)
{
// fixme: Fix the Write function for Long
TIniFile ini(FileName);
return ini.ReadULong(Section, Name, DefaultValue);
}
bool WriteStringToIni(const wxString &FileName, const wxString &Section,
const wxString &Name, const wxString &Value)
{
TIniFile ini(FileName);
ini.WriteString(Section, Name, Value);
return true;
}
wxString ReadStringFromIni(const wxString &FileName, const wxString &Section,
const wxString &Name, const wxString &DefaultValue)
{
TIniFile ini(FileName);
return ini.ReadString(Section, Name, DefaultValue);
}
bool WriteDoubleToIni(const wxString &FileName, const wxString &Section,
const wxString &Name, double Value)
{
TIniFile ini(FileName);
ini.WriteDouble(Section, Name, Value);
return true;
}
double ReadDoubleFromIni(const wxString &FileName, const wxString &Section,
const wxString &Name, double DefaultValue)
{
TIniFile ini(FileName);
return ini.ReadDouble(Section, Name, DefaultValue);
}
bool WriteULongDateTimeToIni(const wxString & FileName,
const wxString & Section, const wxString & Name, wxDateTime Value)
{
TIniFile ini(FileName);
ini.WriteULongDateTime(Section, Name, Value);
return true;
}
wxDateTime ReadULongDateTimeFromIni(const wxString & FileName,
const wxString & Section, const wxString & Name, wxDateTime DefaultValue)
{
TIniFile ini(FileName);
return ini.ReadULongDateTime(Section, Name, DefaultValue);
}
bool WriteDateTimeToIni(const wxString & FileName, const wxString & Section,
const wxString & Name, wxDateTime Value)
{
TIniFile ini(FileName);
ini.WriteDateTime(Section, Name, Value);
return true;
}
wxDateTime ReadDateTimeFromIni(const wxString & FileName,
const wxString & Section, const wxString & Name, wxDateTime DefaultValue)
{
TIniFile ini(FileName);
return ini.ReadDateTime(Section, Name, DefaultValue);
}
bool WriteDateToIni(const wxString & FileName, const wxString & Section,
const wxString & Name, wxDateTime Value)
{
TIniFile ini(FileName);
ini.WriteDate(Section, Name, Value);
return true;
}
wxDateTime ReadDateFromIni(const wxString & FileName, const wxString & Section,
const wxString & Name, wxDateTime DefaultValue)
{
TIniFile ini(FileName);
return ini.ReadDate(Section, Name, DefaultValue);
}
bool WriteTimeToIni(const wxString & FileName, const wxString & Section,
const wxString & Name, wxDateTime Value)
{
TIniFile ini(FileName);
ini.WriteTime(Section, Name, Value);
return true;
}
wxDateTime ReadTimeFromIni(const wxString & FileName, const wxString & Section,
const wxString & Name, wxDateTime DefaultValue)
{
TIniFile ini(FileName);
return ini.ReadTime(Section, Name, DefaultValue);
}
bool WriteColorToIni(const wxString & FileName, const wxString & Section,
const wxString & Name, wxColour Value)
{
TIniFile ini(FileName);
ini.WriteColor(Section, Name, Value);
return true;
}
wxColour ReadColorFromIni(const wxString & FileName, const wxString & Section,
const wxString & Name, wxColour DefaultValue)
{
TIniFile ini(FileName);
return ini.ReadColor(Section, Name, DefaultValue);
}
bool WriteFontToIni(const wxString & FileName, const wxString & Section,
const wxString & Name, wxFont Value)
{
TIniFile ini(FileName);
ini.WriteFont(Section, Name, Value);
return true;
}
wxFont ReadFontFromIni(const wxString & FileName, const wxString & Section,
const wxString & Name, wxFont DefaultValue)
{
TIniFile ini(FileName);
return ini.ReadFont(Section, Name, DefaultValue);
}
bool WritePointToIni(const wxString & FileName, const wxString & Section,
const wxString & Name, wxPoint Value)
{
TIniFile ini(FileName);
ini.WritePoint(Section, Name, Value);
return true;
}
wxPoint ReadPointFromIni(const wxString & FileName, const wxString & Section,
const wxString & Name, wxPoint DefaultValue)
{
TIniFile ini(FileName);
return ini.ReadPoint(Section, Name, DefaultValue);
}
bool WriteRealPointToIni(const wxString & FileName, const wxString & Section,
const wxString & Name, wxRealPoint Value)
{
TIniFile ini(FileName);
ini.WriteRealPoint(Section, Name, Value);
return true;
}
wxRealPoint ReadRealPointFromIni(const wxString & FileName,
const wxString & Section, const wxString & Name, wxRealPoint DefaultValue)
{
TIniFile ini(FileName);
return ini.ReadRealPoint(Section, Name, DefaultValue);
}
bool WriteRectToIni(const wxString & FileName, const wxString & Section,
const wxString & Name, wxRect Value)
{
TIniFile ini(FileName);
ini.WriteRect(Section, Name, Value);
return true;
}
wxRect ReadRectFromIni(const wxString & FileName, const wxString & Section,
const wxString & Name, wxRect DefaultValue)
{
TIniFile ini(FileName);
return ini.ReadRect(Section, Name, DefaultValue);
}
bool WriteSizeToIni(const wxString & FileName, const wxString & Section,
const wxString & Name, wxSize Value)
{
TIniFile ini(FileName);
ini.WriteSize(Section, Name, Value);
return true;
}
wxSize ReadSizeFromIni(const wxString & FileName, const wxString & Section,
const wxString & Name, wxSize DefaultValue)
{
TIniFile ini(FileName);
return ini.ReadSize(Section, Name, DefaultValue);
}