From 4038ab95a094b363f1748f3dcb51511a1217475d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 07:40:05 +0200 Subject: Adding upstream version 2.0.16. Signed-off-by: Daniel Baumann --- docs/html/tutorial-serializer-to-destination.html | 120 ++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 docs/html/tutorial-serializer-to-destination.html (limited to 'docs/html/tutorial-serializer-to-destination.html') diff --git a/docs/html/tutorial-serializer-to-destination.html b/docs/html/tutorial-serializer-to-destination.html new file mode 100644 index 0000000..f126e2f --- /dev/null +++ b/docs/html/tutorial-serializer-to-destination.html @@ -0,0 +1,120 @@ + + + + +Provide a destination for the serialized syntax: Raptor RDF Syntax Library Manual + + + + + + + + + + + + + + + + +
+

+Provide a destination for the serialized syntax

+

The operation of turning RDF triples into a syntax has several +alternatives from functions that do most of the work writing to a file +or string to functions that allow passing in a +raptor_iostream +which can be entirely user-constructed.

+
+

+Serialize to a filename (raptor_serializer_start_to_filename())

+

Serialize to a new filename +(using raptor_new_iostream_to_filename() internally) +and uses asf base URI, the file's URI. +

+
+  const char *filename = "raptor.rdf";
+  raptor_serializer_start_to_filename(rdf_serializer, filename);
+
+

+

+
+
+

+Serialize to a string (raptor_serializer_start_to_string())

+

Serialize to a string that is allocated by the serializer +(using raptor_new_iostream_to_string() internally). The +resulting string is only constructed after raptor_serializer_serialize_end() is called and at that +point it is assigned to the string pointer passed in, with the length +written to the optional length pointer. This function +takes an optional base URI but may be required by some serializers. +

+
+  raptor_uri* uri = raptor_new_uri(world, "http://example.org/base");
+  void *string;  /* destination for string */
+  size_t length; /* length of constructed string */
+  raptor_serializer* rdf_serializer = /* serializer created by some means */ ;
+
+  raptor_serializer_start_to_string(rdf_serializer, uri,
+                                    &string, &length);
+
+

+

+
+
+

+Serialize to a FILE* file handle (raptor_serializer_start_to_file_handle())

+

Serialize to an existing open C FILE* file handle +(using raptor_new_iostream_to_file_handle() internally). The handle is not closed after serializing is finished. This function +takes an optional base URI but may be required by some serializers. +

+
+  raptor_uri* uri = raptor_new_uri(world, "http://example.org/base");
+  FILE* fh = fopen("raptor.rdf", "wb");
+  raptor_serializer* rdf_serializer = /* serializer created by some means */ ;
+
+  raptor_serializer_start_to_file_handle(rdf_serializer, uri, fh);
+
+

+

+
+
+ +

This is the most flexible serializing method as it allows +writing to any +raptor_iostream +which can be constructed to build any form of user-generated structure +via callbacks. The iostream remains owned by the caller that can continue +to write to it after the serializing is finished (after +raptor_serializer_serialize_end()) is called). +

+
+  raptor_uri* uri = raptor_new_uri(world, "http://example.org/base");
+  raptor_iostream* iostream = /* iostream initialized by some means */ ;
+  raptor_serializer* rdf_serializer = /* serializer created by some means */ ;
+
+  raptor_serializer_start_to_iostream(rdf_serializer, uri, iostream);
+
+  while( /* got RDF triples */ ) {
+    raptor_statement* triple = /* ... triple made from somewhere ... */ ;
+    raptor_serializer_serialize_statement(rdf_serializer, triple);
+  }
+  raptor_serializer_serialize_end(rdf_serializer);
+
+  raptor_free_serializer(rdf_serializer);
+
+  /* ... write other stuff to iostream ... */
+
+  raptor_free_iostream(iostream);
+
+

+

+
+
+ + + \ No newline at end of file -- cgit v1.2.3