Browse Source

Write port values in presets as pretty numbers.

git-svn-id: http://svn.drobilla.net/lad/trunk/sratom@4168 a436a847-0d15-0410-975c-d299462d15a1
zrythm_meson
David Robillard 11 years ago
parent
commit
9b3c2ddf33
  1. 20
      sratom/sratom.h
  2. 15
      src/sratom.c

20
sratom/sratom.h

@ -78,10 +78,7 @@ sratom_free(Sratom* sratom); @@ -78,10 +78,7 @@ sratom_free(Sratom* sratom);
/**
Set the sink(s) where sratom will write its output.
This must be called before calling sratom_write(). If @p pretty_numbers is
true, numbers will be written as pretty Turtle literals, rather than string
literals with precise types. The cost of this is the types might get
fudged on a round-trip to RDF and back.
This must be called before calling sratom_write().
*/
SRATOM_API
void
@ -89,8 +86,19 @@ sratom_set_sink(Sratom* sratom, @@ -89,8 +86,19 @@ sratom_set_sink(Sratom* sratom,
const char* base_uri,
SerdStatementSink sink,
SerdEndSink end_sink,
void* handle,
bool pretty_numbers);
void* handle);
/**
Write pretty numeric literals.
If @p pretty_numbers is true, numbers will be written as pretty Turtle
literals, rather than string literals with precise types. The cost of this
is that the types might get fudged on a round-trip to RDF and back.
*/
SRATOM_API
void
sratom_set_pretty_numbers(Sratom* sratom,
bool pretty_numbers);
/**
Write an Atom to RDF.

15
src/sratom.c

@ -96,8 +96,7 @@ sratom_set_sink(Sratom* sratom, @@ -96,8 +96,7 @@ sratom_set_sink(Sratom* sratom,
const char* base_uri,
SerdStatementSink write_statement,
SerdEndSink end_anon,
void* handle,
bool pretty_numbers)
void* handle)
{
if (base_uri) {
serd_node_free(&sratom->base_uri);
@ -107,7 +106,14 @@ sratom_set_sink(Sratom* sratom, @@ -107,7 +106,14 @@ sratom_set_sink(Sratom* sratom,
sratom->write_statement = write_statement;
sratom->end_anon = end_anon;
sratom->handle = handle;
sratom->pretty_numbers = pretty_numbers;
}
SRATOM_API
void
sratom_set_pretty_numbers(Sratom* sratom,
bool pretty_numbers)
{
sratom->pretty_numbers = pretty_numbers;
}
static void
@ -441,8 +447,7 @@ sratom_to_turtle(Sratom* sratom, @@ -441,8 +447,7 @@ sratom_to_turtle(Sratom* sratom,
sratom_set_sink(sratom, base_uri,
(SerdStatementSink)serd_writer_write_statement,
(SerdEndSink)serd_writer_end_anon,
writer,
false);
writer);
sratom_write(sratom, unmap, SERD_EMPTY_S,
subject, predicate, type, size, body);
serd_writer_finish(writer);

Loading…
Cancel
Save