diff options
Diffstat (limited to 'src/index_range.h')
-rw-r--r-- | src/index_range.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/index_range.h b/src/index_range.h new file mode 100644 index 0000000..1e06e90 --- /dev/null +++ b/src/index_range.h @@ -0,0 +1,28 @@ +// Copyright 2022 David Robillard <d@drobilla.net> +// SPDX-License-Identifier: ISC + +#ifndef ZIX_INDEX_RANGE_H +#define ZIX_INDEX_RANGE_H + +#include <stdbool.h> +#include <stddef.h> + +typedef struct { + size_t begin; ///< Index to the first character + size_t end; ///< Index one past the last character +} ZixIndexRange; + +static inline ZixIndexRange +zix_make_range(const size_t begin, const size_t end) +{ + const ZixIndexRange result = {begin, end}; + return result; +} + +static inline bool +zix_is_empty_range(const ZixIndexRange range) +{ + return range.begin == range.end; +} + +#endif // ZIX_INDEX_RANGE_H |