Open-RJ C/C++ User's Journal Synesis Software STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ...

openrj/openrj.h

Go to the documentation of this file.
00001 /* /////////////////////////////////////////////////////////////////////////////
00002  * File:    openrj/openrj.h
00003  *
00004  * Purpose: Root header file for the Open-RJ library
00005  *
00006  * Created: 11th June 2004
00007  * Updated: 26th December 2006
00008  *
00009  * Home:    http://openrj.org/
00010  *
00011  * Copyright (c) 2004-2006, Matthew Wilson and Synesis Software
00012  * All rights reserved.
00013  *
00014  * Redistribution and use in source and binary forms, with or without
00015  * modification, are permitted provided that the following conditions are met:
00016  *
00017  * - Redistributions of source code must retain the above copyright notice, this
00018  *   list of conditions and the following disclaimer.
00019  * - Redistributions in binary form must reproduce the above copyright notice,
00020  *   this list of conditions and the following disclaimer in the documentation
00021  *   and/or other materials provided with the distribution.
00022  * - Neither the names of Matthew Wilson and Synesis Software nor the names of
00023  *   any contributors may be used to endorse or promote products derived from
00024  *   this software without specific prior written permission.
00025  *
00026  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00027  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00029  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00030  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00031  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00032  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00033  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00034  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00035  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00036  * POSSIBILITY OF SUCH DAMAGE.
00037  *
00038  * ////////////////////////////////////////////////////////////////////////// */
00039 
00040 
00046 #ifndef OPENRJ_INCL_OPENRJ_H_OPENRJ
00047 #define OPENRJ_INCL_OPENRJ_H_OPENRJ
00048 
00049 /* /////////////////////////////////////////////////////////////////////////////
00050  * Version information
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 /* !OPENRJ_DOCUMENTATION_SKIP_SECTION */
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 /* !OPENRJ_DOCUMENTATION_SKIP_SECTION */
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  * Includes
00103  */
00104 
00105 #include <stddef.h>     /* for size_t */
00106 
00107 /* /////////////////////////////////////////////////////////////////////////////
00108  * Documentation
00109  */
00110 
00111 /* /////////////////////////////////////////////////////////////////////////////
00112  * Namespace
00113  */
00114 
00115 #if !defined(__cplusplus) && \
00116     !defined(OPENRJ_DOCUMENTATION_SKIP_SECTION) && \
00117     !defined(ORJ_NO_NAMESPACE)
00118 # define ORJ_NO_NAMESPACE
00119 #endif /* __cplusplus, etc. */
00120 
00121 #if !defined(ORJ_NO_NAMESPACE)
00122 
00127 namespace openrj
00128 {
00129 #endif /* !ORJ_NO_NAMESPACE */
00130 
00131 /* /////////////////////////////////////////////////////////////////////////////
00132  * Macros and symbols
00133  */
00134 
00135 #if defined(_CH_)
00136 # define OPENRJ_NO_STRUCT_TAG_PREFIX
00137 #endif /* OPENRJ_DOCUMENTATION_SKIP_SECTION || _CH_ */
00138 
00139 #ifndef OPENRJ_DOCUMENTATION_SKIP_SECTION
00140 # if defined(OPENRJ_NO_STRUCT_TAG_PREFIX)
00141 #  define ORJ_TAG_NAME(x)                   x
00142 # else /* ? OPENRJ_NO_STRUCT_TAG_PREFIX */
00143 #  define ORJ_TAG_NAME(x)                   tag ## x
00144 # endif /* OPENRJ_NO_STRUCT_TAG_PREFIX */
00145 #endif /* !OPENRJ_DOCUMENTATION_SKIP_SECTION */
00146 
00147 /* OPENRJ_NO_STDIO */
00148 
00149 /* OPENRJ_NO_FILE_HANDLING */
00150 
00151 #if defined(OPENRJ_NO_FILE_HANDLING)
00152 # define OPENRJ_NO_STDIO
00153 #endif /* OPENRJ_NO_FILE_HANDLING */
00154 
00155 /* /////////////////////////////////////////////////////////////////////////////
00156  * Ch
00157  */
00158 
00159 #ifdef _CH_
00160 # include <chdl.h>
00161 LOAD_CHDL_CODE(openrjch, OpenRJ)
00162 #endif /* _CH_ */
00163 
00164 /* /////////////////////////////////////////////////////////////////////////////
00165  * Types
00166  */
00167 
00168 /***************************************
00169  * Common types
00170  */
00171 
00178 #ifndef OPENRJ_DOCUMENTATION_SKIP_SECTION
00179 typedef unsigned char           orj_byte_t;
00180 #endif /* !OPENRJ_DOCUMENTATION_SKIP_SECTION */
00181 
00186 typedef char                    orj_char_t;
00187 /* typedef wchar_t           orj_char_t; */
00188 
00189 #ifndef OPENRJ_DOCUMENTATION_SKIP_SECTION
00190 
00191 # ifdef __cplusplus
00192 #  define ORJ_EXTERN_C_         extern "C"
00193 # else /* ? __cplusplus */
00194 #  define ORJ_EXTERN_C_         extern
00195 # endif /* !__cplusplus */
00196 # define ORJ_CALL(rt)           ORJ_EXTERN_C_ rt
00197 
00198 #endif /* !OPENRJ_DOCUMENTATION_SKIP_SECTION */
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 /* __cplusplus */
00216 };
00217 #ifndef OPENRJ_DOCUMENTATION_SKIP_SECTION
00218 typedef enum ORJ_TAG_NAME(ORJ_FLAG)         ORJ_FLAG;
00219 #endif /* !OPENRJ_DOCUMENTATION_SKIP_SECTION */
00220 
00223 enum ORJ_TAG_NAME(ORJRC)
00224 {
00225 /*[OPENRJ:Errors-start]*/
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 /*[OPENRJ:Errors-end]*/
00236 };
00237 #ifndef OPENRJ_DOCUMENTATION_SKIP_SECTION
00238 typedef enum ORJ_TAG_NAME(ORJRC)            ORJRC;
00239 #endif /* !OPENRJ_DOCUMENTATION_SKIP_SECTION */
00240 
00243 enum ORJ_TAG_NAME(ORJ_PARSE_ERROR)
00244 {
00245 /*[OPENRJ:ParseErrors-start]*/
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 /*[OPENRJ:ParseErrors-end]*/
00253 };
00254 #ifndef OPENRJ_DOCUMENTATION_SKIP_SECTION
00255 typedef enum ORJ_TAG_NAME(ORJ_PARSE_ERROR)  ORJ_PARSE_ERROR;
00256 #endif /* !OPENRJ_DOCUMENTATION_SKIP_SECTION */
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 /* !OPENRJ_DOCUMENTATION_SKIP_SECTION */
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 /* !OPENRJ_DOCUMENTATION_SKIP_SECTION */
00284 
00285 typedef ORJStringA                          ORJString;
00286 /* typedef ORJStringW                         ORJString; */
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 /* !OPENRJ_DOCUMENTATION_SKIP_SECTION */
00305 
00306 typedef ORJFieldA                           ORJField;
00307 /* typedef ORJFieldW                          ORJField; */
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 /* !OPENRJ_DOCUMENTATION_SKIP_SECTION */
00328 
00329 typedef ORJRecordA                          ORJRecord;
00330 /* typedef ORJRecordW                         ORJRecord; */
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 /* !OPENRJ_DOCUMENTATION_SKIP_SECTION */
00355 
00356 typedef ORJDatabaseA                        ORJDatabase;
00357 /* typedef ORJDatabaseW                       ORJDatabase; */
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 /* !OPENRJ_DOCUMENTATION_SKIP_SECTION */
00372 
00375 /* /////////////////////////////////////////////////////////////////////////////
00376  * API
00377  */
00378 
00379 /***************************************
00380  * Database manipulation functions
00381  */
00382 
00389 #ifndef OPENRJ_NO_FILE_HANDLING
00390 
00399 ORJ_CALL(ORJRC) ORJ_ReadDatabaseA(  /* [in] */ char const           *jarName
00400                                 ,   /* [in] */ IORJAllocator        *ator
00401                                 ,   /* [in] */ unsigned             flags
00402                                 ,   /* [out] */ ORJDatabaseA const  **pdatabase
00403                                 ,   /* [out] */ ORJError            *error);
00404 #endif /* !OPENRJ_NO_FILE_HANDLING */
00405 
00416 ORJ_CALL(ORJRC) ORJ_CreateDatabaseFromMemoryA(  /* [in] */ char const           *contents
00417                                             ,   /* [in] */ size_t               cbContents
00418                                             ,   /* [in] */ IORJAllocator        *ator
00419                                             ,   /* [in] */ unsigned             flags
00420                                             ,   /* [out] */ ORJDatabaseA const  **pdatabase
00421                                             ,   /* [out] */ ORJError            *error);
00422 
00423 
00428 ORJ_CALL(ORJRC) ORJ_FreeDatabaseA(/* [in] */ ORJDatabaseA const     *database);
00429 
00430 
00436 ORJ_CALL(size_t) ORJ_Database_GetNumLinesA(/* [in] */ ORJDatabaseA const    *database);
00437 
00443 ORJ_CALL(size_t) ORJ_Database_GetNumFieldsA(/* [in] */ ORJDatabaseA const   *database);
00444 
00450 ORJ_CALL(size_t) ORJ_Database_GetNumRecordsA(/* [in] */ ORJDatabaseA const  *database);
00451 
00458 ORJ_CALL(ORJRC) ORJ_Database_GetRecordA(/* [in] */ ORJDatabaseA const   *database
00459                                     ,   /* [in] */ size_t               iRecord
00460                                     ,   /* [in] */ ORJRecordA const     **precord);
00461 
00468 ORJ_CALL(ORJRC) ORJ_Database_GetFieldA( /* [in] */ ORJDatabaseA const   *database
00469                                     ,   /* [in] */ size_t               iField
00470                                     ,   /* [in] */ ORJFieldA const      **pfield);
00471 
00472 
00475 /***************************************
00476  * Record manipulation functions
00477  */
00478 
00494 ORJ_CALL(size_t) ORJ_Record_GetNumFieldsA(  /* [in] */ ORJRecordA const *record);
00495 
00502 ORJ_CALL(ORJRC) ORJ_Record_GetFieldA(       /* [in] */ ORJRecordA const *record
00503                                         ,   /* [in] */ size_t           iField
00504                                         ,   /* [in] */ ORJFieldA const  **pfield);
00505 
00513 ORJ_CALL(ORJFieldA const*) ORJ_Record_FindFieldByNameA( /* [in] */ ORJRecordA const *record
00514                                                     ,   /* [in] */ char const       *fieldName
00515                                                     ,   /* [in] */ char const       *fieldValue);
00516 
00524 ORJ_CALL(ORJFieldA const*) ORJ_Record_FindNextFieldA(   /* [in] */ ORJRecordA const *record
00525                                                     ,   /* [in] */ ORJFieldA const  *fieldAfter /* = NULL */
00526                                                     ,   /* [in] */ char const       *fieldName  /* = NULL */
00527                                                     ,   /* [in] */ char const       *fieldValue /* = NULL */);
00528 
00534 ORJ_CALL(ORJDatabaseA const*) ORJ_Record_GetDatabaseA(  /* [in] */ ORJRecordA const *record);
00535 
00536 
00542 ORJ_CALL(ORJRC) ORJ_Record_GetCommentA(     /* [in] */ ORJRecordA const *record
00543                                         ,   /* [in] */ ORJStringA const **pcomment);
00544 
00545 
00548 /***************************************
00549  * Field manipulation functions
00550  */
00551 
00570 ORJ_CALL(ORJRC) ORJ_Field_GetNameA(         /* [in] */ ORJFieldA const  *field
00571                                         ,   /* [in] */ ORJStringA const **pname);
00572 
00581 ORJ_CALL(ORJRC) ORJ_Field_GetValueA(        /* [in] */ ORJFieldA const  *field
00582                                         ,   /* [in] */ ORJStringA const **pvalue);
00583 
00594 ORJ_CALL(ORJRC) ORJ_Field_GetNameAndValueA( /* [in] */ ORJFieldA const  *field
00595                                         ,   /* [in] */ ORJStringA const **pname
00596                                         ,   /* [in] */ ORJStringA const **pvalue);
00597 
00603 ORJ_CALL(ORJRecordA const*) ORJ_Field_GetRecordA(  /* [in] */ ORJFieldA const *field);
00604 
00608 /***************************************
00609  * Error functions
00610  */
00611 
00623 ORJ_CALL(char const *) ORJ_GetErrorStringA( /* [in] */ ORJRC            errorCode);
00624 
00630 ORJ_CALL(size_t) ORJ_GetErrorStringLengthA( /* [in] */ ORJRC            errorCode);
00631 
00637 ORJ_CALL(char const *) ORJ_GetParseErrorStringA( /* [in] */ ORJ_PARSE_ERROR errorCode);
00638 
00644 ORJ_CALL(size_t) ORJ_GetParseErrorStringLengthA( /* [in] */ ORJ_PARSE_ERROR errorCode);
00645 
00646 
00647 /* \brief Formats an error string 
00648  *
00649  * Formats an error string, specifying information for error code and parse
00650  * error structure information.
00651  *
00652  * \param dest Pointer to a character buffer to receive the formatted results
00653  * \param cchDest Length of dest in characters
00654  * \param rc The Open-RJ result code
00655  * \param error The Open-RJ parsing error structure. Only consulted if 
00656  *   rc == ORJ_RC_PARSEERROR. May be NULL.
00657  * \param fmt Format string. May contain the special format specifier %E, which
00658  *   the formatted error string will replace. If the %E is not specified, then
00659  *   ": " and the formatted error string will be appended to the end of the
00660  *   string.
00661  *
00662  * \note Length of fmt string must be <= 768 characters
00663  *
00664  */
00665 
00666 ORJ_CALL(int) ORJ_FormatErrorA( /* [in] */ char             *dest
00667                             ,   /* [in] */ size_t           cchDest
00668                             ,   /* [in] */ ORJRC            rc
00669                             ,   /* [in] */ ORJError const   *error  /* = NULL */
00670                             ,   /* [in] */ char const       *fmt
00671                             ,   /* [in] */ ...
00672                             );
00673 
00677 # if !defined(OPENRJ_DOCUMENTATION_SKIP_SECTION) && \
00678      !defined(OPENRJ_PURE_API)
00679 /***************************************
00680  * Implementation functions
00681  *
00682  * \note These are subject to change in a future version
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 /* ? __cplusplus */
00691 
00692 #  define ORJ_Database_GetNumLinesA             ORJ_Database_GetNumLinesA_
00693 inline size_t ORJ_Database_GetNumLinesA_(/* [in] */ 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_(/* [in] */ ORJDatabaseA const *database)
00700 {
00701     return database->numFields;
00702 }
00703 #  define ORJ_Database_GetNumRecordsA           ORJ_Database_GetNumRecordsA_
00704 inline size_t ORJ_Database_GetNumRecordsA_(/* [in] */ 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_(/* [in] */ ORJRecordA const *record)
00711 {
00712     return record->numFields;
00713 }
00714 
00715 # endif /* !__cplusplus */
00716 #endif /* !OPENRJ_DOCUMENTATION_SKIP_SECTION && !OPENRJ_PURE_API */
00717 
00718 
00719 #ifdef __cplusplus
00720 # ifndef OPENRJ_NO_FILE_HANDLING
00721 
00725 inline ORJRC ORJ_ReadDatabase(  /* [in] */ orj_char_t const     *jarName
00726                             ,   /* [in] */ IORJAllocator        *ator
00727                             ,   /* [in] */ unsigned             flags
00728                             ,   /* [out] */ ORJDatabase const   **pdatabase
00729                             ,   /* [out] */ ORJError            *error)
00730 {
00731     return ORJ_ReadDatabaseA(jarName, ator, flags, pdatabase, error);
00732 }
00733 # endif /* !OPENRJ_NO_FILE_HANDLING */
00734 
00738 inline ORJRC ORJ_CreateDatabaseFromMemory(  /* [in] */ orj_char_t const     *contents
00739                                         ,   /* [in] */ size_t               cbContents
00740                                         ,   /* [in] */ IORJAllocator        *ator
00741                                         ,   /* [in] */ unsigned             flags
00742                                         ,   /* [out] */ ORJDatabaseA const  **pdatabase
00743                                         ,   /* [out] */ ORJError            *error)
00744 {
00745     return ORJ_CreateDatabaseFromMemoryA(contents, cbContents, ator, flags, pdatabase, error);
00746 }
00747 
00752 inline ORJRC ORJ_FreeDatabase(/* [in] */ ORJDatabase const *database)
00753 {
00754     return ORJ_FreeDatabaseA(database);
00755 }
00756 #else /* ? __cplusplus */
00757 # ifndef OPENRJ_NO_FILE_HANDLING
00758 #  define ORJ_ReadDatabase                      ORJ_ReadDatabaseA
00759 # endif /* !OPENRJ_NO_FILE_HANDLING */
00760 # define ORJ_CreateDatabaseFromMemory           ORJ_CreateDatabaseFromMemoryA
00761 # define ORJ_FreeDatabase                       ORJ_FreeDatabaseA
00762 #endif /* __cplusplus */
00763 
00764 /* /////////////////////////////////////////////////////////////////////////////
00765  * Shims
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;   /* This is ok, because Open-RJ guarantees that strings will be nul-terminated */
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 /* __cplusplus */
01067 
01068 /* /////////////////////////////////////////////////////////////////////////////
01069  * Namespace
01070  */
01071 
01072 #if !defined(ORJ_NO_NAMESPACE)
01073 } /* namespace openrj */
01074 
01075 #ifdef OPENRJ_DOCUMENTATION_SKIP_SECTION
01076 
01085 #endif /* OPENRJ_DOCUMENTATION_SKIP_SECTION */
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 /* !ORJ_NO_NAMESPACE */
01099 
01100 /* ////////////////////////////////////////////////////////////////////////// */
01101 
01102 #endif /* !OPENRJ_INCL_OPENRJ_H_OPENRJ */
01103 
01104 /* ////////////////////////////////////////////////////////////////////////// */

Open-RJ Library documentation © Synesis Software Pty Ltd, 2004-2005