LCOV - code coverage report
Current view: top level - u8stream/include/u8stream - universal_buffer_input_stream.inl (source / functions) Coverage Total Hit
Test: crystal-facet-uml_v1.64.2_covts Lines: 100.0 % 34 34
Test Date: 2025-06-21 07:03:58 Functions: 100.0 % 3 3

            Line data    Source code
       1              : /* File: universal_buffer_input_stream.inl; Copyright and License: see below */
       2              : 
       3              : #include <assert.h>
       4              : 
       5        36313 : static inline char universal_buffer_input_stream_peek_next( universal_buffer_input_stream_t *this_ )
       6              : {
       7        36313 :     assert( (*this_).mem_buf_start != NULL );
       8        36313 :     assert( (*this_).mem_buf_fill >= (*this_).mem_buf_pos );
       9        36313 :     assert( (*this_).mem_buf_size >= (*this_).mem_buf_fill );
      10        36313 :     char result = '\0';
      11              : 
      12        36313 :     const size_t buf_available1 = (*this_).mem_buf_fill - (*this_).mem_buf_pos;
      13        36313 :     if ( buf_available1 == 0 )
      14              :     {
      15              :         /* try to fill buffer */
      16          143 :         (*this_).stream_pos_of_buf += (*this_).mem_buf_fill;
      17          143 :         (*this_).mem_buf_pos = 0;
      18          143 :         (*this_).mem_buf_fill = 0;
      19              :         const int err
      20          143 :             = universal_input_stream_read( (*this_).source, (*this_).mem_buf_start, (*this_).mem_buf_size, &((*this_).mem_buf_fill) );
      21          143 :         if (( 0 == err )&&( (*this_).mem_buf_fill > 0 ))
      22              :         {
      23          114 :             result = (*(  (char(*)[]) (*this_).mem_buf_start  ))[0];
      24              :         }
      25              :     }
      26              :     else
      27              :     {
      28        36170 :         result = (*(  (char(*)[]) (*this_).mem_buf_start  ))[(*this_).mem_buf_pos];
      29              :     }
      30              : 
      31        36313 :     return result;
      32              : }
      33              : 
      34        27923 : static inline char universal_buffer_input_stream_read_next( universal_buffer_input_stream_t *this_ )
      35              : {
      36        27923 :     assert( (*this_).mem_buf_start != NULL );
      37        27923 :     assert( (*this_).mem_buf_fill >= (*this_).mem_buf_pos );
      38        27923 :     assert( (*this_).mem_buf_size >= (*this_).mem_buf_fill );
      39        27923 :     char result = '\0';
      40              : 
      41        27923 :     const size_t buf_available1 = (*this_).mem_buf_fill - (*this_).mem_buf_pos;
      42        27923 :     if ( buf_available1 == 0 )
      43              :     {
      44              :         /* try to fill buffer */
      45            2 :         (*this_).stream_pos_of_buf += (*this_).mem_buf_fill;
      46            2 :         (*this_).mem_buf_pos = 0;
      47            2 :         (*this_).mem_buf_fill = 0;
      48              :         const int err
      49            2 :             = universal_input_stream_read( (*this_).source, (*this_).mem_buf_start, (*this_).mem_buf_size, &((*this_).mem_buf_fill) );
      50            2 :         if (( 0 == err )&&( (*this_).mem_buf_fill > 0 ))
      51              :         {
      52            1 :             result = (*(  (char(*)[]) (*this_).mem_buf_start  ))[0];
      53            1 :             (*this_).mem_buf_pos = 1;
      54              :         }
      55              :     }
      56              :     else
      57              :     {
      58        27921 :         result = (*(  (char(*)[]) (*this_).mem_buf_start  ))[(*this_).mem_buf_pos];
      59        27921 :         (*this_).mem_buf_pos ++;
      60              :     }
      61              : 
      62        27923 :     return result;
      63              : }
      64              : 
      65           52 : static inline size_t universal_buffer_input_stream_read_pos ( universal_buffer_input_stream_t *this_ )
      66              : {
      67           52 :     return (*this_).stream_pos_of_buf + (*this_).mem_buf_pos;
      68              : }
      69              : 
      70              : 
      71              : /*
      72              : Copyright 2021-2025 Andreas Warnke
      73              : 
      74              : Licensed under the Apache License, Version 2.0 (the "License");
      75              : you may not use this file except in compliance with the License.
      76              : You may obtain a copy of the License at
      77              : 
      78              :     http://www.apache.org/licenses/LICENSE-2.0
      79              : 
      80              : Unless required by applicable law or agreed to in writing, software
      81              : distributed under the License is distributed on an "AS IS" BASIS,
      82              : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      83              : See the License for the specific language governing permissions and
      84              : limitations under the License.
      85              : */
        

Generated by: LCOV version 2.0-1