/0.8-beta/uri.html
HTML | 284 lines | 259 code | 25 blank | 0 comment | 0 complexity | 4630bd1facacea0b5ba316cabac8a376 MD5 | raw file
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
- <title>The URI template — cpp-netlib v0.8 documentation</title>
- <link rel="stylesheet" href="_static/cpp-netlib.css" type="text/css" />
- <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
- <script type="text/javascript">
- var DOCUMENTATION_OPTIONS = {
- URL_ROOT: '',
- VERSION: '0.8',
- COLLAPSE_INDEX: false,
- FILE_SUFFIX: '.html',
- HAS_SOURCE: true
- };
- </script>
- <script type="text/javascript" src="_static/jquery.js"></script>
- <script type="text/javascript" src="_static/underscore.js"></script>
- <script type="text/javascript" src="_static/doctools.js"></script>
- <link rel="top" title="cpp-netlib v0.8 documentation" href="index.html" />
- <link rel="up" title="An in-depth look at the cpp-netlib" href="in_depth.html" />
- <link rel="next" title="HTTP implementation" href="http.html" />
- <link rel="prev" title="The message template" href="message.html" />
- </head>
- <body>
- <div class="document">
- <div id="custom-doc" class="yui-t4">
- <div id="hd">
- <h1><a href="index.html">cpp-netlib v0.8 documentation</a></h1>
- <div class="nav">
- « <a href="message.html" title="The message template">previous</a>
- |
- <a href="in_depth.html" title="An in-depth look at the <tt class="docutils literal docutils literal docutils literal docutils literal docutils literal"><span class="pre">cpp-netlib</span></tt>" accesskey="U">up</a>
- |
- <a href="http.html" title="HTTP implementation">next</a> »</div>
- </div>
- <div id="bd">
- <div id="yui-main">
- <div class="yui-b">
- <div class="yui-g" id="uri">
-
- <div class="section" id="the-uri-template">
- <h1>The URI template<a class="headerlink" href="#the-uri-template" title="Permalink to this headline">¶</a></h1>
- <p>In addition to protocol implementations, the <tt class="xref py py-mod docutils literal"><span class="pre">cpp-netlib</span></tt>
- provides a powerful URI template. The URI template implements a
- parser based on <a class="reference external" href="http://tools.ietf.org/html/rfc3986">RFC 3986</a>.</p>
- <div class="section" id="generic-uri-syntax-overview">
- <h2>Generic URI Syntax Overview<a class="headerlink" href="#generic-uri-syntax-overview" title="Permalink to this headline">¶</a></h2>
- <p>A generic URI will take the form:</p>
- <div class="highlight-python"><pre>[scheme:]scheme-specific-part[#fragment]</pre>
- </div>
- <p>A URI is known as <cite>absolute</cite> if it specifies the scheme. Otherwise,
- it is known as a relative URI. Currently, <tt class="docutils literal"><span class="pre">basic_uri</span></tt> supports
- only absolute URIs.</p>
- <p>URIs can be further classified according to whether they’re
- hierarchical or opaque (non-hierarchical).</p>
- <p>Some examples of non-hierarchical URIs include:</p>
- <div class="highlight-python"><pre>mailto:john.doe@example.com
- news:comp.infosystems.www.servers.unix
- tel:+1-816-555-1212</pre>
- </div>
- <p>The data following the first <tt class="docutils literal"><span class="pre">":"</span></tt> is said to be opaque to the URI
- parser and requires no further parsing. By way of example, the
- following shows how a non-hierarchical URI is processed by the parser
- by defining everything after the <tt class="docutils literal"><span class="pre">":"</span></tt> to be a part of the path:</p>
- <img alt="_images/mailto_uri.png" src="_images/mailto_uri.png" />
- <p>A hierarchical URI is identified by a double slash (<tt class="docutils literal"><span class="pre">"//"</span></tt>) after
- the scheme and a scheme-specific component, which <a class="reference external" href="http://tools.ietf.org/html/rfc3986">RFC 3986</a> defines
- to be:</p>
- <div class="highlight-python"><pre>[scheme:][//authority][path][?query][#fragment]</pre>
- </div>
- <p>The authority component can be further broken down to:</p>
- <div class="highlight-python"><pre>[user_info@]host[:port]</pre>
- </div>
- <p>Examples of hierarchical URIs include:</p>
- <div class="highlight-python"><pre>http://www.boost.org/
- file:///bin/bash</pre>
- </div>
- <p>The following example, describing a complex URI using FTP, shows how
- a URI is broken down by the parser:</p>
- <img alt="_images/ftp_uri.png" src="_images/ftp_uri.png" />
- <p>Note that the <tt class="docutils literal"><span class="pre">authority</span></tt> is further subdivided into different
- elements. Another example, using HTTP is given below:</p>
- <img alt="_images/http_uri.png" src="_images/http_uri.png" />
- <p>The difference here between the path in a hierarchical URI and that in
- the example above for the non-hierarchical URI.</p>
- </div>
- <div class="section" id="basic-uri">
- <h2><tt class="docutils literal"><span class="pre">basic_uri</span></tt><a class="headerlink" href="#basic-uri" title="Permalink to this headline">¶</a></h2>
- <p>The <tt class="docutils literal"><span class="pre">basic_uri</span></tt> definition is consistent with that of
- <tt class="docutils literal"><span class="pre">basic_message</span></tt>:</p>
- <div class="highlight-python"><pre>template <class Tag>
- class basic_uri;</pre>
- </div>
- <p>As it stands, the template only supplies a URI parser and no builder.
- To use the parser, it’s as simple as supplying a string to the
- constructor:</p>
- <div class="highlight-python"><pre>boost::network::uri::uri instance("http://cpp-netlib.github.com/");
- assert(boost::is_valid(instance));
- std::cout << "scheme: " << boost::network::uri::scheme(instance) << std::endl
- << "host: " << boost::network::uri::host(instance) << std::endl;</pre>
- </div>
- <p>The command-line output of this program will be:</p>
- <div class="highlight-python"><pre>scheme: http
- host: cpp-netlib.github.com</pre>
- </div>
- <p>A future version of <tt class="docutils literal"><span class="pre">basic_uri</span></tt> will provide a full builder API.</p>
- </div>
- <div class="section" id="uri-concept">
- <h2><tt class="docutils literal"><span class="pre">URI</span> <span class="pre">Concept</span></tt><a class="headerlink" href="#uri-concept" title="Permalink to this headline">¶</a></h2>
- <p><strong>Legend</strong></p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field"><th class="field-name">U:</th><td class="field-body">The URI type.</td>
- </tr>
- <tr class="field"><th class="field-name">u,u_:</th><td class="field-body">An instance of <strong>M</strong>.</td>
- </tr>
- <tr class="field"><th class="field-name">S:</th><td class="field-body">A string type.</td>
- </tr>
- <tr class="field"><th class="field-name">s,v:</th><td class="field-body">An instance of <strong>S</strong>.</td>
- </tr>
- <tr class="field"><th class="field-name">T:</th><td class="field-body">The Tag type.</td>
- </tr>
- </tbody>
- </table>
- <table border="1" class="docutils">
- <colgroup>
- <col width="31%" />
- <col width="24%" />
- <col width="45%" />
- </colgroup>
- <thead valign="bottom">
- <tr><th class="head">Construct</th>
- <th class="head">Result</th>
- <th class="head">Description</th>
- </tr>
- </thead>
- <tbody valign="top">
- <tr><td><tt class="docutils literal"><span class="pre">U(u)</span></tt></td>
- <td>Instance of U</td>
- <td>Copy constructible.</td>
- </tr>
- <tr><td><tt class="docutils literal"><span class="pre">U(s)</span></tt></td>
- <td>Instance of U</td>
- <td>Constructible from string.</td>
- </tr>
- <tr><td><tt class="docutils literal"><span class="pre">u</span> <span class="pre">=</span> <span class="pre">u_;</span></tt></td>
- <td>Reference to u</td>
- <td>Assignable.</td>
- </tr>
- <tr><td><tt class="docutils literal"><span class="pre">u</span> <span class="pre">=</span> <span class="pre">s;</span></tt></td>
- <td>Reference to u</td>
- <td>Assignable from string.</td>
- </tr>
- <tr><td><tt class="docutils literal"><span class="pre">swap(u,</span> <span class="pre">u_);</span></tt></td>
- <td><tt class="docutils literal"><span class="pre">void</span></tt></td>
- <td>Swappable.</td>
- </tr>
- <tr><td><tt class="docutils literal"><span class="pre">scheme(u);</span></tt></td>
- <td>Convertible to S</td>
- <td>Retrieve the URI scheme of <tt class="docutils literal"><span class="pre">u</span></tt>.</td>
- </tr>
- <tr><td><tt class="docutils literal"><span class="pre">user_info(u);</span></tt></td>
- <td>Convertible to S</td>
- <td>Retrieve the user info of <tt class="docutils literal"><span class="pre">u</span></tt>.</td>
- </tr>
- <tr><td><tt class="docutils literal"><span class="pre">host(u);</span></tt></td>
- <td>Convertible to S</td>
- <td>Retrieve the host of <tt class="docutils literal"><span class="pre">u</span></tt>.</td>
- </tr>
- <tr><td><tt class="docutils literal"><span class="pre">port(u);</span></tt></td>
- <td>Convertible to H</td>
- <td>Retrieve the port of <tt class="docutils literal"><span class="pre">u</span></tt>.</td>
- </tr>
- <tr><td><tt class="docutils literal"><span class="pre">path(u);</span></tt></td>
- <td>Convertible to S</td>
- <td>Retrieve the path of <tt class="docutils literal"><span class="pre">u</span></tt>.</td>
- </tr>
- <tr><td><tt class="docutils literal"><span class="pre">query(u);</span></tt></td>
- <td>Convertible to S</td>
- <td>Retrieve the query string of <tt class="docutils literal"><span class="pre">u</span></tt>.</td>
- </tr>
- <tr><td><tt class="docutils literal"><span class="pre">fragment(u);</span></tt></td>
- <td>Convertible to S</td>
- <td>Retrieve the fragment of <tt class="docutils literal"><span class="pre">u</span></tt>.</td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- </div>
- </div>
- </div>
-
-
- <div class="yui-b" id="sidebar">
-
- <div class="sphinxsidebar">
- <div class="sphinxsidebarwrapper">
- <h3><a href="index.html">Table Of Contents</a></h3>
- <ul>
- <li><a class="reference internal" href="#">The URI template</a><ul>
- <li><a class="reference internal" href="#generic-uri-syntax-overview">Generic URI Syntax Overview</a></li>
- <li><a class="reference internal" href="#basic-uri"><tt class="docutils literal"><span class="pre">basic_uri</span></tt></a></li>
- <li><a class="reference internal" href="#uri-concept"><tt class="docutils literal"><span class="pre">URI</span> <span class="pre">Concept</span></tt></a></li>
- </ul>
- </li>
- </ul>
- <h3>Browse</h3>
- <ul>
-
- <li>Prev: <a href="message.html">The message template</a></li>
-
-
- <li>Next: <a href="http.html">HTTP implementation</a></li>
-
- </ul>
- <h3>You are here:</h3>
- <ul>
- <li>
- <a href="index.html">cpp-netlib v0.8 documentation</a>
-
- <ul><li><a href="in_depth.html">An in-depth look at the <tt class="docutils literal docutils literal docutils literal docutils literal docutils literal"><span class="pre">cpp-netlib</span></tt></a>
-
- <ul><li>The URI template</li></ul>
- </li></ul>
- </li>
- </ul>
- <h3>This Page</h3>
- <ul class="this-page-menu">
- <li><a href="_sources/uri.txt"
- rel="nofollow">Show Source</a></li>
- </ul>
- <div id="searchbox" style="display: none">
- <h3>Quick search</h3>
- <form class="search" action="search.html" method="get">
- <input type="text" name="q" size="18" />
- <input type="submit" value="Go" />
- <input type="hidden" name="check_keywords" value="yes" />
- <input type="hidden" name="area" value="default" />
- </form>
- <p class="searchtip" style="font-size: 90%">
- Enter search terms or a module, class or function name.
- </p>
- </div>
- <script type="text/javascript">$('#searchbox').show(0);</script>
- </div>
- </div>
- </div>
-
-
- </div>
- <div id="ft">
- <div class="nav">
- « <a href="message.html" title="The message template">previous</a>
- |
- <a href="in_depth.html" title="An in-depth look at the <tt class="docutils literal docutils literal docutils literal docutils literal docutils literal"><span class="pre">cpp-netlib</span></tt>" accesskey="U">up</a>
- |
- <a href="http.html" title="HTTP implementation">next</a> »</div>
- </div>
- </div>
- <div class="clearer"></div>
- </div>
- <div class="footer">
- documentation automatically generated by <a href="http://sphinx.pocoo.org">Sphinx</a> | style mostly stolen from <a href="http://lettuce.it">lettuce.it</a>
- </div>
- </body>
- </html>