Line data Source code
1 : /* File: pos_search_result_page.inl; Copyright and License: see below */
2 :
3 : #include <assert.h>
4 :
5 0 : static inline void pos_search_result_page_init ( pos_search_result_page_t *this_, uint32_t buffer_start )
6 : {
7 0 : (*this_).buffer_start = buffer_start;
8 0 : (*this_).buffer_length = 0;
9 0 : (*this_).buffer_more_after = false;
10 0 : (*this_).page_start = buffer_start;
11 0 : (*this_).page_length = 0;
12 0 : (*this_).has_prev_page = false;
13 0 : shape_int_rectangle_init_empty( &((*this_).button_prev_box) );
14 0 : (*this_).has_next_page = false;
15 0 : shape_int_rectangle_init_empty( &((*this_).button_next_box) );
16 0 : }
17 :
18 0 : static inline void pos_search_result_page_reinit ( pos_search_result_page_t *this_, uint32_t buffer_start )
19 : {
20 0 : pos_search_result_page_destroy( this_ );
21 0 : pos_search_result_page_init( this_, buffer_start );
22 0 : }
23 :
24 0 : static inline void pos_search_result_page_destroy ( pos_search_result_page_t *this_ )
25 : {
26 0 : (*this_).buffer_length = 0;
27 0 : shape_int_rectangle_destroy( &((*this_).button_prev_box) );
28 0 : shape_int_rectangle_destroy( &((*this_).button_next_box) );
29 0 : }
30 :
31 0 : static inline const pos_search_result_t *pos_search_result_page_get_search_result_layout_const ( const pos_search_result_page_t *this_, uint32_t index )
32 : {
33 0 : assert( index >= (*this_).buffer_start );
34 0 : assert( index < (*this_).buffer_start + (*this_).buffer_length );
35 0 : return &((*this_).element_pos[ index - (*this_).buffer_start ]);
36 : }
37 :
38 0 : static inline pos_search_result_t *pos_search_result_page_get_search_result_layout_ptr ( pos_search_result_page_t *this_, uint32_t index )
39 : {
40 0 : assert( index >= (*this_).buffer_start );
41 0 : assert( index < (*this_).buffer_start + (*this_).buffer_length );
42 0 : return &((*this_).element_pos[ index - (*this_).buffer_start ]);
43 : }
44 :
45 0 : static inline u8_error_t pos_search_result_page_add_search_result ( pos_search_result_page_t *this_, const data_search_result_t *search_result )
46 : {
47 0 : u8_error_t result = U8_ERROR_NONE;
48 0 : if ( (*this_).buffer_length < POS_SEARCH_RESULT_PAGE_MAX_PAGE_SIZE )
49 : {
50 0 : data_search_result_copy( &((*this_).result_list_buf[(*this_).buffer_length]), search_result );
51 0 : pos_search_result_init( &((*this_).element_pos[(*this_).buffer_length]),
52 0 : &((*this_).result_list_buf[(*this_).buffer_length])
53 : );
54 0 : (*this_).buffer_length ++;
55 : }
56 : else
57 : {
58 0 : result = U8_ERROR_ARRAY_BUFFER_EXCEEDED;
59 : }
60 0 : return result;
61 : }
62 :
63 0 : static inline uint32_t pos_search_result_page_get_buffer_start ( const pos_search_result_page_t *this_ )
64 : {
65 0 : return (*this_).buffer_start;
66 : }
67 :
68 0 : static inline uint32_t pos_search_result_page_get_buffer_length ( const pos_search_result_page_t *this_ )
69 : {
70 0 : return (*this_).buffer_length;
71 : }
72 :
73 0 : static inline bool pos_search_result_page_get_buffer_more_after ( const pos_search_result_page_t *this_ )
74 : {
75 0 : return (*this_).buffer_more_after;
76 : }
77 :
78 0 : static inline void pos_search_result_page_set_buffer_more_after ( pos_search_result_page_t *this_, bool buffer_more_after )
79 : {
80 0 : (*this_).buffer_more_after = buffer_more_after;
81 0 : }
82 :
83 0 : static inline uint32_t pos_search_result_page_get_page_start ( const pos_search_result_page_t *this_ )
84 : {
85 0 : return (*this_).page_start;
86 : }
87 :
88 0 : static inline void pos_search_result_page_set_page_start ( pos_search_result_page_t *this_, uint32_t page_start )
89 : {
90 0 : (*this_).page_start = page_start;
91 0 : }
92 :
93 0 : static inline uint32_t pos_search_result_page_get_page_length ( const pos_search_result_page_t *this_ )
94 : {
95 0 : return (*this_).page_length;
96 : }
97 :
98 0 : static inline void pos_search_result_page_set_page_length ( pos_search_result_page_t *this_, uint32_t page_length )
99 : {
100 0 : (*this_).page_length = page_length;
101 0 : }
102 :
103 0 : static inline bool pos_search_result_page_has_prev_page ( const pos_search_result_page_t *this_ )
104 : {
105 0 : return (*this_).has_prev_page;
106 : }
107 :
108 0 : static inline void pos_search_result_page_set_has_prev_page ( pos_search_result_page_t *this_, bool has_prev_page )
109 : {
110 0 : (*this_).has_prev_page = has_prev_page;
111 0 : }
112 :
113 0 : static inline const shape_int_rectangle_t *pos_search_result_page_get_button_prev_box_const ( const pos_search_result_page_t *this_ )
114 : {
115 0 : return &((*this_).button_prev_box);
116 : }
117 :
118 0 : static inline void pos_search_result_page_set_button_prev_box ( pos_search_result_page_t *this_, const shape_int_rectangle_t *button_prev_box )
119 : {
120 0 : shape_int_rectangle_replace( &((*this_).button_prev_box), button_prev_box );
121 0 : }
122 :
123 0 : static inline bool pos_search_result_page_has_next_page ( const pos_search_result_page_t *this_ )
124 : {
125 0 : return (*this_).has_next_page;
126 : }
127 :
128 0 : static inline void pos_search_result_page_set_has_next_page ( pos_search_result_page_t *this_, bool has_next_page )
129 : {
130 0 : (*this_).has_next_page = has_next_page;
131 0 : }
132 :
133 0 : static inline const shape_int_rectangle_t *pos_search_result_page_get_button_next_box_const ( const pos_search_result_page_t *this_ )
134 : {
135 0 : return &((*this_).button_next_box);
136 : }
137 :
138 0 : static inline void pos_search_result_page_set_button_next_box ( pos_search_result_page_t *this_, const shape_int_rectangle_t *button_next_box )
139 : {
140 0 : shape_int_rectangle_replace( &((*this_).button_next_box), button_next_box );
141 0 : }
142 :
143 :
144 : /*
145 : Copyright 2025-2025 Andreas Warnke
146 :
147 : Licensed under the Apache License, Version 2.0 (the "License");
148 : you may not use this file except in compliance with the License.
149 : You may obtain a copy of the License at
150 :
151 : http://www.apache.org/licenses/LICENSE-2.0
152 :
153 : Unless required by applicable law or agreed to in writing, software
154 : distributed under the License is distributed on an "AS IS" BASIS,
155 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
156 : See the License for the specific language governing permissions and
157 : limitations under the License.
158 : */
|