CSLIB

From EDM2
Jump to: navigation, search

CSLIB is a multi-platform database C++ class library that was originally published as shareware for OS/2 and DOS in the early 90s by Dutch software company ComBits Software, but was later ported to Microsoft Windows and Linux. CSLIB is meant to allow C++ software developer to quickly implement databases and database-alike functionality in their applications rather than to rely on third party databases and engines by providing them with a set of easy-to-use C++ classes.

Features

CSLIB contains classes for fixed length records, variable length records, indexes and so forth, and comes with a program generator called CSDBGEN which can be used to build more complex relational databases using the CSLIB database classes if wanted, but it should the main idea behind the library is more to supply the programmer with solutions for local storage rather than compete with large database systems. CSLIB also comes with low-level classes that extend standard file I/O allowing you to create database like files that are more flexible than normal database field records, this can be helpful when traditional relational database is deemed to be too rigid for your application.

DPLAY
The 32-bit MS Windows version of the package also came with a dynamic link library that provided C/C++ software developers with a system that mimics the classic sequential file I/O provided with C++. With the added ability to insert and delete records or portions in files, this allows programmers to continue using flat files in cases when they would otherwise feel the need to switch to small databases and saves a lot of time otherwise spent copying-and-renaming of files. DPLAY was also sold separately.
CST-Library
Early DOS shareware versions of the class library came with a user interface library that alongside CSDBGEN allowed users to create fully fledged relational databases complete with UI, it was removed from later versions of CSLIB when the classes were being made more generic but the company later made a version of it freely downloadable.

Versions

The software was sold in compiler target versions rather than platform target versions, with the following versions being available:

  • CSLIB for Borland C++ for DOS, Windows & NT v2.31
  • CSLIB for Visual C++, DOS, Windows & NT v2.31
  • CSLIB for WATCOM C++, DOS, Windows & NT v2.31
  • CSLIB for Borland C++, OS/2 v2.31
  • CSLIB for WATCOM C++, OS/2 v2.31
  • CSLIB for GNU C++, Linux v2.30

License and availability

  • Discontinued commercial software.
  • The software was sold in compiler target versions rather than platform target versions (see above), each one version cost USD 139, two cost USD 199 and three cost 249. DPLAY on its own sold for USD 39.

Publisher

Code examples

Two CSLIB code examples that ComBits published on their site.

//              Example 1
//
// Very simple example for a database with fixed length records
// and no indexes.
//

  #include "CSTBASE.H"

  void main(void)
  {

    // CSLIB uses a normal C structure as a record.

    typedef struct
    {
       char name[20];
       int  age;
    } record;		// Record with two fields, 'age' and 'name'.


    TBASE  db;		// Declare an instance of the database class.
    record rec;     	// A record.


    	// Create the database on disk.  
    	// Only two parameters are needed: The name of the 
    	// database and the size of the record.
    db.define("demo.dbf",sizeof(record));

	// Open database.
	// 500 kB ram is used for buffering.
    db.open("demo.dbf",500); 


    for(int i=1;i<=12;i++) 
	db.append_rec(); 	// Append 12 records.


    db.read_rec(7,&rec);	// Read record nr 7.


    rec.age=34;                 // Change the 'age field. 
				// Note, this only requires normal C syntax.

    db.write_rec(7,&rec);	// Write record back.

    db.close();                 // Close database.

  }
//              Example 2
//
// This example demonstrates the use of the VRAM class.
// VRAM mimics 'a heap on disk'. It is not a database 
// in the traditional sense.
// 
// Data is manipulated through (virtual) pointers and
// functions like 'free' and 'malloc' are used to 
// release and allocate space on disk.
//  
// Using VRAM is similar to using the heap, only now
// data is stored on disk rather then in RAM.
// 

#include "CSVRAM.H"

void main(void)
{

    VRAM vr;                // A VRAM system.
    VPOI vp;                // A VRAM pointer.
    char *cp;               // A normal character pointer.

    vr.define("VRAM.TST",614);  // Initially create it.

    vr.open("VRAM.TST",50); // Opening with 50 Kb buffers.

    vp=vr.malloc(20);       // Allocate 20 bytes from the virtual heap.
    
    cp=vr.W(vp);            // Obtaining a character pointer to
                            // the allocated space. We are planning to 
                            // write, so the 'W' function is used.

    strcpy(cp,"Some Data"); // Write data into it.

    vr.close();         // Close the VRAM system.
                        // "Some Data" is now on disk!

}