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

openrj/openrj.h File Reference


Detailed Description

[C, C++] This is the root file of the Open-RJ C-API.

#include <stddef.h>

Go to the source code of this file.

Namespaces

namespace  openrj
namespace  stlsoft

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...

Common types

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

Database manipulation functions

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.
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.
ORJRC openrj::ORJ_FreeDatabaseA (ORJDatabaseA const *database)
 Frees the resources associated with the database.
size_t openrj::ORJ_Database_GetNumLinesA (ORJDatabaseA const *database)
 Gives the number of lines in a database.
size_t openrj::ORJ_Database_GetNumFieldsA (ORJDatabaseA const *database)
 Gives the number of fields in a database.
size_t openrj::ORJ_Database_GetNumRecordsA (ORJDatabaseA const *database)
 Gives the number of records in a database.
ORJRC openrj::ORJ_Database_GetRecordA (ORJDatabaseA const *database, size_t iRecord, ORJRecordA const **precord)
 Retrieves a record in the database.
ORJRC openrj::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 openrj::ORJ_Record_GetNumFieldsA (ORJRecordA const *record)
 Gives the number of fields in a record.
ORJRC openrj::ORJ_Record_GetFieldA (ORJRecordA const *record, size_t iField, ORJFieldA const **pfield)
 Gives the number of field in a record.
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.
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.
ORJDatabaseA const * openrj::ORJ_Record_GetDatabaseA (ORJRecordA const *record)
 Gives the database associated with the record.
ORJRC openrj::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 openrj::ORJ_Field_GetNameA (ORJFieldA const *field, ORJStringA const **pname)
 Gives the name of a field.
ORJRC openrj::ORJ_Field_GetValueA (ORJFieldA const *field, ORJStringA const **pvalue)
 Gives the value of a field.
ORJRC openrj::ORJ_Field_GetNameAndValueA (ORJFieldA const *field, ORJStringA const **pname, ORJStringA const **pvalue)
 Gives the name and value of a field.
ORJRecordA const * openrj::ORJ_Field_GetRecordA (ORJFieldA const *field)
 Gives the record associated with the field.

Error functions

char const * openrj::ORJ_GetErrorStringA (ORJRC errorCode)
 Gives the name of the error.
size_t openrj::ORJ_GetErrorStringLengthA (ORJRC errorCode)
 Gives the length of the error string returned by ORJ_GetErrorStringA().
char const * openrj::ORJ_GetParseErrorStringA (ORJ_PARSE_ERROR errorCode)
 Gives the name of the parse-error.
size_t openrj::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 * openrj::c_str_ptr_null_a (ORJStringA const &s)
 Nul-terminated, possibly NULL, C-string representation of the given ORJStringA instance.
char const * openrj::c_str_ptr_null (ORJStringA const &s)
 Nul-terminated, possibly NULL, C-string representation of the given ORJStringA instance.
char const * openrj::c_str_ptr_a (ORJStringA const &s)
 Nul-terminated C-string representation of the given ORJStringA instance.
char const * openrj::c_str_ptr (ORJStringA const &s)
 Nul-terminated C-string representation of the given ORJStringA instance.
char const * openrj::c_str_data_a (ORJStringA const &s)
 Nul-terminated C-string representation of the given ORJStringA instance.
char const * openrj::c_str_data (ORJStringA const &s)
 Nul-terminated C-string representation of the given ORJStringA instance.
size_t openrj::c_str_len_a (ORJStringA const &s)
 Length of the C-string representation of the given ORJStringA instance.
size_t openrj::c_str_len (ORJStringA const &s)
 Length of the C-string representation of the given ORJStringA instance.
char const * openrj::c_str_ptr_null_a (ORJRC rc)
 Nul-terminated, possibly NULL, C-string representation of the given ORJRC instance.
char const * openrj::c_str_ptr_null (ORJRC rc)
 Nul-terminated, possibly NULL, C-string representation of the given ORJRC instance.
char const * openrj::c_str_ptr_a (ORJRC rc)
 Nul-terminated C-string representation of the given ORJRC instance.
char const * openrj::c_str_ptr (ORJRC rc)
 Nul-terminated C-string representation of the given ORJRC instance.
char const * openrj::c_str_data_a (ORJRC rc)
 Not necessarily nul-terminated C-string representation of the given ORJRC instance.
char const * openrj::c_str_data (ORJRC rc)
 Not necessarily nul-terminated C-string representation of the given ORJRC instance.
size_t openrj::c_str_len_a (ORJRC rc)
 Length of the C-string representation of the given ORJRC instance.
size_t openrj::c_str_len (ORJRC rc)
 Length of the C-string representation of the given ORJRC instance.
char const * openrj::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 * openrj::c_str_ptr_null (ORJ_PARSE_ERROR pe)
 Nul-terminated, possibly NULL, C-string representation of the given ORJ_PARSE_ERROR instance.
char const * openrj::c_str_ptr_a (ORJ_PARSE_ERROR pe)
 Nul-terminated C-string representation of the given ORJ_PARSE_ERROR instance.
char const * openrj::c_str_ptr (ORJ_PARSE_ERROR pe)
 Nul-terminated C-string representation of the given ORJ_PARSE_ERROR instance.
char const * openrj::c_str_data_a (ORJ_PARSE_ERROR pe)
 Not necessarily nul-terminated C-string representation of the given ORJ_PARSE_ERROR instance.
char const * openrj::c_str_data (ORJ_PARSE_ERROR pe)
 Not necessarily nul-terminated C-string representation of the given ORJ_PARSE_ERROR instance.
size_t openrj::c_str_len (ORJ_PARSE_ERROR pe)
 Length of the C-string representation of the given ORJ_PARSE_ERROR instance.
size_t openrj::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 & openrj::operator<< (S &stm, ORJStringA const &s)
 Inserts an ORJStringA instance into a stream.
template<class S>
S & openrj::operator<< (S &stm, ORJRC rc)
 Inserts an ORJRC instance into a stream.
template<class S>
S & openrj::operator<< (S &stm, ORJ_PARSE_ERROR pe)
 Inserts an ORJ_PARSE_ERROR instance into a stream.

Defines

#define OPENRJ_VER_MAJOR   1
 The major version number of Open-RJ.
#define OPENRJ_VER_MINOR   6
 The minor version number of Open-RJ.
#define OPENRJ_VER_REVISION   2
 The revision version number of Open-RJ.
#define OPENRJ_VER   OPENRJ_VER_1_6_2
 The current composite version number of Open-RJ.

Functions

ORJRC openrj::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 openrj::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 openrj::ORJ_FreeDatabase (ORJDatabase const *database)
 Frees the resources associated with the database.


Define Documentation

#define OPENRJ_VER   OPENRJ_VER_1_6_2

The current composite version number of Open-RJ.

#define OPENRJ_VER_MAJOR   1

The major version number of Open-RJ.

#define OPENRJ_VER_MINOR   6

The minor version number of Open-RJ.

#define OPENRJ_VER_REVISION   2

The revision version number of Open-RJ.


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