record.h 1.0 KB

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