LCOV - code coverage report
Current view: top level - data/include - data_diagram.inl (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.57.0_covts Lines: 150 179 83.8 %
Date: 2024-04-07 11:14:42 Functions: 28 30 93.3 %

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

Generated by: LCOV version 1.16