tag.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef NULLSOFT_APEV2_TAG_H
  2. #define NULLSOFT_APEV2_TAG_H
  3. #include <bfc/platform/types.h>
  4. #include <vector>
  5. #include "item.h"
  6. #include "flags.h"
  7. namespace APEv2
  8. {
  9. class Tag
  10. {
  11. public:
  12. Tag();
  13. /* Parsing */
  14. int Parse(const void *data, size_t len);
  15. /* Retrieving Data */
  16. int GetString(const char *tag, wchar_t *data, size_t dataLen);
  17. int EnumValue(size_t i, const char **tag, wchar_t *data, size_t dataLen);
  18. int FindItemByKey(const char *key, size_t *index, int compare=ITEM_KEY_COMPARE_CASE_INSENSITIVE);
  19. size_t GetNumItems();
  20. bool IsReadOnly();
  21. bool IsItemReadOnly(size_t index);
  22. /* Setting Data */
  23. Item *AddItem();
  24. int SetString(const char *tag, const wchar_t *data);
  25. int SetKeyValueByIndex(size_t index, const char *key, const wchar_t *data);
  26. int SetFlags(uint32_t flags, uint32_t mask);
  27. /* Removing Data */
  28. void Clear();
  29. int RemoveItem(size_t index);
  30. int RemoveItem(const char *tag);
  31. /* Serializing */
  32. size_t EncodeSize();
  33. int Encode(void *data, size_t len);
  34. private: /* methods */
  35. int ParseData(const void *data, size_t len); /* helper function, call with data pointing to beginning of items block (skip header), and length without footer. */
  36. protected:
  37. int SetItemData(APEv2::Item *item, const wchar_t *data);
  38. private: /* data */
  39. std::vector<APEv2::Item*> items;
  40. uint32_t flags;
  41. };
  42. }
  43. #endif