/*********************************************************************** * ebase library - an embedded C++ database library * * Copyright (C) 2001, Jun Sun, jsun@mvista.com or jsun@junsun.net. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * *********************************************************************** */ #ifndef _ebglobal_h_ #define _ebglobal_h_ /*********************************************************************** * This file provides : * . all external header file inclusion * . platform specific definitions, such as data endianess * . platform specific encapturation, such as EbInt32 * . configuration stuff, such as MAX_NUM_RECORDS * . misc part. * * All other files should include "ebglobal.h" as its first included file, * and they should not include any external header file. ********************************************************************** */ ////////////////////////////////////////////////////////////////////// // external header file includsion ////////////////////////////////////////////////////////////////////// #include #include #include ////////////////////////////////////////////////////////////////////// // platform specific definitions ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// // platform encapturation ////////////////////////////////////////////////////////////////////// // Normally in this section, we should use #ifdef PC ... // Right now ebase is only tested on PC with MVC++ and gcc. // It is not necessary to do so. // -*- // A boolean type used to check if a function call is successful. // typedef enum { EB_SUCCESS = 1, EB_FAILURE = 0 } EbResult; // -*- // Ebase boolean type. // typedef enum { EB_TRUE = 1, EB_FALSE = 0 } EbBoolean; // // Data types used in ebase. // -+- typedef signed char EbInt8; typedef unsigned char EbUint8; typedef signed short EbInt16; typedef unsigned short EbUint16; typedef int EbInt32; typedef unsigned int EbUint32; ////////////////////////////////////////////////////////////////////// // Configuration ////////////////////////////////////////////////////////////////////// // -*- // The EbDataHandle type. It is currently EbUint16, which implies a file // can have no more than 64k number of data. // typedef EbUint16 EbDataHandle; // -*- // The bad (invalid) data handle. const EbDataHandle EB_INVALID_HANDLE = (EbDataHandle)-1; // -*- // The magic word length for data file. const EbInt32 EB_MAGIC_WORD_LENGTH = 4; // -*- // database major versoin number const EbUint8 EB_MAJOR_NUMBER = 1; // -*- // database minor versoin number const EbUint8 EB_MINOR_NUMBER = 0; // -*- // the maximum number of fields that can be definied in a generic // index driver. (Database-specific index driver is not subject to this // constraint.) const EbUint32 EB_MAX_NUM_INDEX_FIELDS = 4; // -*- // maximum number of chars in field name const EbUint32 EB_MAX_FIELD_NAME = 30; // -*- // the maximum length of an encoded data. An encoded data is embedded into // the record. It is currently 255, because the encoded field size is uint8. const EbUint32 EB_MAX_ENCODED_FIELD_SIZE = 255; // -*- // the maximum number of indices const EbUint32 EB_MAX_NUM_INDICES = 255; ////////////////////////////////////////////////////////////////////// // Misc ////////////////////////////////////////////////////////////////////// // debugging functinos for internal use extern void EbAssertFail(const char*, int, const char*); #define EB_ASSERT(e) if (!(e)) { EbAssertFail(__FILE__,__LINE__,#e);} #define EB_ASSERTS(e, m) if (!(e)) { EbAssertFail(__FILE__,__LINE__,m);} #define EB_VERIFY(e, c) EB_ASSERT((e) c) #define EB_CHECK(e) if (!(e)) { EbAssertFail(__FILE__,__LINE__, \ "run-time fatal error."); } #endif // _ebglobal_h_