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

openrj Namespace Reference


Detailed Description

The Open-RJ root namespace.

This the the root namespace for Open-RJ, and contains the C-API functions, along with enumerations and structures.


Classes

struct  IORJAllocator
 Allocator interface for Open-RJ. More...
struct  ORJStringA
 The string type (for ANSI coding). More...
struct  ORJFieldA
 The field type (for ANSI coding). More...
struct  ORJRecordA
 The record type (for ANSI coding). More...
struct  ORJDatabaseA
 The database type (for ANSI coding). More...
struct  ORJError
 Parsing error structure. More...

Namespaces

namespace  cpp
 The namespace of the Open-RJ/C++ mapping.
namespace  stl
 The namespace of the Open-RJ/STL mapping.

Common types

typedef char orj_char_t
 Character type used by Open-RJ.
enum  ORJ_FLAG {
  ORJ_FLAG_ORDERFIELDS = 0x0001,
  ORJ_FLAG_ELIDEBLANKRECORDS = 0x0002,
  ORJ_FLAG_IGNORECASEONLOOKUP = 0x0004,
  ORJ_FLAG_NOREINTERPRETFIELDIDS = 0x0100,
  ORJ_FLAG_FORCEALLFIELDSINTO1RECORD = 0x0008
}
 The flags passed to the database creation functions. More...
enum  ORJRC {
  ORJ_RC_SUCCESS = 0,
  ORJ_RC_CANNOTOPENJARFILE,
  ORJ_RC_NORECORDS,
  ORJ_RC_OUTOFMEMORY,
  ORJ_RC_BADFILEREAD,
  ORJ_RC_PARSEERROR,
  ORJ_RC_INVALIDINDEX,
  ORJ_RC_UNEXPECTED,
  ORJ_RC_INVALIDCONTENT
}
 The return code type of the Open-RJ API. More...
enum  ORJ_PARSE_ERROR {
  ORJ_PARSE_SUCCESS = 0,
  ORJ_PARSE_RECORDSEPARATORINCONTINUATION,
  ORJ_PARSE_UNFINISHEDLINE,
  ORJ_PARSE_UNFINISHEDFIELD,
  ORJ_PARSE_UNFINISHEDRECORD,
  ORJ_PARSE_INVALIDFIELDNAME
}
 Parsing error constants. More...

Database manipulation functions

ORJRC ORJ_ReadDatabaseA (char const *jarName, IORJAllocator *ator, unsigned flags, ORJDatabaseA const **pdatabase, ORJError *error)
 Reads the records from the given file into an Open-RJ databsae.
ORJRC ORJ_CreateDatabaseFromMemoryA (char const *contents, size_t cbContents, IORJAllocator *ator, unsigned flags, ORJDatabaseA const **pdatabase, ORJError *error)
 Reads the records from the memory block into an Open-RJ databsae.
ORJRC ORJ_FreeDatabaseA (ORJDatabaseA const *database)
 Frees the resources associated with the database.
size_t ORJ_Database_GetNumLinesA (ORJDatabaseA const *database)
 Gives the number of lines in a database.
size_t ORJ_Database_GetNumFieldsA (ORJDatabaseA const *database)
 Gives the number of fields in a database.
size_t ORJ_Database_GetNumRecordsA (ORJDatabaseA const *database)
 Gives the number of records in a database.
ORJRC ORJ_Database_GetRecordA (ORJDatabaseA const *database, size_t iRecord, ORJRecordA const **precord)
 Retrieves a record in the database.
ORJRC ORJ_Database_GetFieldA (ORJDatabaseA const *database, size_t iField, ORJFieldA const **pfield)
 Retrieves a field in the database.

Record manipulation functions

These functions may be used instead of direct manipulation of the data structures, which may be necessary when mapping the API to other languages which can only deal in opaque values and function calls (e.g. JNI).

size_t ORJ_Record_GetNumFieldsA (ORJRecordA const *record)
 Gives the number of fields in a record.
