memstreams.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. /**
  14. * @file memstreams.h
  15. * @brief Memory streams structures and macros.
  16. * @addtogroup HAL_MEMORY_STREAMS
  17. * @{
  18. */
  19. #ifndef MEMSTREAMS_H
  20. #define MEMSTREAMS_H
  21. /*===========================================================================*/
  22. /* Driver constants. */
  23. /*===========================================================================*/
  24. /*===========================================================================*/
  25. /* Driver pre-compile time settings. */
  26. /*===========================================================================*/
  27. /*===========================================================================*/
  28. /* Derived constants and error checks. */
  29. /*===========================================================================*/
  30. /*===========================================================================*/
  31. /* Driver data structures and types. */
  32. /*===========================================================================*/
  33. /**
  34. * @brief @p MemStream specific data.
  35. */
  36. #define _memory_stream_data \
  37. _base_sequential_stream_data \
  38. /* Pointer to the stream buffer.*/ \
  39. uint8_t *buffer; \
  40. /* Size of the stream.*/ \
  41. size_t size; \
  42. /* Current end of stream.*/ \
  43. size_t eos; \
  44. /* Current read offset.*/ \
  45. size_t offset;
  46. /**
  47. * @brief @p MemStream virtual methods table.
  48. */
  49. struct MemStreamVMT {
  50. _base_sequential_stream_methods
  51. };
  52. /**
  53. * @extends BaseSequentialStream
  54. *
  55. * @brief Memory stream object.
  56. */
  57. typedef struct {
  58. /** @brief Virtual Methods Table.*/
  59. const struct MemStreamVMT *vmt;
  60. _memory_stream_data
  61. } MemoryStream;
  62. /*===========================================================================*/
  63. /* Driver macros. */
  64. /*===========================================================================*/
  65. /*===========================================================================*/
  66. /* External declarations. */
  67. /*===========================================================================*/
  68. #ifdef __cplusplus
  69. extern "C" {
  70. #endif
  71. void msObjectInit(MemoryStream *msp, uint8_t *buffer,
  72. size_t size, size_t eos);
  73. #ifdef __cplusplus
  74. }
  75. #endif
  76. #endif /* MEMSTREAMS_H */
  77. /** @} */