Line data Source code
1 : /* File: universal_input_stream.inl; Copyright and License: see below */ 2 : 3 : #include <assert.h> 4 : 5 164 : static inline void universal_input_stream_private_init( universal_input_stream_t *this_, 6 : const universal_input_stream_if_t *interface, 7 : universal_input_stream_impl_t* objectdata ) 8 : { 9 164 : assert( interface != NULL ); 10 164 : assert( objectdata != NULL ); 11 164 : (*this_).interface = interface; 12 164 : (*this_).objectdata = objectdata; 13 164 : } 14 : 15 163 : static inline u8_error_t universal_input_stream_private_destroy( universal_input_stream_t *this_ ) 16 : { 17 163 : assert( (*this_).interface != NULL ); 18 163 : assert( (*this_).objectdata != NULL ); 19 163 : (*this_).interface = NULL; 20 163 : (*this_).objectdata = NULL; 21 163 : return U8_ERROR_NONE; 22 : } 23 : 24 2 : static inline const universal_input_stream_if_t* universal_input_stream_get_interface( universal_input_stream_t *this_ ) 25 : { 26 2 : assert( (*this_).interface != NULL ); 27 2 : return (*this_).interface; 28 : } 29 : 30 2 : static inline universal_input_stream_impl_t* universal_input_stream_get_objectdata( universal_input_stream_t *this_ ) 31 : { 32 2 : assert( (*this_).objectdata != NULL ); 33 2 : return (*this_).objectdata; 34 : } 35 : 36 155 : static inline u8_error_t universal_input_stream_read( universal_input_stream_t* this_, 37 : void *out_buffer, 38 : size_t max_size, 39 : size_t *out_length ) 40 : { 41 155 : assert( (*this_).interface != NULL ); 42 155 : assert( (*this_).objectdata != NULL ); 43 155 : assert( (*((*this_).interface)).read != NULL ); 44 155 : return (*( (*((*this_).interface)).read )) ( (*this_).objectdata, out_buffer, max_size, out_length ); 45 : } 46 : 47 2 : static inline u8_error_t universal_input_stream_reset( universal_input_stream_t *this_ ) 48 : { 49 2 : assert( (*this_).interface != NULL ); 50 2 : assert( (*this_).objectdata != NULL ); 51 2 : assert( (*((*this_).interface)).reset != NULL ); 52 2 : return (*( (*((*this_).interface)).reset )) ( (*this_).objectdata ); 53 : } 54 : 55 : /* 56 : Copyright 2021-2024 Andreas Warnke 57 : 58 : Licensed under the Apache License, Version 2.0 (the "License"); 59 : you may not use this file except in compliance with the License. 60 : You may obtain a copy of the License at 61 : 62 : http://www.apache.org/licenses/LICENSE-2.0 63 : 64 : Unless required by applicable law or agreed to in writing, software 65 : distributed under the License is distributed on an "AS IS" BASIS, 66 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 67 : See the License for the specific language governing permissions and 68 : limitations under the License. 69 : */