*allocatedRowsCount = 0;
*deletedRowsCount = 0;
}
-
+
switch(action)
{
case init: break;
/*
Table OpenDatabasesListTable(subclass(DataDriver) driver)
{
- // get the table for databasesList using a temporary archive of a db with a table databases filled
+ // get the table for databasesList using a temporary archive of a db with a table databases filled
// with the list of edb files in data source's dirPath
-
+
TempFile f { };
//ArchiveFile af = ArchiveOpen
-
+
return null;
}
*/
{
File f;
};
-
+
static class EDBArchiveDir : ArchiveDir
{
EDBArchive archive;
strcat(indexName, (index.fieldIndexes[c].order == ascending) ? "+" : "-");
}
tf.Seek(0, start);
-
+
dirTable = db.archive.OpenDirectory(apath, FileStats { }, replace);
dirTable.AddFromFile(indexName, tf, { size = tf.GetSize() }, replace, 0, null, null);
delete dirTable;
dbTables.Add(dbTbl);
dbTbl.dir = archive.OpenDirectory(apath, null, readOnlyDir);
-
+
RowsCountFileEdit(archive, apath, init, &dbTbl.allocatedRowsCount, &dbTbl.deletedRowsCount, &dbTbl.rowsCountPosition);
dbTbl.rowsCount = dbTbl.allocatedRowsCount - dbTbl.deletedRowsCount;
dbTbl.rowPositionsSize = dbTbl.allocatedRowsCount;
dbTbl.rowPositions = new0 uint[Max(1,dbTbl.rowPositionsSize)];
position = dir.first;
-
+
while(true)
{
char fileName[MAX_FILENAME] = "";
int f;
EDBRow row1 = index.row1;
EDBRow row2 = index.row2;
-
+
if(index.cache && index.cache._num == r1)
row1 = index.cache;
else
}
((bool (*)())(void *)row1.GetData)(row1, field, type, (type.type == structClass) ? (void *)data1 : &data1);
((bool (*)())(void *)row2.GetData)(row2, field, type, (type.type == structClass) ? (void *)data2 : &data2);
- fieldResult = order * ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
+ fieldResult = order * ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
(type.type == systemClass || type.type == bitClass || type.type == enumClass || type.type == unitClass) ? &data1 : (void *)data1,
(type.type == systemClass || type.type == bitClass || type.type == enumClass || type.type == unitClass) ? &data2 : (void *)data2);
((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type, (void *)data1);
row2.tbl = ((EDBTable)index.fieldIndexes[f].memberTable).dbTable;
row2.index = ((EDBTable)index.fieldIndexes[f].memberTable).index;
row2.num = 0;
- row2.Find(index.fieldIndexes[f].memberIdField, middle, nil, data2);
+ row2.Find(index.fieldIndexes[f].memberIdField, middle, nil, data2);
field = memberField;
memberField = null;
{
EDBDatabase edb = dbTable.db;
EDBField field
- {
+ {
tbl = dbTable,
name = CopyString(name),
type = type,
{
return EDBRow { tbl = dbTable, index = index, num = 0 };
}
-
+
bool GenerateIndex(int count, FieldIndex * fieldIndexes, bool init)
{
DBIndex index = null;
{
int c;
for(c = 0; c<count; c++)
- if(index.fieldIndexes[c].field != fieldIndexes[c].field ||
+ if(index.fieldIndexes[c].field != fieldIndexes[c].field ||
index.fieldIndexes[c].order != fieldIndexes[c].order ||
index.fieldIndexes[c].memberField != fieldIndexes[c].memberField)
break;
if(c == count)
break;
- }
+ }
}
if(!index)
{
for(field = dbTable.fields.first; field; field = field.next)
if(field == fieldIndexes[c].field)
break;
- if(!field)
+ if(!field)
return false;
}
}
DBTable tbl;
DBIndex index;
BTNode node;
-
+
String aname;
int _num;
uint size;
f.Read(offsets, sizeof(uint), oldNumFields);
tf.Put(numFields);
-
+
tf.Write(offsets, sizeof(uint), numFields);
size = f.GetSize();
{
buffer = renew buffer byte[size];
f.Read(buffer, 1, size);
- tf.Write(buffer, 1, size);
+ tf.Write(buffer, 1, size);
}
// Update the offset of the field we're writing to
break;
}
}
-
+
if(c < numFields)
{
int fileSize = f.GetSize();
BTNode n = (i == index) ? node : null;
int c;
for(c = 0; c<i.numFields; c++)
- if(i.fieldIndexes[c].field == field ||
+ if(i.fieldIndexes[c].field == field ||
i.fieldIndexes[c].memberField == field ||
i.fieldIndexes[c].memberIdField == field)
break;
{
return !_num;
}
-
+
bool Select(MoveOptions move)
{
EDBDatabase edb = tbl.db;
}
delete offsets;
}
-
+
delete f;
}
return result;
{
this.node = node;
num = (uint)node.key;
- return true;
+ return true;
}
}
else if(move == previous)
{
this.node = node;
num = (uint)node.key;
- return true;
+ return true;
}
}
//if(data._class == type)
{
result = order * ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
- (type.type == systemClass || type.type == bitClass || type.type == enumClass || type.type == unitClass) ? &read : (void *)read,
+ (type.type == systemClass || type.type == bitClass || type.type == enumClass || type.type == unitClass) ? &read : (void *)read,
(type.type == systemClass || type.type == bitClass || type.type == enumClass || type.type == unitClass) ? &findData[c].value.i64 : (void *)findData[c].value.i64);
}
((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type, (void *)read);
{
BTNode node = this.node, lastNode = null;
int result;
-
+
if(move == next || move == nil)
{
if(move == next)
{
this.node = node;
num = (uint)node.key;
- return true;
+ return true;
}
}
else if(move == previous)
{
this.node = node;
num = (uint)node.key;
- return true;
+ return true;
}
}
EDBDatabase edb = tbl.db;
TempFile f;
ArchiveDir dirTable;
-
+
RowsCountFileEdit(edb.archive, tbl.apath, reused ? reuse : add, &tbl.allocatedRowsCount, &tbl.deletedRowsCount, &tbl.rowsCountPosition);
tbl.rowsCount = tbl.allocatedRowsCount - tbl.deletedRowsCount;
if(reused)
}
dirTable = edb.archive.OpenDirectory(tbl.apath, FileStats { }, replace);
-
+
f = TempFile { };
f.Seek(0, start);
}
dirTable.AddFromFileAtPosition(tbl.rowPositions[_num - 1], aname, f, { size = f.GetSize() }, replace, 0, null, &tbl.rowPositions[_num - 1]);
delete f;
-
+
delete dirTable;
-
+
{
DBIndex i;
for(i = tbl.indexes.first; i; i = i.next)
ArchiveDir dirTable;
BTNode node = this.node;
int oldNum = this._num;
-
+
RowsCountFileEdit(edb.archive, tbl.apath, del, &tbl.allocatedRowsCount, &tbl.deletedRowsCount, &tbl.rowsCountPosition);
tbl.rowsCount = tbl.allocatedRowsCount - tbl.deletedRowsCount;
tbl.rowPositions[_num - 1] = 0;
-
+
dirTable = edb.archive.OpenDirectory(tbl.apath, FileStats { }, replace);
if(!aname)
{
}
dirTable.Delete(aname);
delete dirTable;
-
+
Select(next);
if(!_num)
Select(last);
-
+
{
DBIndex i;
for(i = tbl.indexes.first; i; i = i.next)
if(tbl.allocatedRowsCount >= id && id > 0 && tbl.rowPositions[id - 1])
{
_num = id;
-
+
if(index)
node = index.tree.FindAll(id);
return true;