ORJRC ORJ_Record_GetFieldA (ORJRecordA const *record, size_t iField, ORJFieldA const **pfield)
 Gives the number of field in a record.
ORJFieldA const * ORJ_Record_FindFieldByNameA (ORJRecordA const *record, char const *fieldName, char const *fieldValue)
 Finds a field in a record, based on the name and, optionally, the value.
ORJFieldA const * ORJ_Record_FindNextFieldA (ORJRecordA const *record, ORJFieldA const *fieldAfter, char const *fieldName, char const *fieldValue)
 Finds a field in a record, relative to a specified field, based on optional name and/or value.
ORJDatabaseA const * ORJ_Record_GetDatabaseA (ORJRecordA const *record)
 Gives the database associated with the record.
ORJRC ORJ_Record_GetCommentA (ORJRecordA const *record, ORJStringA const **pcomment)
 Gives the record comment.

Field manipulation functions

These functions may be used instead of direct manipulation of the data structures, which may be necessary when mapping the API to other languages which can only deal in opaque values and function calls (e.g. JNI).

ORJRC ORJ_Field_GetNameA (ORJFieldA const *field, ORJStringA const **pname)
 Gives the name of a field.
ORJRC ORJ_Field_GetValueA (ORJFieldA const *field, ORJStringA const **pvalue)
 Gives the value of a field.
ORJRC ORJ_Field_GetNameAndValueA (ORJFieldA const *field, ORJStringA const **pname, ORJStringA const **pvalue)
 Gives the name and value of a field.
ORJRecordA const * ORJ_Field_GetRecordA (ORJFieldA const *field)
 Gives the record associated with the field.

Error functions

char const * ORJ_GetErrorStringA (ORJRC errorCode)
 Gives the name of the error.
size_t ORJ_GetErrorStringLengthA (ORJRC errorCode)
 Gives the length of the error string returned by ORJ_GetErrorStringA().
char const * ORJ_GetParseErrorStringA (ORJ_PARSE_ERROR errorCode)
 Gives the name of the parse-error.
size_t ORJ_GetParseErrorStringLengthA (ORJ_PARSE_ERROR errorCode)
 Gives the length of the error string returned by ORJ_GetParseErrorStringA().

String access shims

These functions are string access shims for injection into the stlsoft namespace, in order to facilitate generalised manipulation of the ORJStringA, ORJRC and ORJ_PARSE_ERROR types.

char const * c_str_ptr_null_a (ORJStringA const &s)
 Nul-terminated, possibly NULL, C-string representation of the given ORJStringA instance.
char const * c_str_ptr_null (ORJStringA const &s)
 Nul-terminated, possibly NULL, C-string representation of the given ORJStringA instance.
char const * c_str_ptr_a (ORJStringA const &s)
 Nul-terminated C-string representation of the given ORJStringA instance.
char const * c_str_ptr (ORJStringA const &s)
 Nul-terminated C-string representation of the given ORJStringA instance.
char const * c_str_data_a (ORJStringA const &s)
 Nul-terminated C-string representation of the given ORJStringA instance.
char const * c_str_data (ORJStringA const &s)
 Nul-terminated C-string representation of the given ORJStringA instance.
size_t c_str_len_a (ORJStringA const &s)
 Length of the C-string representation of the given ORJStringA instance.
size_t c_str_len (ORJStringA const &s)
 Length of the C-string representation of the given ORJStringA instance.
char const * c_str_ptr_null_a (ORJRC rc)
 Nul-terminated, possibly NULL, C-string representation of the given ORJRC instance.
char const * c_str_ptr_null (ORJRC rc)
 Nul-terminated, possibly NULL, C-string representation of the given ORJRC instance.
char const * c_str_ptr_a (ORJRC rc)
 Nul-terminated C-string representation of the given ORJRC instance.
char const * c_str_ptr (ORJRC rc)
 Nul-terminated C-string representation of the given ORJRC instance.
