diff options
author | David Robillard <d@drobilla.net> | 2021-04-15 18:34:17 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:06 -0500 |
commit | a970f06aba98736223214a6fa995f4e82acd7132 (patch) | |
tree | fc243e4bf26f4c1f95df6f62abdd6740d87d8afd /include/serd | |
parent | 44feb2724a8fe34992999867f5b6468228b6fc01 (diff) | |
download | serd-a970f06aba98736223214a6fa995f4e82acd7132.tar.gz serd-a970f06aba98736223214a6fa995f4e82acd7132.tar.bz2 serd-a970f06aba98736223214a6fa995f4e82acd7132.zip |
[WIP] Use exess for reading and writing numeric and binary literals
Diffstat (limited to 'include/serd')
-rw-r--r-- | include/serd/node.h | 40 | ||||
-rw-r--r-- | include/serd/string.h | 7 |
2 files changed, 21 insertions, 26 deletions
diff --git a/include/serd/node.h b/include/serd/node.h index 73569b44..79c9ffe1 100644 --- a/include/serd/node.h +++ b/include/serd/node.h @@ -175,28 +175,26 @@ serd_new_boolean(bool b); /** Create a new canonical xsd:decimal literal. - The resulting node will always contain a '.', start with a digit, and end - with a digit (i.e. will have a leading and/or trailing '0' if necessary). - It will never be in scientific notation. A maximum of `frac_digits` digits - will be written after the decimal point, but trailing zeros will - automatically be omitted (except one if `d` is a round integer). + The node will be an xsd:decimal literal, like "12.34", with + datatype xsd:decimal by default, or a custom datatype. - Note that about 16 and 8 fractional digits are required to precisely - represent a double and float, respectively. + The node will always contain a '.', start with a digit, and end with a digit + (a leading and/or trailing '0' will be added if necessary), for example, + "1.0". It will never be in scientific notation. @param d The value for the new node. - @param frac_digits The maximum number of digits after the decimal place. @param datatype Datatype of node, or NULL for xsd:decimal. */ SERD_API SerdNode* SERD_ALLOCATED -serd_new_decimal(double d, - unsigned frac_digits, - const SerdNode* SERD_NULLABLE datatype); +serd_new_decimal(double d, const SerdNode* SERD_NULLABLE datatype); /** Create a new canonical xsd:integer literal. - @param i Integer value to serialise. + The node will be an xsd:integer literal like "1234", with datatype + xsd:integer. + + @param i Integer value of literal. @param datatype Datatype of node, or NULL for xsd:integer. */ SERD_API SerdNode* SERD_ALLOCATED @@ -205,19 +203,17 @@ serd_new_integer(int64_t i, const SerdNode* SERD_NULLABLE datatype); /** Create a new canonical xsd:base64Binary literal. - This function can be used to make a serialisable node out of arbitrary - binary data, which can be decoded using serd_base64_decode(). + This function can be used to make a node out of arbitrary binary data, which + can be decoded using serd_base64_decode(). - @param buf Raw binary input data. - @param size Size of `buf`. - @param wrap_lines Wrap lines at 76 characters to conform to RFC 2045. - @param datatype Datatype of node, or NULL for xsd:base64Binary. + @param buf Raw binary data to encode in node. + @param size Size of `buf` in bytes. + @param datatype Datatype of node, or null for xsd:base64Binary. */ SERD_API SerdNode* SERD_ALLOCATED -serd_new_blob(const void* SERD_NONNULL buf, - size_t size, - bool wrap_lines, - const SerdNode* SERD_NULLABLE datatype); +serd_new_base64(const void* SERD_NONNULL buf, + size_t size, + const SerdNode* SERD_NULLABLE datatype); /// Return a deep copy of `node` SERD_API SerdNode* SERD_ALLOCATED diff --git a/include/serd/string.h b/include/serd/string.h index 7652b05f..b5ba7154 100644 --- a/include/serd/string.h +++ b/include/serd/string.h @@ -35,14 +35,13 @@ serd_strlen(const char* SERD_NONNULL str, SerdNodeFlags* SERD_NULLABLE flags); format used in the Turtle grammar (the decimal point is always "."). */ SERD_API double -serd_strtod(const char* SERD_NONNULL str, - char* SERD_NONNULL* SERD_NULLABLE endptr); +serd_strtod(const char* SERD_NONNULL str, + const char* SERD_NONNULL* SERD_NULLABLE endptr); /** Decode a base64 string. - This function can be used to deserialise a blob node created with - serd_new_blob(). + This function can be used to decode a node created with serd_new_base64(). @param str Base64 string to decode. @param len The length of `str`. |