LCOV - code coverage report
Current view: top level - data/include/entity - data_classifier.inl (source / functions) Coverage Total Hit
Test: crystal-facet-uml_v1.63.2_covts Lines: 100.0 % 182 182
Test Date: 2025-05-01 10:10:14 Functions: 100.0 % 31 31

            Line data    Source code
       1              : /* File: data_classifier.inl; Copyright and License: see below */
       2              : 
       3              : #include "entity/data_id.h"
       4              : #include "u8/u8_trace.h"
       5              : #include "u8/u8_log.h"
       6              : #include <assert.h>
       7              : 
       8         1115 : static inline void data_classifier_init_empty ( data_classifier_t *this_ )
       9              : {
      10         1115 :     (*this_).id = DATA_ROW_VOID;
      11         1115 :     (*this_).main_type = DATA_CLASSIFIER_TYPE_BLOCK;
      12              : 
      13         1115 :     (*this_).stereotype = utf8stringbuf_new( (*this_).private_stereotype_buffer, sizeof((*this_).private_stereotype_buffer) );
      14         1115 :     utf8stringbuf_clear( &((*this_).stereotype) );
      15         1115 :     (*this_).name = utf8stringbuf_new( (*this_).private_name_buffer, sizeof((*this_).private_name_buffer) );
      16         1115 :     utf8stringbuf_clear( &((*this_).name) );
      17         1115 :     (*this_).description = utf8stringbuf_new( (*this_).private_description_buffer, sizeof((*this_).private_description_buffer) );
      18         1115 :     utf8stringbuf_clear( &((*this_).description) );
      19              : 
      20         1115 :     (*this_).x_order = 0;
      21         1115 :     (*this_).y_order = 0;
      22         1115 :     (*this_).list_order = 0;
      23         1115 :     data_uuid_init_new( &((*this_).uuid) );
      24         1115 : }
      25              : 
      26            1 : static inline void data_classifier_reinit_empty ( data_classifier_t *this_ )
      27              : {
      28              :     /* data_classifier_destroy( this_ );  -- not necessary */
      29            1 :     data_classifier_init_empty( this_ );
      30            1 : }
      31              : 
      32            7 : static inline u8_error_t data_classifier_init_new ( data_classifier_t *this_,
      33              :                                                     data_classifier_type_t main_type,
      34              :                                                     const char* stereotype,
      35              :                                                     const char* name,
      36              :                                                     const char* description,
      37              :                                                     int32_t x_order,
      38              :                                                     int32_t y_order,
      39              :                                                     int32_t list_order )
      40              : {
      41            7 :     assert( NULL != stereotype );
      42            7 :     assert( NULL != name );
      43            7 :     assert( NULL != description );
      44              :     utf8error_t strerr;
      45            7 :     u8_error_t result = U8_ERROR_NONE;
      46              : 
      47            7 :     (*this_).id = DATA_ROW_VOID;
      48            7 :     (*this_).main_type = main_type;
      49              : 
      50            7 :     (*this_).stereotype = utf8stringbuf_new( (*this_).private_stereotype_buffer, sizeof((*this_).private_stereotype_buffer) );
      51            7 :     strerr = utf8stringbuf_copy_str( &((*this_).stereotype), stereotype );
      52            7 :     if ( strerr != UTF8ERROR_SUCCESS )
      53              :     {
      54            1 :         U8_LOG_ERROR_INT( "utf8stringbuf_copy_str() failed:", strerr );
      55            1 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
      56              :     }
      57              : 
      58            7 :     (*this_).name = utf8stringbuf_new( (*this_).private_name_buffer, sizeof((*this_).private_name_buffer) );
      59            7 :     strerr = utf8stringbuf_copy_str( &((*this_).name), name );
      60            7 :     if ( strerr != UTF8ERROR_SUCCESS )
      61              :     {
      62            1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
      63            1 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
      64              :     }
      65              : 
      66            7 :     (*this_).description = utf8stringbuf_new( (*this_).private_description_buffer, sizeof((*this_).private_description_buffer) );
      67            7 :     strerr = utf8stringbuf_copy_str( &((*this_).description), description );
      68            7 :     if ( strerr != UTF8ERROR_SUCCESS )
      69              :     {
      70            1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
      71            1 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
      72              :     }
      73              : 
      74            7 :     (*this_).x_order = x_order;
      75            7 :     (*this_).y_order = y_order;
      76            7 :     (*this_).list_order = list_order;
      77            7 :     data_uuid_init_new( &((*this_).uuid) );
      78              : 
      79            7 :     return result;
      80              : }
      81              : 
      82         1315 : static inline u8_error_t data_classifier_init ( data_classifier_t *this_,
      83              :                                                 data_row_t id,
      84              :                                                 data_classifier_type_t main_type,
      85              :                                                 const char* stereotype,
      86              :                                                 const char* name,
      87              :                                                 const char* description,
      88              :                                                 int32_t x_order,
      89              :                                                 int32_t y_order,
      90              :                                                 int32_t list_order,
      91              :                                                 const char* uuid )
      92              : {
      93         1315 :     assert( NULL != stereotype );
      94         1315 :     assert( NULL != name );
      95         1315 :     assert( NULL != description );
      96         1315 :     assert( NULL != uuid );
      97              :     utf8error_t strerr;
      98         1315 :     u8_error_t result = U8_ERROR_NONE;
      99              : 
     100         1315 :     (*this_).id = id;
     101         1315 :     (*this_).main_type = main_type;
     102              : 
     103         1315 :     (*this_).stereotype = utf8stringbuf_new( (*this_).private_stereotype_buffer, sizeof((*this_).private_stereotype_buffer) );
     104         1315 :     strerr = utf8stringbuf_copy_str( &((*this_).stereotype), stereotype );
     105         1315 :     if ( strerr != UTF8ERROR_SUCCESS )
     106              :     {
     107            1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     108            1 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     109              :     }
     110              : 
     111         1315 :     (*this_).name = utf8stringbuf_new( (*this_).private_name_buffer, sizeof((*this_).private_name_buffer) );
     112         1315 :     strerr = utf8stringbuf_copy_str( &((*this_).name), name );
     113         1315 :     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              : 
     119         1315 :     (*this_).description = utf8stringbuf_new( (*this_).private_description_buffer, sizeof((*this_).private_description_buffer) );
     120         1315 :     strerr = utf8stringbuf_copy_str( &((*this_).description), description );
     121         1315 :     if ( strerr != UTF8ERROR_SUCCESS )
     122              :     {
     123            1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     124            1 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     125              :     }
     126              : 
     127         1315 :     (*this_).x_order = x_order;
     128         1315 :     (*this_).y_order = y_order;
     129         1315 :     (*this_).list_order = list_order;
     130         1315 :     result |= data_uuid_init( &((*this_).uuid), uuid );
     131              : 
     132         1315 :     return result;
     133              : }
     134              : 
     135          196 : static inline u8_error_t data_classifier_reinit ( data_classifier_t *this_,
     136              :                                                   data_row_t id,
     137              :                                                   data_classifier_type_t main_type,
     138              :                                                   const char* stereotype,
     139              :                                                   const char* name,
     140              :                                                   const char* description,
     141              :                                                   int32_t x_order,
     142              :                                                   int32_t y_order,
     143              :                                                   int32_t list_order,
     144              :                                                   const char* uuid )
     145              : {
     146          196 :     return data_classifier_init( this_, id, main_type, stereotype, name, description, x_order, y_order, list_order, uuid );
     147              : }
     148              : 
     149          173 : static inline void data_classifier_copy ( data_classifier_t *this_, const data_classifier_t *original )
     150              : {
     151          173 :     assert( NULL != original );
     152              : 
     153          173 :     (*this_) = (*original);
     154              :     /* repair the overwritten pointers */
     155          173 :     (*this_).stereotype = utf8stringbuf_new( (*this_).private_stereotype_buffer, sizeof((*this_).private_stereotype_buffer) );
     156          173 :     (*this_).name = utf8stringbuf_new( (*this_).private_name_buffer, sizeof((*this_).private_name_buffer) );
     157          173 :     (*this_).description = utf8stringbuf_new( (*this_).private_description_buffer, sizeof((*this_).private_description_buffer) );
     158          173 :     data_uuid_copy( &((*this_).uuid), &((*original).uuid) );
     159          173 : }
     160              : 
     161           57 : static inline void data_classifier_replace ( data_classifier_t *this_, const data_classifier_t *that )
     162              : {
     163           57 :     assert( NULL != that );
     164              : 
     165           57 :     (*this_) = (*that);
     166              :     /* repair the overwritten pointers */
     167           57 :     (*this_).stereotype = utf8stringbuf_new( (*this_).private_stereotype_buffer, sizeof((*this_).private_stereotype_buffer) );
     168           57 :     (*this_).name = utf8stringbuf_new( (*this_).private_name_buffer, sizeof((*this_).private_name_buffer) );
     169           57 :     (*this_).description = utf8stringbuf_new( (*this_).private_description_buffer, sizeof((*this_).private_description_buffer) );
     170           57 :     data_uuid_replace( &((*this_).uuid), &((*that).uuid) );
     171           57 : }
     172              : 
     173          709 : static inline void data_classifier_destroy ( data_classifier_t *this_ )
     174              : {
     175          709 :     (*this_).id = DATA_ROW_VOID;
     176          709 :     data_uuid_destroy( &((*this_).uuid) );
     177          709 : }
     178              : 
     179          312 : static inline void data_classifier_trace ( const data_classifier_t *this_ )
     180              : {
     181          312 :     U8_TRACE_INFO( "data_classifier_t" );
     182          312 :     U8_TRACE_INFO_INT( "- id:", (*this_).id );
     183          312 :     U8_TRACE_INFO_INT( "- main_type:", (*this_).main_type );
     184          312 :     U8_TRACE_INFO_STR( "- stereotype:", utf8stringbuf_get_string( &((*this_).stereotype)) );
     185          312 :     U8_TRACE_INFO_STR( "- name:", utf8stringbuf_get_string( &((*this_).name)) );
     186          312 :     U8_TRACE_INFO_STR( "- description:", utf8stringbuf_get_string( &((*this_).description)) );
     187          312 :     U8_TRACE_INFO_INT( "- x_order:", (*this_).x_order );
     188          312 :     U8_TRACE_INFO_INT( "- y_order:", (*this_).y_order );
     189          312 :     U8_TRACE_INFO_INT( "- list_order:", (*this_).list_order );
     190          312 :     U8_TRACE_INFO_STR( "- uuid:", data_uuid_get_string( &((*this_).uuid) ) );
     191          312 : }
     192              : 
     193       247406 : static inline data_row_t data_classifier_get_row_id ( const data_classifier_t *this_ )
     194              : {
     195       247406 :     return (*this_).id;
     196              : }
     197              : 
     198           57 : static inline void data_classifier_set_row_id ( data_classifier_t *this_, data_row_t id )
     199              : {
     200           57 :     (*this_).id = id;
     201           57 : }
     202              : 
     203            1 : static inline data_id_t data_classifier_get_data_id ( const data_classifier_t *this_ )
     204              : {
     205              :     data_id_t result;
     206            1 :     data_id_init ( &result, DATA_TABLE_CLASSIFIER, (*this_).id );
     207            1 :     return result;
     208              : }
     209              : 
     210        34625 : static inline data_classifier_type_t data_classifier_get_main_type ( const data_classifier_t *this_ )
     211              : {
     212        34625 :     return (*this_).main_type;
     213              : }
     214              : 
     215          112 : static inline void data_classifier_set_main_type ( data_classifier_t *this_, data_classifier_type_t main_type )
     216              : {
     217          112 :     (*this_).main_type = main_type;
     218          112 : }
     219              : 
     220          826 : static inline const char *data_classifier_get_stereotype_const ( const data_classifier_t *this_ )
     221              : {
     222          826 :     return utf8stringbuf_get_string( &((*this_).stereotype) );
     223              : }
     224              : 
     225          311 : static inline bool data_classifier_has_stereotype ( const data_classifier_t *this_ )
     226              : {
     227          311 :     return ( ! utf8stringbuf_equals_str( &((*this_).stereotype), "" ) );
     228              : }
     229              : 
     230           18 : static inline u8_error_t data_classifier_set_stereotype ( data_classifier_t *this_, const char *stereotype )
     231              : {
     232           18 :     assert( NULL != stereotype );
     233              : 
     234           18 :     u8_error_t result = U8_ERROR_NONE;
     235              :     utf8error_t strerr;
     236           18 :     strerr = utf8stringbuf_copy_str( &((*this_).stereotype), stereotype );
     237           18 :     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           18 :     return result;
     243              : }
     244              : 
     245         2219 : static inline const char *data_classifier_get_name_const ( const data_classifier_t *this_ )
     246              : {
     247         2219 :     return utf8stringbuf_get_string( &((*this_).name) );
     248              : }
     249              : 
     250           23 : static inline u8_error_t data_classifier_set_name ( data_classifier_t *this_, const char *name )
     251              : {
     252           23 :     assert( NULL != name );
     253              : 
     254           23 :     u8_error_t result = U8_ERROR_NONE;
     255              :     utf8error_t strerr;
     256           23 :     strerr = utf8stringbuf_copy_str( &((*this_).name), name );
     257           23 :     if ( strerr != UTF8ERROR_SUCCESS )
     258              :     {
     259            1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     260            1 :         result = U8_ERROR_STRING_BUFFER_EXCEEDED;
     261              :     }
     262           23 :     return result;
     263              : }
     264              : 
     265          269 : static inline const char *data_classifier_get_description_const ( const data_classifier_t *this_ )
     266              : {
     267          269 :     return utf8stringbuf_get_string( &((*this_).description) );
     268              : }
     269              : 
     270           17 : static inline u8_error_t data_classifier_set_description ( data_classifier_t *this_, const char *description )
     271              : {
     272           17 :     assert( NULL != description );
     273              : 
     274           17 :     u8_error_t result = U8_ERROR_NONE;
     275              :     utf8error_t strerr;
     276           17 :     strerr = utf8stringbuf_copy_str( &((*this_).description), description );
     277           17 :     if ( strerr != UTF8ERROR_SUCCESS )
     278              :     {
     279            1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     280            1 :         result = U8_ERROR_STRING_BUFFER_EXCEEDED;
     281              :     }
     282           17 :     return result;
     283              : }
     284              : 
     285            2 : static inline u8_error_t data_classifier_append_description ( data_classifier_t *this_, const char *description )
     286              : {
     287            2 :     assert( NULL != description );
     288              : 
     289            2 :     u8_error_t result = U8_ERROR_NONE;
     290              :     utf8error_t strerr;
     291            2 :     strerr = utf8stringbuf_append_str( &((*this_).description), description );
     292            2 :     if ( strerr != UTF8ERROR_SUCCESS )
     293              :     {
     294            1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_append_str() failed:", strerr );
     295            1 :         result = U8_ERROR_STRING_BUFFER_EXCEEDED;
     296              :     }
     297            2 :     return result;
     298              : }
     299              : 
     300          258 : static inline int32_t data_classifier_get_x_order ( const data_classifier_t *this_ )
     301              : {
     302          258 :     return (*this_).x_order;
     303              : }
     304              : 
     305           16 : static inline void data_classifier_set_x_order ( data_classifier_t *this_, int32_t x_order )
     306              : {
     307           16 :     (*this_).x_order = x_order;
     308           16 : }
     309              : 
     310          258 : static inline int32_t data_classifier_get_y_order ( const data_classifier_t *this_ )
     311              : {
     312          258 :     return (*this_).y_order;
     313              : }
     314              : 
     315           16 : static inline void data_classifier_set_y_order ( data_classifier_t *this_, int32_t y_order )
     316              : {
     317           16 :     (*this_).y_order = y_order;
     318           16 : }
     319              : 
     320          257 : static inline int32_t data_classifier_get_list_order ( const data_classifier_t *this_ )
     321              : {
     322          257 :     return (*this_).list_order;
     323              : }
     324              : 
     325           15 : static inline void data_classifier_set_list_order ( data_classifier_t *this_, int32_t list_order )
     326              : {
     327           15 :     (*this_).list_order = list_order;
     328           15 : }
     329              : 
     330          300 : static inline const char *data_classifier_get_uuid_const ( const data_classifier_t *this_ )
     331              : {
     332          300 :     return data_uuid_get_string( &((*this_).uuid) );
     333              : }
     334              : 
     335           14 : static inline u8_error_t data_classifier_set_uuid ( data_classifier_t *this_, const char *uuid )
     336              : {
     337           14 :     assert( NULL != uuid );
     338              : 
     339           14 :     const u8_error_t result = data_uuid_reinit( &((*this_).uuid), uuid );
     340              : 
     341           14 :     return result;
     342              : }
     343              : 
     344       100030 : static inline bool data_classifier_is_valid ( const data_classifier_t *this_ )
     345              : {
     346       100030 :     return ( DATA_ROW_VOID != (*this_).id );
     347              : }
     348              : 
     349              : 
     350              : /*
     351              : Copyright 2016-2025 Andreas Warnke
     352              : 
     353              : Licensed under the Apache License, Version 2.0 (the "License");
     354              : you may not use this file except in compliance with the License.
     355              : You may obtain a copy of the License at
     356              : 
     357              :     http://www.apache.org/licenses/LICENSE-2.0
     358              : 
     359              : Unless required by applicable law or agreed to in writing, software
     360              : distributed under the License is distributed on an "AS IS" BASIS,
     361              : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     362              : See the License for the specific language governing permissions and
     363              : limitations under the License.
     364              : */
        

Generated by: LCOV version 2.0-1