
//
// Class definition file for ..\dbsrc\/idxrel.s schema file.
//
// Automatically generated: Generator Revison $Rev$
//

// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
    #pragma hdrstop
#endif

#ifndef WX_PRECOMP
    #include "wx/wx.h"
#endif


#include <iostream.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include "idxrel.h"

char* strNcpy(char* d, char* s, int n);
#define ORD_COMPARE(t) \
	inline long const compare_##t(const pKeyType k1, const pKeyType k2) \
	{ \
		t _t1 = *((t *)k1); \
		t _t2 = *((t *)k2); \
		return (_t1==_t2)?0:((_t1<_t2)?-1:1); \
	} 

#define REAL_COMPARE(t) \
	inline long const compare_##t(const pKeyType k1, const pKeyType k2) \
	{ \
		t _t1 = *((t *)k1); \
		t _t2 = *((t *)k2); \
		return (_t1==_t2)?0:((_t1<_t2)?-1:1); \
	}

inline long const compare_ichar(const pKeyType k1, const pKeyType k2)
{
	char _t1 = tolower(*((char*)k1));
	char _t2 = tolower(*((char*)k2));
	return (_t1==_t2)?0:((_t1<_t2)?-1:1);
}

ORD_COMPARE(short);
ORD_COMPARE(ushort);
ORD_COMPARE(long);
ORD_COMPARE(ulong);
ORD_COMPARE(dateType);
ORD_COMPARE(char);
ORD_COMPARE(uniqueType);
REAL_COMPARE(float);
REAL_COMPARE(double);
REAL_COMPARE(moneyType);

//
// Definitions for class IndexStr
//

const char* Index::relName = "Index";
const bool Index::uniqueFields[1] = {true};
const long Index::keyLengths[1] = {sizeof(_Index_idxStr0)};

void Index::commonInit(void)
{
	memset((IndexStr*)this, 0, sizeof(IndexStr));
	setUnique(-1);
	_off_language=0;
	strArray[0] = _db_strStruct(&_off_language,&language);
	_off_handlerName=0;
	strArray[1] = _db_strStruct(&_off_handlerName,&handlerName);
	_off_boundProject=0;
	strArray[2] = _db_strStruct(&_off_boundProject,&boundProject);
	_off_contentRoot=0;
	strArray[3] = _db_strStruct(&_off_contentRoot,&contentRoot);
	_off_paths=0;
	strArray[4] = _db_strStruct(&_off_paths,&paths);
}

Index::Index() : diaRel("Index"),IndexStr()
{
	commonInit();
}

Index::Index(pKeyType _db_newKey, long _db_numKey) : diaRel("Index"), IndexStr()
{
	commonInit();
	setKey(_db_newKey, _db_numKey);
}

Index& Index::operator=(const Index& X)
{
	if (&X != this) {
		diaRel::operator=(X);
		*((IndexStr*)this) = (IndexStr)(X);
	}
	return *this;
}

pKeyType Index::getKey(const long _db_keyNum) const
{
	char* _db_buffer = new char[getKeyLength(_db_keyNum)];

	switch (_db_keyNum)
	{
		case 0:
		{
			strNcpy(((_Index_idxStr0*)_db_buffer)->name, (char*)name, 128);
			((_Index_idxStr0*)_db_buffer)->id = id;
			break;
		}
	}
	return (pKeyType)_db_buffer;
}

void Index::setKey(const pKeyType _db_buffer, const long _db_keyNum)
{
	switch (_db_keyNum)
	{
		case 0:
		{
			strNcpy((char*)name, ((_Index_idxStr0*)_db_buffer)->name,  128);
			id = ((_Index_idxStr0*)_db_buffer)->id;
			break;
		}
	}
}

Index::operator dbError()
{
	return status;
}

long Index::compare(const pKeyType _db_key, const long _db_keyNum) const
{
	//char* myKey = (char*)getKey(_db_keyNum);
	long res=0;

	switch (_db_keyNum)
	{
#pragma warn -pia
		case 0:
		{
			if (res=strncmp(name, ((_Index_idxStr0*)_db_key)->name, 128))
				break;
			if (res=compare_uniqueType((char*)(&id), (char*)(&((_Index_idxStr0*)_db_key)->id)))
				goto end_compare;
			break;
		}
#pragma warn .pia
	}

end_compare:

	//delete myKey;
	return res;
}

//
// Definitions for class FileStr
//

const char* File::relName = "File";
const bool File::uniqueFields[2] = {true,true};
const long File::keyLengths[2] = {sizeof(_File_idxStr0),sizeof(_File_idxStr1)};

void File::commonInit(void)
{
	memset((FileStr*)this, 0, sizeof(FileStr));
	setUnique(-1);
}

File::File() : diaRel("File"),FileStr()
{
	commonInit();
}

File::File(pKeyType _db_newKey, long _db_numKey) : diaRel("File"), FileStr()
{
	commonInit();
	setKey(_db_newKey, _db_numKey);
}

File& File::operator=(const File& X)
{
	if (&X != this) {
		diaRel::operator=(X);
		*((FileStr*)this) = (FileStr)(X);
	}
	return *this;
}

pKeyType File::getKey(const long _db_keyNum) const
{
	char* _db_buffer = new char[getKeyLength(_db_keyNum)];

	switch (_db_keyNum)
	{
		case 0:
		{
			((_File_idxStr0*)_db_buffer)->id = id;
			break;
		}
		case 1:
		{
			((_File_idxStr1*)_db_buffer)->fk_index = fk_index;
			((_File_idxStr1*)_db_buffer)->id = id;
			break;
		}
	}
	return (pKeyType)_db_buffer;
}

