Branch data Line data Source code
1 : : // Copyright 2022 David Robillard <d@drobilla.net> 2 : : // SPDX-License-Identifier: ISC 3 : : 4 : : #ifndef ZIX_INDEX_RANGE_H 5 : : #define ZIX_INDEX_RANGE_H 6 : : 7 : : #include <stdbool.h> 8 : : #include <stddef.h> 9 : : 10 : : typedef struct { 11 : : size_t begin; ///< Index to the first character 12 : : size_t end; ///< Index one past the last character 13 : : } ZixIndexRange; 14 : : 15 : : static inline ZixIndexRange 16 : 8455 : zix_make_range(const size_t begin, const size_t end) 17 : : { 18 : 8455 : const ZixIndexRange result = {begin, end}; 19 : 8455 : return result; 20 : : } 21 : : 22 : : static inline bool 23 : 13079 : zix_is_empty_range(const ZixIndexRange range) 24 : : { 25 : 13079 : return range.begin == range.end; 26 : : } 27 : : 28 : : #endif // ZIX_INDEX_RANGE_H