Click here to Skip to main content
15,879,326 members
Articles / Database Development / SQL Server

DarkSide SQL Mini Version 1, The embedded database

Rate me:
Please Sign up or sign in to vote.
3.50/5 (27 votes)
23 Mar 2006BSD2 min read 156.4K   2.9K   57  
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.


**/

/**
	unique.h

	Purpose: Checks if a new value will create duplicate entry in
			 an index file

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

#include <string>
#include <vector>
using namespace std;

#include "db_cxx.h"

#include "mydate.h"
using namespace openutils;

#include "dsql_m_structs.h"
#include "bridge.h"
#include "sql_lexer.h"
#include "bdb_index.h"
#include "unique.h"
using namespace dsqlm;

Unique::Unique(Table* table,Database* db) {
	if(db == 0) {
		throw DsqlMException("Unique.cpp - database not inited");
	}
	m_db = db;
	this->table = table;
}

bool Unique::check(Column col,const char* new_val,long pos) {
	char db_name[151];
	sprintf(db_name,"%s\\%s_%s_x",m_db->getDBName().c_str(),
		table->getName().c_str(),
		col.getTitle().c_str());
	BdbIndex index(db_name,false);
	index.get(new_val);	
	long sz = index.getCursorSize();
	if(sz <= 0) {
		return false;
	}else {
		try {
			string val = index.getKey(0);
			long dat = index.getData(0);		
			if(dat == pos) 
				return false;
			else 
				return true;
		}catch(...) {
			return true;
		}		
	}
}

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


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions