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 write_err = U8_ERROR_NONE; 42 : 43 : uint32_t diagram_count; 44 0 : write_err |= data_database_reader_get_diagrams_by_classifier_id( (*this_).db_reader, 45 : data_id_get_row_id( &classifier_id ), 46 : DOCUMENT_LINK_PROVIDER_MAX_LINKS, 47 0 : &((*this_).temp_diagram), 48 : &diagram_count 49 : ); 50 : 51 0 : *out_diagram = &((*this_).temp_diagram); 52 0 : *out_diagram_count = diagram_count; 53 : 54 0 : U8_TRACE_END_ERR( write_err ); 55 0 : return write_err; 56 : } 57 : 58 : 59 : /* 60 : Copyright 2023-2024 Andreas Warnke 61 : 62 : Licensed under the Apache License, Version 2.0 (the "License"); 63 : you may not use this file except in compliance with the License. 64 : You may obtain a copy of the License at 65 : 66 : http://www.apache.org/licenses/LICENSE-2.0 67 : 68 : Unless required by applicable law or agreed to in writing, software 69 : distributed under the License is distributed on an "AS IS" BASIS, 70 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 71 : See the License for the specific language governing permissions and 72 : limitations under the License. 73 : */