#ifndef ITEM_H
#define ITEM_H
#include "endianess.h"
#include "reiserfs.h"
#include "Key.h"
class LeafNode;
class ItemHeader : private item_head {
public:
ItemHeader() {}
uint16 GetLen() const { return le2h(ih_item_len); }
uint16 GetLocation() const { return le2h(ih_item_location); }
uint16 GetVersion() const { return le2h(ih_version); }
const Key *GetKey() const { return Key::CastFrom(&ih_key); }
VKey *GetKey(VKey *k) const { k->SetTo(GetKey(), GetVersion()); return k; }
uint16 GetFreeSpaceReserved() const
{
return (GetVersion() == KEY_FORMAT_3_6
? 0 : le2h(u.ih_free_space_reserved));
}
uint16 GetEntryCount() const { return le2h(u.ih_entry_count); }
uint32 GetDirID() const { return GetKey()->GetDirID(); }
uint32 GetObjectID() const { return GetKey()->GetObjectID(); }
uint64 GetOffset() const { return GetKey()->GetOffset(GetVersion()); }
uint16 GetType() const { return GetKey()->GetType(GetVersion()); }
} _PACKED;
class Item {
public:
Item();
Item(const Item &item);
Item(LeafNode *node, const ItemHeader *header);
~Item();
status_t SetTo(LeafNode *node, const ItemHeader *header);
status_t SetTo(LeafNode *node, int32 index);
void Unset();
LeafNode *GetNode() const;
ItemHeader *GetHeader() const;
int32 GetIndex() const;
void *GetData() const;
uint16 GetLen() const;
uint16 GetType() const;
uint32 GetDirID() const;
uint32 GetObjectID() const;
uint64 GetOffset() const;
const Key *GetKey() const;
VKey *GetKey(VKey *k) const;
uint16 GetEntryCount() const;
status_t Check() const;
Item &operator=(const Item &item);
protected:
LeafNode *fNode;
ItemHeader *fHeader;
};
#endif