diff options
Diffstat (limited to 'include/serd')
-rw-r--r-- | include/serd/node.h | 38 | ||||
-rw-r--r-- | include/serd/string.h | 11 |
2 files changed, 22 insertions, 27 deletions
diff --git a/include/serd/node.h b/include/serd/node.h index 1faba160..90ecde71 100644 --- a/include/serd/node.h +++ b/include/serd/node.h @@ -104,10 +104,9 @@ typedef enum { /// Node flags, which ORed together make a #SerdNodeFlags typedef enum { - SERD_HAS_NEWLINE = 1U << 0U, ///< Contains line breaks ('\\n' or '\\r') - SERD_HAS_QUOTE = 1U << 1U, ///< Contains quotes ('"') - SERD_HAS_DATATYPE = 1U << 2U, ///< Literal node has datatype - SERD_HAS_LANGUAGE = 1U << 3U, ///< Literal node has language + SERD_IS_LONG = 1U << 0U, ///< Literal node should be triple-quoted + SERD_HAS_DATATYPE = 1U << 1U, ///< Literal node has datatype + SERD_HAS_LANGUAGE = 1U << 2U, ///< Literal node has language } SerdNodeFlag; /// Bitwise OR of #SerdNodeFlag values @@ -135,23 +134,30 @@ SERD_API SerdNode* ZIX_ALLOCATED serd_new_string(SerdStringView string); /** - Create a new plain literal node from `str` with `lang`. + Create a new literal node with optional datatype or language. - A plain literal has no datatype, but may have a language tag. The `lang` - may be empty, in which case this is equivalent to `serd_new_string()`. -*/ -SERD_API SerdNode* ZIX_ALLOCATED -serd_new_plain_literal(SerdStringView str, SerdStringView lang); + This can create more complex literals than serd_new_string() with an + associated datatype URI or language tag, as well as control whether a + literal should be written as a short or long (triple-quoted) string. -/** - Create a new typed literal node from `str`. + @param string The string value of the literal. + + @param flags Flags to describe the literal and its metadata. This must be a + valid combination of flags, in particular, at most one of #SERD_HAS_DATATYPE + and #SERD_HAS_LANGUAGE may be set. + + @param meta The string value of the literal's metadata. If + #SERD_HAS_DATATYPE is set, then this must be an absolute datatype URI. If + #SERD_HAS_LANGUAGE is set, then this must be a language tag like "en-ca". + Otherwise, it is ignored. - A typed literal has no language tag, but may have a datatype. The - `datatype` may be NULL, in which case this is equivalent to - `serd_new_string()`. + @return A newly allocated literal node that must be freed with + serd_node_free(), or null if the arguments are invalid or allocation failed. */ SERD_API SerdNode* ZIX_ALLOCATED -serd_new_typed_literal(SerdStringView str, SerdStringView datatype_uri); +serd_new_literal(SerdStringView string, + SerdNodeFlags flags, + SerdStringView meta); /** Create a new node from a blank node label. diff --git a/include/serd/string.h b/include/serd/string.h index 46da939d..11e55e6e 100644 --- a/include/serd/string.h +++ b/include/serd/string.h @@ -5,7 +5,6 @@ #define SERD_STRING_H #include "serd/attributes.h" -#include "serd/node.h" #include "zix/attributes.h" #include <stddef.h> @@ -19,16 +18,6 @@ SERD_BEGIN_DECLS */ /** - Measure a UTF-8 string. - - @return Length of `str` in bytes. - @param str A null-terminated UTF-8 string. - @param flags (Output) Set to the applicable flags. -*/ -SERD_API size_t -serd_strlen(const char* ZIX_NONNULL str, SerdNodeFlags* ZIX_NULLABLE flags); - -/** Decode a base64 string. This function can be used to decode a node created with serd_new_base64(). |