LCOV - code coverage report
Current view: top level - data/include - data_head.inl (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.57.0_covts Lines: 38 46 82.6 %
Date: 2024-04-07 11:14:42 Functions: 7 7 100.0 %

          Line data    Source code
       1             : /* File: data_head.inl; Copyright and License: see below */
       2             : 
       3             : #include "data_id.h"
       4             : #include <assert.h>
       5             : 
       6           5 : 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           5 :     assert( NULL != head_key );
      11           5 :     assert( NULL != head_value );
      12             :     utf8error_t strerr;
      13           5 :     u8_error_t result = U8_ERROR_NONE;
      14             : 
      15           5 :     (*this_).id = DATA_ROW_ID_VOID;
      16             : 
      17           5 :     (*this_).key = utf8stringbuf_init( sizeof((*this_).private_key_buffer), (*this_).private_key_buffer );
      18           5 :     strerr = utf8stringbuf_copy_str( (*this_).key, head_key );
      19           5 :     if ( strerr != UTF8ERROR_SUCCESS )
      20             :     {
      21           0 :         U8_LOG_ERROR_INT( "utf8stringbuf_copy_str() failed:", strerr );
      22           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
      23             :     }
      24             : 
      25           5 :     (*this_).value = utf8stringbuf_init( sizeof((*this_).private_value_buffer), (*this_).private_value_buffer );
      26           5 :     strerr = utf8stringbuf_copy_str( (*this_).value, head_value );
      27           5 :     if ( strerr != UTF8ERROR_SUCCESS )
      28             :     {
      29           0 :         U8_LOG_ERROR_INT( "utf8stringbuf_copy_str() failed:", strerr );
      30           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
      31             :     }
      32             : 
      33           5 :     return result;
      34             : }
      35             : 
      36           6 : 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           6 :     assert( NULL != head_key );
      42           6 :     assert( NULL != head_value );
      43             :     utf8error_t strerr;
      44           6 :     u8_error_t result = U8_ERROR_NONE;
      45             : 
      46           6 :     (*this_).id = head_id;
      47             : 
      48           6 :     (*this_).key = utf8stringbuf_init( sizeof((*this_).private_key_buffer), (*this_).private_key_buffer );
      49           6 :     strerr = utf8stringbuf_copy_str( (*this_).key, head_key );
      50           6 :     if ( strerr != UTF8ERROR_SUCCESS )
      51             :     {
      52           0 :         U8_LOG_ERROR_INT( "utf8stringbuf_copy_str() failed:", strerr );
      53           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
      54             :     }
      55             : 
      56           6 :     (*this_).value = utf8stringbuf_init( sizeof((*this_).private_value_buffer), (*this_).private_value_buffer );
      57           6 :     strerr = utf8stringbuf_copy_str( (*this_).value, head_value );
      58           6 :     if ( strerr != UTF8ERROR_SUCCESS )
      59             :     {
      60           0 :         U8_LOG_ERROR_INT( "utf8stringbuf_copy_str() failed:", strerr );
      61           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
      62             :     }
      63             : 
      64           6 :     return result;
      65             : }
      66             : 
      67             : static inline void data_head_copy ( data_head_t *this_, const data_head_t *original )
      68             : {
      69             :     assert( NULL != original );
      70             : 
      71             :     (*this_) = (*original);
      72             :     /* repair the overwritten pointers */
      73             :     (*this_).key = utf8stringbuf_init( sizeof((*this_).private_key_buffer), (*this_).private_key_buffer );
      74             :     (*this_).value = utf8stringbuf_init( sizeof((*this_).private_value_buffer), (*this_).private_value_buffer );
      75             : }
      76             : 
      77             : static inline void data_head_replace ( data_head_t *this_, const data_head_t *that )
      78             : {
      79             :     assert( NULL != that );
      80             : 
      81             :     (*this_) = (*that);
      82             :     /* repair the overwritten pointers */
      83             :     (*this_).key = utf8stringbuf_init( sizeof((*this_).private_key_buffer), (*this_).private_key_buffer );
      84             :     (*this_).value = utf8stringbuf_init( sizeof((*this_).private_value_buffer), (*this_).private_value_buffer );
      85             : }
      86             : 
      87             : static inline void data_head_destroy ( data_head_t *this_ )
      88             : {
      89             :     (*this_).id = DATA_ROW_ID_VOID;
      90             : }
      91             : 
      92           6 : static inline data_row_id_t data_head_get_row_id ( const data_head_t *this_ )
      93             : {
      94           6 :     return (*this_).id;
      95             : }
      96             : 
      97             : static inline void data_head_set_row_id ( data_head_t *this_, data_row_id_t id )
      98             : {
      99             :     (*this_).id = id;
     100             : }
     101             : 
     102          11 : static inline const char *data_head_get_key_const ( const data_head_t *this_ )
     103             : {
     104          11 :     return utf8stringbuf_get_string( (*this_).key );
     105             : }
     106             : 
     107             : static inline u8_error_t data_head_set_key ( data_head_t *this_, const char *key )
     108             : {
     109             :     assert( NULL != key );
     110             :     u8_error_t result = U8_ERROR_NONE;
     111             :     utf8error_t strerr;
     112             :     strerr = utf8stringbuf_copy_str( (*this_).key, key );
     113             :     if ( strerr != UTF8ERROR_SUCCESS )
     114             :     {
     115             :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     116             :         result = U8_ERROR_STRING_BUFFER_EXCEEDED;
     117             :     }
     118             :     return result;
     119             : }
     120             : 
     121          11 : static inline const char *data_head_get_value_const ( const data_head_t *this_ )
     122             : {
     123          11 :     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             : static inline u8_error_t data_head_set_value ( data_head_t *this_, const char *value )
     132             : {
     133             :     assert( NULL != value );
     134             :     u8_error_t result = U8_ERROR_NONE;
     135             :     utf8error_t strerr;
     136             :     strerr = utf8stringbuf_copy_str( (*this_).value, value );
     137             :     if ( strerr != UTF8ERROR_SUCCESS )
     138             :     {
     139             :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     140             :         result = U8_ERROR_STRING_BUFFER_EXCEEDED;
     141             :     }
     142             :     return result;
     143             : }
     144             : 
     145             : static inline bool data_head_is_valid ( const data_head_t *this_ )
     146             : {
     147             :     return ( DATA_ROW_ID_VOID != (*this_).id );
     148             : }
     149             : 
     150           6 : static inline void data_head_trace ( const data_head_t *this_ )
     151             : {
     152           6 :     U8_TRACE_INFO( "data_head_t" );
     153           6 :     U8_TRACE_INFO_INT( "- id:", (*this_).id );
     154           6 :     U8_TRACE_INFO_STR( "- key:", utf8stringbuf_get_string((*this_).key) );
     155           6 :     U8_TRACE_INFO_STR( "- value:", utf8stringbuf_get_string((*this_).value) );
     156           6 : }
     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