1
0

nxdata.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma once
  2. #include "../../foundation/types.h"
  3. #include "../../nx/nxuri.h"
  4. #include "../../nx/nxapi.h"
  5. #include "../../nx/nxfile.h"
  6. #include "../../nx/nxstring.h"
  7. /* windows implementation */
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. typedef struct nx_data_struct_t *nx_data_t;
  12. NX_API nx_data_t NXDataRetain(nx_data_t data);
  13. NX_API void NXDataRelease(nx_data_t data);
  14. NX_API int NXDataCreate(nx_data_t *data, const void *bytes, size_t length);
  15. NX_API int NXDataCreateWithSize(nx_data_t *data, void **bytes, size_t length);
  16. /* creates an empty data object. useful if you need to store MIME, source URI, etc. without having actual data */
  17. NX_API int NXDataCreateEmpty(nx_data_t *data);
  18. /* you can pass file_stats==NULL if you don't care about the file stats */
  19. NX_API int NXDataCreateFromURI(nx_data_t *data, nx_uri_t filename);
  20. NX_API size_t NXDataSize(nx_data_t data);
  21. NX_API int NXDataGet(nx_data_t data, const void **bytes, size_t *length);
  22. /* You can _only_ call these on your own nx_data_t object _before_ you give it to anyone else! */
  23. NX_API int NXDataSetMIME(nx_data_t data, nx_string_t mime_type);
  24. NX_API int NXDataSetDescription(nx_data_t data, nx_string_t description);
  25. NX_API int NXDataSetSourceURI(nx_data_t data, nx_uri_t source_uri);
  26. NX_API int NXDataSetSourceStat(nx_data_t data, nx_file_stat_t source_stats);
  27. /* you need to call NXStringRelease on what you get back (if the function succeeded) */
  28. NX_API int NXDataGetMIME(nx_data_t data, nx_string_t *mime_type);
  29. NX_API int NXDataGetDescription(nx_data_t data, nx_string_t *description);
  30. NX_API int NXDataGetSourceURI(nx_data_t data, nx_uri_t *source_uri);
  31. NX_API int NXDataGetSourceStat(nx_data_t data, nx_file_stat_t *source_stats);
  32. #ifdef __cplusplus
  33. }
  34. #endif