LCOV - code coverage report
Current view: top level - u8stream/include/utf8stringbuf - utf8codepointiterator.inl (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.57.0_covts Lines: 22 22 100.0 %
Date: 2024-04-07 11:14:42 Functions: 5 5 100.0 %

          Line data    Source code
       1             : /* File: utf8codepointiterator.inl; Copyright and License: see below */
       2             : 
       3             : #ifdef __cplusplus
       4             : extern "C" {
       5             : #endif
       6             : 
       7         259 : static inline void utf8codepointiterator_init ( utf8codepointiterator_t *this_, const utf8stringview_t *stringview )
       8             : {
       9         259 :     (*this_).remaining = *stringview;
      10         259 :     utf8codepointiterator_private_step_to_next( this_ );
      11         259 : }
      12             : 
      13         259 : static inline void utf8codepointiterator_destroy ( utf8codepointiterator_t *this_ )
      14             : {
      15         259 : }
      16             : 
      17        4105 : static inline bool utf8codepointiterator_has_next ( const utf8codepointiterator_t *this_ )
      18             : {
      19        4105 :     return utf8codepoint_is_valid( (*this_).next );
      20             : }
      21             : 
      22        3849 : static inline utf8codepoint_t utf8codepointiterator_next ( utf8codepointiterator_t *this_ )
      23             : {
      24        3849 :     utf8codepoint_t result = (*this_).next;
      25        3849 :     utf8codepointiterator_private_step_to_next( this_ );
      26        3849 :     return result;
      27             : }
      28             : 
      29        4108 : static inline void utf8codepointiterator_private_step_to_next ( utf8codepointiterator_t *this_ )
      30             : {
      31        4108 :     const size_t remaining_len = utf8stringview_get_length( &((*this_).remaining) );
      32        4108 :     if ( remaining_len == 0 )
      33             :     {
      34         262 :         (*this_).next = UTF8CODEPOINT_INVAL_CHAR;
      35             :     }
      36             :     else
      37             :     {
      38        3846 :         (*this_).next = utf8codepoint_init( utf8stringview_get_start( &((*this_).remaining) ), remaining_len );
      39        3846 :         if ( utf8codepoint_is_valid( (*this_).next ) )
      40             :         {
      41        3845 :             const unsigned int next_len = utf8codepoint_get_length( (*this_).next );
      42             :             (*this_).remaining
      43        3845 :                 = UTF8STRINGVIEW( utf8stringview_get_start( &((*this_).remaining) ) + next_len,
      44             :                                   (remaining_len - next_len )
      45             :                                 );
      46             :         }
      47             :         else
      48             :         {
      49           1 :             (*this_).remaining = UTF8STRINGVIEW_EMPTY;
      50             :         }
      51             :     }
      52        4108 : }
      53             : 
      54             : #ifdef __cplusplus
      55             : }
      56             : #endif
      57             : 
      58             : 
      59             : /*
      60             : Copyright 2021-2024 Andreas Warnke
      61             : 
      62             : Licensed under the Apache License, Version 2.0 (the "License");
      63             : you may not use this file except in compliance with the License.
      64             : You may obtain a copy of the License at
      65             : 
      66             :     http://www.apache.org/licenses/LICENSE-2.0
      67             : 
      68             : Unless required by applicable law or agreed to in writing, software
      69             : distributed under the License is distributed on an "AS IS" BASIS,
      70             : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      71             : See the License for the specific language governing permissions and
      72             : limitations under the License.
      73             : */

Generated by: LCOV version 1.16