Line data Source code
1 : /* File: universal_input_stream.inl; Copyright and License: see below */
2 :
3 : #include <assert.h>
4 :
5 168 : 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 168 : assert( interface != NULL );
10 168 : assert( objectdata != NULL );
11 168 : (*this_).interface = interface;
12 168 : (*this_).objectdata = objectdata;
13 168 : }
14 :
15 167 : static inline u8_error_t universal_input_stream_private_destroy( universal_input_stream_t *this_ )
16 : {
17 167 : assert( (*this_).interface != NULL );
18 167 : assert( (*this_).objectdata != NULL );
19 167 : (*this_).interface = NULL;
20 167 : (*this_).objectdata = NULL;
21 167 : 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 164 : 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 164 : assert( (*this_).interface != NULL );
42 164 : assert( (*this_).objectdata != NULL );
43 164 : assert( (*((*this_).interface)).read != NULL );
44 164 : return (*( (*((*this_).interface)).read )) ( (*this_).objectdata, out_buffer, max_size, out_length );
45 : }
46 :
47 4 : static inline u8_error_t universal_input_stream_reset( universal_input_stream_t *this_ )
48 : {
49 4 : assert( (*this_).interface != NULL );
50 4 : assert( (*this_).objectdata != NULL );
51 4 : assert( (*((*this_).interface)).reset != NULL );
52 4 : return (*( (*((*this_).interface)).reset )) ( (*this_).objectdata );
53 : }
54 :
55 : /*
56 : Copyright 2021-2025 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 : */
|