Click here to Skip to main content
Click here to Skip to main content
Articles » Database » Database » General » Downloads
 
Add your own
alternative version

DarkSide SQL Mini Version 1, The embedded database

, 23 Mar 2006 BSD
An embedded database library in C++.
/**
Copyright 2000 - 2003 LogicMatrix. All rights reserved. 

This software is distributed under the LogicMatrix Free Software License. This software may be used for any purpose, personal or commercial. Redistributions in binary /source code form are permitted. Commercial redistribution of larger works derived from, or works which bundle this software requires a "Commercial Redistribution License" which can be purchased from LogicMatrix. Contact LogicMatrix for details

Redistributions qualify as Free and non-commercial under one of the following terms:

1) Redistributions are made at no charge beyond the reasonable cost of materials and delivery.
2) Redistributions in binary/source code form must reproduce this Copyright Notice,these license terms, and the disclaimer/limitation of liability set forth as below, in the documentation and/or other materials
provided with the distribution.

Disclaimer
==========
The Software is provided on an "AS IS" basis. No warranty is
provided that the Software is free of defects, or fit for a
particular purpose. 

Limitation of Liability 
=======================
LogicMatrix shall not be liable for any damages suffered by the Licensee or any third party resulting from use of the Software.


**/

/**
	dsql_m_structs.h

	Purpose: Defines the metadata objects of
	a dsql_mini database

	Author: Vijay Mathew Pandyalakal
	Date:	14/11/2003
	Copyright: logicmatrix
**/

#ifndef DSQL_M_STRUCTS_H_
#define DSQL_M_STRUCTS_H_



class MyDate;
namespace dsqlm {

	class Database;
	
	enum boolean { FALSE=0,TRUE=1 };
	enum DsqlType {SMALLINT,INT,BIGINT,FLOAT,DOUBLE,CHAR,VARCHAR,
		DATE,TIME,TIMESTAMP,BOOL,AUTOID,UID};
	enum ComparissonOperator {EQUALS,NOT_EQUALS,GREATER_THAN,LESSER_THAN,
		GREATER_THAN_OR_EQUAL_TO,LESSER_THAN_OR_EQUAL_TO,
		LIKE};
	enum LogicalOperator {AND,OR};

	// classes defined here
	class DsqlMExcepition;	
	// a column in a table metadata
	class Column {
	private:
		int id;
		char title[33];
		DsqlType type;
		int size;
		int decim_size;
		boolean unique;
		boolean indexed;
		boolean nullable;
		boolean in_active;
	public:
		Column();
		Column(const char* title,DsqlType type,
			int size,int decim_size,boolean unique,
			boolean indexed,boolean nullable);
		void setTitle(const char* title);
		string getTitle();
		void setType(DsqlType type);
		DsqlType getType();
		void setSize(int size);
		int getSize();
		int getId();
		void setId(int id);
		void setDecimSize(int decim_size);
		int getDecimSize();
		void setUnique(boolean unique);
		boolean isUnique();
		void setIndexed(boolean indexed);
		boolean isIndexed();
		void setNullable(boolean nullable);
		boolean isNullable();	
		
		string toString();
		void refresh();
	};

	class Table {
	private:
		char name[33];
		openutils::MyDate created;
		openutils::MyDate last_access;
		Database *db;
	public:
		Table(){ 
		}
		Table(const char* name,Database* db);
		void setName(const char* name);
		string getName();
		openutils::MyDate getCreated();
		openutils::MyDate getLastAccess();

		void create();
		void open();
		void drop();
		long optimize();
		void addColumn(Column col);
		void dropColumn(const char* col_name);
		void modifyColumn(const char* col_name,Column new_col);
		int getNumberOfColumns();
		int getColumnNumber(Column col);
		Column getCol(const char* col_name);
		Column getCol(int col_no);

		int isDuplicateColumn(const char* col_name);
		string toString();
		void operator = (Table t) {
			strcpy(name,t.name);
			created = t.created;
			last_access = t.last_access;
			db = t.db;
		}
	};

	// represents an identifier like a table name,column name etc
	class Identifier {
	public:
		void check(const char* idfn);
	};

	class DsqlMException {
	private:
		string msg;
	public:
		DsqlMException() {
			msg = "";
		}
		DsqlMException(string s) {
			msg = s;
		}
		string getMessage() {
			return msg;
		}
	};
}// namespace dsqlm

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The BSD License

Share

About the Author

No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150224.1 | Last Updated 23 Mar 2006
Article Copyright 2003 by AnOldGreenHorn
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid