@@ -51,25 +51,31 @@ class Resource {
5151 /* *
5252 * Get pointer to data. This may be NULL if no buffer is assigned yet.
5353 * This is the **const** version
54+ *
55+ * @param offset: offset in bytes
5456 */
55- const uint8_t * getData () const {
56- return const_cast <const uint8_t *>(data);
57+ const uint8_t * getData (uint32_t offset = 0 ) const {
58+ return const_cast <const uint8_t *>(data + offset );
5759 }
5860
5961 /* *
6062 * Template method for converting data to an object of particular class
63+ *
64+ * @param offset: offset in bytes
6165 */
6266 template <typename Payload>
63- const Payload& getData () const {
64- return *(reinterpret_cast <const Payload*>(data));
67+ const Payload& getData (uint32_t offset = 0 ) const {
68+ return *(reinterpret_cast <const Payload*>(data + offset ));
6569 }
6670
6771 /* *
6872 * Template method for converting data to an object. This is the **const** version
73+ *
74+ * @param offset: offset in bytes
6975 */
7076 template <typename Payload>
71- Payload& getData () {
72- return *(reinterpret_cast <Payload*>(data));
77+ Payload& getData (uint32_t offset = 0 ) {
78+ return *(reinterpret_cast <Payload*>(data + offset ));
7379 }
7480
7581 /* *
@@ -140,15 +146,21 @@ class Resource {
140146
141147 /* *
142148 * Array conversion
149+ *
150+ * @param offset: offset in bytes
151+ * @param max_size maximum size, actual size can be smaller depending on object size
143152 */
144153 template <typename Array, typename Element>
145- const Array asArray () const ;
154+ const Array asArray (uint32_t offset = 0 , uint32_t max_size = 0xFFFFFFFF ) const ;
146155
147156 /* *
148157 * Array conversion. This is the **const** version
158+ *
159+ * @param offset: offset in bytes
160+ * @param max_size maximum size, actual size can be smaller depending on object size
149161 */
150162 template <typename Array, typename Element>
151- Array asArray ();
163+ Array asArray (uint32_t offset = 0 , uint32_t max_size = 0xFFFFFFFF );
152164
153165 /* *
154166 * Create a new resource with allocated buffer
0 commit comments