1
0

item.h 1020 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. #include "foundation/types.h"
  3. #include "nx/nxstring.h"
  4. #include "nu/PtrDeque.h"
  5. #include "nu/ByteWriter.h"
  6. #include "nu/ByteReader.h"
  7. namespace APEv2
  8. {
  9. enum
  10. {
  11. ITEM_KEY_COMPARE_CASE_INSENSITIVE = 0,
  12. ITEM_KEY_COMPARE_CASE_SENSITIVE = 1,
  13. };
  14. class Item : public nu::PtrDequeNode
  15. {
  16. public:
  17. Item();
  18. ~Item();
  19. /* If successful, puts incremented data pointer in new_data, and new data size remaining in new_len */
  20. int Read(bytereader_t byte_reader);
  21. int Encode(bytewriter_t byte_writer) const;
  22. size_t EncodeSize() const;
  23. bool IsReadOnly();
  24. bool KeyMatch(const char *key, int compare=ITEM_KEY_COMPARE_CASE_INSENSITIVE);
  25. int Get(const void **data, size_t *len) const;
  26. int GetKey(const char **tag) const;
  27. int Set(nx_string_t value);
  28. int Set(const void *data, size_t len, int dataType);
  29. int SetKey(const char *tag);
  30. int New(size_t datalen, int data_type, void **bytes);
  31. uint32_t GetFlags() const;
  32. private:
  33. uint32_t flags;
  34. char *key;
  35. void *value;
  36. uint32_t len;
  37. };
  38. }