Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/tesseract/src/ccutil/list.h @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 /********************************************************************** | |
| 2 ** Licensed under the Apache License, Version 2.0 (the "License"); | |
| 3 ** you may not use this file except in compliance with the License. | |
| 4 ** You may obtain a copy of the License at | |
| 5 ** http://www.apache.org/licenses/LICENSE-2.0 | |
| 6 ** Unless required by applicable law or agreed to in writing, software | |
| 7 ** distributed under the License is distributed on an "AS IS" BASIS, | |
| 8 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 9 ** See the License for the specific language governing permissions and | |
| 10 ** limitations under the License. | |
| 11 * | |
| 12 **********************************************************************/ | |
| 13 | |
| 14 #ifndef LIST_ITERATOR_H | |
| 15 #define LIST_ITERATOR_H | |
| 16 | |
| 17 #include <stdint.h> | |
| 18 | |
| 19 namespace tesseract { | |
| 20 | |
| 21 template <typename ITERATOR, typename CLASSNAME> | |
| 22 class X_ITER : public ITERATOR { | |
| 23 public: | |
| 24 X_ITER() = default; | |
| 25 template <typename U> | |
| 26 X_ITER(U *list) : ITERATOR(list) {} | |
| 27 | |
| 28 CLASSNAME *data() { | |
| 29 return static_cast<CLASSNAME *>(ITERATOR::data()); | |
| 30 } | |
| 31 CLASSNAME *data_relative(int8_t offset) { | |
| 32 return static_cast<CLASSNAME *>(ITERATOR::data_relative(offset)); | |
| 33 } | |
| 34 CLASSNAME *forward() { | |
| 35 return static_cast<CLASSNAME *>(ITERATOR::forward()); | |
| 36 } | |
| 37 CLASSNAME *extract() { | |
| 38 return static_cast<CLASSNAME *>(ITERATOR::extract()); | |
| 39 } | |
| 40 }; | |
| 41 | |
| 42 template <typename CONTAINER, typename ITERATOR, typename CLASSNAME> | |
| 43 class X_LIST : public CONTAINER { | |
| 44 public: | |
| 45 X_LIST() = default; | |
| 46 X_LIST(const X_LIST &) = delete; | |
| 47 X_LIST &operator=(const X_LIST &) = delete; | |
| 48 ~X_LIST() { | |
| 49 clear(); | |
| 50 } | |
| 51 | |
| 52 /* delete elements */ | |
| 53 void clear() { | |
| 54 CONTAINER::internal_clear([](void *link) {delete reinterpret_cast<CLASSNAME *>(link);}); | |
| 55 } | |
| 56 | |
| 57 /* Become a deep copy of src_list */ | |
| 58 template <typename U> | |
| 59 void deep_copy(const U *src_list, CLASSNAME *(*copier)(const CLASSNAME *)) { | |
| 60 X_ITER<ITERATOR, CLASSNAME> from_it(const_cast<U *>(src_list)); | |
| 61 X_ITER<ITERATOR, CLASSNAME> to_it(this); | |
| 62 | |
| 63 for (from_it.mark_cycle_pt(); !from_it.cycled_list(); from_it.forward()) | |
| 64 to_it.add_after_then_move((*copier)(from_it.data())); | |
| 65 } | |
| 66 }; | |
| 67 | |
| 68 } // namespace tesseract | |
| 69 | |
| 70 #endif |