void File::setKey(const pKeyType _db_buffer, const long _db_keyNum)
{
	switch (_db_keyNum)
	{
		case 0:
		{
			id = ((_File_idxStr0*)_db_buffer)->id;
			break;
		}
		case 1:
		{
			fk_index = ((_File_idxStr1*)_db_buffer)->fk_index;
			id = ((_File_idxStr1*)_db_buffer)->id;
			break;
		}
	}
}

File::operator dbError()
{
	return status;
}

long File::compare(const pKeyType _db_key, const long _db_keyNum) const
{
	//char* myKey = (char*)getKey(_db_keyNum);
	long res=0;

	switch (_db_keyNum)
	{
#pragma warn -pia
		case 0:
		{
			if (res=compare_uniqueType((char*)(&id), (char*)(&((_File_idxStr0*)_db_key)->id)))
				goto end_compare;
			break;
		}
		case 1:
		{
			if (res=compare_long((char*)(&fk_index), (char*)(&((_File_idxStr1*)_db_key)->fk_index)))
				goto end_compare;
			if (res=compare_uniqueType((char*)(&id), (char*)(&((_File_idxStr1*)_db_key)->id)))
				goto end_compare;
			break;
		}
#pragma warn .pia
	}

end_compare:

	//delete myKey;
	return res;
}

//
// Definitions for class ItemStr
//

const char* Item::relName = "Item";
const bool Item::uniqueFields[3] = {true,true,true};
const long Item::keyLengths[3] = {sizeof(_Item_idxStr0),sizeof(_Item_idxStr1),sizeof(_Item_idxStr2)};

void Item::commonInit(void)
{
	memset((ItemStr*)this, 0, sizeof(ItemStr));
	setUnique(-1);
	_off_dataStr=0;
	strArray[0] = _db_strStruct(&_off_dataStr,&dataStr);
}

Item::Item() : diaRel("Item"),ItemStr()
{
	commonInit();
}

Item::Item(pKeyType _db_newKey, long _db_numKey) : diaRel("Item"), ItemStr()
{
	commonInit();
	setKey(_db_newKey, _db_numKey);
}

Item& Item::operator=(const Item& X)
{
	if (&X != this) {
		diaRel::operator=(X);
		*((ItemStr*)this) = (ItemStr)(X);
	}
	return *this;
}

pKeyType Item::getKey(const long _db_keyNum) const
{
	char* _db_buffer = new char[getKeyLength(_db_keyNum)];

	switch (_db_keyNum)
	{
		case 0:
		{
			strNcpy(((_Item_idxStr0*)_db_buffer)->context, (char*)context, 32);
			strNcpy(((_Item_idxStr0*)_db_buffer)->name, (char*)name, 32);
			((_Item_idxStr0*)_db_buffer)->type = type;
			((_Item_idxStr0*)_db_buffer)->id = id;
			break;
		}
		case 1:
		{
			((_Item_idxStr1*)_db_buffer)->fk_index = fk_index;
			((_Item_idxStr1*)_db_buffer)->id = id;
			break;
		}
		case 2:
		{
			((_Item_idxStr2*)_db_buffer)->type = type;
			((_Item_idxStr2*)_db_buffer)->id = id;
			break;
		}
	}
	return (pKeyType)_db_buffer;
}

void Item::setKey(const pKeyType _db_buffer, const long _db_keyNum)
{
	switch (_db_keyNum)
	{
		case 0:
		{
			strNcpy((char*)context, ((_Item_idxStr0*)_db_buffer)->context,  32);
			strNcpy((char*)name, ((_Item_idxStr0*)_db_buffer)->name,  32);
			type = ((_Item_idxStr0*)_db_buffer)->type;
			id = ((_Item_idxStr0*)_db_buffer)->id;
			break;
		}
		case 1:
		{
			fk_index = ((_Item_idxStr1*)_db_buffer)->fk_index;
			id = ((_Item_idxStr1*)_db_buffer)->id;
			break;
		}
		case 2:
		{
			type = ((_Item_idxStr2*)_db_buffer)->type;
			id = ((_Item_idxStr2*)_db_buffer)->id;
			break;
		}
	}
}

Item::operator dbError()
{
	return status;
}

long Item::compare(const pKeyType _db_key, const long _db_keyNum) const
{
	//char* myKey = (char*)getKey(_db_keyNum);
	long res=0;

	switch (_db_keyNum)
	{
#pragma warn -pia
		case 0:
		{
			if (res=strncmp(context, ((_Item_idxStr0*)_db_key)->context, 32))
				break;
			if (res=strncmp(name, ((_Item_idxStr0*)_db_key)->name, 32))
				break;
			if (res=compare_long((char*)(&type), (char*)(&((_Item_idxStr0*)_db_key)->type)))
				goto end_compare;
			if (res=compare_uniqueType((char*)(&id), (char*)(&((_Item_idxStr0*)_db_key)->id)))
				goto end_compare;
			break;
		}
		case 1:
		{
			if (res=compare_long((char*)(&fk_index), (char*)(&((_Item_idxStr1*)_db_key)->fk_index)))
				goto end_compare;
			if (res=compare_uniqueType((char*)(&id), (char*)(&((_Item_idxStr1*)_db_key)->id)))
				goto end_compare;
			break;
		}
		case 2:
		{
			if (res=compare_long((char*)(&type), (char*)(&((_Item_idxStr2*)_db_key)->type)))
				goto end_compare;
			if (res=compare_uniqueType((char*)(&id), (char*)(&((_Item_idxStr2*)_db_key)->id)))
				goto end_compare;
			break;
		}
#pragma warn .pia
	}

end_compare:

	//delete myKey;
	return res;
}
