Line data Source code
1 : /* File: data_search_result.inl; Copyright and License: see below */
2 :
3 : #include <assert.h>
4 : #include "u8/u8_log.h"
5 :
6 10 : static inline void data_search_result_init_void ( data_search_result_t *this_ )
7 : {
8 10 : data_id_init_void( &((*this_).match_object_id) );
9 10 : data_type_init_void( &((*this_).match_object_type) );
10 10 : (*this_).match_object_name = utf8stringbuf_new( (*this_).private_match_name_buffer, sizeof((*this_).private_match_name_buffer) );
11 10 : utf8stringbuf_clear( &((*this_).match_object_name) );
12 :
13 10 : data_id_init_void( &((*this_).src_classifier_id) );
14 10 : data_id_init_void( &((*this_).dst_classifier_id) );
15 10 : data_id_init_void( &((*this_).diagram_id) );
16 10 : }
17 :
18 3 : static inline void data_search_result_init_diagram ( data_search_result_t *this_,
19 : data_row_t match_id,
20 : data_diagram_type_t match_type,
21 : const char* match_name )
22 : {
23 3 : assert( NULL != match_name );
24 : utf8error_t strerr;
25 :
26 3 : data_id_init( &((*this_).match_object_id), DATA_TABLE_DIAGRAM, match_id );
27 3 : data_type_init_diagram( &((*this_).match_object_type), match_type );
28 3 : (*this_).match_object_name = utf8stringbuf_new( (*this_).private_match_name_buffer, sizeof((*this_).private_match_name_buffer) );
29 3 : strerr = utf8stringbuf_copy_str( &((*this_).match_object_name), match_name );
30 3 : if ( strerr != UTF8ERROR_SUCCESS )
31 : {
32 : /* just the read-only name of a search result - truncation should not matter */
33 1 : U8_LOG_ANOMALY_INT( "utf8stringbuf_copy_str() failed:", strerr );
34 : }
35 :
36 3 : data_id_init_void( &((*this_).src_classifier_id) );
37 3 : data_id_init_void( &((*this_).dst_classifier_id) );
38 3 : data_id_init( &((*this_).diagram_id), DATA_TABLE_DIAGRAM, match_id );
39 3 : }
40 :
41 2 : static inline void data_search_result_init_classifier ( data_search_result_t *this_,
42 : data_row_t match_id,
43 : data_classifier_type_t match_type,
44 : const char* match_name,
45 : data_row_t diagram_id )
46 : {
47 2 : assert( NULL != match_name );
48 : utf8error_t strerr;
49 :
50 2 : data_id_init( &((*this_).match_object_id), DATA_TABLE_CLASSIFIER, match_id );
51 2 : data_type_init_classifier( &((*this_).match_object_type), match_type );
52 2 : (*this_).match_object_name = utf8stringbuf_new( (*this_).private_match_name_buffer, sizeof((*this_).private_match_name_buffer) );
53 2 : strerr = utf8stringbuf_copy_str( &((*this_).match_object_name), match_name );
54 2 : if ( strerr != UTF8ERROR_SUCCESS )
55 : {
56 : /* just the read-only name of a search result - truncation should not matter */
57 1 : U8_LOG_ANOMALY_INT( "utf8stringbuf_copy_str() failed:", strerr );
58 : }
59 :
60 2 : data_id_init_void( &((*this_).src_classifier_id) );
61 2 : data_id_init_void( &((*this_).dst_classifier_id) );
62 2 : data_id_init( &((*this_).diagram_id), DATA_TABLE_DIAGRAM, diagram_id );
63 2 : }
64 :
65 2 : static inline void data_search_result_init_feature ( data_search_result_t *this_,
66 : data_row_t match_id,
67 : data_feature_type_t match_type,
68 : const char* match_name,
69 : data_row_t classifier_id,
70 : data_row_t diagram_id )
71 : {
72 2 : assert( NULL != match_name );
73 : utf8error_t strerr;
74 :
75 2 : data_id_init( &((*this_).match_object_id), DATA_TABLE_FEATURE, match_id );
76 2 : data_type_init_feature( &((*this_).match_object_type), match_type );
77 2 : (*this_).match_object_name = utf8stringbuf_new( (*this_).private_match_name_buffer, sizeof((*this_).private_match_name_buffer) );
78 2 : strerr = utf8stringbuf_copy_str( &((*this_).match_object_name), match_name );
79 2 : if ( strerr != UTF8ERROR_SUCCESS )
80 : {
81 : /* just the read-only name of a search result - truncation should not matter */
82 1 : U8_LOG_ANOMALY_INT( "utf8stringbuf_copy_str() failed:", strerr );
83 : }
84 :
85 2 : data_id_init( &((*this_).src_classifier_id), DATA_TABLE_CLASSIFIER, classifier_id );
86 2 : data_id_init_void( &((*this_).dst_classifier_id) );
87 2 : data_id_init( &((*this_).diagram_id), DATA_TABLE_DIAGRAM, diagram_id );
88 2 : }
89 :
90 2 : static inline void data_search_result_init_relationship ( data_search_result_t *this_,
91 : data_row_t match_id,
92 : data_relationship_type_t match_type,
93 : const char* match_name,
94 : data_row_t from_classifier_id,
95 : data_row_t to_classifier_id,
96 : data_row_t diagram_id )
97 : {
98 2 : assert( NULL != match_name );
99 : utf8error_t strerr;
100 :
101 2 : data_id_init( &((*this_).match_object_id), DATA_TABLE_RELATIONSHIP, match_id );
102 2 : data_type_init_relationship( &((*this_).match_object_type), match_type );
103 2 : (*this_).match_object_name = utf8stringbuf_new( (*this_).private_match_name_buffer, sizeof((*this_).private_match_name_buffer) );
104 2 : strerr = utf8stringbuf_copy_str( &((*this_).match_object_name), match_name );
105 2 : if ( strerr != UTF8ERROR_SUCCESS )
106 : {
107 : /* just the read-only name of a search result - truncation should not matter */
108 1 : U8_LOG_ANOMALY_INT( "utf8stringbuf_copy_str() failed:", strerr );
109 : }
110 :
111 2 : data_id_init( &((*this_).src_classifier_id), DATA_TABLE_CLASSIFIER, from_classifier_id );
112 2 : data_id_init( &((*this_).dst_classifier_id), DATA_TABLE_CLASSIFIER, to_classifier_id );
113 2 : data_id_init( &((*this_).diagram_id), DATA_TABLE_DIAGRAM, diagram_id );
114 2 : }
115 :
116 6 : static inline void data_search_result_copy ( data_search_result_t *this_, const data_search_result_t *original )
117 : {
118 6 : assert( NULL != original );
119 :
120 6 : *this_ = *original;
121 : /* repair the overwritten pointers */
122 6 : (*this_).match_object_name = utf8stringbuf_new( (*this_).private_match_name_buffer, sizeof((*this_).private_match_name_buffer) );
123 6 : }
124 :
125 8 : static inline void data_search_result_destroy ( data_search_result_t *this_ )
126 : {
127 8 : data_id_destroy( &((*this_).match_object_id) );
128 8 : data_id_destroy( &((*this_).src_classifier_id) );
129 8 : data_id_destroy( &((*this_).dst_classifier_id) );
130 8 : data_id_destroy( &((*this_).diagram_id) );
131 8 : }
132 :
133 1 : static inline data_id_t data_search_result_get_match_id ( const data_search_result_t *this_ )
134 : {
135 1 : return (*this_).match_object_id;
136 : }
137 :
138 1 : static inline data_id_t *data_search_result_get_match_id_ptr ( data_search_result_t *this_ )
139 : {
140 1 : return &((*this_).match_object_id);
141 : }
142 :
143 3 : static inline const data_id_t *data_search_result_get_match_id_const ( const data_search_result_t *this_ )
144 : {
145 3 : return &((*this_).match_object_id);
146 : }
147 :
148 5 : static inline data_type_t data_search_result_get_match_type ( const data_search_result_t *this_ )
149 : {
150 5 : return (*this_).match_object_type;
151 : }
152 :
153 8 : static inline const char* data_search_result_get_match_name_const ( const data_search_result_t *this_ )
154 : {
155 8 : return utf8stringbuf_get_string( &((*this_).match_object_name) );
156 : }
157 :
158 1 : static inline data_id_t data_search_result_get_src_classifier_id ( const data_search_result_t *this_ )
159 : {
160 1 : return (*this_).src_classifier_id;
161 : }
162 :
163 1 : static inline data_id_t *data_search_result_get_src_classifier_id_ptr ( data_search_result_t *this_ )
164 : {
165 1 : return &((*this_).src_classifier_id);
166 : }
167 :
168 2 : static inline const data_id_t *data_search_result_get_src_classifier_id_const ( const data_search_result_t *this_ )
169 : {
170 2 : return &((*this_).src_classifier_id);
171 : }
172 :
173 1 : static inline data_id_t data_search_result_get_dst_classifier_id ( const data_search_result_t *this_ )
174 : {
175 1 : return (*this_).dst_classifier_id;
176 : }
177 :
178 1 : static inline data_id_t *data_search_result_get_dst_classifier_id_ptr ( data_search_result_t *this_ )
179 : {
180 1 : return &((*this_).dst_classifier_id);
181 : }
182 :
183 2 : static inline const data_id_t *data_search_result_get_dst_classifier_id_const ( const data_search_result_t *this_ )
184 : {
185 2 : return &((*this_).dst_classifier_id);
186 : }
187 :
188 1 : static inline data_id_t data_search_result_get_diagram_id ( const data_search_result_t *this_ )
189 : {
190 1 : return (*this_).diagram_id;
191 : }
192 :
193 1 : static inline data_id_t *data_search_result_get_diagram_id_ptr ( data_search_result_t *this_ )
194 : {
195 1 : return &((*this_).diagram_id);
196 : }
197 :
198 2 : static inline const data_id_t *data_search_result_get_diagram_id_const ( const data_search_result_t *this_ )
199 : {
200 2 : return &((*this_).diagram_id);
201 : }
202 :
203 6 : static inline void data_search_result_trace ( const data_search_result_t *this_ )
204 : {
205 6 : U8_TRACE_INFO_STR( "- name:", utf8stringbuf_get_string( &((*this_).match_object_name) ) );
206 6 : U8_TRACE_INFO_INT( "- type:", data_type_get_type_as_int( &((*this_).match_object_type) ) );
207 6 : data_id_trace( &((*this_).match_object_id) );
208 6 : data_id_trace( &((*this_).src_classifier_id) );
209 6 : data_id_trace( &((*this_).dst_classifier_id) );
210 6 : data_id_trace( &((*this_).diagram_id) );
211 6 : }
212 :
213 14 : static inline bool data_search_result_is_valid ( const data_search_result_t *this_ )
214 : {
215 14 : return data_id_is_valid( &((*this_).match_object_id) );
216 : }
217 :
218 :
219 : /*
220 : Copyright 2020-2025 Andreas Warnke
221 :
222 : Licensed under the Apache License, Version 2.0 (the "License");
223 : you may not use this file except in compliance with the License.
224 : You may obtain a copy of the License at
225 :
226 : http://www.apache.org/licenses/LICENSE-2.0
227 :
228 : Unless required by applicable law or agreed to in writing, software
229 : distributed under the License is distributed on an "AS IS" BASIS,
230 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
231 : See the License for the specific language governing permissions and
232 : limitations under the License.
233 : */
|