1
0

nsapev2.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #pragma once
  2. #include "foundation/types.h"
  3. #include "nx/nxstring.h"
  4. #ifdef __ANDROID__
  5. #include "android/nsapev2.h"
  6. #elif defined(_WIN32)
  7. #include "windows/nsapev2.h"
  8. #elif defined(__linux__)
  9. #include "linux/nsapev2.h"
  10. #elif defined (__APPLE__)
  11. #include "osx/nsapev2.h"
  12. #endif
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. typedef struct nsapev2_header_struct_t { } *nsapev2_header_t;
  17. typedef struct nsapev2_tag_struct_t { } *nsapev2_tag_t;
  18. typedef struct nsapev2_item_struct_t { } *nsapev2_item_t;
  19. // must be exactly 32 bytes
  20. NSAPEV2_EXPORT int NSAPEv2_Header_Valid(const void *header_data);
  21. NSAPEV2_EXPORT int NSAPEv2_Header_Create(nsapev2_header_t *header, const void *header_data, size_t header_len);
  22. NSAPEV2_EXPORT int NSAPEv2_Header_TagSize(const nsapev2_header_t header, uint32_t *tag_size);
  23. NSAPEV2_EXPORT int NSAPEv2_Header_HasHeader(nsapev2_header_t header);
  24. NSAPEV2_EXPORT int NSAPEv2_Header_Destroy(nsapev2_header_t header);
  25. // currently, this function makes a copy of any necessary data. in the future, it would be better
  26. // to make another version of this function that "borrows" your data
  27. // if you can guarantee that the memory will outlive the nsapev2_tag_t object
  28. NSAPEV2_EXPORT int NSAPEv2_Tag_Create(nsapev2_tag_t *tag, const nsapev2_header_t header, const void *bytes, size_t bytes_len);
  29. NSAPEV2_EXPORT int NSAPEv2_Tag_New(nsapev2_tag_t *tag);
  30. NSAPEV2_EXPORT int NSAPEv2_Tag_SerializedSize(const nsapev2_tag_t tag, size_t *bytes);
  31. NSAPEV2_EXPORT int NSAPEv2_Tag_Serialize(const nsapev2_tag_t t, void *data, size_t bytes);
  32. NSAPEV2_EXPORT int NSAPEv2_Tag_Destroy(nsapev2_tag_t tag);
  33. NSAPEV2_EXPORT int NSAPEv2_Tag_GetFlags(nsapev2_tag_t tag, uint32_t *flags);
  34. NSAPEV2_EXPORT int NSAPEv2_Tag_SetFlags(nsapev2_tag_t tag, uint32_t flags, uint32_t mask);
  35. NSAPEV2_EXPORT int NSAPEv2_Tag_GetString(const nsapev2_tag_t tag, const char *key, unsigned int index, nx_string_t *value);
  36. NSAPEV2_EXPORT int NSAPEv2_Tag_SetString(nsapev2_tag_t tag, const char *key, unsigned int index, nx_string_t value);
  37. NSAPEV2_EXPORT int NSAPEv2_Tag_GetBinary(const nsapev2_tag_t tag, const char *key, unsigned int index, const void **bytes, size_t *length);
  38. NSAPEV2_EXPORT int NSAPEv2_Tag_SetBinary(nsapev2_tag_t tag, const char *key, unsigned int index, const void *bytes, size_t length);
  39. NSAPEV2_EXPORT int NSAPEv2_Tag_SetArtwork(nsapev2_tag_t t, const char *key, unsigned int index, const char *filename, const void *bytes, size_t length);
  40. /* Items */
  41. // flags
  42. static const uint32_t nsapev2_item_read_write = 0;
  43. static const uint32_t nsapev2_item_read_only = 1;
  44. static const uint32_t nsapev2_item_type_utf8 = 0;
  45. static const uint32_t nsapev2_item_type_binary = 1 << 1;
  46. static const uint32_t nsapev2_item_type_locator = 2 << 1;
  47. // mask flags with these to check the different fields
  48. static const uint32_t nsapev2_item_type_mask = (1 << 2) | (1 << 1);
  49. static const uint32_t nsapev2_item_read_mask = 1 << 0;
  50. NSAPEV2_EXPORT int NSAPEv2_Tag_EnumerateItems(const nsapev2_tag_t tag, const nsapev2_item_t start, nsapev2_item_t *next);
  51. NSAPEV2_EXPORT int NSAPEv2_Tag_GetItemCount(const nsapev2_tag_t t, size_t *count);
  52. NSAPEV2_EXPORT int NSAPEv2_Tag_GetItemAtIndex(const nsapev2_tag_t t, unsigned int index, nsapev2_item_t *item);
  53. NSAPEV2_EXPORT int NSAPEv2_Item_GetInformation(const nsapev2_item_t item, const char **key, uint32_t *flags);
  54. NSAPEV2_EXPORT int NSAPEv2_Item_GetString(const nsapev2_item_t item, nx_string_t *value);
  55. NSAPEV2_EXPORT int NSAPEv2_Item_GetBinary(const nsapev2_item_t item, const void **bytes, size_t *length);
  56. NSAPEV2_EXPORT int NSAPEv2_Item_SetKey(nsapev2_item_t item, const char *key);
  57. NSAPEV2_EXPORT int NSAPEv2_Item_SetString(nsapev2_item_t item, nx_string_t value);
  58. NSAPEV2_EXPORT int NSAPEv2_Tag_RemoveItem(nsapev2_tag_t tag, nsapev2_item_t item);
  59. NSAPEV2_EXPORT int NSAPEv2_Tag_AddItem(nsapev2_tag_t tag, nsapev2_item_t *item);
  60. #ifdef __cplusplus
  61. }
  62. #endif