Open-RJ Logo Open-RJ


Home page

Download Open-RJ

Samples application for your edification

Documentation for the Open-RJ API and mappings

What's been happening with Open-RJ?

Who's involved with Open-RJ?

Who's using Open-RJ?

Get in contact with the Open-RJ team


Page updated:

Samples

There are several sample programs and sample databases provided with the distribution

Sample Databases

There are two sample databases provided with the library distribution, located under the <OPENRJ_ROOT>/samples/ directory, as follows:

  • Pets

    A simple pets database, listing several favoured four-legged creatures. The database currently contains records representing cats and dogs. Each dog record has three fields: Name, Species and Breed. Each cat record has two fields: Name and Species.

    The following small extract shows three records - 1 cat, 2 dogs - wherein Rebel's breed is split over two lines using the continuation character. When read in by the Open-RJ library, that will become "German Shepherd":

    Name:       Fluffy Kitten
    Species:    Cat
    %%
    Name:       Moet
    Species:    Dog
    Breed:      Boxer
    %%
    Name:       Rebel
    Species:    Dog
    Breed:      German \
                Shepherd
    %%
    
  • Imperfect C++ book list

    This is a real Open-RJ database, which was used in the preparation of the accompanying CD for Matthew's new book Imperfect C++.

    The following extract shows how a relatively rich form, e.g. including HTML markups, can be encapsulated within the simple Open-RJ format:

    Author:         Hunt and Thomas
    Title:          Pragmatic Programmer, The
    Url:            http://www.awprofessional.com/title/020161622X
    Publisher:      Addison-Wesley
    Year:           2000
    Description:    An ace book from some fellow <a href = "../resources/index.html#ruby">Ruby</a> \
                    fans. All kinds of great advice. A "must own" book.
    %%
    Author:         Thomas and Hunt
    Title:          Pragmatic Version Control
    Url:            http://www.pragmaticprogrammer.com/starter_kit/vc/
    Publisher:      The Pragmatic Bookshelf
    Year:           2003
    Description:    More pragmatic gems, this time on version control. Another must read in \
                    a digestible and enjoyable presentation.
    %%
    

Both databases may be examined by any of the sample programs.

Sample Programs

There are six sample programs provided with the library, located under the <OPENRJ_ROOT>/test/ directory, as follows:

  • C

    A test client written in C (in <OPENRJ_ROOT>/test/C), implemented in terms of the C-API (in <OPENRJ_ROOT>/include/openrj/openrj.h).

    This is built by the main library makefiles (under <OPENRJ_ROOT>/build/) for the Borland (5.6.4), Metroworks CodeWarrior 8, Digital Mars, GCC (3.4), Intel (8) and Visual C++ (6.0 and 7.1) compilers, and will very likely work with any C compiler.

  • C++

    A test client written in C++ (in <OPENRJ_ROOT>/test/Cpp), implemented in terms of the C++ mapping (in <OPENRJ_ROOT>/include/openrj/cpp/).

    This is built by the main library makefiles (under <OPENRJ_ROOT>/build/) for the Borland (5.6.4), Metroworks CodeWarrior 8, Digital Mars, GCC (3.4), Intel 8 and Visual C++ (6.0 and 7.1) compilers, and will likely work with all modern C++ compilers.

    Note that the C++ mapping requires the presence of the STLSoft libraries, version 1.8.4 or later.

  • Ch

    A test client, test.ch, written in Ch (found in <OPENRJ_ROOT>/mappings/Ch), exercises the Ch mapping.

  • D

    A test client written in D (in <OPENRJ_ROOT>/test/D), implemented in terms of the D mapping (in <OPENRJ_ROOT>/mappings/D/).

    This is built by the makefile in the (also in <OPENRJ_ROOT>/test/) with the with the Digital Mars D compiler (version 0.96 or later).

  • .NET

    A test client written in C# (in <OPENRJ_ROOT>/test/dotNet), implemented in terms of the C++ mapping (in <OPENRJ_ROOT>/mappings/C++.NET/)

    These are both built via the Visual Studio 2003 solution (in the <OPENRJ_ROOT>/ directory). The C++.NET mapping is also built via the main library makefile for Visual C++ 7.1 (in <OPENRJ_ROOT>/build/vc71).

  • Python

    A test Python program is included (in <OPENRJ_ROOT>/test/Python/), implemented in terms of the Python mapping (in <OPENRJ_ROOT>/mappings/Python/)

  • Ruby

    A test Ruby program is included (in <OPENRJ_ROOT>/test/Ruby/), implemented in terms of the Ruby mapping (in <OPENRJ_ROOT>/mappings/Ruby/)

    The mapping has to be built via a Ruby extconf.rb file (also in <OPENRJ_ROOT>/mappings/Ruby/), and has been tested to build correctly with various versions of Visual C++. If you wish to build the Ruby mapping with another library, you will need to adjust the contents of extconf.rb according to the requirements for your chosen compiler.

  • STL

    A test client written in C++/STL (in <OPENRJ_ROOT>/test/STL/), implemented in terms of the C++ mapping (in <OPENRJ_ROOT>/include/openrj/stl/).

    This is built by the main library makefiles (under <OPENRJ_ROOT>/build/) for the Borland (5.6.4), Metroworks CodeWarrior 8, Digital Mars, GCC (3.4), Intel 8 and Visual C++ (6.0 and 7.1) compilers, and will likely work with most modern C++ compilers.

    Note that the STL mapping requires the presence of the STLSoft libraries, version 1.8.4 or later.

Each of these CLI (command-line interface) programs reads in an Open-RJ database file, and prints a hierarchical representation of its full contents to the standard output stream. The usage is roughly similar in each case:

<program> [-o] [-s] <database>

Where:

<program>  -  the program name, e.g. openrj_c_cw8.exe
-o  -  causes the fields in each record to be sorted, by name
-s  -  causes any empty records to be stripped out
<database>  -  the Open-RJ database file, e.g. pets.orj

Each program represents an excellent tutorial for the use of Open-RJ from the different languages supported.

%% Pets
 
Name:    Elsa
Species: Dog
Breed:   Mixed
%%
Name:    Sheltie
Species: Dog
Breed:   Shetland Sheepdog
%%
 
Name:    Sparky
Species: Cat
%%
 
Valid XHTML 1.0! Website content and Open-RJ implementation © Greg Peet & Matthew Wilson SourceForge.net Logo