1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-17 08:30:06 +02:00
audacity/lib-src/libraptor/docs/html/tutorial-serializer-to-destination.html
2010-01-24 09:19:39 +00:00

116 lines
7.3 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
<link rel="start" href="index.html" title="Raptor RDF Syntax Parsing and Serializing 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 Triples">
<meta name="generator" content="GTK-Doc V1.10 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="introduction.html" title="Raptor Overview">
<link rel="part" href="tutorial.html" title="Part I. Raptor Tutorial">
<link rel="chapter" href="tutorial-initialising-finishing.html" title="Initialising and Finishing using the Library">
<link rel="chapter" href="tutorial-querying-functionality.html" title="Listing built-in functionality">
<link rel="chapter" href="tutorial-parsing.html" title="Parsing syntaxes to RDF Triples">
<link rel="chapter" href="tutorial-serializing.html" title="Serializing RDF triples to a syntax">
<link rel="part" href="reference-manual.html" title="Part II. Raptor Reference Manual">
<link rel="chapter" href="raptor-parsers.html" title="Parsers in Raptor (syntax to triples)">
<link rel="chapter" href="raptor-serializers.html" title="Serializers in Raptor (triples to syntax)">
<link rel="index" href="ix01.html" title="Index">
</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="2"><tr valign="middle">
<td><a accesskey="p" href="tutorial-serializer-set-error-warning-handlers.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="tutorial-serializing.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">Raptor RDF Syntax Parsing and Serializing Library Manual</th>
<td><a accesskey="n" href="tutorial-serializer-get-triples.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr></table>
<div class="section" lang="en">
<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="raptor-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" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="serialize-to-filename"></a>Serialize to a filename (<a class="link" href="raptor-section-serializer.html#raptor-serialize-start-to-filename" title="raptor_serialize_start_to_filename ()"><code class="function">raptor_serialize_start_to_filename()</code></a>)</h3></div></div></div>
<p>Serialize to a new filename
(using <a class="link" href="raptor-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_serialize_start_to_filename(rdf_serializer, filename);
</pre>
<p>
</p>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="serialize-to-string"></a>Serialize to a string (<a class="link" href="raptor-section-serializer.html#raptor-serialize-start-to-string" title="raptor_serialize_start_to_string ()"><code class="function">raptor_serialize_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="raptor-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="raptor-section-serializer.html#raptor-serialize-end" title="raptor_serialize_end ()"><code class="function">raptor_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("http://example.org/base");
void *string; /* destination for string */
size_t length; /* length of constructed string */
raptor_serialize_start_to_string(rdf_serializer, uri,
&amp;string, &amp;length);
</pre>
<p>
</p>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="serialize-to-filehandle"></a>Serialize to a FILE* file handle (<a class="link" href="raptor-section-serializer.html#raptor-serialize-start-to-file-handle" title="raptor_serialize_start_to_file_handle ()"><code class="function">raptor_serialize_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="raptor-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("http://example.org/base");
FILE* fh=fopen("raptor.rdf", "wb");
raptor_serialize_start_to_file_handle(rdf_serializer, uri, fh);
</pre>
<p>
</p>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="serialize-to-iostream"></a>Serialize to an <a class="link" href="raptor-section-iostream.html#raptor-iostream" title="raptor_iostream"><span class="type">raptor_iostream</span></a> (<a class="link" href="raptor-section-serializer.html#raptor-serialize-start" title="raptor_serialize_start ()"><code class="function">raptor_serialize_start()</code></a>)</h3></div></div></div>
<p>This is the most flexible serializing method as it allows
writing to any
<a class="link" href="raptor-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.
</p>
<pre class="programlisting">
raptor_uri* uri=raptor_new_uri("http://example.org/base");
raptor_iostream* iostream;
/* iostream initialized by some means */
raptor_serialize_start(rdf_serializer, uri, iostream);
</pre>
<p>
</p>
</div>
</div>
<div class="footer">
<hr>
Generated by GTK-Doc V1.10</div>
</body>
</html>