property.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #pragma once
  2. #ifdef __cplusplus
  3. extern "C" {
  4. #endif
  5. #include <stdbool.h>
  6. #include <core/string.h>
  7. /** Callback type called every time another key-value pair of device information is ready
  8. *
  9. * @param key[in] device information type identifier
  10. * @param value[in] device information value
  11. * @param last[in] whether the passed key-value pair is the last one
  12. * @param context[in] to pass to callback
  13. */
  14. typedef void (*PropertyValueCallback)(const char* key, const char* value, bool last, void* context);
  15. typedef struct {
  16. FuriString* key; /**< key string buffer, must be initialised before use */
  17. FuriString* value; /**< value string buffer, must be initialised before use */
  18. PropertyValueCallback out; /**< output callback function */
  19. char sep; /**< separator character between key parts */
  20. bool last; /**< flag to indicate last element */
  21. void* context; /**< user-defined context, passed through to out callback */
  22. } PropertyValueContext;
  23. /** Builds key and value strings and outputs them via a callback function
  24. *
  25. * @param ctx[in] local property context
  26. * @param fmt[in] value format, set to NULL to bypass formatting
  27. * @param nparts[in] number of key parts (separated by character)
  28. * @param ...[in] list of key parts followed by value
  29. */
  30. void property_value_out(PropertyValueContext* ctx, const char* fmt, unsigned int nparts, ...);
  31. #ifdef __cplusplus
  32. }
  33. #endif