char const * c_str_data_a (ORJRC rc)
 Not necessarily nul-terminated C-string representation of the given ORJRC instance.
char const * c_str_data (ORJRC rc)
 Not necessarily nul-terminated C-string representation of the given ORJRC instance.
size_t c_str_len_a (ORJRC rc)
 Length of the C-string representation of the given ORJRC instance.
size_t c_str_len (ORJRC rc)
 Length of the C-string representation of the given ORJRC instance.
char const * c_str_ptr_null_a (ORJ_PARSE_ERROR pe)
 Nul-terminated, possibly NULL, C-string representation of the given ORJ_PARSE_ERROR instance.
char const * c_str_ptr_null (ORJ_PARSE_ERROR pe)
 Nul-terminated, possibly NULL, C-string representation of the given ORJ_PARSE_ERROR instance.
char const * c_str_ptr_a (ORJ_PARSE_ERROR pe)
 Nul-terminated C-string representation of the given ORJ_PARSE_ERROR instance.
char const * c_str_ptr (ORJ_PARSE_ERROR pe)
 Nul-terminated C-string representation of the given ORJ_PARSE_ERROR instance.
char const * c_str_data_a (ORJ_PARSE_ERROR pe)
 Not necessarily nul-terminated C-string representation of the given ORJ_PARSE_ERROR instance.
char const * c_str_data (ORJ_PARSE_ERROR pe)
 Not necessarily nul-terminated C-string representation of the given ORJ_PARSE_ERROR instance.
size_t c_str_len (ORJ_PARSE_ERROR pe)
 Length of the C-string representation of the given ORJ_PARSE_ERROR instance.
size_t c_str_len_a (ORJ_PARSE_ERROR pe)
 Length of the C-string representation of the given ORJ_PARSE_ERROR instance.

Stream insertion shims

These functions are stream insertion shims for allowing the ORJStringA, ORJRC and ORJ_PARSE_ERROR types to be used with stream instances, a la the IOStreams.

For example:


 ORJRecord *record = . . . ;

 std::cout << record->fields[0] << std::end; // Prints the value of the 0th field in the record

 ORJRC rc = ORJ_RC_INVALIDINDEX;

 std::cout << rc << std::end; // Prints "An invalid index was specified"

 ORJ_PARSE_ERROR pe = ORJ_PARSE_UNFINISHEDLINE;

 std::cout << pe << std::end; // Prints "The last line in the database was not terminated by a line-feed"

 


template<class S>
S & operator<< (S &stm, ORJStringA const &s)
 Inserts an ORJStringA instance into a stream.
template<class S>
S & operator<< (S &stm, ORJRC rc)
 Inserts an ORJRC instance into a stream.
template<class S>
S & operator<< (S &stm, ORJ_PARSE_ERROR pe)
 Inserts an ORJ_PARSE_ERROR instance into a stream.

Functions

ORJRC ORJ_ReadDatabase (orj_char_t const *jarName, IORJAllocator *ator, unsigned flags, ORJDatabase const **pdatabase, ORJError *error)
 Reads the records from the given file into an Open-RJ databsae.
ORJRC ORJ_CreateDatabaseFromMemory (orj_char_t const *contents, size_t cbContents, IORJAllocator *ator, unsigned flags, ORJDatabaseA const **pdatabase, ORJError *error)
 Reads the records from the memory block into an Open-RJ databsae.
ORJRC ORJ_FreeDatabase (ORJDatabase const *database)
 Frees the resources associated with the database.


Typedef Documentation

typedef char orj_char_t

Character type used by Open-RJ.

Note:
As of the current implementation, this is always defined to char


Enumeration Type Documentation

enum ORJ_FLAG

The flags passed to the database creation functions.

