LCOV - code coverage report
Current view: top level - io/source/document - document_link_provider.c (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.62.0_covts Lines: 0 30 0.0 %
Date: 2024-12-21 18:34:41 Functions: 0 3 0.0 %

          Line data    Source code
       1             : /* File: document_link_provider.c; Copyright and License: see below */
       2             : 
       3             : #include "document/document_link_provider.h"
       4             : #include "utf8stringbuf/utf8stringview.h"
       5             : #include "u8/u8_trace.h"
       6             : #include "u8/u8_log.h"
       7             : #include <stdio.h>
       8             : #include <stdbool.h>
       9             : #include <assert.h>
      10             : 
      11           0 : void document_link_provider_init( document_link_provider_t *this_,
      12             :                                   data_database_reader_t *db_reader )
      13             : {
      14           0 :     U8_TRACE_BEGIN();
      15           0 :     assert( NULL != db_reader );
      16             : 
      17           0 :     (*this_).db_reader = db_reader;
      18             : 
      19           0 :     U8_TRACE_END();
      20           0 : }
      21             : 
      22           0 : void document_link_provider_destroy( document_link_provider_t *this_ )
      23             : {
      24           0 :     U8_TRACE_BEGIN();
      25             : 
      26           0 :     (*this_).db_reader = NULL;
      27             : 
      28           0 :     U8_TRACE_END();
      29           0 : }
      30             : 
      31           0 : u8_error_t document_link_provider_get_occurrences( document_link_provider_t *this_,
      32             :                                                    data_id_t classifier_id,
      33             :                                                    data_diagram_t (**out_diagram)[],
      34             :                                                    uint32_t *out_diagram_count )
      35             : {
      36           0 :     U8_TRACE_BEGIN();
      37           0 :     assert ( NULL != (*this_).db_reader );
      38           0 :     assert ( DATA_TABLE_CLASSIFIER == data_id_get_table( &classifier_id ) );
      39           0 :     assert ( NULL != out_diagram );
      40           0 :     assert ( NULL != out_diagram_count );
      41           0 :     u8_error_t db_err = U8_ERROR_NONE;
      42             : 
      43             :     data_diagram_iterator_t diagram_iterator;
      44           0 :     db_err |= data_diagram_iterator_init_empty( &diagram_iterator );
      45           0 :     db_err |= data_database_reader_get_diagrams_by_classifier_id( (*this_).db_reader,
      46             :                                                                   data_id_get_row_id( &classifier_id ),
      47             :                                                                   &diagram_iterator
      48             :                                                                 );
      49           0 :     uint_fast32_t next_idx = 0;
      50           0 :     for ( ; (next_idx < DOCUMENT_LINK_PROVIDER_MAX_LINKS) && data_diagram_iterator_has_next( &diagram_iterator ); next_idx++ )
      51             :     {
      52           0 :         db_err |= data_diagram_iterator_next( &diagram_iterator, &( (*this_).temp_diagrams[next_idx] ) );
      53             :     }
      54           0 :     if ( data_diagram_iterator_has_next( &diagram_iterator ) )
      55             :     {
      56             :         /* This is not an error - rather expected - shuold only be traced...*/
      57           0 :         U8_TRACE_INFO_INT( "document_link_provider_get_occurrences finds too many classifier occurrences", DOCUMENT_LINK_PROVIDER_MAX_LINKS );
      58             :     }
      59           0 :     db_err |= data_diagram_iterator_destroy( &diagram_iterator );
      60             : 
      61           0 :     *out_diagram = &((*this_).temp_diagrams);
      62           0 :     *out_diagram_count = next_idx;
      63             : 
      64           0 :     U8_TRACE_END_ERR( db_err );
      65           0 :     return db_err;
      66             : }
      67             : 
      68             : 
      69             : /*
      70             : Copyright 2023-2024 Andreas Warnke
      71             : 
      72             : Licensed under the Apache License, Version 2.0 (the "License");
      73             : you may not use this file except in compliance with the License.
      74             : You may obtain a copy of the License at
      75             : 
      76             :     http://www.apache.org/licenses/LICENSE-2.0
      77             : 
      78             : Unless required by applicable law or agreed to in writing, software
      79             : distributed under the License is distributed on an "AS IS" BASIS,
      80             : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      81             : See the License for the specific language governing permissions and
      82             : limitations under the License.
      83             : */

Generated by: LCOV version 1.16