00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143 #ifndef INC_MI32_INIDEFNS_H
00144 #define INC_MI32_INIDEFNS_H
00145
00146 #ifndef INC_MI32_STDDEFNS_H
00147 #include <mi32/stddefns.h>
00148 #endif
00149
00150 #ifndef INC_MI32_COLOR_H
00151 #include <mi32/color.h>
00152 #endif
00153
00154 #ifndef INC_MI32_MAPPROJ_H
00155 #include <mi32/mapproj.h>
00156 #endif
00157
00158 #ifndef INC_MI32_FILEPATH_H
00159 #include <mi32/filepath.h>
00160 #endif
00161
00162
00163 #ifdef MISYSTEMDLL
00164 #define LIBEXPORT MI_DLLEXPORT
00165 #else
00166 #define LIBEXPORT MI_DLLIMPORT
00167 #endif
00168
00169
00170 #define INITYPE_IniStruct 0x01000000
00171 #define INITYPE_End 0
00172 #define INITYPE_ByteBoolean 1
00173 #define INITYPE_IntBoolean 2
00174 #define INITYPE_INT8 3
00175 #define INITYPE_UINT8 4
00176 #define INITYPE_INT16 5
00177 #define INITYPE_UINT16 6
00178 #define INITYPE_INT32 7
00179 #define INITYPE_UINT32 8
00180 #define INITYPE_Float 9
00181 #define INITYPE_Double 10
00182 #define INITYPE_String 11
00183 #define INITYPE_ASCII INITYPE_String
00184 #define INITYPE_Unicode 12
00185 #define INITYPE_UNICODE INITYPE_Unicode
00186 #define INITYPE_DPOINT2D 13|INITYPE_IniStruct
00187 #define INITYPE_DPOINT3D 14|INITYPE_IniStruct
00188 #define INITYPE_MAPPROJPARM 15|INITYPE_IniStruct
00189 #define INITYPE_COLOR 17|INITYPE_IniStruct
00190 #define INITYPE_DRECT2D 18|INITYPE_IniStruct
00191 #define INITYPE_Bool 19
00192
00193
00194 #define INIFILE_Standard "tntproc.ini"
00195 #define INIFILE_Host "tnthost.ini"
00196
00197
00198 #define INIFLAG_None 0
00199 #define INIFLAG_WriteRequired 0x00000002
00200 #define INIFLAG_ReadOnly 0x00000004
00201 #define INIFLAG_InternalOnly 0x00000010
00202
00203
00204
00205
00206
00207
00208 extern "C" {
00209
00210 #ifndef GENERATING_DOXYGEN_OUTPUT
00211
00212
00213 LIBEXPORT INT32 _iniRead (
00214 INIHANDLE iniptr,
00215 const char* group,
00216 const char*const field,
00217 UINT32 initype,
00218 void *data,
00219 INT32 count = 1
00220 );
00221
00222 LIBEXPORT INT32 _iniReadString (
00223 INIHANDLE iniptr,
00224 const char* group,
00225 const char*const field,
00226 UINT32 initype,
00227 void *data,
00228 INT32 len
00229 );
00230
00231 LIBEXPORT INT32 _iniReadStringAllocML (
00232 INIHANDLE iniptr,
00233 const char* group,
00234 const char*const field,
00235 UINT32 initype,
00236 void **data
00237 );
00238
00239 LIBEXPORT int _iniWrite (
00240 INIHANDLE iniptr,
00241 const char* group,
00242 const char* field,
00243 UINT32 initype,
00244 const void *data,
00245 INT32 count
00246 );
00247
00248 LIBEXPORT int _iniWriteString (
00249 INIHANDLE iniptr,
00250 const char *group,
00251 const char *field,
00252 UINT32 initype,
00253 const void *data
00254 );
00255
00256 LIBEXPORT int _iniWriteStringML (
00257 INIHANDLE iniptr,
00258 const char *group,
00259 const char *field,
00260 UINT32 initype,
00261 const void *data
00262 );
00263
00264 #endif // GENERATING_DOXYGEN_OUTPUT
00265
00266
00267
00268
00269
00270
00271
00272
00273 LIBEXPORT void IniClose (
00274 INIHANDLE iniptr
00275 );
00276
00277
00278 LIBEXPORT int IniDeleteField (
00279 INIHANDLE iniptr,
00280 const char* group,
00281 const char* field
00282 );
00283
00284
00285 LIBEXPORT int IniDeleteGroup (
00286 INIHANDLE iniptr,
00287 const char* group
00288 );
00289
00290
00291
00292 LIBEXPORT int IniGetBuffer (
00293 INIHANDLE iniptr,
00294 UNICODE **buffer
00295 );
00296
00297
00298
00299 LIBEXPORT const FILEPATH& IniGetFilePath (
00300 INIHANDLE inihandle
00301 );
00302
00303
00304
00305 LIBEXPORT int IniIsWritable (
00306 INIHANDLE iniptr
00307 );
00308
00309
00310 LIBEXPORT ERRVALUE IniListAdd (
00311 const FILEPATH& filepath
00312 );
00313
00314
00315 LIBEXPORT void IniListClear (
00316 );
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332 LIBEXPORT int IniOpen (
00333 const char *basefilename,
00334 INIHANDLE *iniptr,
00335 UINT32 flags = INIFLAG_None
00336 );
00337
00338
00339 LIBEXPORT void IniSetAppName (
00340 const char *AppName
00341 );
00342
00343
00344 LIBEXPORT int IniSetBuffer (
00345 INIHANDLE iniptr,
00346 UNICODE *buffer
00347 );
00348
00349
00350
00351
00352
00353
00354 LIBEXPORT int IniWriteBoolean (
00355 INIHANDLE iniptr,
00356 const char *group,
00357 const char *field,
00358 int value
00359 );
00360
00361 }
00362
00363
00364 LIBEXPORT ERRVALUE IniOpen (
00365 const FILEPATH& filepath,
00366 INIHANDLE *iniptr,
00367 UINT32 flags = INIFLAG_None
00368 );
00369
00370
00371 #ifndef GENERATING_DOXYGEN_OUTPUT
00372
00373
00374 #if defined(MISYSTEMDLL)
00375
00376 extern "C" {
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392 LIBEXPORT INT32 IniReadString (
00393 INIHANDLE iniptr,
00394 const char* group,
00395 const char*const field,
00396 UINT32 initype,
00397 void *data,
00398 INT32 len
00399 );
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409 LIBEXPORT INT32 IniReadStringAlloc (
00410 INIHANDLE iniptr,
00411 const char* group,
00412 const char*const field,
00413 void **data,
00414 UINT32 initype
00415 );
00416
00417
00418
00419
00420
00421
00422 LIBEXPORT INT32 IniReadStringAllocML (
00423 INIHANDLE iniptr,
00424 const char* group,
00425 const char*const field,
00426 UINT32 initype,
00427 void **data
00428 );
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441 LIBEXPORT int IniWriteString (
00442 INIHANDLE iniptr,
00443 const char *group,
00444 const char *field,
00445 UINT32 initype,
00446 const void *data
00447 );
00448
00449
00450
00451
00452 LIBEXPORT int IniWriteStringML (
00453 INIHANDLE iniptr,
00454 const char *group,
00455 const char *field,
00456 UINT32 initype,
00457 const void *data
00458 );
00459
00460 }
00461
00462 #endif
00463
00464 #endif // GENERATING_DOXYGEN_OUTPUT
00465
00466
00467
00468
00469 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, bool& value) { return (_iniRead(hdl,group,field,INITYPE_Bool,&value,1)); }
00470
00471
00472 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, bool& value, bool dft) { value = dft; return (IniRead(hdl,group,field,value)); }
00473
00474
00475 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, INT8& value) { return (_iniRead(hdl,group,field,INITYPE_INT8,&value,1)); }
00476
00477
00478 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, INT8& value, INT8 dft) { value = dft; return (IniRead(hdl,group,field,value)); }
00479
00480
00481 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, INT8& value, INT8 dft, INT8 min, INT8 max) { value = dft; int err = IniRead(hdl,group,field,value); if (value < min) value = min; else if (value > max) value = max; return (err); }
00482
00483
00484 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, UINT8& value) { return (_iniRead(hdl,group,field,INITYPE_UINT8,&value,1)); }
00485
00486
00487 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, UINT8& value, UINT8 dft) { value = dft; return (IniRead(hdl,group,field,value)); }
00488
00489
00490 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, UINT8& value, UINT8 dft, UINT8 min, UINT8 max) { value = dft; int err = IniRead(hdl,group,field,value); if (value < min) value = min; else if (value > max) value = max; return (err); }
00491
00492
00493 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, INT16& value) { return (_iniRead(hdl,group,field,INITYPE_INT16,&value,1)); }
00494
00495
00496 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, INT16& value, INT16 dft) { value = dft; return (IniRead(hdl,group,field,value)); }
00497
00498
00499 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, INT16& value, INT16 dft, INT16 min, INT16 max) { value = dft; int err = IniRead(hdl,group,field,value); if (value < min) value = min; else if (value > max) value = max; return (err); }
00500
00501
00502 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, UINT16& value) { return (_iniRead(hdl,group,field,INITYPE_UINT16,&value,1)); }
00503
00504
00505 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, UINT16& value, UINT16 dft) { value = dft; return (IniRead(hdl,group,field,value)); }
00506
00507
00508 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, UINT16& value, UINT16 dft, UINT16 min, UINT16 max) { value = dft; int err = IniRead(hdl,group,field,value); if (value < min) value = min; else if (value > max) value = max; return (err); }
00509
00510
00511 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, INT32& value) { return (_iniRead(hdl,group,field,INITYPE_INT32,&value,1)); }
00512
00513
00514 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, INT32& value, INT32 dft) { value = dft; return (IniRead(hdl,group,field,value)); }
00515
00516
00517 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, INT32& value, INT32 dft, INT32 min, INT32 max) { value = dft; int err = IniRead(hdl,group,field,value); if (value < min) value = min; else if (value > max) value = max; return (err); }
00518
00519
00520 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, UINT32& value) { return (_iniRead(hdl,group,field,INITYPE_UINT32,&value,1)); }
00521
00522
00523 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, UINT32& value, UINT32 dft) { value = dft; return (IniRead(hdl,group,field,value)); }
00524
00525
00526 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, UINT32& value, UINT32 dft, UINT32 min, UINT32 max) { value = dft; int err = IniRead(hdl,group,field,value); if (value < min) value = min; else if (value > max) value = max; return (err); }
00527
00528 #if defined(WIN32)
00529
00530
00531 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, long& value) { return (_iniRead(hdl,group,field,INITYPE_INT32,&value,1)); }
00532
00533
00534 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, long& value, long dft) { value = dft; return (IniRead(hdl,group,field,value)); }
00535
00536
00537 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, long& value, long dft, long min, long max) { value = dft; long err = IniRead(hdl,group,field,value); if (value < min) value = min; else if (value > max) value = max; return (err); }
00538
00539
00540 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, unsigned long& value) { return (_iniRead(hdl,group,field,INITYPE_INT32,&value,1)); }
00541
00542
00543 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, unsigned long& value, unsigned long dft) { value = dft; return (IniRead(hdl,group,field,value)); }
00544
00545
00546 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, unsigned long& value, unsigned long dft, unsigned long min, unsigned long max) { value = dft; long err = IniRead(hdl,group,field,value); if (value < min) value = min; else if (value > max) value = max; return (err); }
00547
00548 #elif !defined(INT32_is_int)
00549
00550
00551 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, int& value) { return (_iniRead(hdl,group,field,INITYPE_INT32,&value,1)); }
00552
00553
00554 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, int& value, int dft) { value = dft; return (IniRead(hdl,group,field,value)); }
00555
00556
00557 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, int& value, int dft, int min, int max) { value = dft; int err = IniRead(hdl,group,field,value); if (value < min) value = min; else if (value > max) value = max; return (err); }
00558
00559 #endif
00560
00561
00562 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, float& value) { return (_iniRead(hdl,group,field,INITYPE_Float,&value,1)); }
00563
00564
00565 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, float& value, float dft) { value = dft; return (IniRead(hdl,group,field,value)); }
00566
00567
00568 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, float& value, float dft, float min, float max) { value = dft; int err = IniRead(hdl,group,field,value); if (value < min) value = min; else if (value > max) value = max; return (err); }
00569
00570
00571 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, double& value) { return (_iniRead(hdl,group,field,INITYPE_Double,&value,1)); }
00572
00573
00574 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, double& value, double dft) { value = dft; return (IniRead(hdl,group,field,value)); }
00575
00576
00577 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, double& value, double dft, double min, double max) { value = dft; int err = IniRead(hdl,group,field,value); if (value < min) value = min; else if (value > max) value = max; return (err); }
00578
00579
00580 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, char *str, int size) { return (_iniReadString(hdl,group,field,INITYPE_ASCII,str,size)); }
00581
00582
00583 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, UNICODE *str, int size) { return (_iniReadString(hdl,group,field,INITYPE_Unicode,str,size)); }
00584
00585
00586 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, COLOR& value) { return (_iniRead(hdl,group,field,INITYPE_COLOR,&value,1)); }
00587
00588
00589 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, COLOR& value, const COLOR& dft) { value = dft; return (IniRead(hdl,group,field,value)); }
00590
00591
00592 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, DPOINT2D& value) { return (_iniRead(hdl,group,field,INITYPE_DPOINT2D,&value,1)); }
00593
00594
00595 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, DPOINT2D& value, const DPOINT2D& dft) { value = dft; return (IniRead(hdl,group,field,value)); }
00596
00597
00598 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, DPOINT3D& value) { return (_iniRead(hdl,group,field,INITYPE_DPOINT3D,&value,1)); }
00599
00600
00601 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, DPOINT3D& value, const DPOINT3D& dft) { value = dft; return (IniRead(hdl,group,field,value)); }
00602
00603
00604 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, MAPPROJPARM& value) { return (_iniRead(hdl,group,field,INITYPE_MAPPROJPARM,&value,1)); }
00605
00606
00607 inline int IniRead (INIHANDLE hdl, const char *group, const char *field, MAPPROJPARM& value, const MAPPROJPARM& dft) { value = dft; return (IniRead(hdl,group,field,value)); }
00608
00609
00610
00611 inline bool IniReadBoolean (INIHANDLE hdl, const char *group, const char *field, bool dft) { bool value; IniRead(hdl,group,field,value,dft); return (value); }
00612
00613
00614 template <class _CT>
00615 inline int IniReadEnum (
00616 INIHANDLE hdl,
00617 const char *group,
00618 const char *field,
00619 _CT& value
00620 ) {
00621 int err, temp;
00622 if ((err = IniRead(hdl,group,field,temp)) >= 0) {
00623 value = static_cast<_CT>(temp);
00624 }
00625 return (err);
00626 }
00627
00628
00629 template <class _CT>
00630 inline int IniReadEnum (
00631 INIHANDLE hdl,
00632 const char *group,
00633 const char *field,
00634 _CT& value,
00635 _CT dft
00636 ) {
00637 int err, temp;
00638 if ((err = IniRead(hdl,group,field,temp)) >= 0) {
00639 value = static_cast<_CT>(temp);
00640 }
00641 else {
00642 value = dft;
00643 }
00644 return (err);
00645 }
00646
00647
00648 inline int IniReadStringMultiLine (
00649 INIHANDLE iniptr,
00650 const char *group,
00651 const char *field,
00652 char*& string
00653 ) {
00654 return (_iniReadStringAllocML(iniptr,group,field,INITYPE_ASCII,reinterpret_cast<void**>(&string)));
00655 }
00656
00657
00658 inline int IniReadStringMultiLine (
00659 INIHANDLE iniptr,
00660 const char *group,
00661 const char *field,
00662 UNICODE*& string
00663 ) {
00664 return (_iniReadStringAllocML(iniptr,group,field,INITYPE_Unicode,reinterpret_cast<void**>(&string)));
00665 }
00666
00667
00668 inline int IniWrite (INIHANDLE hdl, const char *group, const char *field, const bool& value) { return (IniWriteBoolean(hdl,group,field,value)); }
00669
00670
00671 inline int IniWrite (INIHANDLE hdl, const char *group, const char *field, int value) { return (_iniWrite(hdl,group,field,INITYPE_INT32,&value,1)); }
00672
00673
00674 inline int IniWrite (INIHANDLE hdl, const char *group, const char *field, unsigned int value) { return (_iniWrite(hdl,group,field,INITYPE_UINT32,&value,1)); }
00675
00676 #if defined(WIN32)
00677
00678
00679 inline int IniWrite (INIHANDLE hdl, const char *group, const char *field, long value) { return (_iniWrite(hdl,group,field,INITYPE_INT32,&value,1)); }
00680
00681
00682 inline int IniWrite (INIHANDLE hdl, const char *group, const char *field, unsigned long value) { return (_iniWrite(hdl,group,field,INITYPE_UINT32,&value,1)); }
00683
00684 #elif !defined(INT32_is_int)
00685
00686
00687 inline int IniWrite (INIHANDLE hdl, const char *group, const char *field, INT32 value) { return (_iniWrite(hdl,group,field,INITYPE_INT32,&value,1)); }
00688
00689
00690 inline int IniWrite (INIHANDLE hdl, const char *group, const char *field, UINT32 value) { return (_iniWrite(hdl,group,field,INITYPE_UINT32,&value,1)); }
00691
00692 #endif
00693
00694 #if defined(LONGS_ARE_64_BIT)
00695
00696
00697 inline int IniWrite (INIHANDLE hdl, const char *group, const char *field, MGUI::ID value) { INT32 temp = static_cast<INT32>(value); return (_iniWrite(hdl,group,field,INITYPE_INT32,&temp,1)); }
00698
00699 #endif
00700
00701
00702 inline int IniWrite (INIHANDLE hdl, const char *group, const char *field, double value) { return (_iniWrite(hdl,group,field,INITYPE_Double,&value,1)); }
00703
00704
00705
00706 inline int IniWrite (INIHANDLE hdl, const char *group, const char *field, const char *str) { return (_iniWriteString(hdl,group,field,INITYPE_ASCII,str)); }
00707
00708
00709
00710 inline int IniWrite (INIHANDLE hdl, const char *group, const char *field, const UNICODE *str) { return (_iniWriteString(hdl,group,field,INITYPE_Unicode,str)); }
00711
00712
00713 inline int IniWrite (INIHANDLE hdl, const char *group, const char *field, const COLOR& value) { return (_iniWrite(hdl,group,field,INITYPE_COLOR,&value,1)); }
00714
00715
00716 inline int IniWrite (INIHANDLE hdl, const char *group, const char *field, const DPOINT2D& value) { return (_iniWrite(hdl,group,field,INITYPE_DPOINT2D,&value,1)); }
00717
00718
00719 inline int IniWrite (INIHANDLE hdl, const char *group, const char *field, const DPOINT3D& value) { return (_iniWrite(hdl,group,field,INITYPE_DPOINT3D,&value,1)); }
00720
00721
00722 inline int IniWrite (INIHANDLE hdl, const char *group, const char *field, const MAPPROJPARM& value) { return (_iniWrite(hdl,group,field,INITYPE_MAPPROJPARM,&value,1)); }
00723
00724
00725
00726 inline int IniWriteStringMultiLine (
00727 INIHANDLE iniptr,
00728 const char *group,
00729 const char *field,
00730 const char *string
00731 ) {
00732 return (_iniWriteStringML(iniptr,group,field,INITYPE_ASCII,string));
00733 }
00734
00735
00736 inline int IniWriteStringMultiLine (
00737 INIHANDLE iniptr,
00738 const char *group,
00739 const char *field,
00740 const UNICODE *string
00741 ) {
00742 return (_iniWriteStringML(iniptr,group,field,INITYPE_Unicode,string));
00743 }
00744
00745
00746
00747
00748
00749
00750 class INIHND {
00751 public:
00752
00753
00754 INIHND (
00755 ): m_handle(0) { }
00756
00757
00758 ~INIHND (
00759 ) { Close(); }
00760
00761
00762
00763 operator INIHANDLE (
00764 ) const { return (m_handle); }
00765
00766
00767 void Close (
00768 ) { if (IsOpen()) IniClose(m_handle); m_handle = 0; }
00769
00770
00771 bool IsOpen (
00772 ) const { return (m_handle != 0); }
00773
00774
00775 ERRVALUE OpenHost (
00776 bool readonly = true
00777 ) { Close(); return (IniOpen(INIFILE_Host,&m_handle,(readonly?INIFLAG_ReadOnly:0))); }
00778
00779
00780 ERRVALUE Open (
00781 const FILEPATH& filepath
00782 ) {
00783 if (IsOpen() && filepath == IniGetFilePath(m_handle)) return (0);
00784 Close();
00785 return (IniOpen(filepath,&m_handle));
00786 }
00787
00788 private:
00789 #ifndef GENERATING_DOXYGEN_OUTPUT
00790 INIHANDLE m_handle;
00791
00792 INIHND (const INIHND&);
00793 INIHND& operator= (const INIHND&);
00794 #endif // GENERATING_DOXYGEN_OUTPUT
00795 };
00796
00797
00798 #undef LIBEXPORT
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810 template <class _DT> class INI_AUTO {
00811
00812 public:
00813
00814 INI_AUTO (
00815 const char *field,
00816 const char *group = NULL,
00817 bool copyfield = false,
00818 bool copygroup = false
00819 ) :
00820 m_Group(group),
00821 m_Field(field),
00822 m_CopyGroup(copygroup),
00823 m_CopyField(copyfield)
00824 {
00825 if (copyfield) m_Field = strdup(field);
00826 if (copygroup) m_Group = strdup(group);
00827 IniRead(NULL, m_Group, m_Field, m_Data);
00828 }
00829
00830 INI_AUTO (
00831 const _DT &defaultdata,
00832 const char *field,
00833 const char *group = NULL,
00834 bool copyfield = false,
00835 bool copygroup = false
00836 ) :
00837 m_Data(defaultdata),
00838 m_Group(group),
00839 m_Field(field),
00840 m_CopyGroup(copygroup),
00841 m_CopyField(copyfield)
00842 {
00843 if (copyfield) m_Field = strdup(field);
00844 if (copygroup) m_Group = strdup(group);
00845 IniRead(NULL, m_Group, m_Field, m_Data);
00846 }
00847
00848 ~INI_AUTO (
00849 ) {
00850 if (m_CopyField) free(const_cast<char*>(m_Field));
00851 if (m_CopyGroup) free(const_cast<char*>(m_Group));
00852 }
00853
00854 operator const _DT& (
00855 ) const { return (m_Data); }
00856
00857 const _DT& operator= (
00858 const _DT& dt
00859 ) {
00860 m_Data = dt;
00861 Write();
00862 return (m_Data);
00863 }
00864
00865
00866
00867 void Set (
00868 const _DT& dt,
00869 bool write = true
00870 ) {
00871 m_Data = dt;
00872 if (write)
00873 Write();
00874 }
00875
00876
00877 void Write (
00878 INIHANDLE inihandle = NULL
00879 ) const { IniWrite(inihandle, m_Group, m_Field, m_Data); }
00880
00881 private:
00882 #ifndef GENERATING_DOXYGEN_OUTPUT
00883 _DT m_Data;
00884 const char *m_Group;
00885 const char *m_Field;
00886 bool m_CopyGroup;
00887 bool m_CopyField;
00888 #endif // GENERATING_DOXYGEN_OUTPUT
00889 };
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902 template <class _DT> class INI_AUTO_ENUM {
00903
00904 public:
00905
00906 INI_AUTO_ENUM (
00907 const char *field,
00908 const char *group = NULL,
00909 bool copyfield = false,
00910 bool copygroup = false
00911 ) :
00912 m_Data(data),
00913 m_Group(group),
00914 m_Field(field),
00915 m_CopyGroup(copygroup),
00916 m_CopyField(copyfield)
00917 {
00918 if (copyfield) m_Field = strdup(field);
00919 if (copygroup) m_Group = strdup(group);
00920 IniReadEnum(NULL, m_Group, m_Field, m_Data);
00921 }
00922
00923 INI_AUTO_ENUM (
00924 const _DT &defaultdata,
00925 const char *field,
00926 const char *group = NULL,
00927 bool copyfield = false,
00928 bool copygroup = false
00929 ) :
00930 m_Data(defaultdata),
00931 m_Group(group),
00932 m_Field(field),
00933 m_CopyGroup(copygroup),
00934 m_CopyField(copyfield)
00935 {
00936 if (copyfield) m_Field = strdup(field);
00937 if (copygroup) m_Group = strdup(group);
00938 IniReadEnum(NULL, m_Group, m_Field, m_Data);
00939 }
00940
00941 ~INI_AUTO_ENUM (
00942 ) {
00943 if (m_CopyField) free(const_cast<char*>(m_Field));
00944 if (m_CopyGroup) free(const_cast<char*>(m_Group));
00945 }
00946
00947 operator const _DT& (
00948 ) const { return (m_Data); }
00949
00950 const _DT& operator= (
00951 const _DT& dt
00952 ) {
00953 m_Data = dt;
00954 Write();
00955 return (m_Data);
00956 }
00957
00958
00959
00960 void Set (
00961 const _DT& dt,
00962 bool write = true
00963 ) {
00964 m_Data = dt;
00965 if (write)
00966 Write();
00967 }
00968
00969
00970 void Write (
00971 INIHANDLE inihandle = NULL
00972 ) const { IniWrite(inihandle, m_Group, m_Field, m_Data); }
00973
00974 private:
00975 #ifndef GENERATING_DOXYGEN_OUTPUT
00976
00977 _DT m_Data;
00978 const char *m_Group;
00979 const char *m_Field;
00980 bool m_CopyGroup;
00981 bool