Enumerator:
ORJ_FLAG_ORDERFIELDS  Arranges the fields in alphabetical order
ORJ_FLAG_ELIDEBLANKRECORDS  Causes blank records to be ignored
ORJ_FLAG_IGNORECASEONLOOKUP  Ignores case when looking up field names.
ORJ_FLAG_NOREINTERPRETFIELDIDS  Suppresses Field Identifier Reinterpretation (see help file)
ORJ_FLAG_FORCEALLFIELDSINTO1RECORD  Causes record separators to be ignored, and all fields to be forced into a single record.

enum ORJRC

The return code type of the Open-RJ API.

Enumerator:
ORJ_RC_SUCCESS  Operation was successful
ORJ_RC_CANNOTOPENJARFILE  The given file does not exist, or cannot be accessed
ORJ_RC_NORECORDS  The database file contained no records
ORJ_RC_OUTOFMEMORY  The API suffered memory exhaustion
ORJ_RC_BADFILEREAD  A read operation failed
ORJ_RC_PARSEERROR  Parsing of the database file failed due to a syntax error
ORJ_RC_INVALIDINDEX  An invalid index was specified
ORJ_RC_UNEXPECTED  An unexpected condition was encountered
ORJ_RC_INVALIDCONTENT  The database file contained invalid content
Examples:
example_c_1.c, example_c_2.c, example_c_3.c, example_c_4.c, example_c_5.c, example_c_6.c, example_c_7.c, and example_c_8.c.

enum ORJ_PARSE_ERROR

Parsing error constants.

Enumerator:
ORJ_PARSE_SUCCESS  Parsing was successful
ORJ_PARSE_RECORDSEPARATORINCONTINUATION  A record separator was encountered during a content line continuation
ORJ_PARSE_UNFINISHEDLINE  The last line in the database was not terminated by a line-feed
ORJ_PARSE_UNFINISHEDFIELD  The last record in the database file was not terminated by a record separator
ORJ_PARSE_UNFINISHEDRECORD  The last record in the database file was not terminated by a record separator
ORJ_PARSE_INVALIDFIELDNAME  The field name was not valid


Function Documentation

ORJRC openrj::ORJ_ReadDatabaseA ( char const *  jarName,
IORJAllocator *  ator,
unsigned  flags,
ORJDatabaseA const **  pdatabase,
ORJError *  error 
)

Reads the records from the given file into an Open-RJ databsae.

Parameters:
jarName Name of the Record-JAR file. May not be NULL
ator The allocator to use for allocating memory, May be NULL, in which case CRT malloc() / realloc() / free() are used
flags Combination of the ORJ_FLAG enumeration
error Pointer to an error structure, which is filled out with information if a parsing error is encountered
pdatabase Pointer to a database pointer, in which will be returned the database. May not be NULL. The returned pointer must be freed using ORJ_FreeDatabaseA().

ORJRC openrj::ORJ_CreateDatabaseFromMemoryA ( char const *  contents,
size_t  cbContents,
IORJAllocator *  ator,
unsigned  flags,
ORJDatabaseA const **  pdatabase,
ORJError *  error 
)

Reads the records from the memory block into an Open-RJ databsae.

Parameters:
contents Pointer to the base of the memory contents to parse. May not be NULL
cbContents Number of bytes in the memory contents to parse
ator The allocator to use for allocating memory, May be NULL, in which case CRT malloc() / realloc() / free() are used
flags Combination of the ORJ_FLAG enumeration
error Pointer to an error structure, which is filled out with information if a parsing error is encountered
pdatabase Pointer to a database pointer, in which will be returned the database. May not be NULL. The returned pointer must be freed using ORJ_FreeDatabaseA().

ORJRC openrj::ORJ_FreeDatabaseA ( ORJDatabaseA const *  database  ) 

Frees the resources associated with the database.

Parameters:
database The database. May not be NULL

size_t openrj::ORJ_Database_GetNumLinesA ( ORJDatabaseA const *  database  ) 

Gives the number of lines in a database.

Parameters:
database The database. May not be NULL
Note:
The database is assumed valid. There is no error return
Examples:
example_c_1.c, and example_c_3.c.

