6 public class IteratorPointer : struct;
9 extern int __ecereVMethodID_class_OnCompare;
10 extern int __ecereVMethodID_class_OnFree;
11 extern int __ecereVMethodID_class_OnGetString;
14 public struct BuiltInContainer
25 property Container { get { return this; } }
27 virtual IteratorPointer GetFirst() { return data; }
28 virtual IteratorPointer GetLast() { return (IteratorPointer)(data ? ((byte *)data + (count * type.typeSize) - 1) : null); }
29 virtual IteratorPointer GetPrev(IteratorPointer pointer)
31 return (IteratorPointer)((pointer && (byte *)pointer > (byte *)data) ?
32 ((byte *)pointer - ((type.type == noHeadClass || type.type == normalClass) ? sizeof(void *) : type.typeSize)) : null);
34 virtual IteratorPointer GetNext(IteratorPointer pointer)
36 return (IteratorPointer)((pointer && (byte *)pointer < (byte *)data + (count - 1) *
37 ((type.type == noHeadClass || type.type == normalClass) ? sizeof(void *) : type.typeSize)) ?
38 ((byte *)pointer + ((type.type == noHeadClass || type.type == normalClass) ? sizeof(void *) : type.typeSize)) : null);
40 virtual uint64 GetData(IteratorPointer pointer)
42 uint64 * item = (uint64 *)pointer;
43 return ((((type.type == structClass) ? ((uint64)item) :
44 (type.type == normalClass || type.type == noHeadClass) ? (uint64)*((void **)item) :
45 ((type.typeSize == 1) ? *((unsigned char *)item) :
46 ((type.typeSize == 2) ? *((unsigned short *)item) :
47 ((type.typeSize == 4) ? *((unsigned int *)item) : *((uint64 *)item)))))));
49 virtual bool SetData(IteratorPointer pointer, uint64 data)
53 virtual IteratorPointer GetAtPosition(const uint64 pos, bool create)
55 return data ? (IteratorPointer)((byte *)data +
56 ((type.type == noHeadClass || type.type == normalClass) ? sizeof(void *) : type.typeSize)) : null;
58 virtual IteratorPointer Insert(IteratorPointer after, uint64 value)
62 virtual IteratorPointer Add(uint64 value)
66 virtual void Remove(IteratorPointer it)
69 virtual void Move(IteratorPointer it, IteratorPointer after)
72 virtual void RemoveAll()
75 for(i = GetFirst(); i; i = GetNext(i))
79 virtual void Copy(Container source)
83 virtual IteratorPointer Find(uint64 value)
86 for(i = GetFirst(); i; i = GetNext(i))
88 uint64 data = GetData(i);
90 int result = ((int (*)(void *, void *, void *))(void *)Dclass._vTbl[__ecereVMethodID_class_OnCompare])(Dclass,
91 ((Dclass.type == systemClass && !Dclass.byValueSystemClass) || Dclass.type == bitClass || Dclass.type == enumClass || Dclass.type == unitClass) ? &value : (void *)value,
92 ((Dclass.type == systemClass && !Dclass.byValueSystemClass) || Dclass.type == bitClass || Dclass.type == enumClass || Dclass.type == unitClass) ? &data : (void *)data);
99 virtual void FreeIterator(IteratorPointer it);
100 virtual int GetCount() { return count; }
105 for(i = GetFirst(); i; i = GetNext(i))
106 ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type, (void *)GetData(i));
109 virtual void Delete(IteratorPointer it) { }
111 const char * OnGetString(char * tempString, void * fieldData, bool * needClass)
116 char itemString[4096];
118 byte * data = this.data;
120 tempString[0] = '\0';
121 for(i = 0; i < count; i++)
124 itemString[0] = '\0';
125 result = ((const char *(*)(void *, void *, char *, void *, bool *))(void *)Dclass._vTbl[__ecereVMethodID_class_OnGetString])(
126 Dclass, (type.type == normalClass || type.type == noHeadClass) ? *(void **)data : data, itemString, null, null);
127 if(!first) strcat(tempString, ", ");
128 strcat(tempString, result);
130 data += Dclass.typeSize;