Uri and Uuid: Identifying Things On The Web
Uri and Uuid: Identifying Things On The Web
Overview
>
>
>
URI Structure
>
>
>
>
>
>
URI Examples
http://www.google.com/search?q=POCO
Scheme
Host
Path
Query
Scheme
Host
Path
Fragment
Scheme
User
Host
Path
#include "Poco/URI.h"
#include <iostream>
int main(int argc, char** argv)
{
Poco::URI uri1("http://www.appinf.com:88/sample?example-query#frag");
std::string scheme(uri1.getScheme());
std::string auth(uri1.getAuthority());
std::string host(uri1.getHost());
unsigned short port = uri1.getPort();
std::string path(uri1.getPath());
std::string query(uri1.getQuery());
std::string frag(uri1.getFragment());
std::string pathEtc(uri1.getPathEtc());
query#frag"
//
//
//
//
//
//
//
//
"http"
"www.appinf.com:88"
"www.appinf.com"
88
"/sample"
"example-query"
"frag"
"/sample?example-
Poco::URI uri2;
uri2.setScheme("https");
uri2.setAuthority("www.appinf.com");
uri2.setPath("/another sample");
std::string s(uri2.toString());
// "https://www.appinf.com/another%20sample"
std::string uri3("http://www.appinf.com");
uri3.resolve("/poco/info/index.html");
s = uri3.toString(); // "http://www.appinf.com/poco/info/index.html"
uri3.resolve("support.html");
s = uri3.toString(); // "http://www.appinf.com/poco/info/support.html"
uri3.resolve("http://sourceforge.net/projects/poco");
s = uri3.toString(); // "http://sourceforge.net/projects/poco"
}
return 0;
URIStreamOpener
>
>
>
>
#include
#include
#include
#include
"Poco/URIStreamOpener.h"
"Poco/Net/HTTPStreamFactory.h"
"Poco/Net/FTPStreamFactory.h"
<memory>
std::auto_ptr<std::istream> istr1(
opener.open("http://www.appinf.com/index.html")
);
std::auto_ptr<std::istream> istr2(
opener.open("ftp://ftp.appinf.com/pub/poco/poco-1.2.5.tar.gz")
);
std::auto_ptr<std::istream> istr3(
opener.open("file:///usr/include/stdio.h")
);
return 0;
UUIDs
>
>
>
>
>
time-based
name-based
random
>
>
>
#include "Poco/UUID.h"
#include "Poco/UUIDGenerator.h"
#include <iostream>
using Poco::UUID;
using Poco::UUIDGenerator;
int main(int argc, char** argv)
{
UUIDGenerator& generator = UUIDGenerator::defaultGenerator();
UUID uuid1(generator.create()); // time based
UUID uuid2(generator.createRandom());
UUID uuid3(generator.createFromName(UUID::uri(), "http://appinf.com");
std::cout << uuid1.toString() << std::endl;
std::cout << uuid2.toString() << std::endl;
std::cout << uuid3.toString() << std::endl;
}
return 0;