size_t openrj::ORJ_Database_GetNumFieldsA ( ORJDatabaseA const *  database  ) 

Gives the number of fields in a database.

Parameters:
database The database. May not be NULL
Note:
The database is assumed valid. There is no error return
Examples:
example_c_1.c, and example_c_3.c.

size_t openrj::ORJ_Database_GetNumRecordsA ( ORJDatabaseA const *  database  ) 

Gives the number of records in a database.

Parameters:
database The database. May not be NULL
Note:
The database is assumed valid. There is no error return
Examples:
example_c_1.c, and example_c_3.c.

ORJRC openrj::ORJ_Database_GetRecordA ( ORJDatabaseA const *  database,
size_t  iRecord,
ORJRecordA const **  precord 
)

Retrieves a record in the database.

Parameters:
database The database from which the record is to be retrieved
iRecord Index of the record to be retrieved
precord Pointer to a record pointer. The returned value points at the requested record stucture
Examples:
example_c_1.c, and example_c_3.c.

ORJRC openrj::ORJ_Database_GetFieldA ( ORJDatabaseA const *  database,
size_t  iField,
ORJFieldA const **  pfield 
)

Retrieves a field in the database.

Parameters:
database The database from which the field is to be retrieved
iField Index of the field to be retrieved
pfield Pointer to a field pointer. The returned value points at the requested field stucture
Examples:
example_c_6.c.

size_t openrj::ORJ_Record_GetNumFieldsA ( ORJRecordA const *  record  ) 

Gives the number of fields in a record.

Parameters:
record The record. May not be NULL
Note:
The record is assumed valid. There is no error return
Examples:
example_c_1.c, and example_c_3.c.

ORJRC openrj::ORJ_Record_GetFieldA ( ORJRecordA const *  record,
size_t  iField,
ORJFieldA const **  pfield 
)

Gives the number of field in a record.

Parameters:
record The record from which to retrieve the field
iField Index of the field to be retrieved
pfield Pointer to a field pointer. The returned value points at the requested field stucture
Examples:
example_c_1.c.

ORJFieldA const* openrj::ORJ_Record_FindFieldByNameA ( ORJRecordA const *  record,
char const *  fieldName,
char const *  fieldValue 
)

Finds a field in a record, based on the name and, optionally, the value.

Parameters:
record The record from which to retrieve the field
fieldName The name of the field
fieldValue The value of the field. May be NULL, in which case the first record with the given name will be returned, irrespective of its value.
Examples:
example_c_3.c.

ORJFieldA const* openrj::ORJ_Record_FindNextFieldA ( ORJRecordA const *  record,
ORJFieldA const *  fieldAfter,
char const *  fieldName,
char const *  fieldValue 
)

Finds a field in a record, relative to a specified field, based on optional name and/or value.

Parameters:
record The record from which to retrieve the field
fieldAfter The field to start the search from. NULL to get the first field.
fieldName The name of the field. May be NULL for no filtering on name
fieldValue The value of the field. May be NULL for no filtering on value

ORJDatabaseA const* openrj::ORJ_Record_GetDatabaseA ( ORJRecordA const *  record  ) 

Gives the database associated with the record.

Parameters:
record The record. May not be NULL
Note:
The record is assumed valid. There is no error return

ORJRC openrj::ORJ_Record_GetCommentA ( ORJRecordA const *  record,
ORJStringA const **  pcomment 
)

Gives the record comment.

Parameters:
record The record from which to retrieve the field
pcomment Pointer to a comment pointer. The returned value points at the comment
Examples:
example_c_1.c, and example_c_3.c.

ORJRC openrj::ORJ_Field_GetNameA ( ORJFieldA const *  field,
ORJStringA const **  pname 
)

Gives the name of a field.

Parameters:
field The field whose name is to be retrieved
pname Pointer to a string pointer. The returned value points at a string structure representing the name
Note:
In the current implementation, the field is assumed valid, and the return value is always ORJ_RC_SUCCESS

