diff options
author | David Robillard <d@drobilla.net> | 2021-07-31 16:43:50 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:07 -0500 |
commit | 13892da5556b962d749b42c851b29237e380e36c (patch) | |
tree | 0d2ccb82e86b57055083f069b990b3516ec05a02 /src/turtle.h | |
parent | 0611f1446c37915708ce0ea337c9e84d4cbc3be4 (diff) | |
download | serd-13892da5556b962d749b42c851b29237e380e36c.tar.gz serd-13892da5556b962d749b42c851b29237e380e36c.tar.bz2 serd-13892da5556b962d749b42c851b29237e380e36c.zip |
Factor out and expose prefixed name predicates
Towards using these in the writer to escape names more precisely.
Diffstat (limited to 'src/turtle.h')
-rw-r--r-- | src/turtle.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/turtle.h b/src/turtle.h new file mode 100644 index 00000000..6e7e3a8d --- /dev/null +++ b/src/turtle.h @@ -0,0 +1,32 @@ +// Copyright 2011-2020 David Robillard <d@drobilla.net> +// SPDX-License-Identifier: ISC + +#ifndef SERD_SRC_TURTLE_H +#define SERD_SRC_TURTLE_H + +#include "ntriples.h" +#include "string_utils.h" + +#include <stdbool.h> +#include <string.h> + +static inline bool +is_PN_CHARS_U(const int c) +{ + return c == '_' || is_PN_CHARS_BASE(c); +} + +static inline bool +is_PN_CHARS(const int c) +{ + return (is_PN_CHARS_U(c) || c == '-' || in_range(c, '0', '9') || c == 0xB7 || + (c >= 0x0300 && c <= 0x036F) || (c >= 0x203F && c <= 0x2040)); +} + +static inline bool +is_PN_LOCAL_ESC(const int c) +{ + return strchr("!#$%&\'()*+,-./;=?@_~", c) != NULL; +} + +#endif // SERD_SRC_TURTLE_H |