1
0

Record.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #pragma once
  2. #include "../nde.h"
  3. #include "../Field.h"
  4. #include "Vfs.h"
  5. #include <stdio.h>
  6. #include <deque>
  7. class ColumnField;
  8. class RecordBase
  9. {
  10. public:
  11. RecordBase();
  12. virtual ~RecordBase();
  13. Field *GetField(unsigned char ID);
  14. void Retain();
  15. void Release();
  16. void RemoveField(Field *field);
  17. void AddField(Field *field);
  18. Field* GetLastField()
  19. {
  20. if (Fields.empty())
  21. {
  22. return nullptr;
  23. }
  24. return Fields[Fields.size() - 1];
  25. }
  26. protected:
  27. void Undelete(void);
  28. int InsertionPoint; // TODO: benski> might be able to pass this into WriteFields/WriteIndex
  29. int ref_count;
  30. typedef std::deque<Field*> FieldList;
  31. FieldList Fields;
  32. };
  33. class Record : public RecordBase
  34. {
  35. public:
  36. Record(int RecordPos, int insertionPoint, VFILE *FileHandle,Table *p);
  37. bool InCache() { return ref_count > 1; }
  38. ColumnField *GetColumnByName(const wchar_t *name);
  39. int WriteFields(Table *ParentTable, int RecordIndex);
  40. int WriteIndex(Table *ParentTable, int RecordIndex);
  41. void Delete(Table *ParentTable, int RecordIndex);
  42. typedef bool (__cdecl *FieldsWalker)(Record *record, Field *entry, void *context);
  43. NDE_API void WalkFields(FieldsWalker callback, void *context);
  44. };