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
00046 #ifndef OPENRJ_INCL_OPENRJ_H_OPENRJ
00047 #define OPENRJ_INCL_OPENRJ_H_OPENRJ
00048
00049
00050
00051
00052
00053 #ifndef OPENRJ_DOCUMENTATION_SKIP_SECTION
00054 # define OPENRJ_VER_OPENRJ_H_OPENRJ_MAJOR 1
00055 # define OPENRJ_VER_OPENRJ_H_OPENRJ_MINOR 23
00056 # define OPENRJ_VER_OPENRJ_H_OPENRJ_REVISION 1
00057 # define OPENRJ_VER_OPENRJ_H_OPENRJ_EDIT 57
00058 #endif
00059
00076 #ifndef OPENRJ_DOCUMENTATION_SKIP_SECTION
00077 # define OPENRJ_VER_1_0_1 0x01000100
00078 # define OPENRJ_VER_1_1_1 0x01010100
00079 # define OPENRJ_VER_1_1_2 0x01010200
00080 # define OPENRJ_VER_1_2_1 0x01020100
00081 # define OPENRJ_VER_1_2_2 0x01020200
00082 # define OPENRJ_VER_1_3_1 0x01030100
00083 # define OPENRJ_VER_1_3_2 0x01030200
00084 # define OPENRJ_VER_1_3_3 0x01030300
00085 # define OPENRJ_VER_1_3_4 0x01030400
00086 # define OPENRJ_VER_1_4_1 0x01040100
00087 # define OPENRJ_VER_1_5_1 0x01050100
00088 # define OPENRJ_VER_1_5_2 0x01050200
00089 # define OPENRJ_VER_1_5_3 0x01050300
00090 # define OPENRJ_VER_1_5_4 0x01050400
00091 # define OPENRJ_VER_1_6_1 0x01060100
00092 # define OPENRJ_VER_1_6_2 0x01060200
00093 #endif
00094
00095 #define OPENRJ_VER_MAJOR 1
00096 #define OPENRJ_VER_MINOR 6
00097 #define OPENRJ_VER_REVISION 2
00098
00099 #define OPENRJ_VER OPENRJ_VER_1_6_2
00100
00101
00102
00103
00104
00105 #include <stddef.h>
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 #if !defined(__cplusplus) && \
00116 !defined(OPENRJ_DOCUMENTATION_SKIP_SECTION) && \
00117 !defined(ORJ_NO_NAMESPACE)
00118 # define ORJ_NO_NAMESPACE
00119 #endif
00120
00121 #if !defined(ORJ_NO_NAMESPACE)
00122
00127 namespace openrj
00128 {
00129 #endif
00130
00131
00132
00133
00134
00135 #if defined(_CH_)
00136 # define OPENRJ_NO_STRUCT_TAG_PREFIX
00137 #endif
00138
00139 #ifndef OPENRJ_DOCUMENTATION_SKIP_SECTION
00140 # if defined(OPENRJ_NO_STRUCT_TAG_PREFIX)
00141 # define ORJ_TAG_NAME(x) x
00142 # else
00143 # define ORJ_TAG_NAME(x) tag ## x
00144 # endif
00145 #endif
00146
00147
00148
00149
00150
00151 #if defined(OPENRJ_NO_FILE_HANDLING)
00152 # define OPENRJ_NO_STDIO
00153 #endif
00154
00155
00156
00157
00158
00159 #ifdef _CH_
00160 # include <chdl.h>
00161 LOAD_CHDL_CODE(openrjch, OpenRJ)
00162 #endif
00163
00164
00165
00166
00167
00168
00169
00170
00171
00178 #ifndef OPENRJ_DOCUMENTATION_SKIP_SECTION
00179 typedef unsigned char orj_byte_t;
00180 #endif
00181
00186 typedef char orj_char_t;
00187
00188
00189 #ifndef OPENRJ_DOCUMENTATION_SKIP_SECTION
00190
00191 # ifdef __cplusplus
00192 # define ORJ_EXTERN_C_ extern "C"
00193 # else
00194 # define ORJ_EXTERN_C_ extern
00195 # endif
00196 # define ORJ_CALL(rt) ORJ_EXTERN_C_ rt
00197
00198 #endif
00199
00202 enum ORJ_TAG_NAME(ORJ_FLAG)
00203 {
00204 ORJ_FLAG_ORDERFIELDS = 0x0001
00205 , ORJ_FLAG_ELIDEBLANKRECORDS = 0x0002
00206 , ORJ_FLAG_IGNORECASEONLOOKUP = 0x0004
00207 , ORJ_FLAG_NOREINTERPRETFIELDIDS = 0x0100
00208 , ORJ_FLAG_FORCEALLFIELDSINTO1RECORD = 0x0008
00209 #ifdef __cplusplus
00210 , ORDER_FIELDS = ORJ_FLAG_ORDERFIELDS
00211 , ELIDE_BLANK_RECORDS = ORJ_FLAG_ELIDEBLANKRECORDS
00212 , IGNORE_CASE_ON_LOOKUP = ORJ_FLAG_IGNORECASEONLOOKUP
00213 , NO_REINTERPRET_FIELD_IDS = ORJ_FLAG_NOREINTERPRETFIELDIDS
00214 , FORCE_ALL_FIELDS_INTO_1_RECORD = ORJ_FLAG_FORCEALLFIELDSINTO1RECORD
00215 #endif
00216 };
00217 #ifndef OPENRJ_DOCUMENTATION_SKIP_SECTION
00218 typedef enum ORJ_TAG_NAME(ORJ_FLAG) ORJ_FLAG;
00219 #endif
00220
00223 enum ORJ_TAG_NAME(ORJRC)
00224 {
00225
00226 ORJ_RC_SUCCESS = 0
00227 , ORJ_RC_CANNOTOPENJARFILE
00228 , ORJ_RC_NORECORDS
00229 , ORJ_RC_OUTOFMEMORY
00230 , ORJ_RC_BADFILEREAD
00231 , ORJ_RC_PARSEERROR
00232 , ORJ_RC_INVALIDINDEX
00233 , ORJ_RC_UNEXPECTED
00234 , ORJ_RC_INVALIDCONTENT
00235
00236 };
00237 #ifndef OPENRJ_DOCUMENTATION_SKIP_SECTION
00238 typedef enum ORJ_TAG_NAME(ORJRC) ORJRC;
00239 #endif
00240
00243 enum ORJ_TAG_NAME(ORJ_PARSE_ERROR)
00244 {
00245
00246 ORJ_PARSE_SUCCESS = 0
00247 , ORJ_PARSE_RECORDSEPARATORINCONTINUATION
00248 , ORJ_PARSE_UNFINISHEDLINE
00249 , ORJ_PARSE_UNFINISHEDFIELD
00250 , ORJ_PARSE_UNFINISHEDRECORD
00251 , ORJ_PARSE_INVALIDFIELDNAME
00252
00253 };
00254 #ifndef OPENRJ_DOCUMENTATION_SKIP_SECTION
00255 typedef enum ORJ_TAG_NAME(ORJ_PARSE_ERROR) ORJ_PARSE_ERROR;
00256 #endif
00257
00258
00261 struct ORJ_TAG_NAME(IORJAllocator)
00262 {
00264 void *(*pfnAlloc)(struct ORJ_TAG_NAME(IORJAllocator) *ator, size_t cb);
00266 void *(*pfnRealloc)(struct ORJ_TAG_NAME(IORJAllocator) *ator, void *pv, size_t cb);
00268 void (*pfnFree)(struct ORJ_TAG_NAME(IORJAllocator) *ator, void *pv);
00269 };
00270 #ifndef OPENRJ_DOCUMENTATION_SKIP_SECTION
00271 typedef struct ORJ_TAG_NAME(IORJAllocator) IORJAllocator;
00272 #endif
00273
00276 struct ORJ_TAG_NAME(ORJStringA)
00277 {
00278 size_t len;
00279 char const *ptr;
00280 };
00281 #ifndef OPENRJ_DOCUMENTATION_SKIP_SECTION
00282 typedef struct ORJ_TAG_NAME(ORJStringA) ORJStringA;
00283 #endif
00284
00285 typedef ORJStringA ORJString;
00286
00287
00294 struct ORJ_TAG_NAME(ORJFieldA)
00295 {
00296 size_t mbz0;
00297 ORJStringA name;
00298 ORJStringA value;
00299 void *reserved0;
00301 };
00302 #ifndef OPENRJ_DOCUMENTATION_SKIP_SECTION
00303 typedef struct ORJ_TAG_NAME(ORJFieldA) ORJFieldA;
00304 #endif
00305
00306 typedef ORJFieldA ORJField;
00307
00308
00316 struct ORJ_TAG_NAME(ORJRecordA)
00317 {
00318 size_t mbz0;
00319 size_t numFields;
00320 ORJFieldA *fields;
00321 void *reserved0;
00322 ORJStringA comment;
00324 };
00325 #ifndef OPENRJ_DOCUMENTATION_SKIP_SECTION
00326 typedef struct ORJ_TAG_NAME(ORJRecordA) ORJRecordA;
00327 #endif
00328
00329 typedef ORJRecordA ORJRecord;
00330
00331
00332
00340 struct ORJ_TAG_NAME(ORJDatabaseA)
00341 {
00342 size_t mbz0;
00343 size_t flags;
00344 size_t numLines;
00345 size_t numFields;
00346 ORJFieldA *fields;
00347 size_t numRecords;
00348 ORJRecordA *records;
00349 IORJAllocator *ator;
00351 };
00352 #ifndef OPENRJ_DOCUMENTATION_SKIP_SECTION
00353 typedef struct ORJ_TAG_NAME(ORJDatabaseA) ORJDatabaseA;
00354 #endif
00355
00356 typedef ORJDatabaseA ORJDatabase;
00357
00358
00362 struct ORJ_TAG_NAME(ORJError)
00363 {
00364 size_t reserved0;
00365 unsigned invalidLine;
00366 unsigned invalidColumn;
00367 ORJ_PARSE_ERROR parseError;
00368 };
00369 #ifndef OPENRJ_DOCUMENTATION_SKIP_SECTION
00370 typedef struct ORJ_TAG_NAME(ORJError) ORJError;
00371 #endif
00372
00375
00376
00377
00378
00379
00380
00381
00382
00389 #ifndef OPENRJ_NO_FILE_HANDLING
00390
00399 ORJ_CALL(ORJRC) ORJ_ReadDatabaseA( char const *jarName
00400 , IORJAllocator *ator
00401 , unsigned flags
00402 , ORJDatabaseA const **pdatabase
00403 , ORJError *error);
00404 #endif
00405
00416 ORJ_CALL(ORJRC) ORJ_CreateDatabaseFromMemoryA( char const *contents
00417 , size_t cbContents
00418 , IORJAllocator *ator
00419 , unsigned flags
00420 , ORJDatabaseA const **pdatabase
00421 , ORJError *error);
00422
00423
00428 ORJ_CALL(ORJRC) ORJ_FreeDatabaseA( ORJDatabaseA const *database);
00429
00430
00436 ORJ_CALL(size_t) ORJ_Database_GetNumLinesA( ORJDatabaseA const *database);
00437
00443 ORJ_CALL(size_t) ORJ_Database_GetNumFieldsA( ORJDatabaseA const *database);
00444
00450 ORJ_CALL(size_t) ORJ_Database_GetNumRecordsA( ORJDatabaseA const *database);
00451
00458 ORJ_CALL(ORJRC) ORJ_Database_GetRecordA( ORJDatabaseA const *database
00459 , size_t iRecord
00460 , ORJRecordA const **precord);
00461
00468 ORJ_CALL(ORJRC) ORJ_Database_GetFieldA( ORJDatabaseA const *database
00469 , size_t iField
00470 , ORJFieldA const **pfield);
00471
00472
00475
00476
00477
00478
00494 ORJ_CALL(size_t) ORJ_Record_GetNumFieldsA( ORJRecordA const *record);
00495
00502 ORJ_CALL(ORJRC) ORJ_Record_GetFieldA( ORJRecordA const *record
00503 , size_t iField
00504 , ORJFieldA const **pfield);
00505
00513 ORJ_CALL(ORJFieldA const*) ORJ_Record_FindFieldByNameA( ORJRecordA const *record
00514 , char const *fieldName
00515 , char const *fieldValue);
00516
00524 ORJ_CALL(ORJFieldA const*) ORJ_Record_FindNextFieldA( ORJRecordA const *record
00525 , ORJFieldA const *fieldAfter
00526 , char const *fieldName
00527 , char const *fieldValue );
00528
00534 ORJ_CALL(ORJDatabaseA const*) ORJ_Record_GetDatabaseA( ORJRecordA const *record);
00535
00536
00542 ORJ_CALL(ORJRC) ORJ_Record_GetCommentA( ORJRecordA const *record
00543 , ORJStringA const **pcomment);
00544
00545
00548
00549
00550
00551
00570 ORJ_CALL(ORJRC) ORJ_Field_GetNameA( ORJFieldA const *field
00571 , ORJStringA const **pname);
00572
00581 ORJ_CALL(ORJRC) ORJ_Field_GetValueA( ORJFieldA const *field
00582 , ORJStringA const **pvalue);
00583
00594 ORJ_CALL(ORJRC) ORJ_Field_GetNameAndValueA( ORJFieldA const *field
00595 , ORJStringA const **pname
00596 , ORJStringA const **pvalue);
00597
00603 ORJ_CALL(ORJRecordA const*) ORJ_Field_GetRecordA( ORJFieldA const *field);
00604
00608
00609
00610
00611
00623 ORJ_CALL(char const *) ORJ_GetErrorStringA( ORJRC errorCode);
00624
00630 ORJ_CALL(size_t) ORJ_GetErrorStringLengthA( ORJRC errorCode);
00631
00637 ORJ_CALL(char const *) ORJ_GetParseErrorStringA( ORJ_PARSE_ERROR errorCode);
00638
00644 ORJ_CALL(size_t) ORJ_GetParseErrorStringLengthA( ORJ_PARSE_ERROR errorCode);
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666 ORJ_CALL(int) ORJ_FormatErrorA( char *dest
00667 , size_t cchDest
00668 , ORJRC rc
00669 , ORJError const *error
00670 , char const *fmt
00671 , ...
00672 );
00673
00677 # if !defined(OPENRJ_DOCUMENTATION_SKIP_SECTION) && \
00678 !defined(OPENRJ_PURE_API)
00679
00680
00681
00682
00683
00684
00685 # ifndef __cplusplus
00686 # define ORJ_Database_GetNumLinesA(database) ((size_t)(database)->numLines)
00687 # define ORJ_Database_GetNumFieldsA(database) ((size_t)(database)->numFields)
00688 # define ORJ_Database_GetNumRecordsA(database) ((size_t)(database)->numRecords)
00689 # define ORJ_Record_GetNumFieldsA(record) ((size_t)(record)->numFields)
00690 #else
00691
00692 # define ORJ_Database_GetNumLinesA ORJ_Database_GetNumLinesA_
00693 inline size_t ORJ_Database_GetNumLinesA_( ORJDatabaseA const *database)
00694 {
00695 return database->numLines;
00696 }
00697
00698 # define ORJ_Database_GetNumFieldsA ORJ_Database_GetNumFieldsA_
00699 inline size_t ORJ_Database_GetNumFieldsA_( ORJDatabaseA const *database)
00700 {
00701 return database->numFields;
00702 }
00703 # define ORJ_Database_GetNumRecordsA ORJ_Database_GetNumRecordsA_
00704 inline size_t ORJ_Database_GetNumRecordsA_( ORJDatabaseA const *database)
00705 {
00706 return database->numRecords;
00707 }
00708
00709 # define ORJ_Record_GetNumFieldsA ORJ_Record_GetNumFieldsA_
00710 inline size_t ORJ_Record_GetNumFieldsA_( ORJRecordA const *record)
00711 {
00712 return record->numFields;
00713 }
00714
00715 # endif
00716 #endif
00717
00718
00719 #ifdef __cplusplus
00720 # ifndef OPENRJ_NO_FILE_HANDLING
00721
00725 inline ORJRC ORJ_ReadDatabase( orj_char_t const *jarName
00726 , IORJAllocator *ator
00727 , unsigned flags
00728 , ORJDatabase const **pdatabase
00729 , ORJError *error)
00730 {
00731 return ORJ_ReadDatabaseA(jarName, ator, flags, pdatabase, error);
00732 }
00733 # endif
00734
00738 inline ORJRC ORJ_CreateDatabaseFromMemory( orj_char_t const *contents
00739 , size_t cbContents
00740 , IORJAllocator *ator
00741 , unsigned flags
00742 , ORJDatabaseA const **pdatabase
00743 , ORJError *error)
00744 {
00745 return ORJ_CreateDatabaseFromMemoryA(contents, cbContents, ator, flags, pdatabase, error);
00746 }
00747
00752 inline ORJRC ORJ_FreeDatabase( ORJDatabase const *database)
00753 {
00754 return ORJ_FreeDatabaseA(database);
00755 }
00756 #else
00757 # ifndef OPENRJ_NO_FILE_HANDLING
00758 # define ORJ_ReadDatabase ORJ_ReadDatabaseA
00759 # endif
00760 # define ORJ_CreateDatabaseFromMemory ORJ_CreateDatabaseFromMemoryA
00761 # define ORJ_FreeDatabase ORJ_FreeDatabaseA
00762 #endif
00763
00764
00765
00766
00767
00768 #ifdef __cplusplus
00769
00787 inline char const *c_str_ptr_null_a(ORJStringA const &s)
00788 {
00789 return (0 != s.len) ? s.ptr : NULL;
00790 }
00795 inline char const *c_str_ptr_null(ORJStringA const &s)
00796 {
00797 return c_str_ptr_null_a(s);
00798 }
00799
00804 inline char const *c_str_ptr_a(ORJStringA const &s)
00805 {
00806 return s.ptr;
00807 }
00812 inline char const *c_str_ptr(ORJStringA const &s)
00813 {
00814 return c_str_ptr_a(s);
00815 }
00816
00821 inline char const *c_str_data_a(ORJStringA const &s)
00822 {
00823 return s.ptr;
00824 }
00829 inline char const *c_str_data(ORJStringA const &s)
00830 {
00831 return c_str_data_a(s);
00832 }
00833
00838 inline size_t c_str_len_a(ORJStringA const &s)
00839 {
00840 return s.len;
00841 }
00846 inline size_t c_str_len(ORJStringA const &s)
00847 {
00848 return s.len;
00849 }
00850
00855 inline char const *c_str_ptr_null_a(ORJRC rc)
00856 {
00857 char const *s = ORJ_GetErrorStringA(rc);
00858
00859 return ('\0' != s) ? s : NULL;
00860 }
00865 inline char const *c_str_ptr_null(ORJRC rc)
00866 {
00867 return c_str_ptr_null_a(rc);
00868 }
00869
00874 inline char const *c_str_ptr_a(ORJRC rc)
00875 {
00876 return ORJ_GetErrorStringA(rc);
00877 }
00882 inline char const *c_str_ptr(ORJRC rc)
00883 {
00884 return c_str_ptr_a(rc);
00885 }
00886
00891 inline char const *c_str_data_a(ORJRC rc)
00892 {
00893 return ORJ_GetErrorStringA(rc);
00894 }
00899 inline char const *c_str_data(ORJRC rc)
00900 {
00901 return c_str_data_a(rc);
00902 }
00903
00908 inline size_t c_str_len_a(ORJRC rc)
00909 {
00910 return ORJ_GetErrorStringLengthA(rc);
00911 }
00916 inline size_t c_str_len(ORJRC rc)
00917 {
00918 return ORJ_GetErrorStringLengthA(rc);
00919 }
00920
00925 inline char const *c_str_ptr_null_a(ORJ_PARSE_ERROR pe)
00926 {
00927 char const *s = ORJ_GetParseErrorStringA(pe);
00928
00929 return ('\0' != s) ? s : NULL;
00930 }
00935 inline char const *c_str_ptr_null(ORJ_PARSE_ERROR pe)
00936 {
00937 return c_str_ptr_null_a(pe);
00938 }
00939
00944 inline char const *c_str_ptr_a(ORJ_PARSE_ERROR pe)
00945 {
00946 return ORJ_GetParseErrorStringA(pe);
00947 }
00952 inline char const *c_str_ptr(ORJ_PARSE_ERROR pe)
00953 {
00954 return c_str_ptr_a(pe);
00955 }
00956
00961 inline char const *c_str_data_a(ORJ_PARSE_ERROR pe)
00962 {
00963 return ORJ_GetParseErrorStringA(pe);
00964 }
00969 inline char const *c_str_data(ORJ_PARSE_ERROR pe)
00970 {
00971 return c_str_data_a(pe);
00972 }
00973
00978 inline size_t c_str_len(ORJ_PARSE_ERROR pe)
00979 {
00980 return ORJ_GetParseErrorStringLengthA(pe);
00981 }
00986 inline size_t c_str_len_a(ORJ_PARSE_ERROR pe)
00987 {
00988 return ORJ_GetParseErrorStringLengthA(pe);
00989 }
00990
01032 template <class S>
01033 inline S &operator <<(S &stm, ORJStringA const &s)
01034 {
01035 stm.write(s.ptr, s.len);
01036
01037 return stm;
01038 }
01039
01046 template <class S>
01047 inline S &operator <<(S &stm, ORJRC rc)
01048 {
01049 return stm << c_str_ptr(rc);
01050 }
01051
01058 template <class S>
01059 inline S &operator <<(S &stm, ORJ_PARSE_ERROR pe)
01060 {
01061 return stm << c_str_ptr(pe);
01062 }
01063
01066 #endif
01067
01068
01069
01070
01071
01072 #if !defined(ORJ_NO_NAMESPACE)
01073 }
01074
01075 #ifdef OPENRJ_DOCUMENTATION_SKIP_SECTION
01076
01085 #endif
01086 namespace stlsoft
01087 {
01088 using ::openrj::c_str_ptr_null_a;
01089 using ::openrj::c_str_ptr_null;
01090 using ::openrj::c_str_ptr_a;
01091 using ::openrj::c_str_ptr;
01092 using ::openrj::c_str_data_a;
01093 using ::openrj::c_str_data;
01094 using ::openrj::c_str_len_a;
01095 using ::openrj::c_str_len;
01096 }
01097
01098 #endif
01099
01100
01101
01102 #endif
01103
01104