LCOV - code coverage report
Current view: top level - data/include/entity - data_head.inl (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.61.0_covts Lines: 82 82 100.0 %
Date: 2024-10-26 21:44:38 Functions: 14 14 100.0 %

          Line data    Source code
       1             : /* File: data_head.inl; Copyright and License: see below */
       2             : 
       3             : #include "entity/data_id.h"
       4             : #include <assert.h>
       5             : 
       6           8 : static inline u8_error_t data_head_init_new ( data_head_t *this_,
       7             :                                               const char* head_key,
       8             :                                               const char* head_value )
       9             : {
      10           8 :     assert( NULL != head_key );
      11           8 :     assert( NULL != head_value );
      12             :     utf8error_t strerr;
      13           8 :     u8_error_t result = U8_ERROR_NONE;
      14             : 
      15           8 :     (*this_).id = DATA_ROW_ID_VOID;
      16             : 
      17           8 :     (*this_).key = utf8stringbuf_init( sizeof((*this_).private_key_buffer), (*this_).private_key_buffer );
      18           8 :     strerr = utf8stringbuf_copy_str( (*this_).key, head_key );
      19           8 :     if ( strerr != UTF8ERROR_SUCCESS )
      20             :     {
      21           1 :         U8_LOG_ERROR_INT( "utf8stringbuf_copy_str() failed:", strerr );
      22           1 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
      23             :     }
      24             : 
      25           8 :     (*this_).value = utf8stringbuf_init( sizeof((*this_).private_value_buffer), (*this_).private_value_buffer );
      26           8 :     strerr = utf8stringbuf_copy_str( (*this_).value, head_value );
      27           8 :     if ( strerr != UTF8ERROR_SUCCESS )
      28             :     {
      29           1 :         U8_LOG_ERROR_INT( "utf8stringbuf_copy_str() failed:", strerr );
      30           1 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
      31             :     }
      32             : 
      33           8 :     return result;
      34             : }
      35             : 
      36           8 : static inline u8_error_t data_head_init ( data_head_t *this_,
      37             :                                           data_row_id_t head_id,
      38             :                                           const char* head_key,
      39             :                                           const char* head_value )
      40             : {
      41           8 :     assert( NULL != head_key );
      42           8 :     assert( NULL != head_value );
      43             :     utf8error_t strerr;
      44           8 :     u8_error_t result = U8_ERROR_NONE;
      45             : 
      46           8 :     (*this_).id = head_id;
      47             : 
      48           8 :     (*this_).key = utf8stringbuf_init( sizeof((*this_).private_key_buffer), (*this_).private_key_buffer );
      49           8 :     strerr = utf8stringbuf_copy_str( (*this_).key, head_key );
      50           8 :     if ( strerr != UTF8ERROR_SUCCESS )
      51             :     {
      52           1 :         U8_LOG_ERROR_INT( "utf8stringbuf_copy_str() failed:", strerr );
      53           1 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
      54             :     }
      55             : 
      56           8 :     (*this_).value = utf8stringbuf_init( sizeof((*this_).private_value_buffer), (*this_).private_value_buffer );
      57           8 :     strerr = utf8stringbuf_copy_str( (*this_).value, head_value );
      58           8 :     if ( strerr != UTF8ERROR_SUCCESS )
      59             :     {
      60           1 :         U8_LOG_ERROR_INT( "utf8stringbuf_copy_str() failed:", strerr );
      61           1 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
      62             :     }
      63             : 
      64           8 :     return result;
      65             : }
      66             : 
      67           1 : static inline void data_head_copy ( data_head_t *this_, const data_head_t *original )
      68             : {
      69           1 :     assert( NULL != original );
      70             : 
      71           1 :     (*this_) = (*original);
      72             :     /* repair the overwritten pointers */
      73           1 :     (*this_).key = utf8stringbuf_init( sizeof((*this_).private_key_buffer), (*this_).private_key_buffer );
      74           1 :     (*this_).value = utf8stringbuf_init( sizeof((*this_).private_value_buffer), (*this_).private_value_buffer );
      75           1 : }
      76             : 
      77           1 : static inline void data_head_replace ( data_head_t *this_, const data_head_t *that )
      78             : {
      79           1 :     assert( NULL != that );
      80             : 
      81           1 :     (*this_) = (*that);
      82             :     /* repair the overwritten pointers */
      83           1 :     (*this_).key = utf8stringbuf_init( sizeof((*this_).private_key_buffer), (*this_).private_key_buffer );
      84           1 :     (*this_).value = utf8stringbuf_init( sizeof((*this_).private_value_buffer), (*this_).private_value_buffer );
      85           1 : }
      86             : 
      87           3 : static inline void data_head_destroy ( data_head_t *this_ )
      88             : {
      89           3 :     (*this_).id = DATA_ROW_ID_VOID;
      90           3 : }
      91             : 
      92          11 : static inline data_row_id_t data_head_get_row_id ( const data_head_t *this_ )
      93             : {
      94          11 :     return (*this_).id;
      95             : }
      96             : 
      97           1 : static inline void data_head_set_row_id ( data_head_t *this_, data_row_id_t id )
      98             : {
      99           1 :     (*this_).id = id;
     100           1 : }
     101             : 
     102          18 : static inline const char *data_head_get_key_const ( const data_head_t *this_ )
     103             : {
     104          18 :     return utf8stringbuf_get_string( (*this_).key );
     105             : }
     106             : 
     107           2 : static inline u8_error_t data_head_set_key ( data_head_t *this_, const char *key )
     108             : {
     109           2 :     assert( NULL != key );
     110           2 :     u8_error_t result = U8_ERROR_NONE;
     111             :     utf8error_t strerr;
     112           2 :     strerr = utf8stringbuf_copy_str( (*this_).key, key );
     113           2 :     if ( strerr != UTF8ERROR_SUCCESS )
     114             :     {
     115           1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     116           1 :         result = U8_ERROR_STRING_BUFFER_EXCEEDED;
     117             :     }
     118           2 :     return result;
     119             : }
     120             : 
     121          18 : static inline const char *data_head_get_value_const ( const data_head_t *this_ )
     122             : {
     123          18 :     return utf8stringbuf_get_string( (*this_).value );
     124             : }
     125             : 
     126           6 : static inline bool data_head_has_value ( const data_head_t *this_ )
     127             : {
     128           6 :     return ( ! utf8stringbuf_equals_str( (*this_).value, "" ) );
     129             : }
     130             : 
     131           2 : static inline u8_error_t data_head_set_value ( data_head_t *this_, const char *value )
     132             : {
     133           2 :     assert( NULL != value );
     134           2 :     u8_error_t result = U8_ERROR_NONE;
     135             :     utf8error_t strerr;
     136           2 :     strerr = utf8stringbuf_copy_str( (*this_).value, value );
     137           2 :     if ( strerr != UTF8ERROR_SUCCESS )
     138             :     {
     139           1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     140           1 :         result = U8_ERROR_STRING_BUFFER_EXCEEDED;
     141             :     }
     142           2 :     return result;
     143             : }
     144             : 
     145           7 : static inline bool data_head_is_valid ( const data_head_t *this_ )
     146             : {
     147           7 :     return ( DATA_ROW_ID_VOID != (*this_).id );
     148             : }
     149             : 
     150           7 : static inline void data_head_trace ( const data_head_t *this_ )
     151             : {
     152           7 :     U8_TRACE_INFO( "data_head_t" );
     153           7 :     U8_TRACE_INFO_INT( "- id:", (*this_).id );
     154           7 :     U8_TRACE_INFO_STR( "- key:", utf8stringbuf_get_string((*this_).key) );
     155           7 :     U8_TRACE_INFO_STR( "- value:", utf8stringbuf_get_string((*this_).value) );
     156           7 : }
     157             : 
     158             : 
     159             : /*
     160             : Copyright 2023-2024 Andreas Warnke
     161             : 
     162             : Licensed under the Apache License, Version 2.0 (the "License");
     163             : you may not use this file except in compliance with the License.
     164             : You may obtain a copy of the License at
     165             : 
     166             :     http://www.apache.org/licenses/LICENSE-2.0
     167             : 
     168             : Unless required by applicable law or agreed to in writing, software
     169             : distributed under the License is distributed on an "AS IS" BASIS,
     170             : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     171             : See the License for the specific language governing permissions and
     172             : limitations under the License.
     173             : */

Generated by: LCOV version 1.16