ORJRC openrj::ORJ_Field_GetValueA ( ORJFieldA const *  field,
ORJStringA const **  pvalue 
)

Gives the value of a field.

Parameters:
field The field whose value is to be retrieved
pvalue Pointer to a string pointer. The returned value points at a string structure representing the value
Note:
In the current implementation, the field is assumed valid, and the return value is always ORJ_RC_SUCCESS

ORJRC openrj::ORJ_Field_GetNameAndValueA ( ORJFieldA const *  field,
ORJStringA const **  pname,
ORJStringA const **  pvalue 
)

Gives the name and value of a field.

Parameters:
field The field whose value is to be retrieved
pname Pointer to a string pointer. The returned value points at a string structure representing the name
pvalue Pointer to a string pointer. The returned value points at a string structure representing the value
Note:
In the current implementation, the field is assumed valid, and the return value is always ORJ_RC_SUCCESS
Examples:
example_c_1.c.

ORJRecordA const* openrj::ORJ_Field_GetRecordA ( ORJFieldA const *  field  ) 

Gives the record associated with the field.

Parameters:
field The field. May not be NULL
Note:
The record is assumed valid. There is no error return

char const* openrj::ORJ_GetErrorStringA ( ORJRC  errorCode  ) 

Gives the name of the error.

Parameters:
errorCode The error whose name is to be retrieved
Note:
If the error is not recognised, the function returns the empty string ("")
Examples:
example_c_1.c, example_c_2.c, example_c_3.c, example_c_4.c, example_c_5.c, example_c_6.c, example_c_7.c, and example_c_8.c.

size_t openrj::ORJ_GetErrorStringLengthA ( ORJRC  errorCode  ) 

Gives the length of the error string returned by ORJ_GetErrorStringA().

Parameters:
errorCode The error whose name is to be retrieved
Note:
If the error is not recognised, the function returns 0

char const* openrj::ORJ_GetParseErrorStringA ( ORJ_PARSE_ERROR  errorCode  ) 

Gives the name of the parse-error.

Parameters:
errorCode The parse-error whose name is to be retrieved
Note:
If the error is not recognised, the function returns the empty string ("")

size_t openrj::ORJ_GetParseErrorStringLengthA ( ORJ_PARSE_ERROR  errorCode  ) 

Gives the length of the error string returned by ORJ_GetParseErrorStringA().

Parameters:
errorCode The error whose name is to be retrieved
Note:
If the error is not recognised, the function returns 0

ORJRC openrj::ORJ_ReadDatabase ( orj_char_t const *  jarName,
IORJAllocator *  ator,
unsigned  flags,
ORJDatabase const **  pdatabase,
ORJError *  error 
) [inline]

Reads the records from the given file into an Open-RJ databsae.

Note:
An inline wrapper for ORJ_ReadDatabaseA()
Examples:
example_c_5.c.

ORJRC openrj::ORJ_CreateDatabaseFromMemory ( orj_char_t const *  contents,
size_t  cbContents,
IORJAllocator *  ator,
unsigned  flags,
ORJDatabaseA const **  pdatabase,
ORJError *  error 
) [inline]

Reads the records from the memory block into an Open-RJ databsae.

Note:
An inline wrapper for ORJ_CreateDatabaseFromMemoryA()
Examples:
example_c_1.c, example_c_2.c, example_c_3.c, example_c_4.c, example_c_6.c, example_c_7.c, and example_c_8.c.

ORJRC openrj::ORJ_FreeDatabase ( ORJDatabase const *  database  )  [inline]

Frees the resources associated with the database.

Note:
An inline wrapper for ORJ_FreeDatabaseA()
Examples:
example_c_1.c, example_c_2.c, example_c_3.c, example_c_4.c, example_c_5.c, example_c_6.c, example_c_7.c, and example_c_8.c.


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