diff options
author | David Robillard <d@drobilla.net> | 2022-10-23 13:41:15 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-10-23 13:46:58 -0400 |
commit | c886d489576cd0bc33d7d22d81981c794067946f (patch) | |
tree | f43c8d872401ed80b37f974516d9e9f2fee9d765 /src/index_range.h | |
parent | f95a698b94069ed03f6a8f2d0f7eb089d66c91ef (diff) | |
download | zix-c886d489576cd0bc33d7d22d81981c794067946f.tar.gz zix-c886d489576cd0bc33d7d22d81981c794067946f.tar.bz2 zix-c886d489576cd0bc33d7d22d81981c794067946f.zip |
Add path API
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 |