diff options
Diffstat (limited to 'docs/html/tutorial-serializer-to-destination.html')
-rw-r--r-- | docs/html/tutorial-serializer-to-destination.html | 120 |
1 files changed, 120 insertions, 0 deletions
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 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<title>Provide a destination for the serialized syntax: Raptor RDF Syntax Library Manual</title> +<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"> +<link rel="home" href="index.html" title="Raptor RDF Syntax Library Manual"> +<link rel="up" href="tutorial-serializing.html" title="Serializing RDF triples to a syntax"> +<link rel="prev" href="tutorial-serializer-set-error-warning-handlers.html" title="Set error and warning handlers"> +<link rel="next" href="tutorial-serializer-get-triples.html" title="Get or construct RDF Statements (Triples)"> +<meta name="generator" content="GTK-Doc V1.33.1 (XML mode)"> +<link rel="stylesheet" href="style.css" type="text/css"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle"> +<td width="100%" align="left" class="shortcuts"></td> +<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td> +<td><a accesskey="u" href="tutorial-serializing.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td> +<td><a accesskey="p" href="tutorial-serializer-set-error-warning-handlers.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td> +<td><a accesskey="n" href="tutorial-serializer-get-triples.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td> +</tr></table> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="tutorial-serializer-to-destination"></a>Provide a destination for the serialized syntax</h2></div></div></div> +<p>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 +<a class="link" href="raptor2-section-iostream.html#raptor-iostream" title="raptor_iostream"><span class="type">raptor_iostream</span></a> +which can be entirely user-constructed.</p> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="serialize-to-filename"></a>Serialize to a filename (<a class="link" href="raptor2-section-serializer.html#raptor-serializer-start-to-filename" title="raptor_serializer_start_to_filename ()"><code class="function">raptor_serializer_start_to_filename()</code></a>)</h3></div></div></div> +<p>Serialize to a new filename +(using <a class="link" href="raptor2-section-iostream.html#raptor-new-iostream-to-filename" title="raptor_new_iostream_to_filename ()"><code class="function">raptor_new_iostream_to_filename()</code></a> internally) +and uses asf base URI, the file's URI. +</p> +<pre class="programlisting"> + const char *filename = "raptor.rdf"; + raptor_serializer_start_to_filename(rdf_serializer, filename); +</pre> +<p> +</p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="serialize-to-string"></a>Serialize to a string (<a class="link" href="raptor2-section-serializer.html#raptor-serializer-start-to-string" title="raptor_serializer_start_to_string ()"><code class="function">raptor_serializer_start_to_string()</code></a>)</h3></div></div></div> +<p>Serialize to a string that is allocated by the serializer +(using <a class="link" href="raptor2-section-iostream.html#raptor-new-iostream-to-string" title="raptor_new_iostream_to_string ()"><code class="function">raptor_new_iostream_to_string()</code></a> internally). The +resulting string is only constructed after <a class="link" href="raptor2-section-serializer.html#raptor-serializer-serialize-end" title="raptor_serializer_serialize_end ()"><code class="function">raptor_serializer_serialize_end()</code></a> 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. +</p> +<pre class="programlisting"> + 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); +</pre> +<p> +</p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="serialize-to-filehandle"></a>Serialize to a FILE* file handle (<a class="link" href="raptor2-section-serializer.html#raptor-serializer-start-to-file-handle" title="raptor_serializer_start_to_file_handle ()"><code class="function">raptor_serializer_start_to_file_handle()</code></a>)</h3></div></div></div> +<p>Serialize to an existing open C FILE* file handle +(using <a class="link" href="raptor2-section-iostream.html#raptor-new-iostream-to-file-handle" title="raptor_new_iostream_to_file_handle ()"><code class="function">raptor_new_iostream_to_file_handle()</code></a> internally). The handle is not closed after serializing is finished. This function +takes an optional base URI but may be required by some serializers. +</p> +<pre class="programlisting"> + 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); +</pre> +<p> +</p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="serialize-to-iostream"></a>Serialize to an <a class="link" href="raptor2-section-iostream.html#raptor-iostream" title="raptor_iostream"><span class="type">raptor_iostream</span></a> (<a class="link" href="raptor2-section-serializer.html#raptor-serializer-start-to-iostream" title="raptor_serializer_start_to_iostream ()"><code class="function">raptor_serializer_start_to_iostream()</code></a>)</h3></div></div></div> +<p>This is the most flexible serializing method as it allows +writing to any +<a class="link" href="raptor2-section-iostream.html#raptor-iostream" title="raptor_iostream"><span class="type">raptor_iostream</span></a> +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 +<a class="link" href="raptor2-section-serializer.html#raptor-serializer-serialize-end" title="raptor_serializer_serialize_end ()"><code class="function">raptor_serializer_serialize_end()</code></a>) is called). +</p> +<pre class="programlisting"> + 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); +</pre> +<p> +</p> +</div> +</div> +<div class="footer"> +<hr>Generated by GTK-Doc V1.33.1</div> +</body> +</html>
\ No newline at end of file |