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

            Line data    Source code
       1              : /* File: data_diagram.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          246 : static inline void data_diagram_init_empty ( data_diagram_t *this_ )
       8              : {
       9          246 :     (*this_).id = DATA_ROW_VOID;
      10          246 :     (*this_).parent_id = DATA_ROW_VOID;
      11          246 :     (*this_).diagram_type = DATA_DIAGRAM_TYPE_LIST;
      12              : 
      13          246 :     (*this_).stereotype = utf8stringbuf_new( (*this_).private_stereotype_buffer, sizeof((*this_).private_stereotype_buffer) );
      14          246 :     utf8stringbuf_clear( &((*this_).stereotype) );
      15          246 :     (*this_).name = utf8stringbuf_new( (*this_).private_name_buffer, sizeof((*this_).private_name_buffer) );
      16          246 :     utf8stringbuf_clear( &((*this_).name) );
      17          246 :     (*this_).description = utf8stringbuf_new( (*this_).private_description_buffer, sizeof((*this_).private_description_buffer) );
      18          246 :     utf8stringbuf_clear( &((*this_).description) );
      19              : 
      20          246 :     (*this_).list_order = 0;
      21          246 :     (*this_).display_flags = DATA_DIAGRAM_FLAG_NONE;
      22          246 :     data_uuid_init_new( &((*this_).uuid) );
      23          246 : }
      24              : 
      25            4 : static inline void data_diagram_reinit_empty ( data_diagram_t *this_ )
      26              : {
      27              :     /* data_diagram_destroy( this_ );  -- not necessary */
      28            4 :     data_diagram_init_empty( this_ );
      29            4 : }
      30              : 
      31          139 : static inline u8_error_t data_diagram_init_new ( data_diagram_t *this_,
      32              :                                                  data_row_t parent_diagram_id,
      33              :                                                  data_diagram_type_t diagram_type,
      34              :                                                  const char* stereotype,
      35              :                                                  const char* name,
      36              :                                                  const char* description,
      37              :                                                  int32_t list_order,
      38              :                                                  data_diagram_flag_t display_flags )
      39              : {
      40          139 :     assert( NULL != stereotype );
      41          139 :     assert( NULL != name );
      42          139 :     assert( NULL != description );
      43              :     utf8error_t strerr;
      44          139 :     u8_error_t result = U8_ERROR_NONE;
      45              : 
      46          139 :     (*this_).id = DATA_ROW_VOID;
      47          139 :     (*this_).parent_id = parent_diagram_id;
      48          139 :     (*this_).diagram_type = diagram_type;
      49              : 
      50          139 :     (*this_).stereotype = utf8stringbuf_new( (*this_).private_stereotype_buffer, sizeof((*this_).private_stereotype_buffer) );
      51          139 :     strerr = utf8stringbuf_copy_str( &((*this_).stereotype), stereotype );
      52          139 :     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          139 :     (*this_).name = utf8stringbuf_new( (*this_).private_name_buffer, sizeof((*this_).private_name_buffer) );
      59          139 :     strerr = utf8stringbuf_copy_str( &((*this_).name), name );
      60          139 :     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          139 :     (*this_).description = utf8stringbuf_new( (*this_).private_description_buffer, sizeof((*this_).private_description_buffer) );
      67          139 :     strerr = utf8stringbuf_copy_str( &((*this_).description), description );
      68          139 :     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          139 :     (*this_).list_order = list_order;
      75          139 :     (*this_).display_flags = display_flags;
      76          139 :     data_uuid_init_new( &((*this_).uuid) );
      77              : 
      78          139 :     return result;
      79              : }
      80              : 
      81          180 : static inline u8_error_t data_diagram_init ( data_diagram_t *this_,
      82              :                                              data_row_t diagram_id,
      83              :                                              data_row_t parent_diagram_id,
      84              :                                              data_diagram_type_t diagram_type,
      85              :                                              const char* stereotype,
      86              :                                              const char* name,
      87              :                                              const char* description,
      88              :                                              int32_t list_order,
      89              :                                              data_diagram_flag_t display_flags,
      90              :                                              const char* uuid )
      91              : {
      92          180 :     assert( NULL != stereotype );
      93          180 :     assert( NULL != name );
      94          180 :     assert( NULL != description );
      95          180 :     assert( NULL != uuid );
      96              :     utf8error_t strerr;
      97          180 :     u8_error_t result = U8_ERROR_NONE;
      98              : 
      99          180 :     (*this_).id = diagram_id;
     100          180 :     (*this_).parent_id = parent_diagram_id;
     101          180 :     (*this_).diagram_type = diagram_type;
     102              : 
     103          180 :     (*this_).stereotype = utf8stringbuf_new( (*this_).private_stereotype_buffer, sizeof((*this_).private_stereotype_buffer) );
     104          180 :     strerr = utf8stringbuf_copy_str( &((*this_).stereotype), stereotype );
     105          180 :     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          180 :     (*this_).name = utf8stringbuf_new( (*this_).private_name_buffer, sizeof((*this_).private_name_buffer) );
     112          180 :     strerr = utf8stringbuf_copy_str( &((*this_).name), name );
     113          180 :     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          180 :     (*this_).description = utf8stringbuf_new( (*this_).private_description_buffer, sizeof((*this_).private_description_buffer) );
     120          180 :     strerr = utf8stringbuf_copy_str( &((*this_).description), description );
     121          180 :     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          180 :     (*this_).list_order = list_order;
     127          180 :     (*this_).display_flags = display_flags;
     128          180 :     result |= data_uuid_init( &((*this_).uuid), uuid );
     129              : 
     130          180 :     return result;
     131              : }
     132              : 
     133           44 : static inline void data_diagram_copy ( data_diagram_t *this_, const data_diagram_t *original )
     134              : {
     135           44 :     assert( NULL != original );
     136              : 
     137           44 :     (*this_) = (*original);
     138              :     /* repair the overwritten pointers */
     139           44 :     (*this_).stereotype = utf8stringbuf_new( (*this_).private_stereotype_buffer, sizeof((*this_).private_stereotype_buffer) );
     140           44 :     (*this_).name = utf8stringbuf_new( (*this_).private_name_buffer, sizeof((*this_).private_name_buffer) );
     141           44 :     (*this_).description = utf8stringbuf_new( (*this_).private_description_buffer, sizeof((*this_).private_description_buffer) );
     142           44 :     data_uuid_copy( &((*this_).uuid), &((*original).uuid) );
     143           44 : }
     144              : 
     145          185 : static inline void data_diagram_replace ( data_diagram_t *this_, const data_diagram_t *that )
     146              : {
     147          185 :     assert( NULL != that );
     148              : 
     149          185 :     (*this_) = (*that);
     150              :     /* repair the overwritten pointers */
     151          185 :     (*this_).stereotype = utf8stringbuf_new( (*this_).private_stereotype_buffer, sizeof((*this_).private_stereotype_buffer) );
     152          185 :     (*this_).name = utf8stringbuf_new( (*this_).private_name_buffer, sizeof((*this_).private_name_buffer) );
     153          185 :     (*this_).description = utf8stringbuf_new( (*this_).private_description_buffer, sizeof((*this_).private_description_buffer) );
     154          185 :     data_uuid_replace( &((*this_).uuid), &((*that).uuid) );
     155          185 : }
     156              : 
     157          297 : static inline void data_diagram_destroy ( data_diagram_t *this_ )
     158              : {
     159          297 :     (*this_).id = DATA_ROW_VOID;
     160          297 :     (*this_).parent_id = DATA_ROW_VOID;
     161          297 :     data_uuid_destroy( &((*this_).uuid) );
     162          297 : }
     163              : 
     164          125 : static inline void data_diagram_trace ( const data_diagram_t *this_ )
     165              : {
     166          125 :     U8_TRACE_INFO( "data_diagram_t" );
     167          125 :     U8_TRACE_INFO_INT( "- id:", (*this_).id );
     168          125 :     U8_TRACE_INFO_INT( "- parent_id:", (*this_).parent_id );
     169          125 :     U8_TRACE_INFO_INT( "- diagram_type:", (*this_).diagram_type );
     170          125 :     U8_TRACE_INFO_STR( "- stereotype:", utf8stringbuf_get_string( &((*this_).stereotype)) );
     171          125 :     U8_TRACE_INFO_STR( "- name:", utf8stringbuf_get_string( &((*this_).name)) );
     172          125 :     U8_TRACE_INFO_STR( "- description:", utf8stringbuf_get_string( &((*this_).description)) );
     173          125 :     U8_TRACE_INFO_INT( "- list_order:", (*this_).list_order );
     174          125 :     U8_TRACE_INFO_HEX( "- display_flags:", (*this_).display_flags );
     175          125 :     U8_TRACE_INFO_STR( "- uuid:", data_uuid_get_string( &((*this_).uuid) ) );
     176          125 : }
     177              : 
     178          434 : static inline data_row_t data_diagram_get_row_id ( const data_diagram_t *this_ )
     179              : {
     180          434 :     return (*this_).id;
     181              : }
     182              : 
     183          194 : static inline void data_diagram_set_row_id ( data_diagram_t *this_, data_row_t id )
     184              : {
     185          194 :     (*this_).id = id;
     186          194 : }
     187              : 
     188           45 : static inline data_id_t data_diagram_get_data_id ( const data_diagram_t *this_ )
     189              : {
     190              :     data_id_t result;
     191           45 :     data_id_init ( &result, DATA_TABLE_DIAGRAM, (*this_).id );
     192           45 :     return result;
     193              : }
     194              : 
     195          569 : static inline data_row_t data_diagram_get_parent_row_id ( const data_diagram_t *this_ )
     196              : {
     197          569 :     return (*this_).parent_id;
     198              : }
     199              : 
     200           57 : static inline void data_diagram_set_parent_row_id ( data_diagram_t *this_, data_row_t parent_id )
     201              : {
     202           57 :     (*this_).parent_id = parent_id;
     203           57 : }
     204              : 
     205           12 : static inline data_id_t data_diagram_get_parent_data_id ( const data_diagram_t *this_ )
     206              : {
     207              :     data_id_t result;
     208           12 :     data_id_init ( &result, DATA_TABLE_DIAGRAM, (*this_).parent_id );
     209           12 :     return result;
     210              : }
     211              : 
     212         1021 : static inline data_diagram_type_t data_diagram_get_diagram_type ( const data_diagram_t *this_ )
     213              : {
     214         1021 :     return (*this_).diagram_type;
     215              : }
     216              : 
     217           14 : static inline void data_diagram_set_diagram_type ( data_diagram_t *this_, data_diagram_type_t diagram_type )
     218              : {
     219           14 :     (*this_).diagram_type = diagram_type;
     220           14 : }
     221              : 
     222          216 : static inline const char *data_diagram_get_stereotype_const ( const data_diagram_t *this_ )
     223              : {
     224          216 :     return utf8stringbuf_get_string( &((*this_).stereotype) );
     225              : }
     226              : 
     227            5 : static inline bool data_diagram_has_stereotype ( const data_diagram_t *this_ )
     228              : {
     229            5 :     return ( ! utf8stringbuf_equals_str( &((*this_).stereotype), "" ) );
     230              : }
     231              : 
     232            2 : static inline u8_error_t data_diagram_set_stereotype ( data_diagram_t *this_, const char *stereotype )
     233              : {
     234            2 :     assert( NULL != stereotype );
     235              : 
     236            2 :     u8_error_t result = U8_ERROR_NONE;
     237              :     utf8error_t strerr;
     238            2 :     strerr = utf8stringbuf_copy_str( &((*this_).stereotype), stereotype );
     239            2 :     if ( strerr != UTF8ERROR_SUCCESS )
     240              :     {
     241            1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     242            1 :         result = U8_ERROR_STRING_BUFFER_EXCEEDED;
     243              :     }
     244            2 :     return result;
     245              : }
     246              : 
     247          261 : static inline const char *data_diagram_get_name_const ( const data_diagram_t *this_ )
     248              : {
     249          261 :     return utf8stringbuf_get_string( &((*this_).name) );
     250              : }
     251              : 
     252           12 : static inline u8_error_t data_diagram_set_name ( data_diagram_t *this_, const char *name )
     253              : {
     254           12 :     assert( NULL != name );
     255           12 :     u8_error_t result = U8_ERROR_NONE;
     256              :     utf8error_t strerr;
     257           12 :     strerr = utf8stringbuf_copy_str( &((*this_).name), name );
     258           12 :     if ( strerr != UTF8ERROR_SUCCESS )
     259              :     {
     260            1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     261            1 :         result = U8_ERROR_STRING_BUFFER_EXCEEDED;
     262              :     }
     263           12 :     return result;
     264              : }
     265              : 
     266          218 : static inline const char *data_diagram_get_description_const ( const data_diagram_t *this_ )
     267              : {
     268          218 :     return utf8stringbuf_get_string( &((*this_).description) );
     269              : }
     270              : 
     271           11 : static inline u8_error_t data_diagram_set_description ( data_diagram_t *this_, const char *description )
     272              : {
     273           11 :     assert( NULL != description );
     274           11 :     u8_error_t result = U8_ERROR_NONE;
     275              :     utf8error_t strerr;
     276           11 :     strerr = utf8stringbuf_copy_str( &((*this_).description), description );
     277           11 :     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           11 :     return result;
     283              : }
     284              : 
     285            2 : static inline u8_error_t data_diagram_append_description ( data_diagram_t *this_, const char *description )
     286              : {
     287            2 :     assert( NULL != description );
     288            2 :     u8_error_t result = U8_ERROR_NONE;
     289              :     utf8error_t strerr;
     290            2 :     strerr = utf8stringbuf_append_str( &((*this_).description), description );
     291            2 :     if ( strerr != UTF8ERROR_SUCCESS )
     292              :     {
     293            1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_append_str() failed:", strerr );
     294            1 :         result = U8_ERROR_STRING_BUFFER_EXCEEDED;
     295              :     }
     296            2 :     return result;
     297              : }
     298              : 
     299          227 : static inline int32_t data_diagram_get_list_order ( const data_diagram_t *this_ )
     300              : {
     301          227 :     return (*this_).list_order;
     302              : }
     303              : 
     304           10 : static inline void data_diagram_set_list_order ( data_diagram_t *this_, int32_t list_order )
     305              : {
     306           10 :     (*this_).list_order = list_order;
     307           10 : }
     308              : 
     309          207 : static inline data_diagram_flag_t data_diagram_get_display_flags ( const data_diagram_t *this_ )
     310              : {
     311          207 :     return (*this_).display_flags;
     312              : }
     313              : 
     314            8 : static inline void data_diagram_set_display_flags ( data_diagram_t *this_, data_diagram_flag_t display_flags )
     315              : {
     316            8 :     (*this_).display_flags = display_flags;
     317            8 : }
     318              : 
     319          222 : static inline const char *data_diagram_get_uuid_const ( const data_diagram_t *this_ )
     320              : {
     321          222 :     return data_uuid_get_string( &((*this_).uuid) );
     322              : }
     323              : 
     324           15 : static inline u8_error_t data_diagram_set_uuid ( data_diagram_t *this_, const char *uuid )
     325              : {
     326           15 :     assert( NULL != uuid );
     327              : 
     328           15 :     const u8_error_t result = data_uuid_reinit( &((*this_).uuid), uuid );
     329              : 
     330           15 :     return result;
     331              : }
     332              : 
     333          817 : static inline bool data_diagram_is_valid ( const data_diagram_t *this_ )
     334              : {
     335          817 :     return ( DATA_ROW_VOID != (*this_).id );
     336              : }
     337              : 
     338              : 
     339              : /*
     340              : Copyright 2016-2025 Andreas Warnke
     341              : 
     342              : Licensed under the Apache License, Version 2.0 (the "License");
     343              : you may not use this file except in compliance with the License.
     344              : You may obtain a copy of the License at
     345              : 
     346              :     http://www.apache.org/licenses/LICENSE-2.0
     347              : 
     348              : Unless required by applicable law or agreed to in writing, software
     349              : distributed under the License is distributed on an "AS IS" BASIS,
     350              : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     351              : See the License for the specific language governing permissions and
     352              : limitations under the License.
     353              : */
        

Generated by: LCOV version 2.0-1