turtle printing functions #3

Merged
merged 12 commits into from Mar 30, 2012

Projects

None yet

2 participants

Contributor

Functions for prefixed (using namespaces) printing of terms or uris

dajobe commented on d071bc7 Oct 12, 2011

You need to fix the C90 style.

I'd prefer if there was also a 'write' version of it like
int raptor_term_ntriples_write(const raptor_term term, raptor_iostream iostr);
but with the appropriate args.

That means you can write such a term to any output iostream in turtle format.

Then write raptor_term_to_turtle_string() in terms of that.

Or vice versa. You can build the write version around raptor_term_to_turtle_string().

Update:

I just noticed there is an iostream inside; so you should pull out that core and make a 'write' function, then call it.

I'd prefer if this was raptor_term_to_turtle_counted_string which handled returning an optional length, and then a raptor_term_to_turtle_string() which wrapped it. Trying to reduce the amount of strlen() in the world. You'd need to pass it into raptor_new_iostream_to_string() instead of NULL but it's not a big change.

@dajobe dajobe commented on an outdated diff Mar 29, 2012
src/raptor_serialize_turtle.c
@@ -1191,3 +1191,173 @@ static int raptor_turtle_serialize_statement(raptor_serializer* serializer,
&raptor_turtle_serializer_register_factory);
}
+
+
+/**
+ * raptor_uri_write_turtle:
dajobe
dajobe Mar 29, 2012 Owner

should be called raptor_uri_turtle_write

@dajobe dajobe commented on an outdated diff Mar 29, 2012
src/raptor_serialize_turtle.c
+ raptor_turtle_writer_qname(turtle_writer, qname);
+
+ raptor_free_qname(qname);
+ } else {
+ raptor_turtle_writer_reference(turtle_writer, uri);
+ }
+
+ raptor_free_turtle_writer(turtle_writer);
+
+ return 0;
+}
+
+
+
+/**
+ * raptor_term_write_turtle:
dajobe
dajobe Mar 29, 2012 Owner

should be called raptor_term_turtle_write

@dajobe dajobe commented on an outdated diff Mar 29, 2012
src/raptor_serialize_turtle.c
@@ -1191,3 +1191,173 @@ static int raptor_turtle_serialize_statement(raptor_serializer* serializer,
&raptor_turtle_serializer_register_factory);
}
+
+
+/**
+ * raptor_uri_write_turtle:
+ * @t1: world
+ * @t2: iostream for writing
+ * @t3: uri
+ * @t4: namespace stack
+ * @t5: base URI
dajobe
dajobe Mar 29, 2012 Owner

You need to use @world etc not @t1 here.

@dajobe dajobe commented on an outdated diff Mar 29, 2012
src/raptor_serialize_turtle.c
+ raptor_turtle_writer_reference(turtle_writer, uri);
+ }
+
+ raptor_free_turtle_writer(turtle_writer);
+
+ return 0;
+}
+
+
+
+/**
+ * raptor_term_write_turtle:
+ * @t1: iostream for writing
+ * @t2: term
+ * @t3: namespace stack
+ * @t4: base URI
dajobe
dajobe Mar 29, 2012 Owner

same here

@dajobe dajobe commented on an outdated diff Mar 29, 2012
src/raptor_serialize_turtle.c
+ term->value.literal.datatype);
+ } else if(term->type == RAPTOR_TERM_TYPE_BLANK) {
+ raptor_bnodeid_ntriples_write(term->value.blank.string, term->value.blank.string_len, iostr);
+ } else {
+ rc = 2;
+ }
+
+ raptor_free_turtle_writer(turtle_writer);
+
+ return rc;
+}
+
+
+
+/**
+ * raptor_uri_to_turtle_string:
dajobe
dajobe Mar 29, 2012 Owner

should be a counted version returning length with a wrapper

@dajobe dajobe commented on an outdated diff Mar 29, 2012
src/raptor_serialize_turtle.c
+
+ rc = raptor_uri_write_turtle(world, iostr, uri, nstack, base_uri);
+
+ raptor_free_iostream(iostr);
+ if(rc) {
+ free(s);
+ s = NULL;
+ }
+
+ return s;
+}
+
+
+
+/**
+ * raptor_term_to_turtle_string:
dajobe
dajobe Mar 29, 2012 Owner

should be a counted version returning length with a wrapper

@dajobe dajobe merged commit e905159 into dajobe:master Mar 30, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment