LCOV - code coverage report
Current view: top level - data/include/storage - data_database_head.inl (source / functions) Coverage Total Hit
Test: crystal-facet-uml_v1.71.2_covts Lines: 0.0 % 17 0
Test Date: 2026-08-22 19:47:36 Functions: 0.0 % 1 0

            Line data    Source code
       1              : /* File: data_database_head.inl; Copyright and License: see below */
       2              : 
       3              : #include "u8/u8_trace.h"
       4              : #include "u8/u8_log.h"
       5              : #include <assert.h>
       6              : 
       7              : static inline u8_error_t data_database_head_delete_value_by_key ( data_database_head_t *this_,
       8              :                                                                   const char *key,
       9              :                                                                   bool ignore_not_found,
      10              :                                                                   data_head_t *out_old_head )
      11              : {
      12              :     assert( key != NULL );
      13              :     u8_error_t result;
      14              :     data_head_t head;
      15              :     result = data_database_head_read_value_by_key( this_, key, &head );
      16              :     if ( result == U8_ERROR_NONE )
      17              :     {
      18              :         if ( out_old_head != NULL )
      19              :         {
      20              :             data_head_replace( out_old_head, &head );
      21              :         }
      22              :         result |= data_database_head_delete_value( this_, data_head_get_row( &head ), NULL );
      23              :     }
      24              :     else if ( result == U8_ERROR_NOT_FOUND )
      25              :     {
      26              :         if ( out_old_head != NULL )
      27              :         {
      28              :             data_head_init_new( out_old_head, key, "" );
      29              :         }
      30              :         if ( ignore_not_found )
      31              :         {
      32              :             result = U8_ERROR_NONE;
      33              :         }
      34              :     }
      35              :     return result;
      36              : }
      37              : 
      38            0 : static inline u8_error_t data_database_head_update_value_by_key ( data_database_head_t *this_,
      39              :                                                                   const char *key,
      40              :                                                                   const char* new_head_value,
      41              :                                                                   bool create_if_not_found,
      42              :                                                                   data_head_t *out_old_head )
      43              : {
      44            0 :     assert( key != NULL );
      45            0 :     assert( new_head_value != NULL );
      46              :     u8_error_t result;
      47              :     data_head_t head;
      48            0 :     result = data_database_head_read_value_by_key( this_, key, &head );
      49            0 :     if ( result == U8_ERROR_NONE )
      50              :     {
      51            0 :         if ( out_old_head != NULL )
      52              :         {
      53            0 :             data_head_replace( out_old_head, &head );
      54              :         }
      55            0 :         result |= data_database_head_update_value( this_, data_head_get_row( &head ), new_head_value, NULL );
      56              :     }
      57            0 :     else if ( result == U8_ERROR_NOT_FOUND )
      58              :     {
      59            0 :         if ( out_old_head != NULL )
      60              :         {
      61            0 :             data_head_init_new( out_old_head, key, "" );
      62              :         }
      63            0 :         if ( create_if_not_found )
      64              :         {
      65            0 :             result = U8_ERROR_NONE;
      66            0 :             data_head_init_new( &head, key, new_head_value );
      67            0 :             result |= data_database_head_create_value( this_, &head, NULL );
      68            0 :             data_head_destroy( &head );
      69              :         }
      70              :     }
      71            0 :     return result;
      72              : }
      73              : 
      74              : 
      75              : /*
      76              : Copyright 2025-2026 Andreas Warnke
      77              : 
      78              : Licensed under the Apache License, Version 2.0 (the "License");
      79              : you may not use this file except in compliance with the License.
      80              : You may obtain a copy of the License at
      81              : 
      82              :     http://www.apache.org/licenses/LICENSE-2.0
      83              : 
      84              : Unless required by applicable law or agreed to in writing, software
      85              : distributed under the License is distributed on an "AS IS" BASIS,
      86              : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      87              : See the License for the specific language governing permissions and
      88              : limitations under the License.
      89              : */
        

Generated by: LCOV version 2.0-1