Skip to content

Store Linux C++ class data in a file ( persistence ) and manipulate it programmatically or using Small SQL (included)

License

Notifications You must be signed in to change notification settings

georgetdn/SYSCPPCPlinux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 

Repository files navigation

THIS CODE WAS MERGED INTO https://github.com/georgetdn/SYSCPPCP

SYSCPPCP

Simple Yet Sophisticated C++ Class Persistence or SYSCPPCP

Store C++ class data in a file and manipulate it programmatically or using SmallSQL(included)

Requirements:

Linux 64 bits (tested on Ubuntu), g++-14, version 14.2.0 compiler, GNU Readline library (installed automatically), 'sudo' for user running the install. Follow the link for Windows version

Installing

To install and build the framework and SmallSQL application clone the project go to SYSCPPCP directory in a Bash shell and execute the ./build. You will be prompted to enter your password for sudo to install the GNU Readline library. The build will take about five minutes This process will build a framework based on the sample templates from \SYSCPPCP\SYSCPPCPcodeGenrtators\templates . When you develop your application you will create a set of templates defining the classes in your application, build the framework and add code specific to your application. More on this later.

Getting familiar with the framework

The best way to familiarize yourself with the framework is to execute the sample applications. In Windows Explorer go to \SYSCPPCP\SYSCPPCPtest\QuickStart and start QuickStart.vcxproj Step through the code in debug mode. You should be able to get an understanding of what actions you can perform.

Next, open a command prompt or power shell window and go to SYSCPPCP\SmallSQL\releae and type smallsql ../../syscppcp.dat (./smallsql ../../syscppcp.dat for PS)
You should get a SmallSQL prompt
Type cls to clean the screen
Type SmallSQL> select classes from dual

    Classes(Tables)
    ===============
    Cat
    Child
    Customer
    Dog
    Family
    Invoice
    Item
    Person

This is a list the classes created during build based on the sample templates. For each class a header \SYSCPPCP\SYSCPPCPheaders, a source file in \SYSCPPCP\SYSCPPCPSource, a project file in \SYSCPPCP\SYSCPPCPvcxproj and a static library in \SYSCPPCP\SYSCPPCPlibs. You will need them to build your application. Type SmallSQL> desc Customer

Enumerations
===========
  enum Type
   {
    Retail,
    WholeSale,
    OneTime
   };

Structures
========
struct Name
{
    char First[20];
    char Last [20];
};
Variables(columns)
==================
   int ID;
   Name name;
   char Address1 [41];
   char Address2 [21];
   char City  [21];
   char State  [3];
   char Zip [6];
   Type type ;

You will get the data members of the class - Variables(columns) - an enumeration and structure declarations used to declare the variables 'type' and 'name'. Try SmallSQL> select * from Cat You will get a listing of all records of type Cat stored (serialized) to the database. The database file is \SYSCPPCP\syscppcp.dat. Try SmallSQL> select name.First, name.Last from customer
Syntax Error: Table 'customer' does not exist.
You get an error because class (table) names and variable(columns) names are case sensitive.
The correct statement is
select name.First, name.Last from Customer
Notice that the column names are variable names as you would use them in a program.
name is declared as a structure

Name {
      char  First[20; 
      char Last [20];
    };

You can also try
select name.First, name.Last from Customer where State = NY and City = "New York"
Notice that only strings containing spaces need to be enclosed in quotes. For numbers and enumerations, no quotes or transformations are needed. A few more rules,

  • Only one class(table) can be used in a query
  • Maximum of five where clauses.
  • Except for arrays of char, no arrays can be used in a query
  • For enumerations you have to use the item name not the associated integer value
  • You are not allowed to change the class variables declarations

More examples
SmallSQL> update Customer set name.First = "Milton", name.Last = "Gimbles" where ID = 4597
SmallSQL> delete from Customer where type = OneTime
To exit type bye or exit Note: In your applications, as long as you don't change the generated code, you can declare other variables and functions. The newly declared variables will not be stored in the database. If you need more help read the tutorials. You can also email me at [email protected]

About

Store Linux C++ class data in a file ( persistence ) and manipulate it programmatically or using Small SQL (included)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published