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

          Line data    Source code
       1             : /* File: data_feature.inl; Copyright and License: see below */
       2             : 
       3             : #include "entity/data_id.h"
       4             : #include <assert.h>
       5             : 
       6         122 : static inline void data_feature_init_empty ( data_feature_t *this_ )
       7             : {
       8         122 :     (*this_).id = DATA_ROW_ID_VOID;
       9         122 :     (*this_).classifier_id = DATA_ROW_ID_VOID;
      10         122 :     (*this_).main_type = DATA_FEATURE_TYPE_PROPERTY;
      11             : 
      12         122 :     (*this_).key = utf8stringbuf_init( sizeof((*this_).private_key_buffer), (*this_).private_key_buffer );
      13         122 :     utf8stringbuf_clear( (*this_).key );
      14         122 :     (*this_).value = utf8stringbuf_init( sizeof((*this_).private_value_buffer), (*this_).private_value_buffer );
      15         122 :     utf8stringbuf_clear( (*this_).value );
      16         122 :     (*this_).description = utf8stringbuf_init( sizeof((*this_).private_description_buffer), (*this_).private_description_buffer );
      17         122 :     utf8stringbuf_clear( (*this_).description );
      18             : 
      19         122 :     (*this_).list_order = 0;
      20         122 :     data_uuid_init_new( &((*this_).uuid) );
      21         122 : }
      22             : 
      23           1 : static inline void data_feature_reinit_empty ( data_feature_t *this_ )
      24             : {
      25             :     /* data_feature_destroy( this_ );  -- not necessary */
      26           1 :     data_feature_init_empty( this_ );
      27           1 : }
      28             : 
      29          20 : static inline u8_error_t data_feature_init_new ( data_feature_t *this_,
      30             :                                                  data_feature_type_t feature_main_type,
      31             :                                                  data_row_id_t classifier_id,
      32             :                                                  const char* feature_key,
      33             :                                                  const char* feature_value,
      34             :                                                  const char* feature_description,
      35             :                                                  int32_t list_order )
      36             : {
      37          20 :     assert( NULL != feature_key );
      38          20 :     assert( NULL != feature_value );
      39          20 :     assert( NULL != feature_description );
      40             :     utf8error_t strerr;
      41          20 :     u8_error_t result = U8_ERROR_NONE;
      42             : 
      43          20 :     (*this_).id = DATA_ROW_ID_VOID;
      44          20 :     (*this_).classifier_id = classifier_id;
      45          20 :     (*this_).main_type = feature_main_type;
      46             : 
      47          20 :     (*this_).key = utf8stringbuf_init( sizeof((*this_).private_key_buffer), (*this_).private_key_buffer );
      48          20 :     strerr = utf8stringbuf_copy_str( (*this_).key, feature_key );
      49          20 :     if ( strerr != UTF8ERROR_SUCCESS )
      50             :     {
      51           1 :         U8_LOG_ERROR_INT( "utf8stringbuf_copy_str() failed:", strerr );
      52           1 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
      53             :     }
      54             : 
      55          20 :     (*this_).value = utf8stringbuf_init( sizeof((*this_).private_value_buffer), (*this_).private_value_buffer );
      56          20 :     strerr = utf8stringbuf_copy_str( (*this_).value, feature_value );
      57          20 :     if ( strerr != UTF8ERROR_SUCCESS )
      58             :     {
      59           1 :         U8_LOG_ERROR_INT( "utf8stringbuf_copy_str() failed:", strerr );
      60           1 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
      61             :     }
      62             : 
      63          20 :     (*this_).description = utf8stringbuf_init( sizeof((*this_).private_description_buffer), (*this_).private_description_buffer );
      64          20 :     strerr = utf8stringbuf_copy_str( (*this_).description, feature_description );
      65          20 :     if ( strerr != UTF8ERROR_SUCCESS )
      66             :     {
      67           1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
      68           1 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
      69             :     }
      70             : 
      71          20 :     (*this_).list_order = list_order;
      72          20 :     data_uuid_init_new( &((*this_).uuid) );
      73             : 
      74          20 :     return result;
      75             : }
      76             : 
      77        2309 : static inline u8_error_t data_feature_init ( data_feature_t *this_,
      78             :                                              data_row_id_t feature_id,
      79             :                                              data_feature_type_t feature_main_type,
      80             :                                              data_row_id_t classifier_id,
      81             :                                              const char* feature_key,
      82             :                                              const char* feature_value,
      83             :                                              const char* feature_description,
      84             :                                              int32_t list_order,
      85             :                                              const char* uuid )
      86             : {
      87        2309 :     assert( NULL != feature_key );
      88        2309 :     assert( NULL != feature_value );
      89        2309 :     assert( NULL != feature_description );
      90        2309 :     assert( NULL != uuid );
      91             :     utf8error_t strerr;
      92        2309 :     u8_error_t result = U8_ERROR_NONE;
      93             : 
      94        2309 :     (*this_).id = feature_id;
      95        2309 :     (*this_).classifier_id = classifier_id;
      96        2309 :     (*this_).main_type = feature_main_type;
      97             : 
      98        2309 :     (*this_).key = utf8stringbuf_init( sizeof((*this_).private_key_buffer), (*this_).private_key_buffer );
      99        2309 :     strerr = utf8stringbuf_copy_str( (*this_).key, feature_key );
     100        2309 :     if ( strerr != UTF8ERROR_SUCCESS )
     101             :     {
     102           1 :         U8_LOG_ERROR_INT( "utf8stringbuf_copy_str() failed:", strerr );
     103           1 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     104             :     }
     105             : 
     106        2309 :     (*this_).value = utf8stringbuf_init( sizeof((*this_).private_value_buffer), (*this_).private_value_buffer );
     107        2309 :     strerr = utf8stringbuf_copy_str( (*this_).value, feature_value );
     108        2309 :     if ( strerr != UTF8ERROR_SUCCESS )
     109             :     {
     110           1 :         U8_LOG_ERROR_INT( "utf8stringbuf_copy_str() failed:", strerr );
     111           1 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     112             :     }
     113             : 
     114        2309 :     (*this_).description = utf8stringbuf_init( sizeof((*this_).private_description_buffer), (*this_).private_description_buffer );
     115        2309 :     strerr = utf8stringbuf_copy_str( (*this_).description, feature_description );
     116        2309 :     if ( strerr != UTF8ERROR_SUCCESS )
     117             :     {
     118           1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     119           1 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     120             :     }
     121             : 
     122        2309 :     (*this_).list_order = list_order;
     123        2309 :     result |= data_uuid_init( &((*this_).uuid), uuid );
     124             : 
     125        2309 :     return result;
     126             : }
     127             : 
     128         306 : static inline void data_feature_copy ( data_feature_t *this_, const data_feature_t *original )
     129             : {
     130         306 :     assert( NULL != original );
     131             : 
     132         306 :     (*this_) = (*original);
     133             :     /* repair the overwritten pointers */
     134         306 :     (*this_).key = utf8stringbuf_init( sizeof((*this_).private_key_buffer), (*this_).private_key_buffer );
     135         306 :     (*this_).value = utf8stringbuf_init( sizeof((*this_).private_value_buffer), (*this_).private_value_buffer );
     136         306 :     (*this_).description = utf8stringbuf_init( sizeof((*this_).private_description_buffer), (*this_).private_description_buffer );
     137         306 :     data_uuid_copy( &((*this_).uuid), &((*original).uuid) );
     138         306 : }
     139             : 
     140          56 : static inline void data_feature_replace ( data_feature_t *this_, const data_feature_t *that )
     141             : {
     142          56 :     assert( NULL != that );
     143             : 
     144          56 :     (*this_) = (*that);
     145             :     /* repair the overwritten pointers */
     146          56 :     (*this_).key = utf8stringbuf_init( sizeof((*this_).private_key_buffer), (*this_).private_key_buffer );
     147          56 :     (*this_).value = utf8stringbuf_init( sizeof((*this_).private_value_buffer), (*this_).private_value_buffer );
     148          56 :     (*this_).description = utf8stringbuf_init( sizeof((*this_).private_description_buffer), (*this_).private_description_buffer );
     149          56 :     data_uuid_replace( &((*this_).uuid), &((*that).uuid) );
     150          56 : }
     151             : 
     152         988 : static inline void data_feature_destroy ( data_feature_t *this_ )
     153             : {
     154         988 :     (*this_).id = DATA_ROW_ID_VOID;
     155         988 :     data_uuid_destroy( &((*this_).uuid) );
     156         988 : }
     157             : 
     158      599568 : static inline data_row_id_t data_feature_get_row_id ( const data_feature_t *this_ )
     159             : {
     160      599568 :     return (*this_).id;
     161             : }
     162             : 
     163          65 : static inline void data_feature_set_row_id ( data_feature_t *this_, data_row_id_t id )
     164             : {
     165          65 :     (*this_).id = id;
     166          65 : }
     167             : 
     168           3 : static inline data_id_t data_feature_get_data_id ( const data_feature_t *this_ )
     169             : {
     170             :     data_id_t result;
     171           3 :     data_id_init ( &result, DATA_TABLE_FEATURE, (*this_).id );
     172           3 :     return result;
     173             : }
     174             : 
     175       35073 : static inline data_row_id_t data_feature_get_classifier_row_id ( const data_feature_t *this_ )
     176             : {
     177       35073 :     return (*this_).classifier_id;
     178             : }
     179             : 
     180          11 : static inline void data_feature_set_classifier_row_id ( data_feature_t *this_, data_row_id_t classifier_id )
     181             : {
     182          11 :     (*this_).classifier_id = classifier_id;
     183          11 : }
     184             : 
     185           1 : static inline data_id_t data_feature_get_classifier_data_id ( const data_feature_t *this_ )
     186             : {
     187             :     data_id_t result;
     188           1 :     data_id_init ( &result, DATA_TABLE_CLASSIFIER, (*this_).classifier_id );
     189           1 :     return result;
     190             : }
     191             : 
     192       34045 : static inline data_feature_type_t data_feature_get_main_type ( const data_feature_t *this_ )
     193             : {
     194       34045 :     return (*this_).main_type;
     195             : }
     196             : 
     197          25 : static inline void data_feature_set_main_type ( data_feature_t *this_, data_feature_type_t main_type )
     198             : {
     199          25 :     (*this_).main_type = main_type;
     200          25 : }
     201             : 
     202         405 : static inline const char *data_feature_get_key_const ( const data_feature_t *this_ )
     203             : {
     204         405 :     return utf8stringbuf_get_string( (*this_).key );
     205             : }
     206             : 
     207          25 : static inline u8_error_t data_feature_set_key ( data_feature_t *this_, const char *key )
     208             : {
     209          25 :     assert( NULL != key );
     210          25 :     u8_error_t result = U8_ERROR_NONE;
     211             :     utf8error_t strerr;
     212          25 :     strerr = utf8stringbuf_copy_str( (*this_).key, key );
     213          25 :     if ( strerr != UTF8ERROR_SUCCESS )
     214             :     {
     215           1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     216           1 :         result = U8_ERROR_STRING_BUFFER_EXCEEDED;
     217             :     }
     218          25 :     return result;
     219             : }
     220             : 
     221         408 : static inline const char *data_feature_get_value_const ( const data_feature_t *this_ )
     222             : {
     223         408 :     return utf8stringbuf_get_string( (*this_).value );
     224             : }
     225             : 
     226           3 : static inline bool data_feature_has_value ( const data_feature_t *this_ )
     227             : {
     228           3 :     return ( ! utf8stringbuf_equals_str( (*this_).value, "" ) );
     229             : }
     230             : 
     231          26 : static inline u8_error_t data_feature_set_value ( data_feature_t *this_, const char *value )
     232             : {
     233          26 :     assert( NULL != value );
     234          26 :     u8_error_t result = U8_ERROR_NONE;
     235             :     utf8error_t strerr;
     236          26 :     strerr = utf8stringbuf_copy_str( (*this_).value, value );
     237          26 :     if ( strerr != UTF8ERROR_SUCCESS )
     238             :     {
     239           1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     240           1 :         result = U8_ERROR_STRING_BUFFER_EXCEEDED;
     241             :     }
     242          26 :     return result;
     243             : }
     244             : 
     245         406 : static inline const char *data_feature_get_description_const ( const data_feature_t *this_ )
     246             : {
     247         406 :     return utf8stringbuf_get_string( (*this_).description );
     248             : }
     249             : 
     250          25 : static inline u8_error_t data_feature_set_description ( data_feature_t *this_, const char *description )
     251             : {
     252          25 :     assert( NULL != description );
     253          25 :     u8_error_t result = U8_ERROR_NONE;
     254             :     utf8error_t strerr;
     255          25 :     strerr = utf8stringbuf_copy_str( (*this_).description, description );
     256          25 :     if ( strerr != UTF8ERROR_SUCCESS )
     257             :     {
     258           1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     259           1 :         result = U8_ERROR_STRING_BUFFER_EXCEEDED;
     260             :     }
     261          25 :     return result;
     262             : }
     263             : 
     264           2 : static inline u8_error_t data_feature_append_description ( data_feature_t *this_, const char *description )
     265             : {
     266           2 :     assert( NULL != description );
     267           2 :     u8_error_t result = U8_ERROR_NONE;
     268             :     utf8error_t strerr;
     269           2 :     strerr = utf8stringbuf_append_str( (*this_).description, description );
     270           2 :     if ( strerr != UTF8ERROR_SUCCESS )
     271             :     {
     272           1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_append_str() failed:", strerr );
     273           1 :         result = U8_ERROR_STRING_BUFFER_EXCEEDED;
     274             :     }
     275           2 :     return result;
     276             : }
     277             : 
     278         403 : static inline int32_t data_feature_get_list_order ( const data_feature_t *this_ )
     279             : {
     280         403 :     return (*this_).list_order;
     281             : }
     282             : 
     283          24 : static inline void data_feature_set_list_order ( data_feature_t *this_, int32_t list_order )
     284             : {
     285          24 :     (*this_).list_order = list_order;
     286          24 : }
     287             : 
     288         426 : static inline const char *data_feature_get_uuid_const ( const data_feature_t *this_ )
     289             : {
     290         426 :     return data_uuid_get_string( &((*this_).uuid) );
     291             : }
     292             : 
     293          14 : static inline u8_error_t data_feature_set_uuid ( data_feature_t *this_, const char *uuid )
     294             : {
     295          14 :     assert( NULL != uuid );
     296             : 
     297          14 :     const u8_error_t result = data_uuid_reinit( &((*this_).uuid), uuid );
     298             : 
     299          14 :     return result;
     300             : }
     301             : 
     302       35902 : static inline bool data_feature_is_valid ( const data_feature_t *this_ )
     303             : {
     304       35902 :     return ( DATA_ROW_ID_VOID != (*this_).id );
     305             : }
     306             : 
     307         391 : static inline void data_feature_trace ( const data_feature_t *this_ )
     308             : {
     309         391 :     U8_TRACE_INFO( "data_feature_t" );
     310         391 :     U8_TRACE_INFO_INT( "- id:", (*this_).id );
     311         391 :     U8_TRACE_INFO_INT( "- main_type:", (*this_).main_type );
     312         391 :     U8_TRACE_INFO_INT( "- classifier_id:", (*this_).classifier_id );
     313         391 :     U8_TRACE_INFO_STR( "- key:", utf8stringbuf_get_string((*this_).key) );
     314         391 :     U8_TRACE_INFO_STR( "- value:", utf8stringbuf_get_string((*this_).value) );
     315         391 :     U8_TRACE_INFO_STR( "- description:", utf8stringbuf_get_string((*this_).description) );
     316         391 :     U8_TRACE_INFO_INT( "- list_order:", (*this_).list_order );
     317         391 :     U8_TRACE_INFO_STR( "- uuid:", data_uuid_get_string( &((*this_).uuid) ) );
     318         391 : }
     319             : 
     320             : 
     321             : /*
     322             : Copyright 2016-2024 Andreas Warnke
     323             : 
     324             : Licensed under the Apache License, Version 2.0 (the "License");
     325             : you may not use this file except in compliance with the License.
     326             : You may obtain a copy of the License at
     327             : 
     328             :     http://www.apache.org/licenses/LICENSE-2.0
     329             : 
     330             : Unless required by applicable law or agreed to in writing, software
     331             : distributed under the License is distributed on an "AS IS" BASIS,
     332             : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     333             : See the License for the specific language governing permissions and
     334             : limitations under the License.
     335             : */

Generated by: LCOV version 1.16