├── tests ├── .gitignore ├── CMakeLists.txt ├── assert_algebraic.h └── test.c ├── examples ├── .gitignore ├── CMakeLists.txt └── demo.c ├── scripts ├── docs.sh ├── open-docs.sh ├── test-all.sh ├── test.sh ├── test-examples.sh ├── check-fmt.sh └── fmt.sh ├── .gitmodules ├── .clang-format ├── CMakeLists.txt ├── .gitignore ├── .github └── workflows │ └── c-cpp.yml ├── LICENSE ├── README.md ├── CHANGELOG.md ├── slice99.h └── Doxyfile /tests/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /examples/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /scripts/docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | doxygen 4 | -------------------------------------------------------------------------------- /scripts/open-docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | xdg-open docs/index.html 4 | -------------------------------------------------------------------------------- /scripts/test-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | bash scripts/test.sh 4 | bash scripts/test-examples.sh 5 | -------------------------------------------------------------------------------- /scripts/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir -p tests/build 4 | cd tests/build 5 | cmake .. 6 | cmake --build . 7 | ./test 8 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "run-clang-format"] 2 | path = run-clang-format 3 | url = https://github.com/Sarcasm/run-clang-format.git 4 | -------------------------------------------------------------------------------- /scripts/test-examples.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir -p examples/build 4 | cd examples/build 5 | cmake .. 6 | cmake --build . 7 | ./demo 8 | cd ../.. 9 | -------------------------------------------------------------------------------- /scripts/check-fmt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ./run-clang-format/run-clang-format.py \ 4 | --exclude examples/build \ 5 | --exclude tests/build \ 6 | -r slice99.h examples tests 7 | -------------------------------------------------------------------------------- /scripts/fmt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | find tests examples \ 4 | \( -path examples/build -o -path tests/build \) -prune -false -o \ 5 | \( -iname "*.h" \) -or \( -iname "*.c" \) | xargs clang-format -i slice99.h 6 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | Language: Cpp 2 | BasedOnStyle: LLVM 3 | 4 | IndentWidth: 4 5 | ContinuationIndentWidth: 4 6 | ColumnLimit: 100 7 | 8 | AllowShortFunctionsOnASingleLine: Empty 9 | AllowAllArgumentsOnNextLine: true 10 | AllowAllParametersOfDeclarationOnNextLine: true 11 | 12 | AlignConsecutiveMacros: true 13 | AlignAfterOpenBracket: AlwaysBreak 14 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10.0) 2 | project(slice99 LANGUAGES C) 3 | 4 | # Fix the warnings about `DOWNLOAD_EXTRACT_TIMESTAMP` in newer CMake versions. 5 | if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") 6 | cmake_policy(SET CMP0135 NEW) 7 | endif() 8 | 9 | add_library(${PROJECT_NAME} INTERFACE) 10 | target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | 54 | # Doxygen 55 | docs/ 56 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | project(examples LANGUAGES C) 3 | 4 | add_subdirectory(.. build) 5 | 6 | if(CMAKE_C_COMPILER_ID STREQUAL "Clang") 7 | add_compile_options(-Weverything -fsanitize=address) 8 | add_link_options(-fsanitize=address) 9 | elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU") 10 | add_compile_options(-Wall -Wextra -pedantic -fsanitize=address) 11 | add_link_options(-fsanitize=address) 12 | endif() 13 | 14 | add_executable(demo demo.c) 15 | 16 | get_property( 17 | EXAMPLES 18 | DIRECTORY . 19 | PROPERTY BUILDSYSTEM_TARGETS) 20 | 21 | foreach(TARGET ${EXAMPLES}) 22 | target_link_libraries(${TARGET} slice99) 23 | set_target_properties(${TARGET} PROPERTIES C_STANDARD 99 C_STANDARD_REQUIRED 24 | ON) 25 | endforeach() 26 | -------------------------------------------------------------------------------- /.github/workflows/c-cpp.yml: -------------------------------------------------------------------------------- 1 | name: C/C++ CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | 17 | - name: Download run-clang-format 18 | run: git submodule update --init run-clang-format 19 | 20 | - name: Test 21 | run: ./scripts/test-all.sh 22 | 23 | - name: Check code formatting 24 | run: ./scripts/check-fmt.sh 25 | 26 | deploy-docs: 27 | runs-on: ubuntu-latest 28 | 29 | steps: 30 | - uses: actions/checkout@v2 31 | 32 | - name: Install Doxygen 33 | run: sudo apt install doxygen graphviz 34 | 35 | - name: Build the docs 36 | run: ./scripts/docs.sh 37 | 38 | - name: Deploy the docs 39 | uses: peaceiris/actions-gh-pages@v3 40 | with: 41 | github_token: ${{ secrets.GITHUB_TOKEN }} 42 | publish_dir: ./docs/ 43 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | project(examples LANGUAGES C) 3 | 4 | # Fix the warnings about `DOWNLOAD_EXTRACT_TIMESTAMP` in newer CMake versions. 5 | if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") 6 | cmake_policy(SET CMP0135 NEW) 7 | endif() 8 | 9 | add_subdirectory(.. build) 10 | 11 | if(CMAKE_C_COMPILER_ID STREQUAL "Clang") 12 | add_compile_options(-Weverything -fsanitize=address) 13 | add_link_options(-fsanitize=address) 14 | elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU") 15 | add_compile_options(-Wall -Wextra -pedantic -fsanitize=address) 16 | add_link_options(-fsanitize=address) 17 | endif() 18 | 19 | add_executable(test test.c) 20 | 21 | get_property( 22 | TESTS 23 | DIRECTORY . 24 | PROPERTY BUILDSYSTEM_TARGETS) 25 | 26 | foreach(TARGET ${TESTS}) 27 | target_link_libraries(${TARGET} slice99) 28 | set_target_properties(${TARGET} PROPERTIES C_STANDARD 99 C_STANDARD_REQUIRED 29 | ON) 30 | endforeach() 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020-2025 hirrolot 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/demo.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | int main(void) { 6 | Slice99 str = Slice99_from_str("hello world"); 7 | 8 | // Accessors { 9 | assert(*(char *)Slice99_first(str) == 'h'); 10 | assert(*(char *)Slice99_last(str) == 'd'); 11 | assert(*(char *)Slice99_get(str, 4) == 'o'); 12 | // } 13 | 14 | // Subslicing { 15 | assert(Slice99_primitive_eq(Slice99_sub(str, 3, 9), Slice99_from_str("lo wor"))); 16 | // } 17 | 18 | // Predicates { 19 | assert(!Slice99_is_empty(str)); 20 | assert(Slice99_primitive_starts_with(str, Slice99_from_str("hello"))); 21 | assert(Slice99_primitive_ends_with(str, Slice99_from_str("world"))); 22 | // } 23 | 24 | // Mutators { 25 | Slice99 data = Slice99_from_array((int[]){5, 8, 1, 9}); 26 | int backup; 27 | 28 | Slice99_swap(data, 1, 3, &backup); 29 | assert(*(int *)Slice99_get(data, 1) == 9); 30 | assert(*(int *)Slice99_get(data, 3) == 8); 31 | 32 | data = Slice99_from_array((int[]){1, 2, 3}); 33 | Slice99_reverse(data, &backup); 34 | assert(Slice99_primitive_eq(data, Slice99_from_array((int[]){3, 2, 1}))); 35 | // } 36 | 37 | // ... and more! 38 | } 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Slice99 2 | [![CI](https://github.com/hirrolot/slice99/workflows/C/C++%20CI/badge.svg)](https://github.com/hirrolot/slice99/actions) 3 | [![docs](https://img.shields.io/badge/docs-github.io-blue)](https://hirrolot.github.io/slice99/slice99_8h.html) 4 | 5 | This library provides [array slicing] facilities for pure C99. 6 | 7 | [array slicing]: https://en.wikipedia.org/wiki/Array_slicing 8 | 9 | [[`examples/demo.c`](examples/demo.c)] [ [Playground >>](https://godbolt.org/z/cz5z1Mz4o) ] 10 | ```c 11 | #include 12 | 13 | #include 14 | 15 | int main(void) { 16 | Slice99 str = Slice99_from_str("hello world"); 17 | 18 | // Accessors { 19 | assert(*(char *)Slice99_first(str) == 'h'); 20 | assert(*(char *)Slice99_last(str) == 'd'); 21 | assert(*(char *)Slice99_get(str, 4) == 'o'); 22 | // } 23 | 24 | // Subslicing { 25 | assert(Slice99_primitive_eq(Slice99_sub(str, 3, 9), Slice99_from_str("lo wor"))); 26 | // } 27 | 28 | // Predicates { 29 | assert(!Slice99_is_empty(str)); 30 | assert(Slice99_primitive_starts_with(str, Slice99_from_str("hello"))); 31 | assert(Slice99_primitive_ends_with(str, Slice99_from_str("world"))); 32 | // } 33 | 34 | // Mutators { 35 | Slice99 data = Slice99_from_array((int[]){5, 8, 1, 9}); 36 | int backup; 37 | 38 | Slice99_swap(data, 1, 3, &backup); 39 | assert(*(int *)Slice99_get(data, 1) == 9); 40 | assert(*(int *)Slice99_get(data, 3) == 8); 41 | 42 | data = Slice99_from_array((int[]){1, 2, 3}); 43 | Slice99_reverse(data, &backup); 44 | assert(Slice99_primitive_eq(data, Slice99_from_array((int[]){3, 2, 1}))); 45 | // } 46 | 47 | // ... and more! 48 | } 49 | ``` 50 | 51 | The main type is [`Slice99`]. It represents a pointer to some array accompanied with an array item size and its length. The utilities `Slice99_*` are used to manipulate this type. 52 | 53 | [`Slice99`]: https://hirrolot.github.io/slice99/structSlice99.html 54 | 55 | ## Motivation 56 | 57 | Normally, we pass a data pointer with its length as separate arguments: 58 | 59 | ```c 60 | void foo(size_t len, uint8_t buffer[static len]) { /* ... */ } 61 | ``` 62 | 63 | However, this interface is notoriously easy to misuse by passing an invalid length or a null pointer for `buffer`. Moreover, programmers frequently tend to perform specific operations on `buffer` and `len`, leading to even more bugs and code clutter: 64 | 65 | ```c 66 | // Advance the buffer by HEADER_SIZE. 67 | buffer += HEADER_SIZE; 68 | len -= HEADER_SIZE; 69 | ``` 70 | 71 | Slice99 reifies such patterns into functions (`Slice99_advance` below), thus assisting in code safety and clarity: 72 | 73 | ```c 74 | void foo(Slice99 buffer) { 75 | // ... 76 | buffer = Slice99_advance(buffer, HEADER_SIZE); 77 | // ... 78 | } 79 | ``` 80 | 81 | Another use case of Slice99 is zero-copy parsers: you can return slices from your parser pointing to actual data, without `malloc`ing and `memcpy`ing just to append `'\0'` each time. 82 | 83 | ## Installation 84 | 85 | Slice99 consists of just one header `slice99.h` and nothing else; therefore, the only thing you need to tell your compiler is to add `slice99` to include directories. 86 | 87 | If you use CMake, the recommended way is either [`FetchContent`] or [`add_subdirectory`], e.g.: 88 | 89 | [`FetchContent`]: https://cmake.org/cmake/help/latest/module/FetchContent.html 90 | [`add_subdirectory`]: https://cmake.org/cmake/help/latest/command/add_subdirectory.html 91 | 92 | ```cmake 93 | include(FetchContent) 94 | 95 | FetchContent_Declare( 96 | slice99 97 | URL https://github.com/hirrolot/slice99/archive/refs/tags/vx.y.z.tar.gz # vx.y.z 98 | ) 99 | 100 | FetchContent_MakeAvailable(slice99) 101 | 102 | target_link_libraries(MyProject slice99) 103 | ``` 104 | 105 | Using [`add_subdirectory`]: 106 | 107 | ```cmake 108 | add_subdirectory(slice99) 109 | target_link_libraries(MyProject slice99) 110 | ``` 111 | 112 | In the latter case, I encourage you to download Slice99 as a [Git submodule] to be able to update it with `git submodule update --remote` when necessary. 113 | 114 | [Git submodule]: https://git-scm.com/book/en/v2/Git-Tools-Submodules 115 | 116 | Happy hacking! 117 | 118 | ## Typed slices 119 | 120 | You can define a strongly typed slice with `SLICE99_DEF_TYPED`: 121 | 122 | ```c 123 | 124 | #include 125 | 126 | typedef struct { 127 | double x, y; 128 | } Point; 129 | 130 | SLICE99_DEF_TYPED(MyPoints, Point); 131 | 132 | int main(void) { 133 | MyPoints points = (MyPoints)Slice99_typed_from_array( 134 | (Point[]){{1.5, 32.5}, {12.0, 314.01}, {-134.10, -9.3}}); 135 | 136 | MyPoints first_two = MyPoints_sub(points, 0, 2); 137 | Point *first = MyPoints_first(points); 138 | bool is_empty = MyPoints_is_empty(points); 139 | } 140 | ``` 141 | 142 | `SLICE99_DEF_TYPED(MyPoints, Point)` generates a slice named `MyPoints` of the following structure: 143 | 144 | ```c 145 | typedef struct { 146 | Point *ptr; 147 | size_t len; 148 | } MyPoints; 149 | ``` 150 | 151 | It also generates `inline static` functions like `MyPoints_sub` that type-check their arguments. These functions merely desugar to their untyped `Slice99_*` counterparts. 152 | 153 | ### Fundamental types 154 | 155 | This library automatically defines typed slices of several fundamental types. I recommend using them instead of untyped `Slice99`, if possible. For more information, see the docs. 156 | 157 | ## Projects using Slice99 158 | 159 | - [`OpenIPC/smolrtsp`](https://github.com/OpenIPC/smolrtsp) -- A small, portable, extensible RTSP 1.0 implementation in C99. 160 | 161 | ## Release procedure 162 | 163 | 1. Update the `PROJECT_NUMBER` field in `Doxyfile`. 164 | 2. Update `SLICE99_MAJOR`, `SLICE99_MINOR`, and `SLICE99_PATCH` in `slice99.h`. 165 | 3. Update `CHANGELOG.md`. 166 | 4. Release the project in [GitHub Releases]. 167 | 168 | [GitHub Releases]: https://github.com/hirrolot/slice99/releases 169 | 170 | ## FAQ 171 | 172 | ### Q: Can I use this library to develop bare-metal software? 173 | 174 | A: Yes, see the [docs](https://hirrolot.github.io/slice99/slice99_8h.html#details). 175 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 5 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6 | 7 | ## unreleased 8 | 9 | ## 0.7.8 - 2025-03-17 10 | 11 | ### Fixed 12 | 13 | - Update the minimum required CMake version to 3.10.0 due to deprecation (see [metalang99/issues/33](https://github.com/hirrolot/metalang99/issues/33)). 14 | 15 | ## 0.7.7 - 2023-03-11 16 | 17 | ### Fixed 18 | 19 | - Fix the `DOWNLOAD_EXTRACT_TIMESTAMP` CMake warning (see [datatype99/issues/15](https://github.com/hirrolot/datatype99/issues/15)). 20 | 21 | ## 0.7.6 - 2022-03-01 22 | 23 | ### Added 24 | 25 | - String formatting support: 26 | - The `CharSlice99_(v)(n)fmt` functions that make `CharSlice99` out of a formatted string. 27 | - The `CharSlice99_alloca_fmt` convenience macro. 28 | - The `SLICE99_DISABLE_STDIO` macro setting. 29 | - The `SLICE99_VSPRINTF`, `SLICE99_VSNPRINTF`, and `SLICE99_SNPRINTF` macros. 30 | 31 | ## 0.7.5 - 2022-02-26 32 | 33 | ### Fixed 34 | 35 | - Segfault: allocate space for a null terminator in `CharSlice99_alloca_c_str`. 36 | 37 | ## 0.7.4 - 2022-02-26 38 | 39 | ### Added 40 | 41 | - `CharSlice99_alloca_c_str`, which allocates a C-string using `alloca`. 42 | 43 | ### Fixed 44 | 45 | - Surround the `ptr` parameter of `Slice99_from_typed_ptr` with parentheses to avoid macro expansion issues. 46 | 47 | ## 0.7.3 - 2022-02-25 48 | 49 | ### Fixed 50 | 51 | - Return a `void *` pointer from `SLICE99_APPEND(_ARRAY)`. 52 | 53 | ## 0.7.2 - 2021-12-09 54 | 55 | ### Fixed 56 | 57 | - Specify `C` as the project language in `CMakeLists.txt`. Previously, CMake detected C++ and required a C++ compiler in order to compile the project. 58 | 59 | ## 0.7.1 - 2021-12-01 60 | 61 | ### Added 62 | 63 | - Add the root `CMakeLists.txt` to be able to use CMake with [`FetchContent`] or [`add_subdirectory`]. 64 | 65 | [`FetchContent`]: https://cmake.org/cmake/help/latest/module/FetchContent.html 66 | [`add_subdirectory`]: https://cmake.org/cmake/help/latest/command/add_subdirectory.html 67 | 68 | ## 0.7.0 - 2021-09-07 69 | 70 | ### Added 71 | 72 | - `SLICE99_APPEND(_ARRAY)` to write an object/array to a memory buffer. 73 | - `SLICE99_TO_OCTETS` to convert an object to `U8Slice99`. 74 | 75 | ### Changed 76 | 77 | - `Slice99_typed_from_array(T, x)` => `(T)Slice99_typed_from_array(x)` [**BC**]. 78 | 79 | ### Fixed 80 | 81 | - Show `(I8|I16|I32|I64)Slice99` type definitions in the docs. 82 | 83 | ## 0.6.0 - 2021-08-21 84 | 85 | ### Changed 86 | 87 | - `SLICE99_TO_TYPED(x, T)` => `(T)SLICE99_TO_TYPED(x)` [**BC**]. 88 | 89 | ## 0.5.1 - 2021-08-20 90 | 91 | ### Added 92 | 93 | - `CharSlice99_from_str` & `CharSlice99_c_str` as equivalents of the corresponding `Slice99` functions. 94 | 95 | ## 0.5.0 - 2021-06-24 96 | 97 | ### Removed 98 | 99 | - `Slice99_pack_to_(u8|u16|u32|u64)` and `Slice99_pack_to_(u8|u16|u32|u64)_beginning` due to too specific domain. 100 | 101 | ## 0.4.1 - 2021-06-20 102 | 103 | ### Added 104 | 105 | - The `Slice99_pack_to_(u8|u16|u32|u64)_beginning` functions. They are like `Slice99_pack_to_(u8|u16|u32|u64)` but only take the beginning of a slice. 106 | - Specify `__attribute__((always_inline))` on `SLICE99_DEF_TYPED`-generated functions if compiling on GCC. 107 | - Typed slices of fundamental types (unconditionally defined): 108 | - `CharSlice99` of `char`. 109 | - `SCharSlice99` of `signed char`. 110 | - `UCharSlice99` of `unsigned char`. 111 | - `ShortSlice99` of `short`. 112 | - `UShortSlice99` of `unsigned short`. 113 | - `IntSlice99` of `int`. 114 | - `UIntSlice99` of `unsigned int`. 115 | - `LongSlice99` of `long`. 116 | - `ULongSlice99` of `unsigned long`. 117 | - `LongLongSlice99` of `long long`. 118 | - `ULongLongSlice99` of `unsigned long long`. 119 | - `FloatSlice99` of `float`. 120 | - `DoubleSlice99` of `double`. 121 | - `LongDoubleSlice99` of `long double`. 122 | - `BoolSlice99` of `_Bool`. 123 | - Typed slices of fixed-width integer types (each if supported by the platform): 124 | - `U8Slice99` of `uint8_t`. 125 | - `U16Slice99` of `uint16_t`. 126 | - `U32Slice99` of `uint32_t`. 127 | - `U64Slice99` of `uint64_t`. 128 | - `I8Slice99` of `int8_t`. 129 | - `I16Slice99` of `int16_t`. 130 | - `I32Slice99` of `int32_t`. 131 | - `I64Slice99` of `int64_t`. 132 | 133 | ### Fixed 134 | 135 | - Do not specify `SLICE99_PURE` for `Slice99_pack_to_(u8|u16|u32|u64)` as they use `SLICE99_ASSERT`. 136 | 137 | ## 0.4.0 - 2021-05-30 138 | 139 | ### Added 140 | 141 | - Static typing for slices (all macros): 142 | - `SLICE99_DEF_TYPED` to generate a typed slice definition. 143 | - `SLICE99_TO_(UN)TYPED` to convert between typed and untyped slices. 144 | - `Slice99_typed_from_array` to obtain a typed slice. 145 | 146 | ### Removed 147 | 148 | - Useless higher-order functions: `Slice99_for_each`, `Slice99_find`. 149 | - I/O functions: `Slice99_fwrite(_ln)`, `Slice99_write(_ln)`. 150 | - Field updating functions: `Slice99_update_(ptr|item_size)`. 151 | - `Slice99Maybe` facilities: 152 | - The `Slice99Maybe` type. 153 | - The `Slice99Maybe_(just|nothing)` functions. 154 | 155 | ## 0.3.0 - 2021-03-27 156 | 157 | ### Added 158 | 159 | - `SLICE99_(MAJOR|MINOR|PATCH)` representing the corresponding components of a library version. 160 | 161 | ### Removed 162 | 163 | - Sorting facilities: `Slice99_sort`, `SLICE99_INCLUDE_SORT`, `SLICE99_QSORT`. 164 | - Binary search facilities: `Slice99_bsearch`, `SLICE99_INCLUDE_BSEARCH`, `SLICE99_BSEARCH`. 165 | 166 | ### Changed 167 | 168 | - `Slice99_array_len` -> `SLICE99_ARRAY_LEN`. 169 | 170 | ## 0.2.1 - 2021-02-21 171 | 172 | ### Added 173 | 174 | - `Slice99_pack_to_(u8|u16|u32|u64)` to pack a slice into an integer. 175 | 176 | ## 0.2.0 - 2021-02-11 177 | 178 | ### Added 179 | 180 | - `Slice99_copy` to copy one slice to the beginning of another one. 181 | - `Slice99_c_str` to construct a null-terminated C string. 182 | - `Slice99_find` to find an element in a slice. 183 | - `Slice99_for_each` to walk through all elements in a slice. 184 | - `Slice99_from_typed_ptr` to obtain a slice from a properly typed pointer. 185 | - `Slice99_advance` to advance a slice by N bytes. 186 | - `Slice99_update_(ptr|item_size|len)` to update a specific field. 187 | - An optional slice `Slice99Maybe` with value constructors `Slice99Maybe_just`, `Slice99Maybe_nothing`. 188 | - Tell a compiler to warn about an unused result of certain functions. 189 | - Tell a compiler that certain functions are constant. 190 | 191 | ### Changed 192 | 193 | - `Slice99_copy` -> `Slice99_copy_non_overlapping`. 194 | - Use `ptrdiff_t` as an index. Reify these macros into the corresponding functions: 195 | - `Slice99_get(_cast_type)` -> `Slice99_get`. 196 | - `Slice99_sub(_cast_type)` -> `Slice99_sub`. 197 | - `Slice99_swap` -> `Slice99_swap`. 198 | 199 | ## 0.1.0 - 2021-01-02 200 | 201 | ### Added 202 | 203 | - This excellent project. 204 | -------------------------------------------------------------------------------- /tests/assert_algebraic.h: -------------------------------------------------------------------------------- 1 | #ifndef ASSERT_ALGEBRAIC_H 2 | #define ASSERT_ALGEBRAIC_H 3 | 4 | #include 5 | 6 | #define ASSERT_IMPLICATION(x, y) \ 7 | do { \ 8 | if (x) { \ 9 | assert(y); \ 10 | } \ 11 | } while (0) 12 | 13 | #define ASSERT_BIDIRECTIONAL_IMPLICATION(x, y) \ 14 | do { \ 15 | ASSERT_IMPLICATION(x, y); \ 16 | ASSERT_IMPLICATION(y, x); \ 17 | } while (0) 18 | 19 | #define ASSERT_REFLEXIVE(f, x) assert(f(x, x)) 20 | 21 | #define ASSERT_IRREFLEXIVE(f, x) assert(!f(x, x)) 22 | 23 | #define ASSERT_SYMMETRIC(f, x, y) ASSERT_BIDIRECTIONAL_IMPLICATION(f(x, y), f(y, x)) 24 | 25 | #define ASSERT_ANTISYMMETRIC(f, eq, x, y) ASSERT_IMPLICATION(f(x, y) && f(y, x), eq(x, y)) 26 | 27 | #define ASSERT_ASYMMETRIC(f, x, y) ASSERT_IMPLICATION(f(x, y), !f(y, x)) 28 | 29 | #define ASSERT_TRANSITIVE(f, x, y, z) ASSERT_IMPLICATION(f(x, y) && f(y, z), f(x, z)) 30 | 31 | #define ASSERT_ANTITRANSITIVE(f, x, y, z) ASSERT_IMPLICATION(f(x, y) && f(y, z), !f(x, z)) 32 | 33 | #define ASSERT_CONNEXIVE(f, x, y) assert(f(x, y) || f(y, x)) 34 | 35 | #define ASSERT_SEMICONNEXIVE(f, eq, x, y) assert(f(x, y) || f(y, x) || eq(x, y)) 36 | 37 | #define ASSERT_BIJECTIVE(f, g, eq, x) assert(eq(g(f(x)), x)) 38 | 39 | #define ASSERT_INVOLUTIVE(f, eq, x) ASSERT_BIJECTIVE(f, f, eq, x) 40 | 41 | #define ASSERT_IDEMPOTENT(f, eq, x) assert(eq(f(x, x), x)) 42 | 43 | #define ASSERT_COMMUTATIVE(f, eq, x, y) assert(eq(f(x, y), f(y, x))) 44 | 45 | #define ASSERT_ASSOCIATIVE(f, eq, x, y, z) assert(eq(f(f(x, y), z), f(x, f(y, z)))) 46 | 47 | #define ASSERT_LEFT_DISTRIBUTIVE(f1, f2, eq, x, y, z) \ 48 | assert(eq(f1(x, f2(y, z)), f2(f1(x, y), f1(x, z)))) 49 | 50 | #define ASSERT_RIGHT_DISTRIBUTIVE(f1, f2, eq, x, y, z) \ 51 | assert(eq(f1(f2(y, z), x), f2(f1(y, x), f1(z, x)))) 52 | 53 | #define ASSERT_DISTRIBUTIVE(f1, f2, eq, x, y, z) \ 54 | do { \ 55 | ASSERT_LEFT_DISTRIBUTIVE(f1, f2, eq, x, y, z); \ 56 | ASSERT_RIGHT_DISTRIBUTIVE(f1, f2, eq, x, y, z); \ 57 | } while (0) 58 | 59 | #define ASSERT_EQUIVALENCE(f, x, y, z) \ 60 | do { \ 61 | ASSERT_REFLEXIVE(f, x); \ 62 | ASSERT_SYMMETRIC(f, x, y); \ 63 | ASSERT_TRANSITIVE(f, x, y, z); \ 64 | } while (0) 65 | 66 | #define ASSERT_LEFT_IDENTITY(f, eq, e, x) assert(eq(f(e, x), x)) 67 | 68 | #define ASSERT_RIGHT_IDENTITY(f, eq, e, x) assert(eq(f(x, e), x)) 69 | 70 | #define ASSERT_IDENTITY(f, eq, e, x) \ 71 | do { \ 72 | ASSERT_LEFT_IDENTITY(f, eq, e, x); \ 73 | ASSERT_RIGHT_IDENTITY(f, eq, e, x); \ 74 | } while (0) 75 | 76 | #define ASSERT_LEFT_ZERO(f, eq, z, x) assert(eq(f(z, x), z)) 77 | 78 | #define ASSERT_RIGHT_ZERO(f, eq, z, x) assert(eq(f(x, z), z)) 79 | 80 | #define ASSERT_ZERO(f, eq, z, x) \ 81 | do { \ 82 | ASSERT_LEFT_ZERO(f, eq, z, x); \ 83 | ASSERT_RIGHT_ZERO(f, eq, z, x); \ 84 | } while (0) 85 | 86 | #define ASSERT_PREORDER(f, x, y, z) \ 87 | do { \ 88 | ASSERT_REFLEXIVE(f, x); \ 89 | ASSERT_TRANSITIVE(f, x, y, z); \ 90 | } while (0) 91 | 92 | #define ASSERT_PARTIAL_ORDER(f, eq, x, y, z) \ 93 | do { \ 94 | ASSERT_PREORDER(f, x, y, z); \ 95 | ASSERT_ANTISYMMETRIC(f, eq, x, y); \ 96 | } while (0) 97 | 98 | #define ASSERT_STRICT_PARTIAL_ORDER(f, x, y, z) \ 99 | do { \ 100 | ASSERT_TRANSITIVE(f, x, y, z); \ 101 | ASSERT_ASYMMETRIC(f, x, y); \ 102 | } while (0) 103 | 104 | #define ASSERT_TOTAL_ORDER(f, eq, x, y, z) \ 105 | do { \ 106 | ASSERT_ANTISYMMETRIC(f, eq, x, y); \ 107 | ASSERT_TRANSITIVE(f, x, y, z); \ 108 | ASSERT_CONNEXIVE(f, x, y); \ 109 | } while (0) 110 | 111 | #define ASSERT_STRICT_TOTAL_ORDER(f, eq, x, y, z) \ 112 | do { \ 113 | ASSERT_ASYMMETRIC(f, x, y); \ 114 | ASSERT_TRANSITIVE(f, x, y, z); \ 115 | ASSERT_SEMICONNEXIVE(f, eq, x, y); \ 116 | } while (0) 117 | 118 | #endif // ASSERT_ALGEBRAIC_H 119 | -------------------------------------------------------------------------------- /tests/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #include "assert_algebraic.h" 14 | 15 | // Auxiliary stuff { 16 | 17 | #define TEST(name) static void test_##name(void) 18 | 19 | #define ASSERT_SLICE(slice, expected_ptr, expected_item_size, expected_len) \ 20 | do { \ 21 | Slice99 slice_ = (slice); \ 22 | assert(slice_.ptr == (expected_ptr)); \ 23 | assert(slice_.item_size == (expected_item_size)); \ 24 | assert(slice_.len == (expected_len)); \ 25 | \ 26 | } while (0) 27 | 28 | #define PTR 29 | #define ITEM_SIZE 30 | #define LEN 31 | 32 | static int int_cmp(const void *lhs, const void *rhs) { 33 | return *(const int *)lhs - *(const int *)rhs; 34 | } 35 | 36 | static bool int_eq(Slice99 lhs, Slice99 rhs) { 37 | return Slice99_eq(lhs, rhs, int_cmp); 38 | } 39 | 40 | static Slice99 random_int_slice(void) { 41 | const size_t len = rand() % 10; 42 | int *buffer = malloc(len * sizeof buffer[0]); 43 | assert(buffer); 44 | 45 | for (size_t i = 0; i < len; i++) { 46 | buffer[i] = rand() % INT_MAX; 47 | } 48 | 49 | return Slice99_new(buffer, sizeof buffer[0], len); 50 | } 51 | // } (Auxiliary stuff) 52 | 53 | TEST(array_len) { 54 | const char x[10]; 55 | const int y[86]; 56 | const double z[291]; 57 | 58 | assert(SLICE99_ARRAY_LEN(x) == sizeof x / sizeof x[0]); 59 | assert(SLICE99_ARRAY_LEN(y) == sizeof y / sizeof y[0]); 60 | assert(SLICE99_ARRAY_LEN(z) == sizeof z / sizeof z[0]); 61 | } 62 | 63 | TEST(write_to_buffer) { 64 | const int n = 123; 65 | const int array[] = {1, 2, 3}; 66 | const struct { 67 | int x; 68 | long long y; 69 | } foo = {.x = 456, .y = -193993}; 70 | 71 | char buffer[sizeof n + sizeof array + sizeof foo] = {0}; 72 | void *buffer_ptr = buffer; 73 | 74 | #define TEST_WRITE(obj_start, val) \ 75 | do { \ 76 | buffer_ptr = SLICE99_APPEND(buffer_ptr, val); \ 77 | assert(obj_start + sizeof val == buffer_ptr); \ 78 | assert(memcmp(obj_start, &val, sizeof val) == 0); \ 79 | } while (0) 80 | 81 | TEST_WRITE(buffer, n); 82 | TEST_WRITE(buffer + sizeof n, array); 83 | TEST_WRITE(buffer + sizeof n + sizeof array, foo); 84 | 85 | #undef TEST_WRITE 86 | } 87 | 88 | TEST(write_array_to_buffer) { 89 | int data[] = {1, 2, 3, 4, 5}; 90 | int buffer[SLICE99_ARRAY_LEN(data)] = {0}; 91 | 92 | void *buffer_ptr = SLICE99_APPEND_ARRAY(buffer, (int *)data, SLICE99_ARRAY_LEN(data)); 93 | assert(buffer + SLICE99_ARRAY_LEN(data) == buffer_ptr); 94 | assert(memcmp(buffer, data, sizeof data) == 0); 95 | } 96 | 97 | TEST(to_octets) { 98 | const int n = 123; 99 | const int array[] = {1, 2, 3}; 100 | const struct { 101 | int x; 102 | long long y; 103 | } foo = {.x = 456, .y = -193993}; 104 | 105 | #define TEST_TO_OCTETS(obj) \ 106 | do { \ 107 | U8Slice99 result = SLICE99_TO_OCTETS(obj); \ 108 | assert(sizeof obj == result.len); \ 109 | assert(memcmp(&(obj), result.ptr, sizeof obj) == 0); \ 110 | } while (0) 111 | 112 | #ifdef __clang__ 113 | #pragma clang diagnostic push 114 | #pragma clang diagnostic ignored "-Wcast-qual" 115 | #endif 116 | 117 | TEST_TO_OCTETS(n); 118 | TEST_TO_OCTETS(array); 119 | TEST_TO_OCTETS(foo); 120 | 121 | #ifdef __clang__ 122 | #pragma clang diagnostic pop 123 | #endif 124 | 125 | #undef TEST_TO_OCTETS 126 | } 127 | 128 | TEST(from_str) { 129 | // clang-format off 130 | { 131 | char *str = ""; 132 | ASSERT_SLICE( 133 | Slice99_from_str(str), 134 | PTR str, 135 | ITEM_SIZE sizeof str[0], 136 | LEN strlen(str) 137 | ); 138 | 139 | str = "abc"; 140 | ASSERT_SLICE( 141 | Slice99_from_str(str), 142 | PTR str, 143 | ITEM_SIZE sizeof str[0], 144 | LEN strlen(str) 145 | ); 146 | } 147 | 148 | { 149 | char *str = ""; 150 | ASSERT_SLICE( 151 | SLICE99_TO_UNTYPED(CharSlice99_from_str(str)), 152 | PTR str, 153 | ITEM_SIZE sizeof str[0], 154 | LEN strlen(str) 155 | ); 156 | 157 | str = "abc"; 158 | ASSERT_SLICE( 159 | SLICE99_TO_UNTYPED(CharSlice99_from_str(str)), 160 | PTR str, 161 | ITEM_SIZE sizeof str[0], 162 | LEN strlen(str) 163 | ); 164 | } 165 | // clang-format on 166 | } 167 | 168 | TEST(from_ptrdiff) { 169 | int data[] = {1, 2, 3, 4, 5}; 170 | 171 | // clang-format off 172 | ASSERT_SLICE( 173 | Slice99_from_ptrdiff(data, data, sizeof data[0]), 174 | PTR data, 175 | ITEM_SIZE sizeof data[0], 176 | LEN 0 177 | ); 178 | 179 | ASSERT_SLICE( 180 | Slice99_from_ptrdiff(data, data + SLICE99_ARRAY_LEN(data), sizeof data[0]), 181 | PTR data, 182 | ITEM_SIZE sizeof data[0], 183 | LEN SLICE99_ARRAY_LEN(data) 184 | ); 185 | 186 | ASSERT_SLICE( 187 | Slice99_from_ptrdiff(data + 1, data + 4, sizeof data[0]), 188 | PTR data + 1, 189 | ITEM_SIZE sizeof data[0], 190 | LEN 3 191 | ); 192 | // clang-format on 193 | } 194 | 195 | TEST(from_typed_ptr) { 196 | int data[] = {1, 2, 3, 4, 5}; 197 | Slice99 slice = Slice99_from_typed_ptr((int *)data, 5); 198 | 199 | // clang-format off 200 | ASSERT_SLICE( 201 | slice, 202 | PTR data, 203 | ITEM_SIZE sizeof data[0], 204 | LEN 5 205 | ); 206 | // clang-format on 207 | } 208 | 209 | TEST(update_len) { 210 | Slice99 slice = Slice99_from_str("abc"); 211 | const size_t new_len = 1; 212 | 213 | // clang-format off 214 | ASSERT_SLICE( 215 | Slice99_update_len(slice, new_len), 216 | PTR slice.ptr, 217 | ITEM_SIZE slice.item_size, 218 | LEN new_len 219 | ); 220 | // clang-format on 221 | } 222 | 223 | TEST(is_empty) { 224 | assert(!Slice99_is_empty(Slice99_from_array((int[]){1, 2, 3}))); 225 | assert(Slice99_is_empty(Slice99_new("abc", 1, 0))); 226 | } 227 | 228 | TEST(size) { 229 | assert(Slice99_size(Slice99_from_array((int[]){1, 2, 3})) == sizeof(int) * 3); 230 | assert(Slice99_size(Slice99_new("abc", 1, 0)) == 0); 231 | } 232 | 233 | TEST(get) { 234 | int data[] = {1, 2, 3}; 235 | Slice99 slice = Slice99_from_array(data); 236 | 237 | assert(Slice99_get(slice, 0) == &data[0]); 238 | assert(Slice99_get(slice, 1) == &data[1]); 239 | assert(Slice99_get(slice, 2) == &data[2]); 240 | 241 | assert((int *)Slice99_get(slice, 3) - 1 == &data[2]); 242 | assert((int *)Slice99_get(slice, -1) + 1 == &data[0]); 243 | } 244 | 245 | TEST(first) { 246 | int data[] = {1, 2, 3}; 247 | assert(Slice99_first(Slice99_from_array(data)) == &data[0]); 248 | } 249 | 250 | TEST(last) { 251 | int data[] = {1, 2, 3}; 252 | assert(Slice99_last(Slice99_from_array(data)) == &data[2]); 253 | } 254 | 255 | TEST(sub) { 256 | int data[] = {1, 2, 3, 4, 5}; 257 | 258 | // clang-format off 259 | ASSERT_SLICE( 260 | Slice99_sub(Slice99_from_array(data), 0, 0), 261 | PTR data, 262 | ITEM_SIZE sizeof data[0], 263 | LEN 0 264 | ); 265 | 266 | ASSERT_SLICE( 267 | Slice99_sub(Slice99_from_array(data), 0, 3), 268 | PTR data, 269 | ITEM_SIZE sizeof data[0], 270 | LEN 3 271 | ); 272 | 273 | ASSERT_SLICE( 274 | Slice99_sub(Slice99_from_array(data), 2, 4), 275 | PTR data + 2, 276 | ITEM_SIZE sizeof data[0], 277 | LEN 2 278 | ); 279 | 280 | ASSERT_SLICE( 281 | Slice99_sub(Slice99_new(data + 2, sizeof data[0], 3), -2, 1), 282 | PTR data, 283 | ITEM_SIZE sizeof data[0], 284 | LEN 3 285 | ); 286 | 287 | ASSERT_SLICE( 288 | Slice99_sub(Slice99_new(data + 3, sizeof data[0], 2), -2, -1), 289 | PTR data + 1, 290 | ITEM_SIZE sizeof data[0], 291 | LEN 1 292 | ); 293 | // clang-format on 294 | } 295 | 296 | TEST(advance) { 297 | int data[] = {1, 2, 3, 4, 5}; 298 | 299 | // clang-format off 300 | ASSERT_SLICE( 301 | Slice99_advance(Slice99_from_array(data), 0), 302 | PTR data, 303 | ITEM_SIZE sizeof data[0], 304 | LEN 5 305 | ); 306 | 307 | ASSERT_SLICE( 308 | Slice99_advance(Slice99_from_array(data), 1), 309 | PTR data + 1, 310 | ITEM_SIZE sizeof data[0], 311 | LEN 4 312 | ); 313 | 314 | ASSERT_SLICE( 315 | Slice99_advance(Slice99_from_array(data), 5), 316 | PTR data + 5, 317 | ITEM_SIZE sizeof data[0], 318 | LEN 0 319 | ); 320 | 321 | ASSERT_SLICE( 322 | Slice99_advance(Slice99_new(data + 1, sizeof data[0], 4), -1), 323 | PTR data, 324 | ITEM_SIZE sizeof data[0], 325 | LEN 5 326 | ); 327 | // clang-format on 328 | } 329 | 330 | TEST(primitive_eq_basic) { 331 | char str[] = "12345"; 332 | 333 | Slice99 slice_1 = Slice99_from_array((int[]){1, 2, 3, 4, 5}), 334 | slice_2 = Slice99_from_array((int[]){1, 2, 3, 4, 5}), 335 | slice_3 = Slice99_from_array((int[]){6, 7, 8}); 336 | 337 | assert(Slice99_primitive_eq(slice_1, slice_2)); 338 | 339 | assert(!Slice99_primitive_eq(slice_1, slice_3)); 340 | assert(!Slice99_primitive_eq(Slice99_from_str(str), slice_1)); 341 | } 342 | 343 | TEST(primitive_eq_is_equivalence) { 344 | for (size_t i = 0; i < 100; i++) { 345 | Slice99 slices[] = { 346 | random_int_slice(), 347 | random_int_slice(), 348 | random_int_slice(), 349 | }; 350 | 351 | ASSERT_EQUIVALENCE(Slice99_primitive_eq, slices[0], slices[1], slices[2]); 352 | 353 | free(slices[0].ptr); 354 | free(slices[1].ptr); 355 | free(slices[2].ptr); 356 | } 357 | } 358 | 359 | TEST(primitive_eq) { 360 | test_primitive_eq_basic(); 361 | test_primitive_eq_is_equivalence(); 362 | } 363 | 364 | TEST(eq_basic) { 365 | Slice99 slice_1 = Slice99_from_array((int[]){1, 2, 3, 4, 5}), 366 | slice_2 = Slice99_from_array((int[]){1, 2, 3, 4, 5}), 367 | slice_3 = Slice99_from_array((int[]){6, 7, 8}); 368 | 369 | assert(Slice99_primitive_eq(slice_1, slice_2)); 370 | assert(!Slice99_primitive_eq(slice_1, slice_3)); 371 | } 372 | 373 | TEST(eq_is_equivalence) { 374 | for (size_t i = 0; i < 100; i++) { 375 | Slice99 slices[] = { 376 | random_int_slice(), 377 | random_int_slice(), 378 | random_int_slice(), 379 | }; 380 | 381 | ASSERT_EQUIVALENCE(int_eq, slices[0], slices[1], slices[2]); 382 | 383 | free(slices[0].ptr); 384 | free(slices[1].ptr); 385 | free(slices[2].ptr); 386 | } 387 | } 388 | 389 | TEST(eq) { 390 | test_eq_basic(); 391 | test_eq_is_equivalence(); 392 | } 393 | 394 | TEST(primitive_starts_with_basic) { 395 | Slice99 slice = Slice99_from_array((int[]){1, 2, 3, 4, 5}); 396 | 397 | assert(Slice99_primitive_starts_with(slice, Slice99_sub(slice, 0, 0))); 398 | assert(Slice99_primitive_starts_with(slice, Slice99_sub(slice, 0, 3))); 399 | 400 | assert(!Slice99_primitive_starts_with(slice, Slice99_sub(slice, 1, 2))); 401 | assert(!Slice99_primitive_starts_with(slice, Slice99_sub(slice, 3, 5))); 402 | } 403 | 404 | TEST(primitive_starts_with_partial_order) { 405 | for (size_t i = 0; i < 100; i++) { 406 | Slice99 slices[] = { 407 | random_int_slice(), 408 | random_int_slice(), 409 | random_int_slice(), 410 | }; 411 | 412 | ASSERT_PARTIAL_ORDER( 413 | Slice99_primitive_starts_with, Slice99_primitive_eq, slices[0], slices[1], slices[2]); 414 | 415 | free(slices[0].ptr); 416 | free(slices[1].ptr); 417 | free(slices[2].ptr); 418 | } 419 | } 420 | 421 | TEST(primitive_starts_with_empty_slice_is_min) { 422 | for (size_t i = 0; i < 100; i++) { 423 | Slice99 slice = random_int_slice(); 424 | assert(Slice99_primitive_starts_with(slice, Slice99_empty(sizeof(int)))); 425 | free(slice.ptr); 426 | } 427 | } 428 | 429 | TEST(primitive_starts_with) { 430 | test_primitive_starts_with_basic(); 431 | test_primitive_starts_with_partial_order(); 432 | test_primitive_starts_with_empty_slice_is_min(); 433 | } 434 | 435 | #define STARTS_WITH(slice, prefix) Slice99_starts_with(slice, prefix, int_cmp) 436 | 437 | TEST(starts_with_basic) { 438 | Slice99 slice = Slice99_from_array((int[]){1, 2, 3, 4, 5}); 439 | 440 | assert(STARTS_WITH(slice, Slice99_sub(slice, 0, 0))); 441 | assert(STARTS_WITH(slice, Slice99_sub(slice, 0, 3))); 442 | 443 | assert(!STARTS_WITH(slice, Slice99_sub(slice, 1, 2))); 444 | assert(!STARTS_WITH(slice, Slice99_sub(slice, 3, 5))); 445 | } 446 | 447 | TEST(starts_with_partial_order) { 448 | for (size_t i = 0; i < 100; i++) { 449 | Slice99 slices[] = { 450 | random_int_slice(), 451 | random_int_slice(), 452 | random_int_slice(), 453 | }; 454 | 455 | #define EQ(slice, other) Slice99_eq(slice, other, int_cmp) 456 | 457 | ASSERT_PARTIAL_ORDER(STARTS_WITH, EQ, slices[0], slices[1], slices[2]); 458 | 459 | #undef EQ 460 | 461 | free(slices[0].ptr); 462 | free(slices[1].ptr); 463 | free(slices[2].ptr); 464 | } 465 | } 466 | 467 | TEST(starts_with_empty_slice_is_min) { 468 | for (size_t i = 0; i < 100; i++) { 469 | Slice99 slice = random_int_slice(); 470 | assert(STARTS_WITH(slice, Slice99_empty(sizeof(int)))); 471 | free(slice.ptr); 472 | } 473 | } 474 | 475 | TEST(starts_with) { 476 | test_starts_with_basic(); 477 | test_starts_with_partial_order(); 478 | test_starts_with_empty_slice_is_min(); 479 | } 480 | 481 | #undef STARTS_WITH 482 | 483 | TEST(primitive_ends_with_basic) { 484 | Slice99 slice = Slice99_from_array((int[]){1, 2, 3, 4, 5}); 485 | 486 | assert(Slice99_primitive_ends_with(slice, Slice99_sub(slice, 0, 0))); 487 | assert(Slice99_primitive_ends_with(slice, Slice99_sub(slice, 3, (ptrdiff_t)slice.len))); 488 | 489 | assert(!Slice99_primitive_ends_with(slice, Slice99_sub(slice, 1, 4))); 490 | assert(!Slice99_primitive_ends_with(slice, Slice99_sub(slice, 0, 3))); 491 | } 492 | 493 | TEST(primitive_ends_with_partial_order) { 494 | for (size_t i = 0; i < 100; i++) { 495 | Slice99 slices[] = { 496 | random_int_slice(), 497 | random_int_slice(), 498 | random_int_slice(), 499 | }; 500 | 501 | ASSERT_PARTIAL_ORDER( 502 | Slice99_primitive_ends_with, Slice99_primitive_eq, slices[0], slices[1], slices[2]); 503 | 504 | free(slices[0].ptr); 505 | free(slices[1].ptr); 506 | free(slices[2].ptr); 507 | } 508 | } 509 | 510 | TEST(primitive_ends_with_empty_slice_is_max) { 511 | for (size_t i = 0; i < 100; i++) { 512 | Slice99 slice = random_int_slice(); 513 | assert(Slice99_primitive_ends_with(slice, Slice99_empty(sizeof(int)))); 514 | free(slice.ptr); 515 | } 516 | } 517 | 518 | TEST(primitive_ends_with) { 519 | test_primitive_ends_with_basic(); 520 | test_primitive_ends_with_partial_order(); 521 | test_primitive_ends_with_empty_slice_is_max(); 522 | } 523 | 524 | #define ENDS_WITH(slice, postfix) Slice99_ends_with(slice, postfix, int_cmp) 525 | 526 | TEST(ends_with_basic) { 527 | Slice99 slice = Slice99_from_array((int[]){1, 2, 3, 4, 5}); 528 | 529 | assert(ENDS_WITH(slice, Slice99_sub(slice, 0, 0))); 530 | assert(ENDS_WITH(slice, Slice99_sub(slice, 3, (ptrdiff_t)slice.len))); 531 | 532 | assert(!ENDS_WITH(slice, Slice99_sub(slice, 1, 4))); 533 | assert(!ENDS_WITH(slice, Slice99_sub(slice, 0, 3))); 534 | } 535 | 536 | TEST(ends_with_partial_order) { 537 | for (size_t i = 0; i < 100; i++) { 538 | Slice99 slices[] = { 539 | random_int_slice(), 540 | random_int_slice(), 541 | random_int_slice(), 542 | }; 543 | 544 | #define EQ(slice, other) Slice99_eq(slice, other, int_cmp) 545 | 546 | ASSERT_PARTIAL_ORDER(ENDS_WITH, EQ, slices[0], slices[1], slices[2]); 547 | 548 | #undef EQ 549 | 550 | free(slices[0].ptr); 551 | free(slices[1].ptr); 552 | free(slices[2].ptr); 553 | } 554 | } 555 | 556 | TEST(ends_with_empty_slice_is_max) { 557 | for (size_t i = 0; i < 100; i++) { 558 | Slice99 slice = random_int_slice(); 559 | assert(ENDS_WITH(slice, Slice99_empty(sizeof(int)))); 560 | free(slice.ptr); 561 | } 562 | } 563 | 564 | TEST(ends_with) { 565 | test_ends_with_basic(); 566 | test_ends_with_partial_order(); 567 | test_ends_with_empty_slice_is_max(); 568 | } 569 | 570 | #undef ENDS_WITH 571 | 572 | TEST(copy) { 573 | #define CHECK_COPY \ 574 | do { \ 575 | const int expected[] = {2, 3, 4, 5}; \ 576 | assert(memcmp(dst.ptr, expected, sizeof expected) == 0); \ 577 | } while (0) 578 | 579 | { 580 | Slice99 dst = Slice99_from_array((int[]){1, 2, 3, 4, 5}), 581 | src = Slice99_sub(dst, 1, (ptrdiff_t)dst.len); 582 | 583 | Slice99_copy(dst, src); 584 | CHECK_COPY; 585 | } 586 | 587 | { 588 | Slice99 dst = Slice99_from_array((int[]){1, 2, 3, 4, 5}), 589 | src = Slice99_sub(dst, 1, (ptrdiff_t)dst.len); 590 | 591 | Slice99_copy(Slice99_update_len(dst, 0), src); 592 | CHECK_COPY; 593 | } 594 | 595 | #undef CHECK_COPY 596 | } 597 | 598 | // clang-format off 599 | TEST(copy_non_overlapping) { 600 | #define CHECK_COPY assert(memcmp(copied, data, sizeof data) == 0) 601 | 602 | { 603 | int data[] = {1, 2, 3, 4, 5}; 604 | int copied[SLICE99_ARRAY_LEN(data)]; 605 | 606 | Slice99_copy_non_overlapping(Slice99_from_array(copied), Slice99_from_array(data)); 607 | CHECK_COPY; 608 | } 609 | 610 | { 611 | int data[] = {1, 2, 3, 4, 5}; 612 | int copied[SLICE99_ARRAY_LEN(data)]; 613 | 614 | Slice99_copy_non_overlapping(Slice99_new(copied, sizeof copied[0], 0), Slice99_from_array(data)); 615 | CHECK_COPY; 616 | } 617 | 618 | #undef CHECK_COPY 619 | } 620 | // clang-format on 621 | 622 | TEST(swap) { 623 | int backup; 624 | 625 | Slice99 slice = Slice99_from_array((int[]){1, 2, 3, 4, 5}); 626 | 627 | Slice99_swap(slice, 1, 3, &backup); 628 | assert(*(int *)Slice99_get(slice, 1) == 4); 629 | assert(*(int *)Slice99_get(slice, 3) == 2); 630 | } 631 | 632 | TEST(swap_with_slice) { 633 | int backup; 634 | 635 | #define LHS_DATA 1, 2, 3, 4, 5 636 | #define RHS_DATA 6, 7, 8, 9, 0 637 | 638 | int lhs_data[] = {LHS_DATA}, rhs_data[] = {RHS_DATA}; 639 | Slice99 lhs = Slice99_from_array(lhs_data), rhs = Slice99_from_array(rhs_data); 640 | 641 | Slice99_swap_with_slice(lhs, rhs, &backup); 642 | 643 | assert(memcmp(lhs.ptr, (int[]){RHS_DATA}, sizeof rhs_data) == 0); 644 | assert(memcmp(rhs.ptr, (int[]){LHS_DATA}, sizeof lhs_data) == 0); 645 | 646 | #undef LHS_DATA 647 | #undef RHS_DATA 648 | } 649 | 650 | TEST(reverse_basic) { 651 | int backup; 652 | int data[] = {1, 2, 3, 4, 5}; 653 | 654 | Slice99 slice = Slice99_from_array(data); 655 | Slice99_reverse(slice, &backup); 656 | assert(memcmp(slice.ptr, data, Slice99_size(slice)) == 0); 657 | } 658 | 659 | static Slice99 slice_rev_aux(Slice99 slice) { 660 | int backup; 661 | Slice99_reverse(slice, &backup); 662 | return slice; 663 | } 664 | 665 | TEST(reverse_involutive) { 666 | for (size_t i = 0; i < 100; i++) { 667 | Slice99 slice = random_int_slice(); 668 | 669 | int *saved_array = malloc(Slice99_size(slice)); 670 | assert(saved_array); 671 | memcpy(saved_array, slice.ptr, Slice99_size(slice)); 672 | Slice99 saved_slice = Slice99_new(saved_array, sizeof saved_array[0], slice.len); 673 | 674 | ASSERT_INVOLUTIVE(slice_rev_aux, Slice99_primitive_eq, saved_slice); 675 | 676 | free(slice.ptr); 677 | free(saved_array); 678 | } 679 | } 680 | 681 | TEST(reverse) { 682 | test_reverse_basic(); 683 | test_reverse_involutive(); 684 | } 685 | 686 | TEST(split_at_empty_slice) { 687 | Slice99 slice = Slice99_empty(1), lhs, rhs; 688 | Slice99_split_at(slice, 0, &lhs, &rhs); 689 | 690 | // clang-format off 691 | ASSERT_SLICE( 692 | lhs, 693 | PTR slice.ptr, 694 | ITEM_SIZE slice.item_size, 695 | LEN slice.len 696 | ); 697 | ASSERT_SLICE( 698 | rhs, 699 | PTR slice.ptr, 700 | ITEM_SIZE slice.item_size, 701 | LEN slice.len 702 | ); 703 | // clang-format on 704 | } 705 | 706 | TEST(split_at_non_empty_slice) { 707 | Slice99 slice = Slice99_from_array((int[]){1, 2, 3, 4, 5}), lhs, rhs; 708 | Slice99_split_at(slice, 2, &lhs, &rhs); 709 | 710 | // clang-format off 711 | ASSERT_SLICE( 712 | lhs, 713 | PTR slice.ptr, 714 | ITEM_SIZE slice.item_size, 715 | LEN 2 716 | ); 717 | ASSERT_SLICE( 718 | rhs, 719 | PTR (int *)slice.ptr + 2, 720 | ITEM_SIZE slice.item_size, 721 | LEN 3 722 | ); 723 | // clang-format on 724 | } 725 | 726 | TEST(split_at_beginning) { 727 | Slice99 slice = Slice99_from_array((int[]){1, 2, 3, 4, 5}), lhs, rhs; 728 | Slice99_split_at(slice, 0, &lhs, &rhs); 729 | 730 | // clang-format off 731 | ASSERT_SLICE( 732 | lhs, 733 | PTR slice.ptr, 734 | ITEM_SIZE slice.item_size, 735 | LEN 0 736 | ); 737 | ASSERT_SLICE( 738 | rhs, 739 | PTR slice.ptr, 740 | ITEM_SIZE slice.item_size, 741 | LEN slice.len 742 | ); 743 | // clang-format on 744 | } 745 | 746 | TEST(split_at_end) { 747 | Slice99 slice = Slice99_from_array((int[]){1, 2, 3, 4, 5}), lhs, rhs; 748 | Slice99_split_at(slice, 5, &lhs, &rhs); 749 | 750 | // clang-format off 751 | ASSERT_SLICE( 752 | lhs, 753 | PTR slice.ptr, 754 | ITEM_SIZE slice.item_size, 755 | LEN slice.len 756 | ); 757 | ASSERT_SLICE( 758 | rhs, 759 | PTR (int *)slice.ptr + 5, 760 | ITEM_SIZE slice.item_size, 761 | LEN 0 762 | ); 763 | // clang-format on 764 | } 765 | 766 | TEST(split_at) { 767 | test_split_at_empty_slice(); 768 | test_split_at_non_empty_slice(); 769 | test_split_at_beginning(); 770 | test_split_at_end(); 771 | } 772 | 773 | TEST(to_c_str) { 774 | { 775 | Slice99 slice = Slice99_from_array((char[]){'a', 'b', 'c'}); 776 | assert(strcmp(Slice99_c_str(slice, (char[4]){0}), "abc") == 0); 777 | } 778 | 779 | { 780 | CharSlice99 char_slice = (CharSlice99)Slice99_typed_from_array((char[]){'a', 'b', 'c'}); 781 | 782 | assert(strcmp(CharSlice99_c_str(char_slice, (char[4]){0}), "abc") == 0); 783 | assert(strcmp(CharSlice99_alloca_c_str(char_slice), "abc") == 0); 784 | } 785 | } 786 | 787 | typedef struct { 788 | int x, y; 789 | } Point; 790 | 791 | SLICE99_DEF_TYPED(MyPoints, Point); 792 | 793 | TEST(def_typed) { 794 | #define TYPECHECK(fn, expected_type) \ 795 | do { \ 796 | expected_type = fn; \ 797 | (void)_; \ 798 | } while (0) 799 | 800 | TYPECHECK(MyPoints_new, MyPoints(*_)(Point *, size_t)); 801 | TYPECHECK(MyPoints_from_ptrdiff, MyPoints(*_)(Point *, Point *)); 802 | TYPECHECK(MyPoints_empty, MyPoints(*_)(void)); 803 | TYPECHECK(MyPoints_update_len, MyPoints(*_)(MyPoints, size_t)); 804 | TYPECHECK(MyPoints_is_empty, bool (*_)(MyPoints)); 805 | TYPECHECK(MyPoints_size, size_t(*_)(MyPoints)); 806 | TYPECHECK(MyPoints_get, Point * (*_)(MyPoints, ptrdiff_t)); 807 | TYPECHECK(MyPoints_first, Point * (*_)(MyPoints)); 808 | TYPECHECK(MyPoints_last, Point * (*_)(MyPoints)); 809 | TYPECHECK(MyPoints_sub, MyPoints(*_)(MyPoints, ptrdiff_t, ptrdiff_t)); 810 | TYPECHECK(MyPoints_advance, MyPoints(*_)(MyPoints, ptrdiff_t)); 811 | 812 | TYPECHECK(MyPoints_primitive_eq, bool (*_)(MyPoints, MyPoints)); 813 | TYPECHECK(MyPoints_eq, bool (*_)(MyPoints, MyPoints, int (*)(const Point *, const Point *))); 814 | 815 | TYPECHECK(MyPoints_primitive_starts_with, bool (*_)(MyPoints, MyPoints)); 816 | TYPECHECK( 817 | MyPoints_starts_with, bool (*_)(MyPoints, MyPoints, int (*)(const Point *, const Point *))); 818 | 819 | TYPECHECK(MyPoints_primitive_ends_with, bool (*_)(MyPoints, MyPoints)); 820 | TYPECHECK( 821 | MyPoints_ends_with, bool (*_)(MyPoints, MyPoints, int (*)(const Point *, const Point *))); 822 | 823 | TYPECHECK(MyPoints_copy, void (*_)(MyPoints, MyPoints)); 824 | TYPECHECK(MyPoints_copy_non_overlapping, void (*_)(MyPoints, MyPoints)); 825 | TYPECHECK(MyPoints_swap, void (*_)(MyPoints, ptrdiff_t, ptrdiff_t, Point *restrict)); 826 | TYPECHECK(MyPoints_swap_with_slice, void (*_)(MyPoints, MyPoints, Point *restrict)); 827 | TYPECHECK(MyPoints_reverse, void (*_)(MyPoints, Point *restrict)); 828 | TYPECHECK( 829 | MyPoints_split_at, void (*_)(MyPoints, size_t, MyPoints *restrict, MyPoints *restrict)); 830 | 831 | #undef TYPECHECK 832 | 833 | // Slice99_typed_from_array 834 | { 835 | MyPoints points = 836 | (MyPoints)Slice99_typed_from_array((Point[]){{1, 32}, {12, 314}, {-134, -9}}); 837 | (void)points; 838 | } 839 | } 840 | 841 | TEST(fundamentals) { 842 | #pragma GCC diagnostic push 843 | #pragma GCC diagnostic ignored "-Wunused-result" 844 | 845 | (void)CharSlice99_new((char[]){'a', 'b', 'c'}, 3); 846 | (void)SCharSlice99_new((signed char[]){'a', 'b', 'c'}, 3); 847 | (void)UCharSlice99_new((unsigned char[]){'a', 'b', 'c'}, 3); 848 | 849 | (void)ShortSlice99_new((short[]){1, 2, 3}, 3); 850 | (void)UShortSlice99_new((unsigned short[]){1, 2, 3}, 3); 851 | 852 | (void)IntSlice99_new((int[]){1, 2, 3}, 3); 853 | (void)UIntSlice99_new((unsigned int[]){1, 2, 3}, 3); 854 | 855 | (void)LongSlice99_new((long[]){1, 2, 3}, 3); 856 | (void)ULongSlice99_new((unsigned long[]){1, 2, 3}, 3); 857 | (void)LongLongSlice99_new((long long[]){1, 2, 3}, 3); 858 | (void)ULongLongSlice99_new((unsigned long long[]){1, 2, 3}, 3); 859 | 860 | (void)FloatSlice99_new((float[]){1, 2, 3}, 3); 861 | (void)DoubleSlice99_new((double[]){1, 2, 3}, 3); 862 | (void)LongDoubleSlice99_new((long double[]){1, 2, 3}, 3); 863 | 864 | (void)BoolSlice99_new((_Bool[]){1, 2, 3}, 3); 865 | 866 | (void)U8Slice99_new((uint8_t[]){1, 2, 3}, 3); 867 | (void)U16Slice99_new((uint16_t[]){1, 2, 3}, 3); 868 | (void)U32Slice99_new((uint32_t[]){1, 2, 3}, 3); 869 | (void)U64Slice99_new((uint64_t[]){1, 2, 3}, 3); 870 | 871 | (void)I8Slice99_new((int8_t[]){1, 2, 3}, 3); 872 | (void)I16Slice99_new((int16_t[]){1, 2, 3}, 3); 873 | (void)I32Slice99_new((int32_t[]){1, 2, 3}, 3); 874 | (void)I64Slice99_new((int64_t[]){1, 2, 3}, 3); 875 | 876 | #pragma GCC diagnostic pop 877 | } 878 | 879 | TEST(to_typed) { 880 | char *str = "abc"; 881 | const Slice99 x = Slice99_from_str(str); 882 | CharSlice99 y = (CharSlice99)SLICE99_TO_TYPED(x); 883 | 884 | assert(x.ptr == y.ptr); 885 | assert(x.len == y.len); 886 | } 887 | 888 | TEST(to_untyped) { 889 | // clang-format off 890 | char *str = "abc"; 891 | ASSERT_SLICE( 892 | SLICE99_TO_UNTYPED(CharSlice99_from_str(str)), 893 | PTR str, 894 | ITEM_SIZE sizeof str[0], 895 | LEN strlen(str) 896 | ); 897 | // clang-format on 898 | } 899 | 900 | TEST(fmt) { 901 | char *expected = "123 --- abc", *fmt = "%d --- %s"; 902 | const size_t bufsz = strlen(expected) + 1; 903 | char *buffer = alloca(bufsz); 904 | 905 | #define CHECK assert(CharSlice99_primitive_eq(ret, CharSlice99_from_str(expected))) 906 | 907 | CharSlice99 ret; 908 | 909 | ret = CharSlice99_fmt(buffer, fmt, 123, "abc"); 910 | CHECK; 911 | memset(buffer, '\0', bufsz); 912 | return; 913 | ret = CharSlice99_nfmt(buffer, bufsz, fmt, 123, "abc"); 914 | CHECK; 915 | memset(buffer, '\0', bufsz); 916 | return; 917 | ret = CharSlice99_alloca_fmt(fmt, 123, "abc"); 918 | CHECK; 919 | memset(buffer, '\0', bufsz); 920 | 921 | #undef CHECK 922 | } 923 | 924 | int main(void) { 925 | srand((unsigned)time(NULL)); 926 | 927 | test_array_len(); 928 | test_write_to_buffer(); 929 | test_write_array_to_buffer(); 930 | test_to_octets(); 931 | test_from_str(); 932 | test_from_ptrdiff(); 933 | test_from_typed_ptr(); 934 | test_update_len(); 935 | test_is_empty(); 936 | test_size(); 937 | test_get(); 938 | test_first(); 939 | test_last(); 940 | test_sub(); 941 | test_advance(); 942 | test_primitive_eq(); 943 | test_eq(); 944 | test_primitive_starts_with(); 945 | test_starts_with(); 946 | test_primitive_ends_with(); 947 | test_ends_with(); 948 | test_copy(); 949 | test_copy_non_overlapping(); 950 | test_swap(); 951 | test_swap_with_slice(); 952 | test_reverse(); 953 | test_split_at(); 954 | test_to_c_str(); 955 | 956 | test_def_typed(); 957 | test_fundamentals(); 958 | test_to_typed(); 959 | test_to_untyped(); 960 | 961 | test_fmt(); 962 | 963 | puts("All the tests have passed!"); 964 | } 965 | -------------------------------------------------------------------------------- /slice99.h: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2020-2025 hirrolot 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | */ 24 | 25 | /** 26 | * @file 27 | * @brief A slice of some array. 28 | * 29 | * Some macros are automatically defined in case they have not been defined before including this 30 | * header file; these are: #SLICE99_ASSERT, #SLICE99_MEMCMP, #SLICE99_MEMCPY, #SLICE99_MEMMOVE, 31 | * #SLICE99_STRLEN, #SLICE99_VSPRINTF, #SLICE99_VSNPRINTF, and #SLICE99_SNPRINTF. They represent the 32 | * corresponding standard library's functions, although actual implementations can differ. If you 33 | * develop software for a freestanding environment, these macros must be defined beforehand. If you 34 | * do not want to implement string formatting macros from `stdio.h`, define `SLICE99_DISABLE_STDIO` 35 | * and Slice99 will not require them from you. 36 | */ 37 | 38 | /** 39 | * @mainpage 40 | * 41 | * This library provides array slicing 42 | * facilities for pure C99.
43 | * 44 | * All the documentation is located in slice99.h. See our official GitHub repository for a high-level 46 | * overview. 47 | */ 48 | 49 | #ifndef SLICE99_H 50 | #define SLICE99_H 51 | 52 | #include 53 | #include 54 | #include 55 | #include 56 | 57 | #ifndef SLICE99_ASSERT 58 | #include 59 | /// Like `assert`. 60 | #define SLICE99_ASSERT assert 61 | #endif // SLICE99_ASSERT 62 | 63 | #ifndef SLICE99_MEMCMP 64 | #include 65 | /// Like `memcmp`. 66 | #define SLICE99_MEMCMP memcmp 67 | #endif 68 | 69 | #ifndef SLICE99_MEMCPY 70 | #include 71 | /// Like `memcpy`. 72 | #define SLICE99_MEMCPY memcpy 73 | #endif 74 | 75 | #ifndef SLICE99_MEMMOVE 76 | #include 77 | /// Like `memmove`. 78 | #define SLICE99_MEMMOVE memmove 79 | #endif 80 | 81 | #ifndef SLICE99_STRLEN 82 | #include 83 | /// Like `strlen`. 84 | #define SLICE99_STRLEN strlen 85 | #endif 86 | 87 | #ifndef DOXYGEN_IGNORE 88 | 89 | #ifdef __GNUC__ 90 | #define SLICE99_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) 91 | #else 92 | #define SLICE99_WARN_UNUSED_RESULT 93 | #endif // __GNU__ 94 | 95 | #if defined(__GNUC__) && !defined(__clang__) 96 | 97 | #define SLICE99_CONST __attribute__((const)) 98 | #define SLICE99_PURE __attribute__((pure)) 99 | #define SLICE99_ALWAYS_INLINE __attribute__((always_inline)) 100 | #define SLICE99_FORMAT_HINT(archetype, string_idx, first_to_check) \ 101 | __attribute__((format(archetype, string_idx, first_to_check))) 102 | 103 | #else 104 | 105 | #define SLICE99_CONST 106 | #define SLICE99_PURE 107 | #define SLICE99_ALWAYS_INLINE 108 | #define SLICE99_FORMAT_HINT(_archetype, _string_idx, _first_to_check) 109 | 110 | #endif 111 | 112 | #endif // DOXYGEN_IGNORE 113 | 114 | /** 115 | * The major version number. 116 | */ 117 | #define SLICE99_MAJOR 0 118 | 119 | /** 120 | * The minor version number. 121 | */ 122 | #define SLICE99_MINOR 7 123 | 124 | /** 125 | * The patch version number. 126 | */ 127 | #define SLICE99_PATCH 8 128 | 129 | /** 130 | * Defines the strongly typed slice @p name containing items of type @p T. 131 | * 132 | * This macro defines 133 | * 134 | * @code 135 | * typedef struct { 136 | * T *ptr; 137 | * size_t len; 138 | * } name; 139 | * @endcode 140 | * 141 | * Also, it specialises all the functions operating on #Slice99. Every function (except for 142 | * #Slice99_from_str and #Slice99_c_str) is defined by the following rules: 143 | * 144 | * - A function named `Slice99_*` becomes `name_*`. 145 | * - `void *` is replaced by `T *`. 146 | * - `Slice99` is replaced by `name`. 147 | * - `size_t item_size` parameters are removed (e.g., as in #Slice99_new, #Slice99_empty, 148 | * #Slice99_from_ptrdiff). 149 | * - All function preconditions, invariants, and postconditions remain the same. 150 | * 151 | * #Slice99_from_str and #Slice99_c_str are derived only for `CharSlice99`. 152 | * 153 | * # Examples 154 | * 155 | * @code 156 | * #include 157 | * 158 | * typedef struct { 159 | * double x, y; 160 | * } Point; 161 | * 162 | * SLICE99_DEF_TYPED(MyPoints, Point); 163 | * 164 | * int main(void) { 165 | * MyPoints points = (MyPoints)Slice99_typed_from_array( 166 | * (Point[]){{1.5, 32.5}, {12.0, 314.01}, {-134.10, -9.3}}); 167 | * 168 | * MyPoints first_two = MyPoints_sub(points, 0, 2); 169 | * Point *first = MyPoints_first(points); 170 | * bool is_empty = MyPoints_is_empty(points); 171 | * } 172 | * @endcode 173 | */ 174 | #define SLICE99_DEF_TYPED(name, T) \ 175 | typedef struct { \ 176 | T *ptr; \ 177 | size_t len; \ 178 | } name; \ 179 | \ 180 | inline static SLICE99_ALWAYS_INLINE SLICE99_WARN_UNUSED_RESULT name name##_new( \ 181 | T *ptr, size_t len) { \ 182 | const Slice99 result = Slice99_new((void *)ptr, sizeof(T), len); \ 183 | return (name)SLICE99_TO_TYPED(result); \ 184 | } \ 185 | \ 186 | inline static SLICE99_ALWAYS_INLINE SLICE99_WARN_UNUSED_RESULT name name##_from_ptrdiff( \ 187 | T *start, T *end) { \ 188 | const Slice99 result = Slice99_from_ptrdiff((void *)start, (void *)end, sizeof(T)); \ 189 | return (name)SLICE99_TO_TYPED(result); \ 190 | } \ 191 | \ 192 | inline static SLICE99_ALWAYS_INLINE SLICE99_WARN_UNUSED_RESULT name name##_empty(void) { \ 193 | const Slice99 result = Slice99_empty(sizeof(T)); \ 194 | return (name)SLICE99_TO_TYPED(result); \ 195 | } \ 196 | \ 197 | inline static SLICE99_ALWAYS_INLINE SLICE99_WARN_UNUSED_RESULT name name##_update_len( \ 198 | name self, size_t new_len) { \ 199 | const Slice99 result = Slice99_update_len(SLICE99_TO_UNTYPED(self), new_len); \ 200 | return (name)SLICE99_TO_TYPED(result); \ 201 | } \ 202 | \ 203 | inline static SLICE99_ALWAYS_INLINE SLICE99_WARN_UNUSED_RESULT \ 204 | SLICE99_CONST bool name##_is_empty(name self) { \ 205 | return Slice99_is_empty(SLICE99_TO_UNTYPED(self)); \ 206 | } \ 207 | \ 208 | inline static SLICE99_ALWAYS_INLINE SLICE99_WARN_UNUSED_RESULT SLICE99_CONST size_t \ 209 | name##_size(name self) { \ 210 | return Slice99_size(SLICE99_TO_UNTYPED(self)); \ 211 | } \ 212 | \ 213 | inline static SLICE99_ALWAYS_INLINE SLICE99_WARN_UNUSED_RESULT SLICE99_CONST T *name##_get( \ 214 | name self, ptrdiff_t i) { \ 215 | return (T *)Slice99_get(SLICE99_TO_UNTYPED(self), i); \ 216 | } \ 217 | \ 218 | inline static SLICE99_ALWAYS_INLINE SLICE99_WARN_UNUSED_RESULT SLICE99_CONST T *name##_first( \ 219 | name self) { \ 220 | return (T *)Slice99_first(SLICE99_TO_UNTYPED(self)); \ 221 | } \ 222 | \ 223 | inline static SLICE99_ALWAYS_INLINE SLICE99_WARN_UNUSED_RESULT SLICE99_CONST T *name##_last( \ 224 | name self) { \ 225 | return (T *)Slice99_last(SLICE99_TO_UNTYPED(self)); \ 226 | } \ 227 | \ 228 | inline static SLICE99_ALWAYS_INLINE SLICE99_WARN_UNUSED_RESULT name name##_sub( \ 229 | name self, ptrdiff_t start_idx, ptrdiff_t end_idx) { \ 230 | const Slice99 result = Slice99_sub(SLICE99_TO_UNTYPED(self), start_idx, end_idx); \ 231 | return (name)SLICE99_TO_TYPED(result); \ 232 | } \ 233 | \ 234 | inline static SLICE99_ALWAYS_INLINE SLICE99_WARN_UNUSED_RESULT name name##_advance( \ 235 | name self, ptrdiff_t offset) { \ 236 | const Slice99 result = Slice99_advance(SLICE99_TO_UNTYPED(self), offset); \ 237 | return (name)SLICE99_TO_TYPED(result); \ 238 | } \ 239 | \ 240 | inline static SLICE99_ALWAYS_INLINE SLICE99_WARN_UNUSED_RESULT bool name##_primitive_eq( \ 241 | name lhs, name rhs) { \ 242 | return Slice99_primitive_eq(SLICE99_TO_UNTYPED(lhs), SLICE99_TO_UNTYPED(rhs)); \ 243 | } \ 244 | \ 245 | inline static SLICE99_ALWAYS_INLINE SLICE99_WARN_UNUSED_RESULT bool name##_eq( \ 246 | name lhs, name rhs, int (*cmp)(const T *, const T *)) { \ 247 | return Slice99_eq( \ 248 | SLICE99_TO_UNTYPED(lhs), SLICE99_TO_UNTYPED(rhs), \ 249 | (int (*)(const void *, const void *))cmp); \ 250 | } \ 251 | \ 252 | inline static SLICE99_ALWAYS_INLINE SLICE99_WARN_UNUSED_RESULT bool \ 253 | name##_primitive_starts_with(name self, name prefix) { \ 254 | return Slice99_primitive_starts_with( \ 255 | SLICE99_TO_UNTYPED(self), SLICE99_TO_UNTYPED(prefix)); \ 256 | } \ 257 | \ 258 | inline static SLICE99_ALWAYS_INLINE SLICE99_WARN_UNUSED_RESULT bool name##_starts_with( \ 259 | name self, name prefix, int (*cmp)(const T *, const T *)) { \ 260 | return Slice99_starts_with( \ 261 | SLICE99_TO_UNTYPED(self), SLICE99_TO_UNTYPED(prefix), \ 262 | (int (*)(const void *, const void *))cmp); \ 263 | } \ 264 | \ 265 | inline static SLICE99_ALWAYS_INLINE SLICE99_WARN_UNUSED_RESULT bool \ 266 | name##_primitive_ends_with(name self, name postfix) { \ 267 | return Slice99_primitive_ends_with(SLICE99_TO_UNTYPED(self), SLICE99_TO_UNTYPED(postfix)); \ 268 | } \ 269 | \ 270 | inline static SLICE99_ALWAYS_INLINE SLICE99_WARN_UNUSED_RESULT bool name##_ends_with( \ 271 | name self, name postfix, int (*cmp)(const T *, const T *)) { \ 272 | return Slice99_ends_with( \ 273 | SLICE99_TO_UNTYPED(self), SLICE99_TO_UNTYPED(postfix), \ 274 | (int (*)(const void *, const void *))cmp); \ 275 | } \ 276 | \ 277 | inline static SLICE99_ALWAYS_INLINE void name##_copy(name self, name other) { \ 278 | Slice99_copy(SLICE99_TO_UNTYPED(self), SLICE99_TO_UNTYPED(other)); \ 279 | } \ 280 | \ 281 | inline static SLICE99_ALWAYS_INLINE void name##_copy_non_overlapping(name self, name other) { \ 282 | Slice99_copy_non_overlapping(SLICE99_TO_UNTYPED(self), SLICE99_TO_UNTYPED(other)); \ 283 | } \ 284 | \ 285 | inline static SLICE99_ALWAYS_INLINE void name##_swap( \ 286 | name self, ptrdiff_t lhs, ptrdiff_t rhs, T *restrict backup) { \ 287 | Slice99_swap(SLICE99_TO_UNTYPED(self), lhs, rhs, (void *restrict)backup); \ 288 | } \ 289 | \ 290 | inline static SLICE99_ALWAYS_INLINE void name##_swap_with_slice( \ 291 | name self, name other, T *restrict backup) { \ 292 | Slice99_swap_with_slice( \ 293 | SLICE99_TO_UNTYPED(self), SLICE99_TO_UNTYPED(other), (void *restrict)backup); \ 294 | } \ 295 | \ 296 | inline static SLICE99_ALWAYS_INLINE void name##_reverse(name self, T *restrict backup) { \ 297 | Slice99_reverse(SLICE99_TO_UNTYPED(self), (void *restrict)backup); \ 298 | } \ 299 | \ 300 | inline static SLICE99_ALWAYS_INLINE void name##_split_at( \ 301 | name self, size_t i, name *restrict lhs, name *restrict rhs) { \ 302 | SLICE99_ASSERT(lhs); \ 303 | SLICE99_ASSERT(rhs); \ 304 | \ 305 | Slice99 lhs_untyped = SLICE99_TO_UNTYPED(*lhs), rhs_untyped = SLICE99_TO_UNTYPED(*rhs); \ 306 | \ 307 | Slice99_split_at(SLICE99_TO_UNTYPED(self), i, &lhs_untyped, &rhs_untyped); \ 308 | \ 309 | *lhs = (name)SLICE99_TO_TYPED(lhs_untyped); \ 310 | *rhs = (name)SLICE99_TO_TYPED(rhs_untyped); \ 311 | } \ 312 | \ 313 | struct slice99_priv_trailing_comma 314 | 315 | /** 316 | * Converts #Slice99 to a typed representation. 317 | * 318 | * @pre @p self must be an expression of type #Slice99. 319 | * 320 | * # Examples 321 | * 322 | * @code 323 | * #include 324 | * 325 | * int main(void) { 326 | * Slice99 x = Slice99_from_str("abc"); 327 | * CharSlice99 y = (CharSlice99)SLICE99_TO_TYPED(x); 328 | * (void)y; 329 | * } 330 | * @endcode 331 | */ 332 | #define SLICE99_TO_TYPED(self) \ 333 | { .ptr = (self).ptr, .len = (self).len } 334 | 335 | /** 336 | * Converts the typed slice @p self to #Slice99. 337 | * 338 | * @pre @p self must be an expression of type defined by #SLICE99_DEF_TYPED. 339 | * 340 | * # Examples 341 | * 342 | * @code 343 | * #include 344 | * 345 | * int main(void) { 346 | * CharSlice99 x = CharSlice99_from_str("abc"); 347 | * Slice99 y = SLICE99_TO_UNTYPED(x); 348 | * (void)y; 349 | * } 350 | * @endcode 351 | */ 352 | #define SLICE99_TO_UNTYPED(self) Slice99_new((self).ptr, sizeof(*(self).ptr), (self).len) 353 | 354 | /** 355 | * Computes a number of items in an array expression. 356 | */ 357 | #define SLICE99_ARRAY_LEN(...) (sizeof(__VA_ARGS__) / sizeof((__VA_ARGS__)[0])) 358 | 359 | /** 360 | * Copies @p obj to @p buffer, returning the next position of @p buffer to write to. 361 | * 362 | * This macro is no different from `memcpy` except for the return value. It is useful when you 363 | * want to write a sequence of objects to some memory buffer, e.g., to a packet header: 364 | * 365 | * @code 366 | * const uint16_t x = 123; 367 | * const uint32_t y = 456; 368 | * 369 | * header = SLICE99_APPEND(header, x); 370 | * header = SLICE99_APPEND(header, y); 371 | * // ... 372 | * @endcode 373 | * 374 | * @param[out] buffer The memory area to write to. 375 | * @param[in] obj The object (lvalue) that will be copied to @p buffer, byte-by-byte. 376 | * 377 | * @return `(void *)((char *)buffer + sizeof(obj))` 378 | * 379 | * @pre @p buffer must be capable of holding at least `sizeof(obj)` bytes. 380 | * @pre @p buffer and @p obj must be non-overlapping. 381 | * 382 | * @see #SLICE99_APPEND_ARRAY 383 | */ 384 | #define SLICE99_APPEND(buffer, obj) \ 385 | ((void *)((char *)SLICE99_MEMCPY((buffer), &(obj), sizeof(obj)) + sizeof(obj))) 386 | 387 | /** 388 | * Copies the array of length @p len accessible through @p ptr into @p buffer, returning the next 389 | * position of @p buffer to write to. 390 | * 391 | * This function has the same requirements and a return value as of #SLICE99_APPEND. 392 | */ 393 | #define SLICE99_APPEND_ARRAY(buffer, ptr, len) \ 394 | /* clang-format off */ \ 395 | ((void *)((char *)SLICE99_MEMCPY((buffer), (ptr), sizeof((ptr)[0]) * (len)) + \ 396 | sizeof((ptr)[0]) * (len))) /* clang-format on */ 397 | 398 | #ifdef UINT8_MAX 399 | 400 | /** 401 | * Constructs `U8Slice99` from @p obj. 402 | * 403 | * @param[in] obj The object (lvalue) to which the resulting slice will point to. 404 | * 405 | * @return An octet slice pointing to @p obj of length `sizeof(obj)`. 406 | */ 407 | #define SLICE99_TO_OCTETS(obj) U8Slice99_new((uint8_t *)&(obj), sizeof(obj)) 408 | 409 | #endif 410 | 411 | /** 412 | * Constructs a slice from an array expression. 413 | * 414 | * The resulting slice will have #Slice99.len equal to the number of items in the array, and 415 | * #Slice99.item_size equal to the size of each item. 416 | */ 417 | #define Slice99_from_array(...) \ 418 | Slice99_new((void *)(__VA_ARGS__), sizeof((__VA_ARGS__)[0]), SLICE99_ARRAY_LEN(__VA_ARGS__)) 419 | 420 | /** 421 | * The same as #Slice99_from_array but for typed slices. 422 | * 423 | * # Examples 424 | * 425 | * @code 426 | * #include 427 | * 428 | * int main(void) { 429 | * IntSlice99 x = (IntSlice99)Slice99_typed_from_array((int[]){1, 2, 3}); 430 | * (void)x; 431 | * } 432 | * @endcode 433 | */ 434 | #define Slice99_typed_from_array(...) \ 435 | { .ptr = (__VA_ARGS__), .len = SLICE99_ARRAY_LEN(__VA_ARGS__) } 436 | 437 | /** 438 | * Constructs a slice from a pointer of a non-`void` type and a length. 439 | * 440 | * It is equivalent to #Slice99_new but it automatically computes an item size as `sizeof(*ptr)`. 441 | * 442 | * @param[in] ptr The pointer of the resulting slice. Must not point to `void`. 443 | * @param[in] len The length of the resulting slice. 444 | */ 445 | #define Slice99_from_typed_ptr(ptr, len) Slice99_new(ptr, sizeof(*(ptr)), len) 446 | 447 | /** 448 | * A slice of some array. 449 | * 450 | * This structure should not be constructed manually; use #Slice99_new instead. 451 | * 452 | * @invariant #ptr must not be `NULL`. 453 | * @invariant #item_size must be strictly greater than 0. 454 | */ 455 | typedef struct { 456 | /** 457 | * The pointer to data. 458 | */ 459 | void *ptr; 460 | 461 | /** 462 | * The size of each item in the array addressed by #ptr. 463 | */ 464 | size_t item_size; 465 | 466 | /** 467 | * The count of items in the array addressed by #ptr. 468 | */ 469 | size_t len; 470 | } Slice99; 471 | 472 | /** 473 | * Constructs a slice. 474 | * 475 | * @param[in] ptr The value of Slice99#ptr. 476 | * @param[in] item_size The value of Slice99#item_size. 477 | * @param[in] len The value of Slice99#len. 478 | * 479 | * @pre `ptr != NULL` 480 | * @pre `item_size > 0` 481 | */ 482 | inline static SLICE99_WARN_UNUSED_RESULT Slice99 483 | Slice99_new(void *ptr, size_t item_size, size_t len) { 484 | SLICE99_ASSERT(ptr); 485 | SLICE99_ASSERT(item_size > 0); 486 | 487 | return (Slice99){.ptr = ptr, .item_size = item_size, .len = len}; 488 | } 489 | 490 | /** 491 | * Constructs a slice from @p str. 492 | * 493 | * @param[in] str Any null-terminated string. 494 | * 495 | * @pre `str != NULL` 496 | */ 497 | inline static SLICE99_WARN_UNUSED_RESULT Slice99 Slice99_from_str(char *str) { 498 | SLICE99_ASSERT(str); 499 | 500 | return Slice99_new(str, sizeof(char), SLICE99_STRLEN(str)); 501 | } 502 | 503 | /** 504 | * Constructs a slice residing between @p start (inclusively) and @p end (exclusively). 505 | * 506 | * @param[in] start The start position of a returned slice, inclusively. 507 | * @param[in] end The end position of a returned slice, exlusively. 508 | * @param[in] item_size The value of Slice99#item_size. 509 | * 510 | * @pre `start != NULL` 511 | * @pre `end != NULL` 512 | * @pre `((char *)end - (char *)start) >= 0` 513 | * @pre `(((char *)end - (char *)start)) % item_size == 0` 514 | */ 515 | inline static SLICE99_WARN_UNUSED_RESULT Slice99 516 | Slice99_from_ptrdiff(void *start, void *end, size_t item_size) { 517 | SLICE99_ASSERT(start); 518 | SLICE99_ASSERT(end); 519 | 520 | const ptrdiff_t diff = (char *)end - (char *)start; 521 | 522 | SLICE99_ASSERT(diff >= 0); 523 | SLICE99_ASSERT((size_t)diff % item_size == 0); 524 | 525 | return Slice99_new(start, item_size, (size_t)(diff / (ptrdiff_t)item_size)); 526 | } 527 | 528 | /** 529 | * Constructs an empty slice. 530 | * 531 | * @param[in] item_size The value of Slice99#item_size. 532 | * 533 | * @pre `item_size > 0` 534 | */ 535 | inline static SLICE99_WARN_UNUSED_RESULT Slice99 Slice99_empty(size_t item_size) { 536 | SLICE99_ASSERT(item_size > 0); 537 | return Slice99_new("", item_size, 0); 538 | } 539 | 540 | /** 541 | * Updates @p self with the new length @p new_len. 542 | * 543 | * @param[in] self The slice whose length will be updated. 544 | * @param[in] new_len The new length. 545 | */ 546 | inline static SLICE99_WARN_UNUSED_RESULT Slice99 Slice99_update_len(Slice99 self, size_t new_len) { 547 | return Slice99_new(self.ptr, self.item_size, new_len); 548 | } 549 | 550 | /** 551 | * Checks whether @p self is empty or not. 552 | * 553 | * @param[in] self The checked slice. 554 | * 555 | * @return `true` if @p self is empty, otherwise `false`. 556 | */ 557 | inline static SLICE99_WARN_UNUSED_RESULT SLICE99_CONST bool Slice99_is_empty(Slice99 self) { 558 | return self.len == 0; 559 | } 560 | 561 | /** 562 | * Computes a total size in bytes. 563 | * 564 | * @param[in] self The slice whose size is to be computed. 565 | */ 566 | inline static SLICE99_WARN_UNUSED_RESULT SLICE99_CONST size_t Slice99_size(Slice99 self) { 567 | return self.item_size * self.len; 568 | } 569 | 570 | /** 571 | * Computes a pointer to the @p i -indexed item. 572 | * 573 | * @param[in] self The slice upon which the pointer will be computed. 574 | * @param[in] i The index of a desired item. Can be negative. 575 | * 576 | * @pre `self.item_size` must be representable as `ptrdiff_t`. 577 | */ 578 | inline static SLICE99_WARN_UNUSED_RESULT SLICE99_CONST void * 579 | Slice99_get(Slice99 self, ptrdiff_t i) { 580 | return (void *)((char *)self.ptr + i * (ptrdiff_t)self.item_size); 581 | } 582 | 583 | /** 584 | * Computes a pointer to the first item. 585 | * 586 | * @param[in] self The slice upon which the pointer will be computed. 587 | */ 588 | inline static SLICE99_WARN_UNUSED_RESULT SLICE99_CONST void *Slice99_first(Slice99 self) { 589 | return Slice99_get(self, 0); 590 | } 591 | 592 | /** 593 | * Computes a pointer to the last item. 594 | * 595 | * @param[in] self The slice upon which the pointer will be computed. 596 | * 597 | * @pre `self.len` must be representable as `ptrdiff_t`. 598 | */ 599 | inline static SLICE99_WARN_UNUSED_RESULT SLICE99_CONST void *Slice99_last(Slice99 self) { 600 | return Slice99_get(self, (ptrdiff_t)self.len - 1); 601 | } 602 | 603 | /** 604 | * Subslicing @p self with [@p start_idx `..` @p end_idx]. 605 | * 606 | * @param[in] self The original slice. 607 | * @param[in] start_idx The index at which a new slice will reside, inclusively. 608 | * @param[in] end_idx The index at which a new slice will end, exclusively. 609 | * 610 | * @return A slice with the aforementioned properties. 611 | * 612 | * @pre `start_idx <= end_idx` 613 | */ 614 | inline static SLICE99_WARN_UNUSED_RESULT Slice99 615 | Slice99_sub(Slice99 self, ptrdiff_t start_idx, ptrdiff_t end_idx) { 616 | SLICE99_ASSERT(start_idx <= end_idx); 617 | 618 | return Slice99_from_ptrdiff( 619 | Slice99_get(self, start_idx), Slice99_get(self, end_idx), self.item_size); 620 | } 621 | 622 | /** 623 | * Advances @p self by @p offset items. 624 | * 625 | * @param[in] self The original slice. 626 | * @param[in] offset The number of items to advance. Can be negative. 627 | * 628 | * @return A slice advanced by @p offset items. 629 | * 630 | * @pre `offset <= (self).len` 631 | * @pre `self.len` must be representable as `ptrdiff_t`. 632 | */ 633 | inline static SLICE99_WARN_UNUSED_RESULT Slice99 Slice99_advance(Slice99 self, ptrdiff_t offset) { 634 | return Slice99_sub(self, offset, (ptrdiff_t)self.len); 635 | } 636 | 637 | /** 638 | * Performs a byte-by-byte comparison of @p lhs with @p rhs. 639 | * 640 | * @param[in] lhs The first slice to be compared. 641 | * @param[in] rhs The second slice to be compared. 642 | * 643 | * @return `true` if @p lhs and @p rhs are equal, `false` otherwise. 644 | */ 645 | inline static SLICE99_WARN_UNUSED_RESULT bool Slice99_primitive_eq(Slice99 lhs, Slice99 rhs) { 646 | return Slice99_size(lhs) != Slice99_size(rhs) 647 | ? false 648 | : SLICE99_MEMCMP(lhs.ptr, rhs.ptr, Slice99_size(lhs)) == 0; 649 | } 650 | 651 | /** 652 | * Performs a comparison of @p lhs with @p rhs with a user-supplied comparator. 653 | * 654 | * @param[in] lhs The first slice to be compared. 655 | * @param[in] rhs The second slice to be compared. 656 | * @param[in] cmp The function deciding whether two items are equal ot not (0 if equal, any other 657 | * value otherwise). 658 | * 659 | * @return `true` if @p lhs and @p rhs are equal, `false` otherwise. 660 | * 661 | * @pre `lhs.item_size == rhs.item_size` 662 | * @pre `cmp != NULL` 663 | * @pre `lhs.len` and `rhs.len` must be representable as `ptrdiff_t`. 664 | */ 665 | inline static SLICE99_WARN_UNUSED_RESULT bool 666 | Slice99_eq(Slice99 lhs, Slice99 rhs, int (*cmp)(const void *, const void *)) { 667 | SLICE99_ASSERT(lhs.item_size == rhs.item_size); 668 | SLICE99_ASSERT(cmp); 669 | 670 | if (lhs.len != rhs.len) { 671 | return false; 672 | } 673 | 674 | for (ptrdiff_t i = 0; i < (ptrdiff_t)lhs.len; i++) { 675 | if (cmp(Slice99_get(lhs, i), Slice99_get(rhs, i)) != 0) { 676 | return false; 677 | } 678 | } 679 | 680 | return true; 681 | } 682 | 683 | /** 684 | * Checks whether @p prefix is a prefix of @p self, byte-by-byte. 685 | * 686 | * @param[in] self The slice to be checked for @p prefix. 687 | * @param[in] prefix The slice to be checked whether it is a prefix of @p self. 688 | * 689 | * @return `true` if @p prefix is a prefix of @p self, otherwise `false`. 690 | * 691 | * @pre `prefix.len` must be representable as `ptrdiff_t`. 692 | */ 693 | inline static SLICE99_WARN_UNUSED_RESULT bool 694 | Slice99_primitive_starts_with(Slice99 self, Slice99 prefix) { 695 | return Slice99_size(self) < Slice99_size(prefix) 696 | ? false 697 | : Slice99_primitive_eq(Slice99_sub(self, 0, (ptrdiff_t)prefix.len), prefix); 698 | } 699 | 700 | /** 701 | * Checks whether @p prefix is a prefix of @p self with a user-supplied comparator. 702 | * 703 | * @param[in] self The slice to be checked for @p prefix. 704 | * @param[in] prefix The slice to be checked whether it is a prefix of @p self. 705 | * @param[in] cmp The function deciding whether two items are equal ot not (0 if equal, any other 706 | * value otherwise). 707 | * 708 | * @return `true` if @p prefix is a prefix of @p self, otherwise `false`. 709 | * 710 | * @pre `self.item_size == prefix.item_size` 711 | * @pre `cmp != NULL` 712 | * @pre `prefix.len` must be representable as `ptrdiff_t`. 713 | */ 714 | inline static SLICE99_WARN_UNUSED_RESULT bool 715 | Slice99_starts_with(Slice99 self, Slice99 prefix, int (*cmp)(const void *, const void *)) { 716 | SLICE99_ASSERT(self.item_size == prefix.item_size); 717 | SLICE99_ASSERT(cmp); 718 | 719 | return self.len < prefix.len 720 | ? false 721 | : Slice99_eq(Slice99_sub(self, 0, (ptrdiff_t)prefix.len), prefix, cmp); 722 | } 723 | 724 | /** 725 | * Checks whether @p postfix is a postfix of @p self, byte-by-byte. 726 | * 727 | * @param[in] self The slice to be checked for @p postfix. 728 | * @param[in] postfix The slice to be checked whether it is a postfix of @p self. 729 | * 730 | * @return `true` if @p postfix is a postfix of @p self, otherwise `false`. 731 | * 732 | * @pre `self.len` and `postfix.len` must be representable as `ptrdiff_t`. 733 | */ 734 | inline static SLICE99_WARN_UNUSED_RESULT bool 735 | Slice99_primitive_ends_with(Slice99 self, Slice99 postfix) { 736 | return Slice99_size(self) < Slice99_size(postfix) 737 | ? false 738 | : Slice99_primitive_eq( 739 | Slice99_sub( 740 | self, (ptrdiff_t)self.len - (ptrdiff_t)postfix.len, (ptrdiff_t)self.len), 741 | postfix); 742 | } 743 | 744 | /** 745 | * Checks whether @p postfix is a postfix of @p self with a user-supplied comparator. 746 | * 747 | * @param[in] self The slice to be checked for @p postfix. 748 | * @param[in] postfix The slice to be checked whether it is a postfix of @p self. 749 | * @param[in] cmp The function deciding whether two items are equal ot not (0 if equal, any other 750 | * value otherwise). 751 | * 752 | * @return `true` if @p postfix is a postfix of @p self, otherwise `false`. 753 | * 754 | * @pre `self.item_size == postfix.item_size` 755 | * @pre `cmp != NULL` 756 | * @pre `self.len` and `postfix.len` must be representable as `ptrdiff_t`. 757 | */ 758 | inline static SLICE99_WARN_UNUSED_RESULT bool 759 | Slice99_ends_with(Slice99 self, Slice99 postfix, int (*cmp)(const void *, const void *)) { 760 | SLICE99_ASSERT(self.item_size == postfix.item_size); 761 | SLICE99_ASSERT(cmp); 762 | 763 | return self.len < postfix.len 764 | ? false 765 | : Slice99_eq( 766 | Slice99_sub( 767 | self, (ptrdiff_t)self.len - (ptrdiff_t)postfix.len, (ptrdiff_t)self.len), 768 | postfix, cmp); 769 | } 770 | 771 | /** 772 | * Copies @p other to the beginning of @p self, byte-by-byte. 773 | * 774 | * @param[out] self The location to which the whole @p other will be copied. 775 | * @param[in] other The slice to be copied to @p self. 776 | */ 777 | inline static void Slice99_copy(Slice99 self, Slice99 other) { 778 | SLICE99_MEMMOVE(self.ptr, other.ptr, Slice99_size(other)); 779 | } 780 | 781 | /** 782 | * The same as #Slice99_copy except that @p self and @p other must be non-overlapping. 783 | * 784 | * @pre @p self and @p other must be non-overlapping. 785 | */ 786 | inline static void Slice99_copy_non_overlapping(Slice99 self, Slice99 other) { 787 | SLICE99_MEMCPY(self.ptr, other.ptr, Slice99_size(other)); 788 | } 789 | 790 | /** 791 | * Swaps the @p lhs -indexed and @p rhs -indexed items. 792 | * 793 | * @param[out] self The slice in which @p lhs and @p rhs will be swapped. 794 | * @param[in] lhs The index of the first item. 795 | * @param[in] rhs The index of the second item. 796 | * @param[out] backup The memory area of `self.item_size` bytes accessible for reading and writing. 797 | * 798 | * @pre `backup != NULL` 799 | * @pre @p backup must not overlap with `Slice99_get(self, lhs)` and `Slice99_get(self, rhs)`. 800 | * @pre `Slice99_get(self, lhs)` and `Slice99_get(self, rhs)` must not overlap. 801 | */ 802 | inline static void Slice99_swap(Slice99 self, ptrdiff_t lhs, ptrdiff_t rhs, void *restrict backup) { 803 | SLICE99_ASSERT(backup); 804 | 805 | SLICE99_MEMCPY((backup), Slice99_get(self, lhs), (self).item_size); 806 | SLICE99_MEMCPY(Slice99_get(self, lhs), Slice99_get(self, rhs), (self).item_size); 807 | SLICE99_MEMCPY(Slice99_get(self, rhs), (backup), (self).item_size); 808 | } 809 | 810 | /** 811 | * Swaps all the items in @p self with those in @p other. 812 | * 813 | * @param[out] self The first slice to be swapped. 814 | * @param[out] other The second slice to be swapped. 815 | * @param[out] backup The memory area of `self.item_size` bytes accessible for reading and writing. 816 | * 817 | * @pre `self.len == other.len` 818 | * @pre `self.item_size == other.item_size` 819 | * @pre @p backup must not overlap with @p self and @p other. 820 | * @pre @p self and @p other must not overlap. 821 | * @pre `self.len` must be representable as `ptrdiff_t`. 822 | */ 823 | inline static void Slice99_swap_with_slice(Slice99 self, Slice99 other, void *restrict backup) { 824 | SLICE99_ASSERT(self.len == other.len); 825 | SLICE99_ASSERT(self.item_size == other.item_size); 826 | 827 | for (ptrdiff_t i = 0; i < (ptrdiff_t)self.len; i++) { 828 | SLICE99_MEMCPY(backup, Slice99_get(self, i), self.item_size); 829 | SLICE99_MEMCPY(Slice99_get(self, i), Slice99_get(other, i), self.item_size); 830 | SLICE99_MEMCPY(Slice99_get(other, i), backup, self.item_size); 831 | } 832 | } 833 | 834 | /** 835 | * Reverses the order of items in @p self. 836 | * 837 | * @param[out] self The slice to be reversed. 838 | * @param[out] backup The memory area of `self.item_size` bytes accessible for reading and writing. 839 | * 840 | * @pre `backup != NULL` 841 | * @pre `self.len` must be representable as `ptrdiff_t`. 842 | */ 843 | inline static void Slice99_reverse(Slice99 self, void *restrict backup) { 844 | SLICE99_ASSERT(backup); 845 | 846 | for (ptrdiff_t i = 0; i < (ptrdiff_t)self.len / 2; i++) { 847 | Slice99_swap(self, i, (ptrdiff_t)self.len - i - 1, backup); 848 | } 849 | } 850 | 851 | /** 852 | * Splits @p self into two parts. 853 | * 854 | * @param[in] self The slice to be splitted into @p lhs and @p rhs. 855 | * @param[in] i The index at which @p self will be splitted. 856 | * @param[out] lhs The first part of @p self indexed as [0; @p i). 857 | * @param[out] rhs The second part of @p self indexed as [@p i; `self.len`). 858 | * 859 | * @pre `i <= self.len` 860 | * @pre `lhs != NULL` 861 | * @pre `rhs != NULL` 862 | * @pre `self.len` and @p i must be representable as `ptrdiff_t`. 863 | */ 864 | inline static void 865 | Slice99_split_at(Slice99 self, size_t i, Slice99 *restrict lhs, Slice99 *restrict rhs) { 866 | SLICE99_ASSERT(i <= self.len); 867 | SLICE99_ASSERT(lhs); 868 | SLICE99_ASSERT(rhs); 869 | 870 | *lhs = Slice99_sub(self, 0, (ptrdiff_t)i); 871 | *rhs = Slice99_sub(self, (ptrdiff_t)i, (ptrdiff_t)self.len); 872 | } 873 | 874 | /** 875 | * Copies @p self to @p out and appends '\0' to the end. 876 | * 877 | * @param[in] self The slice that will be copied. 878 | * @param[in] out The memory area to which @p self and the null character will be copied. 879 | * 880 | * @return The pointer @p out. 881 | * 882 | * @pre @p out must be capable of writing `Slice99_size(self) + 1` bytes. 883 | * @pre @p out must not overlap with @p self. 884 | */ 885 | inline static char *Slice99_c_str(Slice99 self, char out[restrict]) { 886 | SLICE99_ASSERT(out); 887 | 888 | SLICE99_MEMCPY(out, self.ptr, Slice99_size(self)); 889 | out[Slice99_size(self)] = '\0'; 890 | return out; 891 | } 892 | 893 | SLICE99_DEF_TYPED(CharSlice99, char); 894 | SLICE99_DEF_TYPED(SCharSlice99, signed char); 895 | SLICE99_DEF_TYPED(UCharSlice99, unsigned char); 896 | 897 | SLICE99_DEF_TYPED(ShortSlice99, short); 898 | SLICE99_DEF_TYPED(UShortSlice99, unsigned short); 899 | 900 | SLICE99_DEF_TYPED(IntSlice99, int); 901 | SLICE99_DEF_TYPED(UIntSlice99, unsigned int); 902 | 903 | SLICE99_DEF_TYPED(LongSlice99, long); 904 | SLICE99_DEF_TYPED(ULongSlice99, unsigned long); 905 | SLICE99_DEF_TYPED(LongLongSlice99, long long); 906 | SLICE99_DEF_TYPED(ULongLongSlice99, unsigned long long); 907 | 908 | SLICE99_DEF_TYPED(FloatSlice99, float); 909 | SLICE99_DEF_TYPED(DoubleSlice99, double); 910 | SLICE99_DEF_TYPED(LongDoubleSlice99, long double); 911 | 912 | SLICE99_DEF_TYPED(BoolSlice99, _Bool); 913 | 914 | // Unsigned integers { 915 | #ifdef UINT8_MAX 916 | SLICE99_DEF_TYPED(U8Slice99, uint8_t); 917 | #endif 918 | 919 | #ifdef UINT16_MAX 920 | SLICE99_DEF_TYPED(U16Slice99, uint16_t); 921 | #endif 922 | 923 | #ifdef UINT32_MAX 924 | SLICE99_DEF_TYPED(U32Slice99, uint32_t); 925 | #endif 926 | 927 | #ifdef UINT64_MAX 928 | SLICE99_DEF_TYPED(U64Slice99, uint64_t); 929 | #endif 930 | // } (Unsigned integers) 931 | 932 | // Signed integers { 933 | #ifdef INT8_MAX 934 | SLICE99_DEF_TYPED(I8Slice99, int8_t); 935 | #endif 936 | 937 | #ifdef INT16_MAX 938 | SLICE99_DEF_TYPED(I16Slice99, int16_t); 939 | #endif 940 | 941 | #ifdef INT32_MAX 942 | SLICE99_DEF_TYPED(I32Slice99, int32_t); 943 | #endif 944 | 945 | #ifdef INT64_MAX 946 | SLICE99_DEF_TYPED(I64Slice99, int64_t); 947 | #endif 948 | // } (Signed integers) 949 | 950 | /** 951 | * The same as #Slice99_from_str. 952 | */ 953 | inline static SLICE99_WARN_UNUSED_RESULT CharSlice99 CharSlice99_from_str(char *str) { 954 | return (CharSlice99)SLICE99_TO_TYPED(Slice99_from_str(str)); 955 | } 956 | 957 | /** 958 | * The same as #Slice99_c_str. 959 | */ 960 | inline static char *CharSlice99_c_str(CharSlice99 self, char out[restrict]) { 961 | return Slice99_c_str(SLICE99_TO_UNTYPED(self), out); 962 | } 963 | 964 | /** 965 | * Makes a null-terminated string out of `CharSlice99` using `alloca`. 966 | * 967 | * The same as #CharSlice99_c_str, except that the second parameter is allocated using `alloca`. Do 968 | * not use this macro for big strings to avoid stack overflow. 969 | */ 970 | #define CharSlice99_alloca_c_str(self) CharSlice99_c_str((self), alloca((self).len + 1)) 971 | 972 | #ifndef SLICE99_DISABLE_STDIO 973 | 974 | #ifndef SLICE99_VSPRINTF 975 | #include 976 | /// Like `vsprintf`. Defined only if it has not been defined previously **and** 977 | /// `SLICE99_DISABLE_STDIO` is **not** defined. 978 | #define SLICE99_VSPRINTF vsprintf 979 | #endif 980 | 981 | #ifndef SLICE99_VSNPRINTF 982 | #include 983 | /// Like `vsnprintf`. Defined only if it has not been defined previously **and** 984 | /// `SLICE99_DISABLE_STDIO` is **not** defined. 985 | #define SLICE99_VSNPRINTF vsnprintf 986 | #endif 987 | 988 | #ifndef SLICE99_SNPRINTF 989 | #include 990 | /// Like `snprintf`. Defined only if it has not been defined previously **and** 991 | /// `SLICE99_DISABLE_STDIO` is **not** defined. 992 | #define SLICE99_SNPRINTF snprintf 993 | #endif 994 | 995 | #ifndef DOXYGEN_IGNORE 996 | 997 | // Doxygen fails to parse function declarations with function-like macro invocations. 998 | 999 | #define SLICE99_FORMAT_HINT_2_0 SLICE99_FORMAT_HINT(printf, 2, 0) 1000 | #define SLICE99_FORMAT_HINT_2_3 SLICE99_FORMAT_HINT(printf, 2, 3) 1001 | #define SLICE99_FORMAT_HINT_3_0 SLICE99_FORMAT_HINT(printf, 3, 0) 1002 | #define SLICE99_FORMAT_HINT_3_4 SLICE99_FORMAT_HINT(printf, 3, 4) 1003 | 1004 | #endif // DOXYGEN_IGNORE 1005 | 1006 | /** 1007 | * Prints a formatted string to @p out and returns the corresponding character slice. 1008 | * 1009 | * Defined only if `SLICE99_DISABLE_STDIO` is **not** defined. 1010 | * 1011 | * @param[out] out The buffer that must be capable of holding all characters that will be written by 1012 | * #SLICE99_VSPRINTF. 1013 | * @param[in] fmt The `printf`-like format string. 1014 | * @param[in] list The variadic function arguments reified into `va_list`. 1015 | * 1016 | * @return A character slice constructed from @p out. 1017 | * 1018 | * @pre `out != NULL` 1019 | * @pre `fmt != NULL` 1020 | */ 1021 | inline static SLICE99_WARN_UNUSED_RESULT SLICE99_FORMAT_HINT_2_0 CharSlice99 1022 | CharSlice99_vfmt(char out[restrict], const char *restrict fmt, va_list list) { 1023 | SLICE99_ASSERT(out); 1024 | SLICE99_ASSERT(fmt); 1025 | 1026 | SLICE99_VSPRINTF(out, fmt, list); 1027 | return CharSlice99_from_str(out); 1028 | } 1029 | 1030 | /** 1031 | * The #CharSlice99_vfmt twin. 1032 | * 1033 | * Defined only if `SLICE99_DISABLE_STDIO` is **not** defined. 1034 | */ 1035 | inline static SLICE99_WARN_UNUSED_RESULT SLICE99_FORMAT_HINT_2_3 CharSlice99 1036 | CharSlice99_fmt(char out[restrict], const char *restrict fmt, ...) { 1037 | va_list ap; 1038 | va_start(ap, fmt); 1039 | const CharSlice99 result = CharSlice99_vfmt(out, fmt, ap); 1040 | va_end(ap); 1041 | return result; 1042 | } 1043 | 1044 | /** 1045 | * The same as #CharSlice99_vfmt but writes at most `bufsz - 1` characters. 1046 | * 1047 | * Defined only if `SLICE99_DISABLE_STDIO` is **not** defined. 1048 | */ 1049 | inline static SLICE99_WARN_UNUSED_RESULT SLICE99_FORMAT_HINT_3_0 CharSlice99 1050 | CharSlice99_vnfmt(char out[restrict], size_t bufsz, const char *restrict fmt, va_list list) { 1051 | SLICE99_VSNPRINTF(out, bufsz, fmt, list); 1052 | return CharSlice99_from_str(out); 1053 | } 1054 | 1055 | /** 1056 | * The #CharSlice99_vnfmt twin. 1057 | * 1058 | * Defined only if `SLICE99_DISABLE_STDIO` is **not** defined. 1059 | */ 1060 | inline static SLICE99_WARN_UNUSED_RESULT SLICE99_FORMAT_HINT_3_4 CharSlice99 1061 | CharSlice99_nfmt(char out[restrict], size_t bufsz, const char *restrict fmt, ...) { 1062 | va_list ap; 1063 | va_start(ap, fmt); 1064 | const CharSlice99 result = CharSlice99_vnfmt(out, bufsz, fmt, ap); 1065 | va_end(ap); 1066 | return result; 1067 | } 1068 | 1069 | #ifndef DOXYGEN_IGNORE 1070 | 1071 | #undef SLICE99_FORMAT_HINT_2_0 1072 | #undef SLICE99_FORMAT_HINT_2_3 1073 | #undef SLICE99_FORMAT_HINT_3_0 1074 | #undef SLICE99_FORMAT_HINT_3_4 1075 | 1076 | #endif // DOXYGEN_IGNORE 1077 | 1078 | /** 1079 | * Printfs a formatted string to a character slice using `alloca`. 1080 | * 1081 | * The same as #CharSlice99_fmt, except that the first parameter is allocated using `alloca`. Do not 1082 | * use this macro for big strings to avoid stack overflow. 1083 | * 1084 | * Defined only if `SLICE99_DISABLE_STDIO` is **not** defined. 1085 | */ 1086 | #define CharSlice99_alloca_fmt(fmt, ...) \ 1087 | CharSlice99_fmt(alloca(SLICE99_SNPRINTF(NULL, 0, (fmt), __VA_ARGS__) + 1), (fmt), __VA_ARGS__) 1088 | 1089 | #endif // SLICE99_DISABLE_STDIO 1090 | 1091 | #endif // SLICE99_H 1092 | -------------------------------------------------------------------------------- /Doxyfile: -------------------------------------------------------------------------------- 1 | # Doxyfile 1.8.13 2 | 3 | # This file describes the settings to be used by the documentation system 4 | # doxygen (www.doxygen.org) for a project. 5 | # 6 | # All text after a double hash (##) is considered a comment and is placed in 7 | # front of the TAG it is preceding. 8 | # 9 | # All text after a single hash (#) is considered a comment and will be ignored. 10 | # The format is: 11 | # TAG = value [value, ...] 12 | # For lists, items can also be appended using: 13 | # TAG += value [value, ...] 14 | # Values that contain spaces should be placed between quotes (\" \"). 15 | 16 | #--------------------------------------------------------------------------- 17 | # Project related configuration options 18 | #--------------------------------------------------------------------------- 19 | 20 | # This tag specifies the encoding used for all characters in the config file 21 | # that follow. The default is UTF-8 which is also the encoding used for all text 22 | # before the first occurrence of this tag. Doxygen uses libiconv (or the iconv 23 | # built into libc) for the transcoding. See http://www.gnu.org/software/libiconv 24 | # for the list of possible encodings. 25 | # The default value is: UTF-8. 26 | 27 | DOXYFILE_ENCODING = UTF-8 28 | 29 | # The PROJECT_NAME tag is a single word (or a sequence of words surrounded by 30 | # double-quotes, unless you are using Doxywizard) that should identify the 31 | # project for which the documentation is generated. This name is used in the 32 | # title of most generated pages and in a few other places. 33 | # The default value is: My Project. 34 | 35 | PROJECT_NAME = "Slice99" 36 | 37 | # The PROJECT_NUMBER tag can be used to enter a project or revision number. This 38 | # could be handy for archiving the generated documentation or if some version 39 | # control system is used. 40 | 41 | PROJECT_NUMBER = 0.7.8 42 | 43 | # Using the PROJECT_BRIEF tag one can provide an optional one line description 44 | # for a project that appears at the top of each page and should give viewer a 45 | # quick idea about the purpose of the project. Keep the description short. 46 | 47 | PROJECT_BRIEF = "Memory slices for C99" 48 | 49 | # With the PROJECT_LOGO tag one can specify a logo or an icon that is included 50 | # in the documentation. The maximum height of the logo should not exceed 55 51 | # pixels and the maximum width should not exceed 200 pixels. Doxygen will copy 52 | # the logo to the output directory. 53 | 54 | PROJECT_LOGO = 55 | 56 | # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path 57 | # into which the generated documentation will be written. If a relative path is 58 | # entered, it will be relative to the location where doxygen was started. If 59 | # left blank the current directory will be used. 60 | 61 | OUTPUT_DIRECTORY = 62 | 63 | # If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- 64 | # directories (in 2 levels) under the output directory of each output format and 65 | # will distribute the generated files over these directories. Enabling this 66 | # option can be useful when feeding doxygen a huge amount of source files, where 67 | # putting all generated files in the same directory would otherwise causes 68 | # performance problems for the file system. 69 | # The default value is: NO. 70 | 71 | CREATE_SUBDIRS = NO 72 | 73 | # If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII 74 | # characters to appear in the names of generated files. If set to NO, non-ASCII 75 | # characters will be escaped, for example _xE3_x81_x84 will be used for Unicode 76 | # U+3044. 77 | # The default value is: NO. 78 | 79 | ALLOW_UNICODE_NAMES = NO 80 | 81 | # The OUTPUT_LANGUAGE tag is used to specify the language in which all 82 | # documentation generated by doxygen is written. Doxygen will use this 83 | # information to generate all constant output in the proper language. 84 | # Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, 85 | # Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), 86 | # Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, 87 | # Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), 88 | # Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, 89 | # Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, 90 | # Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, 91 | # Ukrainian and Vietnamese. 92 | # The default value is: English. 93 | 94 | OUTPUT_LANGUAGE = English 95 | 96 | # If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member 97 | # descriptions after the members that are listed in the file and class 98 | # documentation (similar to Javadoc). Set to NO to disable this. 99 | # The default value is: YES. 100 | 101 | BRIEF_MEMBER_DESC = YES 102 | 103 | # If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief 104 | # description of a member or function before the detailed description 105 | # 106 | # Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 107 | # brief descriptions will be completely suppressed. 108 | # The default value is: YES. 109 | 110 | REPEAT_BRIEF = YES 111 | 112 | # This tag implements a quasi-intelligent brief description abbreviator that is 113 | # used to form the text in various listings. Each string in this list, if found 114 | # as the leading text of the brief description, will be stripped from the text 115 | # and the result, after processing the whole list, is used as the annotated 116 | # text. Otherwise, the brief description is used as-is. If left blank, the 117 | # following values are used ($name is automatically replaced with the name of 118 | # the entity):The $name class, The $name widget, The $name file, is, provides, 119 | # specifies, contains, represents, a, an and the. 120 | 121 | ABBREVIATE_BRIEF = "The $name class" \ 122 | "The $name widget" \ 123 | "The $name file" \ 124 | is \ 125 | provides \ 126 | specifies \ 127 | contains \ 128 | represents \ 129 | a \ 130 | an \ 131 | the 132 | 133 | # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 134 | # doxygen will generate a detailed section even if there is only a brief 135 | # description. 136 | # The default value is: NO. 137 | 138 | ALWAYS_DETAILED_SEC = NO 139 | 140 | # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all 141 | # inherited members of a class in the documentation of that class as if those 142 | # members were ordinary class members. Constructors, destructors and assignment 143 | # operators of the base classes will not be shown. 144 | # The default value is: NO. 145 | 146 | INLINE_INHERITED_MEMB = NO 147 | 148 | # If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path 149 | # before files name in the file list and in the header files. If set to NO the 150 | # shortest path that makes the file name unique will be used 151 | # The default value is: YES. 152 | 153 | FULL_PATH_NAMES = YES 154 | 155 | # The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. 156 | # Stripping is only done if one of the specified strings matches the left-hand 157 | # part of the path. The tag can be used to show relative paths in the file list. 158 | # If left blank the directory from which doxygen is run is used as the path to 159 | # strip. 160 | # 161 | # Note that you can specify absolute paths here, but also relative paths, which 162 | # will be relative from the directory where doxygen is started. 163 | # This tag requires that the tag FULL_PATH_NAMES is set to YES. 164 | 165 | STRIP_FROM_PATH = 166 | 167 | # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the 168 | # path mentioned in the documentation of a class, which tells the reader which 169 | # header file to include in order to use a class. If left blank only the name of 170 | # the header file containing the class definition is used. Otherwise one should 171 | # specify the list of include paths that are normally passed to the compiler 172 | # using the -I flag. 173 | 174 | STRIP_FROM_INC_PATH = 175 | 176 | # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but 177 | # less readable) file names. This can be useful is your file systems doesn't 178 | # support long names like on DOS, Mac, or CD-ROM. 179 | # The default value is: NO. 180 | 181 | SHORT_NAMES = NO 182 | 183 | # If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the 184 | # first line (until the first dot) of a Javadoc-style comment as the brief 185 | # description. If set to NO, the Javadoc-style will behave just like regular Qt- 186 | # style comments (thus requiring an explicit @brief command for a brief 187 | # description.) 188 | # The default value is: NO. 189 | 190 | JAVADOC_AUTOBRIEF = YES 191 | 192 | # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first 193 | # line (until the first dot) of a Qt-style comment as the brief description. If 194 | # set to NO, the Qt-style will behave just like regular Qt-style comments (thus 195 | # requiring an explicit \brief command for a brief description.) 196 | # The default value is: NO. 197 | 198 | QT_AUTOBRIEF = NO 199 | 200 | # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a 201 | # multi-line C++ special comment block (i.e. a block of //! or /// comments) as 202 | # a brief description. This used to be the default behavior. The new default is 203 | # to treat a multi-line C++ comment block as a detailed description. Set this 204 | # tag to YES if you prefer the old behavior instead. 205 | # 206 | # Note that setting this tag to YES also means that rational rose comments are 207 | # not recognized any more. 208 | # The default value is: NO. 209 | 210 | MULTILINE_CPP_IS_BRIEF = NO 211 | 212 | # If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the 213 | # documentation from any documented member that it re-implements. 214 | # The default value is: YES. 215 | 216 | INHERIT_DOCS = YES 217 | 218 | # If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new 219 | # page for each member. If set to NO, the documentation of a member will be part 220 | # of the file/class/namespace that contains it. 221 | # The default value is: NO. 222 | 223 | SEPARATE_MEMBER_PAGES = NO 224 | 225 | # The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen 226 | # uses this value to replace tabs by spaces in code fragments. 227 | # Minimum value: 1, maximum value: 16, default value: 4. 228 | 229 | TAB_SIZE = 4 230 | 231 | # This tag can be used to specify a number of aliases that act as commands in 232 | # the documentation. An alias has the form: 233 | # name=value 234 | # For example adding 235 | # "sideeffect=@par Side Effects:\n" 236 | # will allow you to put the command \sideeffect (or @sideeffect) in the 237 | # documentation, which will result in a user-defined paragraph with heading 238 | # "Side Effects:". You can put \n's in the value part of an alias to insert 239 | # newlines. 240 | 241 | ALIASES = 242 | 243 | # This tag can be used to specify a number of word-keyword mappings (TCL only). 244 | # A mapping has the form "name=value". For example adding "class=itcl::class" 245 | # will allow you to use the command class in the itcl::class meaning. 246 | 247 | TCL_SUBST = 248 | 249 | # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources 250 | # only. Doxygen will then generate output that is more tailored for C. For 251 | # instance, some of the names that are used will be different. The list of all 252 | # members will be omitted, etc. 253 | # The default value is: NO. 254 | 255 | OPTIMIZE_OUTPUT_FOR_C = YES 256 | 257 | # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or 258 | # Python sources only. Doxygen will then generate output that is more tailored 259 | # for that language. For instance, namespaces will be presented as packages, 260 | # qualified scopes will look different, etc. 261 | # The default value is: NO. 262 | 263 | OPTIMIZE_OUTPUT_JAVA = NO 264 | 265 | # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran 266 | # sources. Doxygen will then generate output that is tailored for Fortran. 267 | # The default value is: NO. 268 | 269 | OPTIMIZE_FOR_FORTRAN = NO 270 | 271 | # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL 272 | # sources. Doxygen will then generate output that is tailored for VHDL. 273 | # The default value is: NO. 274 | 275 | OPTIMIZE_OUTPUT_VHDL = NO 276 | 277 | # Doxygen selects the parser to use depending on the extension of the files it 278 | # parses. With this tag you can assign which parser to use for a given 279 | # extension. Doxygen has a built-in mapping, but you can override or extend it 280 | # using this tag. The format is ext=language, where ext is a file extension, and 281 | # language is one of the parsers supported by doxygen: IDL, Java, Javascript, 282 | # C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: 283 | # FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: 284 | # Fortran. In the later case the parser tries to guess whether the code is fixed 285 | # or free formatted code, this is the default for Fortran type files), VHDL. For 286 | # instance to make doxygen treat .inc files as Fortran files (default is PHP), 287 | # and .f files as C (default is Fortran), use: inc=Fortran f=C. 288 | # 289 | # Note: For files without extension you can use no_extension as a placeholder. 290 | # 291 | # Note that for custom extensions you also need to set FILE_PATTERNS otherwise 292 | # the files are not read by doxygen. 293 | 294 | EXTENSION_MAPPING = 295 | 296 | # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments 297 | # according to the Markdown format, which allows for more readable 298 | # documentation. See http://daringfireball.net/projects/markdown/ for details. 299 | # The output of markdown processing is further processed by doxygen, so you can 300 | # mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in 301 | # case of backward compatibilities issues. 302 | # The default value is: YES. 303 | 304 | MARKDOWN_SUPPORT = YES 305 | 306 | # When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up 307 | # to that level are automatically included in the table of contents, even if 308 | # they do not have an id attribute. 309 | # Note: This feature currently applies only to Markdown headings. 310 | # Minimum value: 0, maximum value: 99, default value: 0. 311 | # This tag requires that the tag MARKDOWN_SUPPORT is set to YES. 312 | 313 | TOC_INCLUDE_HEADINGS = 0 314 | 315 | # When enabled doxygen tries to link words that correspond to documented 316 | # classes, or namespaces to their corresponding documentation. Such a link can 317 | # be prevented in individual cases by putting a % sign in front of the word or 318 | # globally by setting AUTOLINK_SUPPORT to NO. 319 | # The default value is: YES. 320 | 321 | AUTOLINK_SUPPORT = YES 322 | 323 | # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want 324 | # to include (a tag file for) the STL sources as input, then you should set this 325 | # tag to YES in order to let doxygen match functions declarations and 326 | # definitions whose arguments contain STL classes (e.g. func(std::string); 327 | # versus func(std::string) {}). This also make the inheritance and collaboration 328 | # diagrams that involve STL classes more complete and accurate. 329 | # The default value is: NO. 330 | 331 | BUILTIN_STL_SUPPORT = NO 332 | 333 | # If you use Microsoft's C++/CLI language, you should set this option to YES to 334 | # enable parsing support. 335 | # The default value is: NO. 336 | 337 | CPP_CLI_SUPPORT = NO 338 | 339 | # Set the SIP_SUPPORT tag to YES if your project consists of sip (see: 340 | # http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen 341 | # will parse them like normal C++ but will assume all classes use public instead 342 | # of private inheritance when no explicit protection keyword is present. 343 | # The default value is: NO. 344 | 345 | SIP_SUPPORT = NO 346 | 347 | # For Microsoft's IDL there are propget and propput attributes to indicate 348 | # getter and setter methods for a property. Setting this option to YES will make 349 | # doxygen to replace the get and set methods by a property in the documentation. 350 | # This will only work if the methods are indeed getting or setting a simple 351 | # type. If this is not the case, or you want to show the methods anyway, you 352 | # should set this option to NO. 353 | # The default value is: YES. 354 | 355 | IDL_PROPERTY_SUPPORT = YES 356 | 357 | # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 358 | # tag is set to YES then doxygen will reuse the documentation of the first 359 | # member in the group (if any) for the other members of the group. By default 360 | # all members of a group must be documented explicitly. 361 | # The default value is: NO. 362 | 363 | DISTRIBUTE_GROUP_DOC = NO 364 | 365 | # If one adds a struct or class to a group and this option is enabled, then also 366 | # any nested class or struct is added to the same group. By default this option 367 | # is disabled and one has to add nested compounds explicitly via \ingroup. 368 | # The default value is: NO. 369 | 370 | GROUP_NESTED_COMPOUNDS = NO 371 | 372 | # Set the SUBGROUPING tag to YES to allow class member groups of the same type 373 | # (for instance a group of public functions) to be put as a subgroup of that 374 | # type (e.g. under the Public Functions section). Set it to NO to prevent 375 | # subgrouping. Alternatively, this can be done per class using the 376 | # \nosubgrouping command. 377 | # The default value is: YES. 378 | 379 | SUBGROUPING = YES 380 | 381 | # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions 382 | # are shown inside the group in which they are included (e.g. using \ingroup) 383 | # instead of on a separate page (for HTML and Man pages) or section (for LaTeX 384 | # and RTF). 385 | # 386 | # Note that this feature does not work in combination with 387 | # SEPARATE_MEMBER_PAGES. 388 | # The default value is: NO. 389 | 390 | INLINE_GROUPED_CLASSES = NO 391 | 392 | # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions 393 | # with only public data fields or simple typedef fields will be shown inline in 394 | # the documentation of the scope in which they are defined (i.e. file, 395 | # namespace, or group documentation), provided this scope is documented. If set 396 | # to NO, structs, classes, and unions are shown on a separate page (for HTML and 397 | # Man pages) or section (for LaTeX and RTF). 398 | # The default value is: NO. 399 | 400 | INLINE_SIMPLE_STRUCTS = NO 401 | 402 | # When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or 403 | # enum is documented as struct, union, or enum with the name of the typedef. So 404 | # typedef struct TypeS {} TypeT, will appear in the documentation as a struct 405 | # with name TypeT. When disabled the typedef will appear as a member of a file, 406 | # namespace, or class. And the struct will be named TypeS. This can typically be 407 | # useful for C code in case the coding convention dictates that all compound 408 | # types are typedef'ed and only the typedef is referenced, never the tag name. 409 | # The default value is: NO. 410 | 411 | TYPEDEF_HIDES_STRUCT = NO 412 | 413 | # The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This 414 | # cache is used to resolve symbols given their name and scope. Since this can be 415 | # an expensive process and often the same symbol appears multiple times in the 416 | # code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small 417 | # doxygen will become slower. If the cache is too large, memory is wasted. The 418 | # cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range 419 | # is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 420 | # symbols. At the end of a run doxygen will report the cache usage and suggest 421 | # the optimal cache size from a speed point of view. 422 | # Minimum value: 0, maximum value: 9, default value: 0. 423 | 424 | LOOKUP_CACHE_SIZE = 0 425 | 426 | #--------------------------------------------------------------------------- 427 | # Build related configuration options 428 | #--------------------------------------------------------------------------- 429 | 430 | # If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in 431 | # documentation are documented, even if no documentation was available. Private 432 | # class members and static file members will be hidden unless the 433 | # EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. 434 | # Note: This will also disable the warnings about undocumented members that are 435 | # normally produced when WARNINGS is set to YES. 436 | # The default value is: NO. 437 | 438 | EXTRACT_ALL = NO 439 | 440 | # If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will 441 | # be included in the documentation. 442 | # The default value is: NO. 443 | 444 | EXTRACT_PRIVATE = NO 445 | 446 | # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal 447 | # scope will be included in the documentation. 448 | # The default value is: NO. 449 | 450 | EXTRACT_PACKAGE = NO 451 | 452 | # If the EXTRACT_STATIC tag is set to YES, all static members of a file will be 453 | # included in the documentation. 454 | # The default value is: NO. 455 | 456 | EXTRACT_STATIC = YES 457 | 458 | # If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined 459 | # locally in source files will be included in the documentation. If set to NO, 460 | # only classes defined in header files are included. Does not have any effect 461 | # for Java sources. 462 | # The default value is: YES. 463 | 464 | EXTRACT_LOCAL_CLASSES = YES 465 | 466 | # This flag is only useful for Objective-C code. If set to YES, local methods, 467 | # which are defined in the implementation section but not in the interface are 468 | # included in the documentation. If set to NO, only methods in the interface are 469 | # included. 470 | # The default value is: NO. 471 | 472 | EXTRACT_LOCAL_METHODS = NO 473 | 474 | # If this flag is set to YES, the members of anonymous namespaces will be 475 | # extracted and appear in the documentation as a namespace called 476 | # 'anonymous_namespace{file}', where file will be replaced with the base name of 477 | # the file that contains the anonymous namespace. By default anonymous namespace 478 | # are hidden. 479 | # The default value is: NO. 480 | 481 | EXTRACT_ANON_NSPACES = NO 482 | 483 | # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all 484 | # undocumented members inside documented classes or files. If set to NO these 485 | # members will be included in the various overviews, but no documentation 486 | # section is generated. This option has no effect if EXTRACT_ALL is enabled. 487 | # The default value is: NO. 488 | 489 | HIDE_UNDOC_MEMBERS = NO 490 | 491 | # If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all 492 | # undocumented classes that are normally visible in the class hierarchy. If set 493 | # to NO, these classes will be included in the various overviews. This option 494 | # has no effect if EXTRACT_ALL is enabled. 495 | # The default value is: NO. 496 | 497 | HIDE_UNDOC_CLASSES = NO 498 | 499 | # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend 500 | # (class|struct|union) declarations. If set to NO, these declarations will be 501 | # included in the documentation. 502 | # The default value is: NO. 503 | 504 | HIDE_FRIEND_COMPOUNDS = NO 505 | 506 | # If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any 507 | # documentation blocks found inside the body of a function. If set to NO, these 508 | # blocks will be appended to the function's detailed documentation block. 509 | # The default value is: NO. 510 | 511 | HIDE_IN_BODY_DOCS = NO 512 | 513 | # The INTERNAL_DOCS tag determines if documentation that is typed after a 514 | # \internal command is included. If the tag is set to NO then the documentation 515 | # will be excluded. Set it to YES to include the internal documentation. 516 | # The default value is: NO. 517 | 518 | INTERNAL_DOCS = NO 519 | 520 | # If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file 521 | # names in lower-case letters. If set to YES, upper-case letters are also 522 | # allowed. This is useful if you have classes or files whose names only differ 523 | # in case and if your file system supports case sensitive file names. Windows 524 | # and Mac users are advised to set this option to NO. 525 | # The default value is: system dependent. 526 | 527 | CASE_SENSE_NAMES = YES 528 | 529 | # If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with 530 | # their full class and namespace scopes in the documentation. If set to YES, the 531 | # scope will be hidden. 532 | # The default value is: NO. 533 | 534 | HIDE_SCOPE_NAMES = NO 535 | 536 | # If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will 537 | # append additional text to a page's title, such as Class Reference. If set to 538 | # YES the compound reference will be hidden. 539 | # The default value is: NO. 540 | 541 | HIDE_COMPOUND_REFERENCE= NO 542 | 543 | # If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of 544 | # the files that are included by a file in the documentation of that file. 545 | # The default value is: YES. 546 | 547 | SHOW_INCLUDE_FILES = NO 548 | 549 | # If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each 550 | # grouped member an include statement to the documentation, telling the reader 551 | # which file to include in order to use the member. 552 | # The default value is: NO. 553 | 554 | SHOW_GROUPED_MEMB_INC = NO 555 | 556 | # If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include 557 | # files with double quotes in the documentation rather than with sharp brackets. 558 | # The default value is: NO. 559 | 560 | FORCE_LOCAL_INCLUDES = NO 561 | 562 | # If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the 563 | # documentation for inline members. 564 | # The default value is: YES. 565 | 566 | INLINE_INFO = YES 567 | 568 | # If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the 569 | # (detailed) documentation of file and class members alphabetically by member 570 | # name. If set to NO, the members will appear in declaration order. 571 | # The default value is: YES. 572 | 573 | SORT_MEMBER_DOCS = YES 574 | 575 | # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief 576 | # descriptions of file, namespace and class members alphabetically by member 577 | # name. If set to NO, the members will appear in declaration order. Note that 578 | # this will also influence the order of the classes in the class list. 579 | # The default value is: NO. 580 | 581 | SORT_BRIEF_DOCS = NO 582 | 583 | # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the 584 | # (brief and detailed) documentation of class members so that constructors and 585 | # destructors are listed first. If set to NO the constructors will appear in the 586 | # respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. 587 | # Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief 588 | # member documentation. 589 | # Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting 590 | # detailed member documentation. 591 | # The default value is: NO. 592 | 593 | SORT_MEMBERS_CTORS_1ST = NO 594 | 595 | # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy 596 | # of group names into alphabetical order. If set to NO the group names will 597 | # appear in their defined order. 598 | # The default value is: NO. 599 | 600 | SORT_GROUP_NAMES = NO 601 | 602 | # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by 603 | # fully-qualified names, including namespaces. If set to NO, the class list will 604 | # be sorted only by class name, not including the namespace part. 605 | # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. 606 | # Note: This option applies only to the class list, not to the alphabetical 607 | # list. 608 | # The default value is: NO. 609 | 610 | SORT_BY_SCOPE_NAME = NO 611 | 612 | # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper 613 | # type resolution of all parameters of a function it will reject a match between 614 | # the prototype and the implementation of a member function even if there is 615 | # only one candidate or it is obvious which candidate to choose by doing a 616 | # simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still 617 | # accept a match between prototype and implementation in such cases. 618 | # The default value is: NO. 619 | 620 | STRICT_PROTO_MATCHING = NO 621 | 622 | # The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo 623 | # list. This list is created by putting \todo commands in the documentation. 624 | # The default value is: YES. 625 | 626 | GENERATE_TODOLIST = YES 627 | 628 | # The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test 629 | # list. This list is created by putting \test commands in the documentation. 630 | # The default value is: YES. 631 | 632 | GENERATE_TESTLIST = YES 633 | 634 | # The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug 635 | # list. This list is created by putting \bug commands in the documentation. 636 | # The default value is: YES. 637 | 638 | GENERATE_BUGLIST = YES 639 | 640 | # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) 641 | # the deprecated list. This list is created by putting \deprecated commands in 642 | # the documentation. 643 | # The default value is: YES. 644 | 645 | GENERATE_DEPRECATEDLIST= YES 646 | 647 | # The ENABLED_SECTIONS tag can be used to enable conditional documentation 648 | # sections, marked by \if ... \endif and \cond 649 | # ... \endcond blocks. 650 | 651 | ENABLED_SECTIONS = 652 | 653 | # The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the 654 | # initial value of a variable or macro / define can have for it to appear in the 655 | # documentation. If the initializer consists of more lines than specified here 656 | # it will be hidden. Use a value of 0 to hide initializers completely. The 657 | # appearance of the value of individual variables and macros / defines can be 658 | # controlled using \showinitializer or \hideinitializer command in the 659 | # documentation regardless of this setting. 660 | # Minimum value: 0, maximum value: 10000, default value: 30. 661 | 662 | MAX_INITIALIZER_LINES = 30 663 | 664 | # Set the SHOW_USED_FILES tag to NO to disable the list of files generated at 665 | # the bottom of the documentation of classes and structs. If set to YES, the 666 | # list will mention the files that were used to generate the documentation. 667 | # The default value is: YES. 668 | 669 | SHOW_USED_FILES = YES 670 | 671 | # Set the SHOW_FILES tag to NO to disable the generation of the Files page. This 672 | # will remove the Files entry from the Quick Index and from the Folder Tree View 673 | # (if specified). 674 | # The default value is: YES. 675 | 676 | SHOW_FILES = YES 677 | 678 | # Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces 679 | # page. This will remove the Namespaces entry from the Quick Index and from the 680 | # Folder Tree View (if specified). 681 | # The default value is: YES. 682 | 683 | SHOW_NAMESPACES = YES 684 | 685 | # The FILE_VERSION_FILTER tag can be used to specify a program or script that 686 | # doxygen should invoke to get the current version for each file (typically from 687 | # the version control system). Doxygen will invoke the program by executing (via 688 | # popen()) the command command input-file, where command is the value of the 689 | # FILE_VERSION_FILTER tag, and input-file is the name of an input file provided 690 | # by doxygen. Whatever the program writes to standard output is used as the file 691 | # version. For an example see the documentation. 692 | 693 | FILE_VERSION_FILTER = 694 | 695 | # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed 696 | # by doxygen. The layout file controls the global structure of the generated 697 | # output files in an output format independent way. To create the layout file 698 | # that represents doxygen's defaults, run doxygen with the -l option. You can 699 | # optionally specify a file name after the option, if omitted DoxygenLayout.xml 700 | # will be used as the name of the layout file. 701 | # 702 | # Note that if you run doxygen from a directory containing a file called 703 | # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE 704 | # tag is left empty. 705 | 706 | LAYOUT_FILE = 707 | 708 | # The CITE_BIB_FILES tag can be used to specify one or more bib files containing 709 | # the reference definitions. This must be a list of .bib files. The .bib 710 | # extension is automatically appended if omitted. This requires the bibtex tool 711 | # to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. 712 | # For LaTeX the style of the bibliography can be controlled using 713 | # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the 714 | # search path. See also \cite for info how to create references. 715 | 716 | CITE_BIB_FILES = 717 | 718 | #--------------------------------------------------------------------------- 719 | # Configuration options related to warning and progress messages 720 | #--------------------------------------------------------------------------- 721 | 722 | # The QUIET tag can be used to turn on/off the messages that are generated to 723 | # standard output by doxygen. If QUIET is set to YES this implies that the 724 | # messages are off. 725 | # The default value is: NO. 726 | 727 | QUIET = NO 728 | 729 | # The WARNINGS tag can be used to turn on/off the warning messages that are 730 | # generated to standard error (stderr) by doxygen. If WARNINGS is set to YES 731 | # this implies that the warnings are on. 732 | # 733 | # Tip: Turn warnings on while writing the documentation. 734 | # The default value is: YES. 735 | 736 | WARNINGS = YES 737 | 738 | # If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate 739 | # warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag 740 | # will automatically be disabled. 741 | # The default value is: YES. 742 | 743 | WARN_IF_UNDOCUMENTED = NO 744 | 745 | # If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for 746 | # potential errors in the documentation, such as not documenting some parameters 747 | # in a documented function, or documenting parameters that don't exist or using 748 | # markup commands wrongly. 749 | # The default value is: YES. 750 | 751 | WARN_IF_DOC_ERROR = YES 752 | 753 | # This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that 754 | # are documented, but have no documentation for their parameters or return 755 | # value. If set to NO, doxygen will only warn about wrong or incomplete 756 | # parameter documentation, but not about the absence of documentation. 757 | # The default value is: NO. 758 | 759 | WARN_NO_PARAMDOC = NO 760 | 761 | # If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when 762 | # a warning is encountered. 763 | # The default value is: NO. 764 | 765 | WARN_AS_ERROR = NO 766 | 767 | # The WARN_FORMAT tag determines the format of the warning messages that doxygen 768 | # can produce. The string should contain the $file, $line, and $text tags, which 769 | # will be replaced by the file and line number from which the warning originated 770 | # and the warning text. Optionally the format may contain $version, which will 771 | # be replaced by the version of the file (if it could be obtained via 772 | # FILE_VERSION_FILTER) 773 | # The default value is: $file:$line: $text. 774 | 775 | WARN_FORMAT = "$file:$line: $text" 776 | 777 | # The WARN_LOGFILE tag can be used to specify a file to which warning and error 778 | # messages should be written. If left blank the output is written to standard 779 | # error (stderr). 780 | 781 | WARN_LOGFILE = 782 | 783 | #--------------------------------------------------------------------------- 784 | # Configuration options related to the input files 785 | #--------------------------------------------------------------------------- 786 | 787 | # The INPUT tag is used to specify the files and/or directories that contain 788 | # documented source files. You may enter file names like myfile.cpp or 789 | # directories like /usr/src/myproject. Separate the files or directories with 790 | # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING 791 | # Note: If this tag is empty the current directory is searched. 792 | 793 | INPUT = slice99.h 794 | 795 | # This tag can be used to specify the character encoding of the source files 796 | # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses 797 | # libiconv (or the iconv built into libc) for the transcoding. See the libiconv 798 | # documentation (see: http://www.gnu.org/software/libiconv) for the list of 799 | # possible encodings. 800 | # The default value is: UTF-8. 801 | 802 | INPUT_ENCODING = UTF-8 803 | 804 | # If the value of the INPUT tag contains directories, you can use the 805 | # FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and 806 | # *.h) to filter out the source-files in the directories. 807 | # 808 | # Note that for custom extensions or not directly supported extensions you also 809 | # need to set EXTENSION_MAPPING for the extension otherwise the files are not 810 | # read by doxygen. 811 | # 812 | # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, 813 | # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, 814 | # *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, 815 | # *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, 816 | # *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf and *.qsf. 817 | 818 | FILE_PATTERNS = *.c \ 819 | *.cc \ 820 | *.cxx \ 821 | *.cpp \ 822 | *.c++ \ 823 | *.java \ 824 | *.ii \ 825 | *.ixx \ 826 | *.ipp \ 827 | *.i++ \ 828 | *.inl \ 829 | *.idl \ 830 | *.ddl \ 831 | *.odl \ 832 | *.h \ 833 | *.hh \ 834 | *.hxx \ 835 | *.hpp \ 836 | *.h++ \ 837 | *.cs \ 838 | *.d \ 839 | *.php \ 840 | *.php4 \ 841 | *.php5 \ 842 | *.phtml \ 843 | *.inc \ 844 | *.m \ 845 | *.markdown \ 846 | *.md \ 847 | *.mm \ 848 | *.dox \ 849 | *.py \ 850 | *.pyw \ 851 | *.f90 \ 852 | *.f95 \ 853 | *.f03 \ 854 | *.f08 \ 855 | *.f \ 856 | *.for \ 857 | *.tcl \ 858 | *.vhd \ 859 | *.vhdl \ 860 | *.ucf \ 861 | *.qsf 862 | 863 | # The RECURSIVE tag can be used to specify whether or not subdirectories should 864 | # be searched for input files as well. 865 | # The default value is: NO. 866 | 867 | RECURSIVE = NO 868 | 869 | # The EXCLUDE tag can be used to specify files and/or directories that should be 870 | # excluded from the INPUT source files. This way you can easily exclude a 871 | # subdirectory from a directory tree whose root is specified with the INPUT tag. 872 | # 873 | # Note that relative paths are relative to the directory from which doxygen is 874 | # run. 875 | 876 | EXCLUDE = 877 | 878 | # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or 879 | # directories that are symbolic links (a Unix file system feature) are excluded 880 | # from the input. 881 | # The default value is: NO. 882 | 883 | EXCLUDE_SYMLINKS = NO 884 | 885 | # If the value of the INPUT tag contains directories, you can use the 886 | # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 887 | # certain files from those directories. 888 | # 889 | # Note that the wildcards are matched against the file with absolute path, so to 890 | # exclude all test directories for example use the pattern */test/* 891 | 892 | EXCLUDE_PATTERNS = 893 | 894 | # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names 895 | # (namespaces, classes, functions, etc.) that should be excluded from the 896 | # output. The symbol name can be a fully qualified name, a word, or if the 897 | # wildcard * is used, a substring. Examples: ANamespace, AClass, 898 | # AClass::ANamespace, ANamespace::*Test 899 | # 900 | # Note that the wildcards are matched against the file with absolute path, so to 901 | # exclude all test directories use the pattern */test/* 902 | 903 | EXCLUDE_SYMBOLS = 904 | 905 | # The EXAMPLE_PATH tag can be used to specify one or more files or directories 906 | # that contain example code fragments that are included (see the \include 907 | # command). 908 | 909 | EXAMPLE_PATH = 910 | 911 | # If the value of the EXAMPLE_PATH tag contains directories, you can use the 912 | # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and 913 | # *.h) to filter out the source-files in the directories. If left blank all 914 | # files are included. 915 | 916 | EXAMPLE_PATTERNS = * 917 | 918 | # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 919 | # searched for input files to be used with the \include or \dontinclude commands 920 | # irrespective of the value of the RECURSIVE tag. 921 | # The default value is: NO. 922 | 923 | EXAMPLE_RECURSIVE = NO 924 | 925 | # The IMAGE_PATH tag can be used to specify one or more files or directories 926 | # that contain images that are to be included in the documentation (see the 927 | # \image command). 928 | 929 | IMAGE_PATH = 930 | 931 | # The INPUT_FILTER tag can be used to specify a program that doxygen should 932 | # invoke to filter for each input file. Doxygen will invoke the filter program 933 | # by executing (via popen()) the command: 934 | # 935 | # 936 | # 937 | # where is the value of the INPUT_FILTER tag, and is the 938 | # name of an input file. Doxygen will then use the output that the filter 939 | # program writes to standard output. If FILTER_PATTERNS is specified, this tag 940 | # will be ignored. 941 | # 942 | # Note that the filter must not add or remove lines; it is applied before the 943 | # code is scanned, but not when the output code is generated. If lines are added 944 | # or removed, the anchors will not be placed correctly. 945 | # 946 | # Note that for custom extensions or not directly supported extensions you also 947 | # need to set EXTENSION_MAPPING for the extension otherwise the files are not 948 | # properly processed by doxygen. 949 | 950 | INPUT_FILTER = 951 | 952 | # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern 953 | # basis. Doxygen will compare the file name with each pattern and apply the 954 | # filter if there is a match. The filters are a list of the form: pattern=filter 955 | # (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how 956 | # filters are used. If the FILTER_PATTERNS tag is empty or if none of the 957 | # patterns match the file name, INPUT_FILTER is applied. 958 | # 959 | # Note that for custom extensions or not directly supported extensions you also 960 | # need to set EXTENSION_MAPPING for the extension otherwise the files are not 961 | # properly processed by doxygen. 962 | 963 | FILTER_PATTERNS = 964 | 965 | # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 966 | # INPUT_FILTER) will also be used to filter the input files that are used for 967 | # producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). 968 | # The default value is: NO. 969 | 970 | FILTER_SOURCE_FILES = NO 971 | 972 | # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file 973 | # pattern. A pattern will override the setting for FILTER_PATTERN (if any) and 974 | # it is also possible to disable source filtering for a specific pattern using 975 | # *.ext= (so without naming a filter). 976 | # This tag requires that the tag FILTER_SOURCE_FILES is set to YES. 977 | 978 | FILTER_SOURCE_PATTERNS = 979 | 980 | # If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that 981 | # is part of the input, its contents will be placed on the main page 982 | # (index.html). This can be useful if you have a project on for instance GitHub 983 | # and want to reuse the introduction page also for the doxygen output. 984 | 985 | USE_MDFILE_AS_MAINPAGE = 986 | 987 | #--------------------------------------------------------------------------- 988 | # Configuration options related to source browsing 989 | #--------------------------------------------------------------------------- 990 | 991 | # If the SOURCE_BROWSER tag is set to YES then a list of source files will be 992 | # generated. Documented entities will be cross-referenced with these sources. 993 | # 994 | # Note: To get rid of all source code in the generated output, make sure that 995 | # also VERBATIM_HEADERS is set to NO. 996 | # The default value is: NO. 997 | 998 | SOURCE_BROWSER = NO 999 | 1000 | # Setting the INLINE_SOURCES tag to YES will include the body of functions, 1001 | # classes and enums directly into the documentation. 1002 | # The default value is: NO. 1003 | 1004 | INLINE_SOURCES = NO 1005 | 1006 | # Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any 1007 | # special comment blocks from generated source code fragments. Normal C, C++ and 1008 | # Fortran comments will always remain visible. 1009 | # The default value is: YES. 1010 | 1011 | STRIP_CODE_COMMENTS = YES 1012 | 1013 | # If the REFERENCED_BY_RELATION tag is set to YES then for each documented 1014 | # function all documented functions referencing it will be listed. 1015 | # The default value is: NO. 1016 | 1017 | REFERENCED_BY_RELATION = NO 1018 | 1019 | # If the REFERENCES_RELATION tag is set to YES then for each documented function 1020 | # all documented entities called/used by that function will be listed. 1021 | # The default value is: NO. 1022 | 1023 | REFERENCES_RELATION = NO 1024 | 1025 | # If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set 1026 | # to YES then the hyperlinks from functions in REFERENCES_RELATION and 1027 | # REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will 1028 | # link to the documentation. 1029 | # The default value is: YES. 1030 | 1031 | REFERENCES_LINK_SOURCE = YES 1032 | 1033 | # If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the 1034 | # source code will show a tooltip with additional information such as prototype, 1035 | # brief description and links to the definition and documentation. Since this 1036 | # will make the HTML file larger and loading of large files a bit slower, you 1037 | # can opt to disable this feature. 1038 | # The default value is: YES. 1039 | # This tag requires that the tag SOURCE_BROWSER is set to YES. 1040 | 1041 | SOURCE_TOOLTIPS = YES 1042 | 1043 | # If the USE_HTAGS tag is set to YES then the references to source code will 1044 | # point to the HTML generated by the htags(1) tool instead of doxygen built-in 1045 | # source browser. The htags tool is part of GNU's global source tagging system 1046 | # (see http://www.gnu.org/software/global/global.html). You will need version 1047 | # 4.8.6 or higher. 1048 | # 1049 | # To use it do the following: 1050 | # - Install the latest version of global 1051 | # - Enable SOURCE_BROWSER and USE_HTAGS in the config file 1052 | # - Make sure the INPUT points to the root of the source tree 1053 | # - Run doxygen as normal 1054 | # 1055 | # Doxygen will invoke htags (and that will in turn invoke gtags), so these 1056 | # tools must be available from the command line (i.e. in the search path). 1057 | # 1058 | # The result: instead of the source browser generated by doxygen, the links to 1059 | # source code will now point to the output of htags. 1060 | # The default value is: NO. 1061 | # This tag requires that the tag SOURCE_BROWSER is set to YES. 1062 | 1063 | USE_HTAGS = NO 1064 | 1065 | # If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a 1066 | # verbatim copy of the header file for each class for which an include is 1067 | # specified. Set to NO to disable this. 1068 | # See also: Section \class. 1069 | # The default value is: YES. 1070 | 1071 | VERBATIM_HEADERS = YES 1072 | 1073 | # If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the 1074 | # clang parser (see: http://clang.llvm.org/) for more accurate parsing at the 1075 | # cost of reduced performance. This can be particularly helpful with template 1076 | # rich C++ code for which doxygen's built-in parser lacks the necessary type 1077 | # information. 1078 | # Note: The availability of this option depends on whether or not doxygen was 1079 | # generated with the -Duse-libclang=ON option for CMake. 1080 | # The default value is: NO. 1081 | 1082 | CLANG_ASSISTED_PARSING = NO 1083 | 1084 | # If clang assisted parsing is enabled you can provide the compiler with command 1085 | # line options that you would normally use when invoking the compiler. Note that 1086 | # the include paths will already be set by doxygen for the files and directories 1087 | # specified with INPUT and INCLUDE_PATH. 1088 | # This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. 1089 | 1090 | CLANG_OPTIONS = 1091 | 1092 | #--------------------------------------------------------------------------- 1093 | # Configuration options related to the alphabetical class index 1094 | #--------------------------------------------------------------------------- 1095 | 1096 | # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all 1097 | # compounds will be generated. Enable this if the project contains a lot of 1098 | # classes, structs, unions or interfaces. 1099 | # The default value is: YES. 1100 | 1101 | ALPHABETICAL_INDEX = YES 1102 | 1103 | # The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in 1104 | # which the alphabetical index list will be split. 1105 | # Minimum value: 1, maximum value: 20, default value: 5. 1106 | # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. 1107 | 1108 | COLS_IN_ALPHA_INDEX = 5 1109 | 1110 | # In case all classes in a project start with a common prefix, all classes will 1111 | # be put under the same header in the alphabetical index. The IGNORE_PREFIX tag 1112 | # can be used to specify a prefix (or a list of prefixes) that should be ignored 1113 | # while generating the index headers. 1114 | # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. 1115 | 1116 | IGNORE_PREFIX = 1117 | 1118 | #--------------------------------------------------------------------------- 1119 | # Configuration options related to the HTML output 1120 | #--------------------------------------------------------------------------- 1121 | 1122 | # If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output 1123 | # The default value is: YES. 1124 | 1125 | GENERATE_HTML = YES 1126 | 1127 | # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a 1128 | # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of 1129 | # it. 1130 | # The default directory is: html. 1131 | # This tag requires that the tag GENERATE_HTML is set to YES. 1132 | 1133 | HTML_OUTPUT = docs 1134 | 1135 | # The HTML_FILE_EXTENSION tag can be used to specify the file extension for each 1136 | # generated HTML page (for example: .htm, .php, .asp). 1137 | # The default value is: .html. 1138 | # This tag requires that the tag GENERATE_HTML is set to YES. 1139 | 1140 | HTML_FILE_EXTENSION = .html 1141 | 1142 | # The HTML_HEADER tag can be used to specify a user-defined HTML header file for 1143 | # each generated HTML page. If the tag is left blank doxygen will generate a 1144 | # standard header. 1145 | # 1146 | # To get valid HTML the header file that includes any scripts and style sheets 1147 | # that doxygen needs, which is dependent on the configuration options used (e.g. 1148 | # the setting GENERATE_TREEVIEW). It is highly recommended to start with a 1149 | # default header using 1150 | # doxygen -w html new_header.html new_footer.html new_stylesheet.css 1151 | # YourConfigFile 1152 | # and then modify the file new_header.html. See also section "Doxygen usage" 1153 | # for information on how to generate the default header that doxygen normally 1154 | # uses. 1155 | # Note: The header is subject to change so you typically have to regenerate the 1156 | # default header when upgrading to a newer version of doxygen. For a description 1157 | # of the possible markers and block names see the documentation. 1158 | # This tag requires that the tag GENERATE_HTML is set to YES. 1159 | 1160 | HTML_HEADER = 1161 | 1162 | # The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each 1163 | # generated HTML page. If the tag is left blank doxygen will generate a standard 1164 | # footer. See HTML_HEADER for more information on how to generate a default 1165 | # footer and what special commands can be used inside the footer. See also 1166 | # section "Doxygen usage" for information on how to generate the default footer 1167 | # that doxygen normally uses. 1168 | # This tag requires that the tag GENERATE_HTML is set to YES. 1169 | 1170 | HTML_FOOTER = 1171 | 1172 | # The HTML_STYLESHEET tag can be used to specify a user-defined cascading style 1173 | # sheet that is used by each HTML page. It can be used to fine-tune the look of 1174 | # the HTML output. If left blank doxygen will generate a default style sheet. 1175 | # See also section "Doxygen usage" for information on how to generate the style 1176 | # sheet that doxygen normally uses. 1177 | # Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as 1178 | # it is more robust and this tag (HTML_STYLESHEET) will in the future become 1179 | # obsolete. 1180 | # This tag requires that the tag GENERATE_HTML is set to YES. 1181 | 1182 | HTML_STYLESHEET = 1183 | 1184 | # The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined 1185 | # cascading style sheets that are included after the standard style sheets 1186 | # created by doxygen. Using this option one can overrule certain style aspects. 1187 | # This is preferred over using HTML_STYLESHEET since it does not replace the 1188 | # standard style sheet and is therefore more robust against future updates. 1189 | # Doxygen will copy the style sheet files to the output directory. 1190 | # Note: The order of the extra style sheet files is of importance (e.g. the last 1191 | # style sheet in the list overrules the setting of the previous ones in the 1192 | # list). For an example see the documentation. 1193 | # This tag requires that the tag GENERATE_HTML is set to YES. 1194 | 1195 | HTML_EXTRA_STYLESHEET = 1196 | 1197 | # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or 1198 | # other source files which should be copied to the HTML output directory. Note 1199 | # that these files will be copied to the base HTML output directory. Use the 1200 | # $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these 1201 | # files. In the HTML_STYLESHEET file, use the file name only. Also note that the 1202 | # files will be copied as-is; there are no commands or markers available. 1203 | # This tag requires that the tag GENERATE_HTML is set to YES. 1204 | 1205 | HTML_EXTRA_FILES = 1206 | 1207 | # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen 1208 | # will adjust the colors in the style sheet and background images according to 1209 | # this color. Hue is specified as an angle on a colorwheel, see 1210 | # http://en.wikipedia.org/wiki/Hue for more information. For instance the value 1211 | # 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 1212 | # purple, and 360 is red again. 1213 | # Minimum value: 0, maximum value: 359, default value: 220. 1214 | # This tag requires that the tag GENERATE_HTML is set to YES. 1215 | 1216 | HTML_COLORSTYLE_HUE = 220 1217 | 1218 | # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors 1219 | # in the HTML output. For a value of 0 the output will use grayscales only. A 1220 | # value of 255 will produce the most vivid colors. 1221 | # Minimum value: 0, maximum value: 255, default value: 100. 1222 | # This tag requires that the tag GENERATE_HTML is set to YES. 1223 | 1224 | HTML_COLORSTYLE_SAT = 100 1225 | 1226 | # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the 1227 | # luminance component of the colors in the HTML output. Values below 100 1228 | # gradually make the output lighter, whereas values above 100 make the output 1229 | # darker. The value divided by 100 is the actual gamma applied, so 80 represents 1230 | # a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not 1231 | # change the gamma. 1232 | # Minimum value: 40, maximum value: 240, default value: 80. 1233 | # This tag requires that the tag GENERATE_HTML is set to YES. 1234 | 1235 | HTML_COLORSTYLE_GAMMA = 80 1236 | 1237 | # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML 1238 | # page will contain the date and time when the page was generated. Setting this 1239 | # to YES can help to show when doxygen was last run and thus if the 1240 | # documentation is up to date. 1241 | # The default value is: NO. 1242 | # This tag requires that the tag GENERATE_HTML is set to YES. 1243 | 1244 | HTML_TIMESTAMP = NO 1245 | 1246 | # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML 1247 | # documentation will contain sections that can be hidden and shown after the 1248 | # page has loaded. 1249 | # The default value is: NO. 1250 | # This tag requires that the tag GENERATE_HTML is set to YES. 1251 | 1252 | HTML_DYNAMIC_SECTIONS = NO 1253 | 1254 | # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries 1255 | # shown in the various tree structured indices initially; the user can expand 1256 | # and collapse entries dynamically later on. Doxygen will expand the tree to 1257 | # such a level that at most the specified number of entries are visible (unless 1258 | # a fully collapsed tree already exceeds this amount). So setting the number of 1259 | # entries 1 will produce a full collapsed tree by default. 0 is a special value 1260 | # representing an infinite number of entries and will result in a full expanded 1261 | # tree by default. 1262 | # Minimum value: 0, maximum value: 9999, default value: 100. 1263 | # This tag requires that the tag GENERATE_HTML is set to YES. 1264 | 1265 | HTML_INDEX_NUM_ENTRIES = 100 1266 | 1267 | # If the GENERATE_DOCSET tag is set to YES, additional index files will be 1268 | # generated that can be used as input for Apple's Xcode 3 integrated development 1269 | # environment (see: http://developer.apple.com/tools/xcode/), introduced with 1270 | # OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a 1271 | # Makefile in the HTML output directory. Running make will produce the docset in 1272 | # that directory and running make install will install the docset in 1273 | # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at 1274 | # startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html 1275 | # for more information. 1276 | # The default value is: NO. 1277 | # This tag requires that the tag GENERATE_HTML is set to YES. 1278 | 1279 | GENERATE_DOCSET = NO 1280 | 1281 | # This tag determines the name of the docset feed. A documentation feed provides 1282 | # an umbrella under which multiple documentation sets from a single provider 1283 | # (such as a company or product suite) can be grouped. 1284 | # The default value is: Doxygen generated docs. 1285 | # This tag requires that the tag GENERATE_DOCSET is set to YES. 1286 | 1287 | DOCSET_FEEDNAME = "Doxygen generated docs" 1288 | 1289 | # This tag specifies a string that should uniquely identify the documentation 1290 | # set bundle. This should be a reverse domain-name style string, e.g. 1291 | # com.mycompany.MyDocSet. Doxygen will append .docset to the name. 1292 | # The default value is: org.doxygen.Project. 1293 | # This tag requires that the tag GENERATE_DOCSET is set to YES. 1294 | 1295 | DOCSET_BUNDLE_ID = org.doxygen.Project 1296 | 1297 | # The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify 1298 | # the documentation publisher. This should be a reverse domain-name style 1299 | # string, e.g. com.mycompany.MyDocSet.documentation. 1300 | # The default value is: org.doxygen.Publisher. 1301 | # This tag requires that the tag GENERATE_DOCSET is set to YES. 1302 | 1303 | DOCSET_PUBLISHER_ID = org.doxygen.Publisher 1304 | 1305 | # The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. 1306 | # The default value is: Publisher. 1307 | # This tag requires that the tag GENERATE_DOCSET is set to YES. 1308 | 1309 | DOCSET_PUBLISHER_NAME = Publisher 1310 | 1311 | # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three 1312 | # additional HTML index files: index.hhp, index.hhc, and index.hhk. The 1313 | # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop 1314 | # (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on 1315 | # Windows. 1316 | # 1317 | # The HTML Help Workshop contains a compiler that can convert all HTML output 1318 | # generated by doxygen into a single compiled HTML file (.chm). Compiled HTML 1319 | # files are now used as the Windows 98 help format, and will replace the old 1320 | # Windows help format (.hlp) on all Windows platforms in the future. Compressed 1321 | # HTML files also contain an index, a table of contents, and you can search for 1322 | # words in the documentation. The HTML workshop also contains a viewer for 1323 | # compressed HTML files. 1324 | # The default value is: NO. 1325 | # This tag requires that the tag GENERATE_HTML is set to YES. 1326 | 1327 | GENERATE_HTMLHELP = NO 1328 | 1329 | # The CHM_FILE tag can be used to specify the file name of the resulting .chm 1330 | # file. You can add a path in front of the file if the result should not be 1331 | # written to the html output directory. 1332 | # This tag requires that the tag GENERATE_HTMLHELP is set to YES. 1333 | 1334 | CHM_FILE = 1335 | 1336 | # The HHC_LOCATION tag can be used to specify the location (absolute path 1337 | # including file name) of the HTML help compiler (hhc.exe). If non-empty, 1338 | # doxygen will try to run the HTML help compiler on the generated index.hhp. 1339 | # The file has to be specified with full path. 1340 | # This tag requires that the tag GENERATE_HTMLHELP is set to YES. 1341 | 1342 | HHC_LOCATION = 1343 | 1344 | # The GENERATE_CHI flag controls if a separate .chi index file is generated 1345 | # (YES) or that it should be included in the master .chm file (NO). 1346 | # The default value is: NO. 1347 | # This tag requires that the tag GENERATE_HTMLHELP is set to YES. 1348 | 1349 | GENERATE_CHI = NO 1350 | 1351 | # The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) 1352 | # and project file content. 1353 | # This tag requires that the tag GENERATE_HTMLHELP is set to YES. 1354 | 1355 | CHM_INDEX_ENCODING = 1356 | 1357 | # The BINARY_TOC flag controls whether a binary table of contents is generated 1358 | # (YES) or a normal table of contents (NO) in the .chm file. Furthermore it 1359 | # enables the Previous and Next buttons. 1360 | # The default value is: NO. 1361 | # This tag requires that the tag GENERATE_HTMLHELP is set to YES. 1362 | 1363 | BINARY_TOC = NO 1364 | 1365 | # The TOC_EXPAND flag can be set to YES to add extra items for group members to 1366 | # the table of contents of the HTML help documentation and to the tree view. 1367 | # The default value is: NO. 1368 | # This tag requires that the tag GENERATE_HTMLHELP is set to YES. 1369 | 1370 | TOC_EXPAND = NO 1371 | 1372 | # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and 1373 | # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that 1374 | # can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help 1375 | # (.qch) of the generated HTML documentation. 1376 | # The default value is: NO. 1377 | # This tag requires that the tag GENERATE_HTML is set to YES. 1378 | 1379 | GENERATE_QHP = NO 1380 | 1381 | # If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify 1382 | # the file name of the resulting .qch file. The path specified is relative to 1383 | # the HTML output folder. 1384 | # This tag requires that the tag GENERATE_QHP is set to YES. 1385 | 1386 | QCH_FILE = 1387 | 1388 | # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help 1389 | # Project output. For more information please see Qt Help Project / Namespace 1390 | # (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). 1391 | # The default value is: org.doxygen.Project. 1392 | # This tag requires that the tag GENERATE_QHP is set to YES. 1393 | 1394 | QHP_NAMESPACE = org.doxygen.Project 1395 | 1396 | # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt 1397 | # Help Project output. For more information please see Qt Help Project / Virtual 1398 | # Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- 1399 | # folders). 1400 | # The default value is: doc. 1401 | # This tag requires that the tag GENERATE_QHP is set to YES. 1402 | 1403 | QHP_VIRTUAL_FOLDER = doc 1404 | 1405 | # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom 1406 | # filter to add. For more information please see Qt Help Project / Custom 1407 | # Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- 1408 | # filters). 1409 | # This tag requires that the tag GENERATE_QHP is set to YES. 1410 | 1411 | QHP_CUST_FILTER_NAME = 1412 | 1413 | # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the 1414 | # custom filter to add. For more information please see Qt Help Project / Custom 1415 | # Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- 1416 | # filters). 1417 | # This tag requires that the tag GENERATE_QHP is set to YES. 1418 | 1419 | QHP_CUST_FILTER_ATTRS = 1420 | 1421 | # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this 1422 | # project's filter section matches. Qt Help Project / Filter Attributes (see: 1423 | # http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). 1424 | # This tag requires that the tag GENERATE_QHP is set to YES. 1425 | 1426 | QHP_SECT_FILTER_ATTRS = 1427 | 1428 | # The QHG_LOCATION tag can be used to specify the location of Qt's 1429 | # qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the 1430 | # generated .qhp file. 1431 | # This tag requires that the tag GENERATE_QHP is set to YES. 1432 | 1433 | QHG_LOCATION = 1434 | 1435 | # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be 1436 | # generated, together with the HTML files, they form an Eclipse help plugin. To 1437 | # install this plugin and make it available under the help contents menu in 1438 | # Eclipse, the contents of the directory containing the HTML and XML files needs 1439 | # to be copied into the plugins directory of eclipse. The name of the directory 1440 | # within the plugins directory should be the same as the ECLIPSE_DOC_ID value. 1441 | # After copying Eclipse needs to be restarted before the help appears. 1442 | # The default value is: NO. 1443 | # This tag requires that the tag GENERATE_HTML is set to YES. 1444 | 1445 | GENERATE_ECLIPSEHELP = NO 1446 | 1447 | # A unique identifier for the Eclipse help plugin. When installing the plugin 1448 | # the directory name containing the HTML and XML files should also have this 1449 | # name. Each documentation set should have its own identifier. 1450 | # The default value is: org.doxygen.Project. 1451 | # This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. 1452 | 1453 | ECLIPSE_DOC_ID = org.doxygen.Project 1454 | 1455 | # If you want full control over the layout of the generated HTML pages it might 1456 | # be necessary to disable the index and replace it with your own. The 1457 | # DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top 1458 | # of each HTML page. A value of NO enables the index and the value YES disables 1459 | # it. Since the tabs in the index contain the same information as the navigation 1460 | # tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. 1461 | # The default value is: NO. 1462 | # This tag requires that the tag GENERATE_HTML is set to YES. 1463 | 1464 | DISABLE_INDEX = NO 1465 | 1466 | # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index 1467 | # structure should be generated to display hierarchical information. If the tag 1468 | # value is set to YES, a side panel will be generated containing a tree-like 1469 | # index structure (just like the one that is generated for HTML Help). For this 1470 | # to work a browser that supports JavaScript, DHTML, CSS and frames is required 1471 | # (i.e. any modern browser). Windows users are probably better off using the 1472 | # HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can 1473 | # further fine-tune the look of the index. As an example, the default style 1474 | # sheet generated by doxygen has an example that shows how to put an image at 1475 | # the root of the tree instead of the PROJECT_NAME. Since the tree basically has 1476 | # the same information as the tab index, you could consider setting 1477 | # DISABLE_INDEX to YES when enabling this option. 1478 | # The default value is: NO. 1479 | # This tag requires that the tag GENERATE_HTML is set to YES. 1480 | 1481 | GENERATE_TREEVIEW = NO 1482 | 1483 | # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that 1484 | # doxygen will group on one line in the generated HTML documentation. 1485 | # 1486 | # Note that a value of 0 will completely suppress the enum values from appearing 1487 | # in the overview section. 1488 | # Minimum value: 0, maximum value: 20, default value: 4. 1489 | # This tag requires that the tag GENERATE_HTML is set to YES. 1490 | 1491 | ENUM_VALUES_PER_LINE = 4 1492 | 1493 | # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used 1494 | # to set the initial width (in pixels) of the frame in which the tree is shown. 1495 | # Minimum value: 0, maximum value: 1500, default value: 250. 1496 | # This tag requires that the tag GENERATE_HTML is set to YES. 1497 | 1498 | TREEVIEW_WIDTH = 250 1499 | 1500 | # If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to 1501 | # external symbols imported via tag files in a separate window. 1502 | # The default value is: NO. 1503 | # This tag requires that the tag GENERATE_HTML is set to YES. 1504 | 1505 | EXT_LINKS_IN_WINDOW = NO 1506 | 1507 | # Use this tag to change the font size of LaTeX formulas included as images in 1508 | # the HTML documentation. When you change the font size after a successful 1509 | # doxygen run you need to manually remove any form_*.png images from the HTML 1510 | # output directory to force them to be regenerated. 1511 | # Minimum value: 8, maximum value: 50, default value: 10. 1512 | # This tag requires that the tag GENERATE_HTML is set to YES. 1513 | 1514 | FORMULA_FONTSIZE = 10 1515 | 1516 | # Use the FORMULA_TRANPARENT tag to determine whether or not the images 1517 | # generated for formulas are transparent PNGs. Transparent PNGs are not 1518 | # supported properly for IE 6.0, but are supported on all modern browsers. 1519 | # 1520 | # Note that when changing this option you need to delete any form_*.png files in 1521 | # the HTML output directory before the changes have effect. 1522 | # The default value is: YES. 1523 | # This tag requires that the tag GENERATE_HTML is set to YES. 1524 | 1525 | FORMULA_TRANSPARENT = YES 1526 | 1527 | # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see 1528 | # http://www.mathjax.org) which uses client side Javascript for the rendering 1529 | # instead of using pre-rendered bitmaps. Use this if you do not have LaTeX 1530 | # installed or if you want to formulas look prettier in the HTML output. When 1531 | # enabled you may also need to install MathJax separately and configure the path 1532 | # to it using the MATHJAX_RELPATH option. 1533 | # The default value is: NO. 1534 | # This tag requires that the tag GENERATE_HTML is set to YES. 1535 | 1536 | USE_MATHJAX = NO 1537 | 1538 | # When MathJax is enabled you can set the default output format to be used for 1539 | # the MathJax output. See the MathJax site (see: 1540 | # http://docs.mathjax.org/en/latest/output.html) for more details. 1541 | # Possible values are: HTML-CSS (which is slower, but has the best 1542 | # compatibility), NativeMML (i.e. MathML) and SVG. 1543 | # The default value is: HTML-CSS. 1544 | # This tag requires that the tag USE_MATHJAX is set to YES. 1545 | 1546 | MATHJAX_FORMAT = HTML-CSS 1547 | 1548 | # When MathJax is enabled you need to specify the location relative to the HTML 1549 | # output directory using the MATHJAX_RELPATH option. The destination directory 1550 | # should contain the MathJax.js script. For instance, if the mathjax directory 1551 | # is located at the same level as the HTML output directory, then 1552 | # MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax 1553 | # Content Delivery Network so you can quickly see the result without installing 1554 | # MathJax. However, it is strongly recommended to install a local copy of 1555 | # MathJax from http://www.mathjax.org before deployment. 1556 | # The default value is: http://cdn.mathjax.org/mathjax/latest. 1557 | # This tag requires that the tag USE_MATHJAX is set to YES. 1558 | 1559 | MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest 1560 | 1561 | # The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax 1562 | # extension names that should be enabled during MathJax rendering. For example 1563 | # MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols 1564 | # This tag requires that the tag USE_MATHJAX is set to YES. 1565 | 1566 | MATHJAX_EXTENSIONS = 1567 | 1568 | # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces 1569 | # of code that will be used on startup of the MathJax code. See the MathJax site 1570 | # (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an 1571 | # example see the documentation. 1572 | # This tag requires that the tag USE_MATHJAX is set to YES. 1573 | 1574 | MATHJAX_CODEFILE = 1575 | 1576 | # When the SEARCHENGINE tag is enabled doxygen will generate a search box for 1577 | # the HTML output. The underlying search engine uses javascript and DHTML and 1578 | # should work on any modern browser. Note that when using HTML help 1579 | # (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) 1580 | # there is already a search function so this one should typically be disabled. 1581 | # For large projects the javascript based search engine can be slow, then 1582 | # enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to 1583 | # search using the keyboard; to jump to the search box use + S 1584 | # (what the is depends on the OS and browser, but it is typically 1585 | # , /