1
0

Record.h 1.2 KB

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