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

Using Open-RJ in C

Building the base libraries

1. Open a console window with appropriate environment set up for your chosen compiler.

2. Navigate to the requesite directory under the Open-RJ build directory. For example, if your compiler is Borland C/C++ 5.6, then change directory to $OPENRJ_DEV/build/bc56 (where $OPENRJ_DEV is the actual directory into which you have installed the Open-RJ distribution.

3. Execute the MAKE command. For compilers that support multiple platforms, there will be multiple makefiles in the directory, e.g. makefile.mac, makefile.win32. In that case, you should stipulate the makefile, using the -f flag. For others, that are one platform only, there will just be a single file named makefile.

So, to build the files and test programs for Borland C/C++ 5.6, which is a Win32-only compiler you would simply execute "make". Conversely, for GCC, which is supported on multiple platforms, you would execute the command "make -f makefile.unix".

Using Open-RJ in C

Open-RJ is written in C, and expresses a C-API, so programming in C means programming to the core API.

There are two sample programs provided:

C_simple

This sample/test program, located in the test/C_simple subdirectory, shows a minimal use of the API, to load a memory database (from a literal string), display information about the database (# of lines, fields, records), and then enumerate the records and their constituent fields.

It performs these tasks twice, demonstrating the use of the raw data structures, and of the API functions.

C_full

This sample/test program, located in the test/C_full subdirectory, shows a full use of the C-API, including error-handling and use of the file-database function to load a file named on the command-line. It also allows the specification of the ORJ_FLAG_ORDERFIELDS and/or ORJ_FLAG_ELIDEBLANKRECORDS flags, via the command-line, which can moderate the database contents as expressed by the API.

This program has various aspects that are peripheral to the quick absorption of the API, and should be examined and tested after C_simple.


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