Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Terribly sorry, couldn't help it. :s</p> <h3>url.hh</h3> <pre><code>#ifndef URL_HH_ #define URL_HH_ #include &lt;string&gt; struct url { url(const std::string&amp; url_s); // omitted copy, ==, accessors, ... private: void parse(const std::string&amp; url_s); private: std::string protocol_, host_, path_, query_; }; #endif /* URL_HH_ */ </code></pre> <h3>url.cc</h3> <pre><code>#include "url.hh" #include &lt;string&gt; #include &lt;algorithm&gt; #include &lt;cctype&gt; #include &lt;functional&gt; using namespace std; // ctors, copy, equality, ... void url::parse(const string&amp; url_s) { const string prot_end("://"); string::const_iterator prot_i = search(url_s.begin(), url_s.end(), prot_end.begin(), prot_end.end()); protocol_.reserve(distance(url_s.begin(), prot_i)); transform(url_s.begin(), prot_i, back_inserter(protocol_), ptr_fun&lt;int,int&gt;(tolower)); // protocol is icase if( prot_i == url_s.end() ) return; advance(prot_i, prot_end.length()); string::const_iterator path_i = find(prot_i, url_s.end(), '/'); host_.reserve(distance(prot_i, path_i)); transform(prot_i, path_i, back_inserter(host_), ptr_fun&lt;int,int&gt;(tolower)); // host is icase string::const_iterator query_i = find(path_i, url_s.end(), '?'); path_.assign(path_i, query_i); if( query_i != url_s.end() ) ++query_i; query_.assign(query_i, url_s.end()); } </code></pre> <h3>main.cc</h3> <pre><code>// ... url u("HTTP://stackoverflow.com/questions/2616011/parse-a.py?url=1"); cout &lt;&lt; u.protocol() &lt;&lt; '\t' &lt;&lt; u.host() &lt;&lt; ... </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload