eXtremeDB DLL 笔记
DLL 例子
c
// 预处理
#define int1 signed<1>
#define int2 signed<2>
#define int4 signed<4>
#define uint4 unsigned<4>
#define uint2 unsigned<2>
#define uint1 unsigned<1>
// 结构体声明
struct SampleStruct {
uint2 s1;
char<20> s2;
};
struct BigStruct {
string str;
uint2 u2;
uint4 u4;
vector <SampleStruct> vss;
};
// DDL 声明语句
declare database simple;
/*
* estimated number of class instances is in square brackets
* 方括号中为估计的实例数
*/
declare OID SampleStruct[20000];
/*
* “compact” keyword: Total object size, including overhead is less than 64K.
* Size calculation does NOT count size of blob(s) fields
* embedded in the class
*
* compact 关键字:总对象大小,包括开销小于 64K
* 大小计算不计算 Blob 字段的大小
*
*/
compact class SampleClass {
/* basic data types 基本数据类型 */
uint1 a = 0;
uint2 b;
uint4 c;
/* oid reference */
ref d;
/* vectors - could be made of any type */
vector <uint2> numbers;
vector <SampleStruct> ss;
/* strings are limited to 64K */
string str;
/* Binary data object, blobs are unlimited*/
blob blo;
/* optional structure, the value could be missing */
optional BigStruct big_struct;
/* voluntary means could be initiated and dropped at runtime
* unique means unique
* tree means tree-based index (sort order is
* supported)
* hash means hash-based index
* list means the objects could be sequentially scanned
*/
voluntary unique tree< a,b,ss.s2> SAM;
/* estimated number of class instances is in square brackets */
hash <a> AAAA[10000];
hash <ss.s2> SSS2[10000];
hash <numbers> NNNN[10000];
event <new> new;
event <delete> delete;
event <a update> update;
autoid;
oid;
list;
};