diff --git a/index.html b/index.html new file mode 100644 index 000000000..2cac53c9b --- /dev/null +++ b/index.html @@ -0,0 +1,25 @@ + + + + + + + + + + + + Automatic redirection failed, please go to index.html. + + + + diff --git a/libs/network/doc/architecture.qbk b/libs/network/doc/architecture.qbk index d43eeb565..dbf417258 100644 --- a/libs/network/doc/architecture.qbk +++ b/libs/network/doc/architecture.qbk @@ -7,11 +7,19 @@ [section:architecture Architecture] -__cnl__ is built upon __boost_asio__, a high-quality, portable asynchronous I/O library that provides a solid interface for C++ network programming. +__cnl__ is built upon __boost_asio__, a high-quality, portable +asynchronous I/O library that provides a solid interface for C++ +network programming. -The architecture is driven by the requirement to separate requests and responses from the transport mechanism. Additionally, it utilises generic programming techniques to make decisions at compile-time, resulting in more efficient and stable client code. +The architecture is driven by the requirement to separate requests and +responses from the transport mechanism. Additionally, it utilises +generic programming techniques to make decisions at compile-time, +resulting in more efficient and stable client code. -There are two main features of the architecture which use modern C++ techniques to allow extensibility without comprimising efficiency: tags and directives. It is these techniques that underpin the design of the message. +There are two main features of the architecture which use modern C++ +techniques to allow extensibility without comprimising efficiency: +tags and directives. It is these techniques that underpin the design +of the message. [include message.qbk] [include uri.qbk] diff --git a/libs/network/doc/html/c___network_library/acknowledgements.html b/libs/network/doc/html/c___network_library/acknowledgements.html new file mode 100644 index 000000000..5e68c3a6e --- /dev/null +++ b/libs/network/doc/html/c___network_library/acknowledgements.html @@ -0,0 +1,46 @@ + + + +Acknowledgements + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHome +
+
+

+ Acknowledgements +

+

+ Much of the implementation of the HTTP package was ported from the + Pion Network Library. +

+
+ + + +
+
+
+PrevUpHome +
+ + diff --git a/libs/network/doc/html/c___network_library/architecture.html b/libs/network/doc/html/c___network_library/architecture.html new file mode 100644 index 000000000..5ede1b1e1 --- /dev/null +++ b/libs/network/doc/html/c___network_library/architecture.html @@ -0,0 +1,85 @@ + + + +Architecture + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+ Architecture +

+
+
The Message
+
+
+ Tag Dispatching
+
+ Concepts
+
+ Message
+
+ Transformation layer
+
+ Rendering layer
+
+
The URI
+
+
+ URI Concepts
+
+
+ URI
+
+ HTTP URI
+
+
+
+

+ C++ Network Library is built upon Boost.Asio, + a high-quality, portable asynchronous I/O library that provides a solid interface + for C++ network programming. +

+

+ The architecture is driven by the requirement to separate requests and responses + from the transport mechanism. Additionally, it utilises generic programming + techniques to make decisions at compile-time, resulting in more efficient and + stable client code. +

+

+ There are two main features of the architecture which use modern C++ techniques + to allow extensibility without comprimising efficiency: tags and directives. + It is these techniques that underpin the design of the message. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/libs/network/doc/html/c___network_library/architecture/message.html b/libs/network/doc/html/c___network_library/architecture/message.html new file mode 100644 index 000000000..e10b49170 --- /dev/null +++ b/libs/network/doc/html/c___network_library/architecture/message.html @@ -0,0 +1,151 @@ + + + +The Message + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+ The Message +

+
+
+ Tag Dispatching
+
+ Concepts
+
+ Message
+
+ Transformation layer
+
+ Rendering layer
+
+

+ The initial concept behind the C++ Network Library is the basic_message + template. The advantage of this is that basic_message + can be specialized for different protocol implementations. +

+

+ basic_message is presented below: +

+

+

+

+ +

+
namespace boost { namespace network {
+template <
+    class Tag
+    >
+class basic_message {
+public:
+    1typedef typename string<Tag>::type string_type;
+    2typedef typename headers_container<Tag>::type headers_container_type;
+
+    3basic_message(const basic_message &);
+    4basic_message &operator = (const basic_message &);
+    5void swap(basic_message &);
+
+    6headers_container_type & headers() const;
+    7string_type & body() const;
+    8string_type & source() const;
+    9string_type & destination() const;
+};
+
+10typedef basic_message<tags::default_> message;
+}}
+
+

+

+

+

+

+

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

1

Defines the underlying string type, so that the message can be specialized + for different text encodings

2

Defines a container for message headers

3

Copy + constructor

4

Assignment operator

5

Swap function

6

Accesses the message headers +

7

Accesses the message body

8

Accesses the source of the message

9

Accesses the + destination of the message

10

Defines a message with default parameters.

+

+

+

+

+

+ basic_message is the bare minimum for a class to model + the Message concept. It is intended to be extended and customized according + to the requirements of different protocols. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/libs/network/doc/html/c___network_library/architecture/message/message_concepts.html b/libs/network/doc/html/c___network_library/architecture/message/message_concepts.html new file mode 100644 index 000000000..270e44e3e --- /dev/null +++ b/libs/network/doc/html/c___network_library/architecture/message/message_concepts.html @@ -0,0 +1,221 @@ + + + +Concepts + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+ + Concepts +

+
+ Message
+

+ basic_message is DefaultConstructible, + CopyConstructible + and Assignable. +

+
+ +
+ + Description +
+

+ A type models the URI Concept if the type adheres to the following usage + semantics, and is DefaultConstructible and EqualityComparable. +

+
+

Notation

+
+
M
+

+ A Message Type. +

+
m, + m_
+

+ A Message Type instance. +

+
S
+

+ A String Type. +

+
s
+

+ A String Type instance. +

+
O
+

+ An Ostringstream Type. +

+
o
+

+ An Ostringstream Type instance. +

+
C
+

+ A Header Container Type. +

+
c
+

+ A Header Container Type instance. +

+
+
+
+ + Valid + Expressions +
+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Expression +

+
+

+ Return Type +

+
+

+ Description +

+
+

+ M m_(m); +

+
+

+

+
+

+ M must be Copy constructible. +

+
+

+ M m_; m_ + = m; +

+
+

+

+
+

+ M must be Assignable. +

+
+

+ swap(m, + m_); +

+
+

+ void +

+
+

+ Swap should be availabe via ADL. +

+
+

+ M::string_type +

+
+

+ S +

+
+

+ M should have a nested type string_type + of type S. +

+
+

+ M::headers_container_type +

+
+

+ C +

+
+

+ M should have a nested type headers_container_type + of type C. +

+
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/libs/network/doc/html/c___network_library/architecture/message/rendering_layer.html b/libs/network/doc/html/c___network_library/architecture/message/rendering_layer.html new file mode 100644 index 000000000..d4013f9c6 --- /dev/null +++ b/libs/network/doc/html/c___network_library/architecture/message/rendering_layer.html @@ -0,0 +1,55 @@ + + + +Rendering layer + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+ + Rendering layer +

+

+ The rendering layer defines the algorithms used to render a message into + different formats or types. Rendering functions should apply to any type + that models the Message Concept. Functions in the rendering layer take + the form: +

+
template <
+    class Tag
+    >
+unspecified &render(const basic_message<Tag> &, ...);
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/libs/network/doc/html/c___network_library/architecture/message/tag_dispatching.html b/libs/network/doc/html/c___network_library/architecture/message/tag_dispatching.html new file mode 100644 index 000000000..a45ee35d5 --- /dev/null +++ b/libs/network/doc/html/c___network_library/architecture/message/tag_dispatching.html @@ -0,0 +1,119 @@ + + + +Tag Dispatching + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+ + Tag Dispatching +

+

+ The basic_message template has a single argument (Tag). + Tags are useful because: +

+
    +
  1. + It's possible to specialize the message for different storage requirements; +
  2. +
  3. + It's possible to extend the message to support different network protocols. +
  4. +
+

+ The storage requirements for each of these can differ depending on factors + such as the string encoding type or memory usage. For different reasons, + its possible to assume a string implementation might be: +

+
    +
  1. std::string
  2. +
  3. std::wstring
  4. +
  5. std::vector<boost::uint32_t>
  6. +
  7. CString
  8. +
  9. QString
  10. +
+

+ The C++ Network Library uses tag dispatching to specialize the message + interface at compile time. +

+
namespace boost {
+namespace network {
+template <
+    class Tag
+    >
+class unsupported_tag;
+
+template <
+    class Tag
+    >
+struct string {
+    typedef unsupported_tag<Tag> type;
+};
+
+namespace tags {
+struct default_ { };
+} // namespace tags
+
+template <>
+struct string<tags::default_> {
+    typedef std::string type;
+};
+} // namespace network
+} // namespace boost
+
+

+ This technique is extended to two more metafunctions that are used by + basic_message: +

+
namespace boost {
+namespace network {
+template <
+    class Tag
+    >
+struct ostringstream {
+    typedef unsupported_tag<Tag> type;
+};
+
+template <
+    class Tag
+    >
+struct headers_container {
+    typedef unsupported_tag<Tag> type;
+};
+} // namespace network
+} // namespace boost
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/libs/network/doc/html/c___network_library/architecture/message/transformation_layer.html b/libs/network/doc/html/c___network_library/architecture/message/transformation_layer.html new file mode 100644 index 000000000..cec3a6bb4 --- /dev/null +++ b/libs/network/doc/html/c___network_library/architecture/message/transformation_layer.html @@ -0,0 +1,55 @@ + + + +Transformation layer + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+ + Transformation layer +

+

+ The transformation layer defines the algorithms that can be applied on + messages to transform parts or whole messages into different forms or representations. + Transformations should apply to any type that models the Message concept. + Functions in the transform layer take the form: +

+
template <
+    class Tag
+    >
+basic_message<Tag> &transform(basic_message<Tag> &, ...);
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/libs/network/doc/html/c___network_library/architecture/uri.html b/libs/network/doc/html/c___network_library/architecture/uri.html new file mode 100644 index 000000000..694bc3e04 --- /dev/null +++ b/libs/network/doc/html/c___network_library/architecture/uri.html @@ -0,0 +1,63 @@ + + + +The URI + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+ The URI +

+
+
+ URI Concepts
+
+
+ URI
+
+ HTTP URI
+
+
+

+ The library includes a URI object and parser implementation that allows users + of the library to easily interact with different kinds of valid URI formats. +

+

+ Currently the library supports a bare URI implementation that only parsers + the scheme and leaves the scheme specific part as is, as well as a very liberal + HTTP URI parser. The HTTP URI object only supports absolute URIs that start + with either 'http' or 'https'. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/libs/network/doc/html/c___network_library/architecture/uri/concepts.html b/libs/network/doc/html/c___network_library/architecture/uri/concepts.html new file mode 100644 index 000000000..8784e8464 --- /dev/null +++ b/libs/network/doc/html/c___network_library/architecture/uri/concepts.html @@ -0,0 +1,412 @@ + + + +URI Concepts + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+ URI + Concepts +

+
+
+ URI
+
+ HTTP URI
+
+

+ This page describes the URI Concepts implemented within cpp-netlib. The + following concepts are also implemented as Boost.Concept_check types enforced + by the URI library. +

+

+ URI Concepts are organized into a hierarchy of conepts. +

+
+
+ + URI +
+
+ + Description +
+

+ A type models the URI Concept if the type adheres to the following usage + semantics, and is DefaultConstructible and EqualityComparable. +

+
+

Notation

+
+
U
+

+ A URI Type. +

+
u,u_
+

+ A URI Type instance. +

+
S
+

+ A String Type. +

+
s
+

+ A String Type instance. +

+
+
+
+ + Valid + Expressions +
+

+ For any URI, the following expressions must be valid: +

+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Expression +

+
+

+ Return Type +

+
+

+ Description +

+
+

+ U u_(u) +

+
+

+

+
+

+ U must be Copy constructible. +

+
+

+ U u_(s) +

+
+

+

+
+

+ U can be constructed from a string s. +

+
+

+ swap(u,u_) +

+
+

+ void +

+
+

+ Swap should be availabe via ADL. +

+
+

+ protocol(u) +

+
+

+ S +

+
+

+ Return the protocol part of the URI. +

+
+

+ rest(u) +

+
+

+ S +

+
+

+ Return the rest of the URI, excluding the protocol part. +

+
+

+ valid(u) +

+
+

+ bool +

+
+

+ Return true whether the URI is a valid URI. +

+
+

+ U::string_type +

+
+

+ S +

+
+

+ U should have a nested type string_type + of type S. +

+
+
+
+ +

+ A type models the HTTP URI Concept if the type adheres to the following + usage semantics, and if the type also models the URI Concept. +

+
+

Notation

+
+
H
+

+ An HTTP URI Type. +

+
h,h_
+

+ An HTTP URI Type instance. +

+
S
+

+ A String Type. +

+
s
+

+ A String Type instance. +

+
+
+
+ + Valid + Expressions +
+

+ For any HTTP URI, the following expressions must be valid: +

+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Expression +

+
+

+ Return Type +

+
+

+ Description +

+
+

+ user_info(h) +

+
+

+ S +

+
+

+ Retrieve the user-info part of the HTTP URI. +

+
+

+ host(h) +

+
+

+ S +

+
+

+ Retrieve the host part of the HTTP URI. +

+
+

+ port(h) +

+
+

+ uint32_t +

+
+

+ Retrieve the port part of the HTTP URI. +

+
+

+ path(h) +

+
+

+ S +

+
+

+ Retrieve the path part of the HTTP URI. +

+
+

+ query(h) +

+
+

+ S +

+
+

+ Retrieve the query part of the HTTP URI. +

+
+

+ fragment(h) +

+
+

+ S +

+
+

+ Retrieve the fragment part of the HTTP URI. +

+
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/libs/network/doc/html/c___network_library/architecture/uri/uri_concepts.html b/libs/network/doc/html/c___network_library/architecture/uri/uri_concepts.html new file mode 100644 index 000000000..29f61d696 --- /dev/null +++ b/libs/network/doc/html/c___network_library/architecture/uri/uri_concepts.html @@ -0,0 +1,431 @@ + + + +URI Concepts + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+ + URI Concepts +

+
+
+ URI
+
+ HTTP URI
+
+

+ This page describes the URI Concepts implemented within cpp-netlib. The + following concepts are also implemented as Boost.Concept_check types enforced + by the URI library. +

+

+ URI Concepts are organized into a hierarchy of conepts. +

+
+
+ + URI +
+
+ + Description +
+

+ A type models the URI Concept if the type adheres to the following usage + semantics, and is DefaultConstructible and EqualityComparable. +

+
+

Notation

+
+
U
+

+ A URI Type. +

+
u, + u_
+

+ A URI Type instance. +

+
S
+

+ A String Type. +

+
s
+

+ A String Type instance. +

+
+
+
+ + Valid + Expressions +
+

+ For any URI, the following expressions must be valid: +

+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Expression +

+
+

+ Return Type +

+
+

+ Description +

+
+

+ U u_(u); +

+
+

+

+
+

+ U must be Copy constructible. +

+
+

+ U u_; u_ + = u; +

+
+

+

+
+

+ U must be Assignable. +

+
+

+ U u_(s); +

+
+

+

+
+

+ U can be constructed from a string s. +

+
+

+ swap(u, + u_); +

+
+

+ void +

+
+

+ Swap should be availabe via ADL. +

+
+

+ protocol(u); +

+
+

+ S +

+
+

+ Return the protocol part of the URI. +

+
+

+ rest(u); +

+
+

+ S +

+
+

+ Return the rest of the URI, excluding the protocol part. +

+
+

+ valid(u); +

+
+

+ bool +

+
+

+ Return true whether the URI is a valid URI. +

+
+

+ U::string_type +

+
+

+ S +

+
+

+ U should have a nested type string_type + of type S. +

+
+
+
+ +

+ A type models the HTTP URI Concept if the type adheres to the following + usage semantics, and if the type also models the URI Concept. +

+
+

Notation

+
+
H
+

+ An HTTP URI Type. +

+
h,h_
+

+ An HTTP URI Type instance. +

+
S
+

+ A String Type. +

+
s
+

+ A String Type instance. +

+
+
+
+ + Valid + Expressions +
+

+ For any HTTP URI, the following expressions must be valid: +

+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Expression +

+
+

+ Return Type +

+
+

+ Description +

+
+

+ user_info(h) +

+
+

+ S +

+
+

+ Retrieve the user-info part of the HTTP URI. +

+
+

+ host(h) +

+
+

+ S +

+
+

+ Retrieve the host part of the HTTP URI. +

+
+

+ port(h) +

+
+

+ uint32_t +

+
+

+ Retrieve the port part of the HTTP URI. +

+
+

+ path(h) +

+
+

+ S +

+
+

+ Retrieve the path part of the HTTP URI. +

+
+

+ query(h) +

+
+

+ S +

+
+

+ Retrieve the query part of the HTTP URI. +

+
+

+ fragment(h) +

+
+

+ S +

+
+

+ Retrieve the fragment part of the HTTP URI. +

+
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/libs/network/doc/html/c___network_library/examples.html b/libs/network/doc/html/c___network_library/examples.html new file mode 100644 index 000000000..ab85f154e --- /dev/null +++ b/libs/network/doc/html/c___network_library/examples.html @@ -0,0 +1,48 @@ + + + +Examples + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+ Examples +

+
+
HTTP Client
+
Simple 'wget' + Clone
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/libs/network/doc/html/c___network_library/examples/http_client.html b/libs/network/doc/html/c___network_library/examples/http_client.html new file mode 100644 index 000000000..42941dcdc --- /dev/null +++ b/libs/network/doc/html/c___network_library/examples/http_client.html @@ -0,0 +1,135 @@ + + + +HTTP Client + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+ HTTP Client +

+

+

+

+ This application takes a URL as a command line argument and prints the + resource to the console. +

+

+

+

+ +

+
#include <boost/program_options.hpp>
+#include <boost/network/protocol/http.hpp>
+#include <string>
+#include <iostream>
+
+namespace po = boost::program_options;
+using namespace std;
+
+int main(int argc, char * argv[]) {
+    po::options_description options("Allowed options");
+    string output_filename, source;
+    bool show_headers;
+    options.add_options()
+        ("help,h", "produce help message")
+        ("headers,H", "print headers")
+        ("source,s", po::value<string>(&source), "source URL")
+        ;
+
+    po::positional_options_description positional_options;
+    positional_options.add("source", 1);
+    po::variables_map vm;
+    try {
+        po::store(po::command_line_parser(argc, argv).options(options).positional(positional_options).run(),
+            vm);
+        po::notify(vm);
+    } catch(exception & e) {
+        cout << "Error: " << e.what() << endl;
+        cout << options << endl;
+        return EXIT_FAILURE;
+    };
+
+    if (vm.count("help")) {
+        cout << options << endl;
+        return EXIT_SUCCESS;
+    };
+
+    if (vm.count("source") < 1) {
+        cout << "Error: Source URL required." << endl;
+        cout << options << endl;
+        return EXIT_FAILURE;
+    };
+
+    show_headers = vm.count("headers") ? true : false ;
+
+    //try {
+        using namespace boost::network;
+
+        http::basic_client<tags::http_keepalive_8bit_udp_resolve,1,1>::request request(source);
+        request << header("Connection", "close");
+        http::basic_client<tags::http_keepalive_8bit_udp_resolve,1,1> client(
+            http::basic_client<tags::http_keepalive_8bit_udp_resolve,1,1>::follow_redirects
+            );
+        http::basic_client<tags::http_keepalive_8bit_udp_resolve,1,1>::response response;
+        response = client.get(request);
+
+        if (show_headers) {
+            headers_range<http::basic_client<tags::http_keepalive_8bit_udp_resolve,1,1>::response>::type headers_ = headers(response);
+            boost::range_iterator<headers_range<http::basic_client<tags::http_keepalive_8bit_udp_resolve,1,1>::response>::type>::type header, past_end;
+            header = begin(headers_);
+            past_end = end(headers_);
+            while (header != past_end) {
+                cout << header->first << ": " << header->second << endl;
+                ++header;
+            };
+            cout << endl;
+        };
+
+        cout << body(response) << endl;
+        
+    //} catch (exception & e) {
+    //    cout << "Error: " << e.what() << endl;
+    //    return EXIT_FAILURE;
+    //};
+
+    return EXIT_SUCCESS;
+}
+
+

+

+

+

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/libs/network/doc/html/c___network_library/examples/simple_wget.html b/libs/network/doc/html/c___network_library/examples/simple_wget.html new file mode 100644 index 000000000..26fc7c771 --- /dev/null +++ b/libs/network/doc/html/c___network_library/examples/simple_wget.html @@ -0,0 +1,111 @@ + + + +Simple 'wget' Clone + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+ Simple 'wget' + Clone +

+

+

+

+ +

+
/*
+  This is a very basic clone of wget.  It's missing a lot of
+  features, such as content-type detection, but it does the
+  fundamental things the same.
+  
+  It demonstrates the use the http::uri and the http::client.
+*/
+
+
+#include <boost/network.hpp>
+#include <boost/network/uri/http/uri.hpp>
+#include <string>
+#include <fstream>
+#include <iostream>
+
+
+namespace http = boost::network::http;
+namespace uri = boost::network::uri;
+
+
+namespace {
+std::string get_filename(const char *url) {
+    uri::http::uri uri(url);
+    std::string path = uri::path(uri);
+    std::size_t index = path.find_last_of('/');
+    std::string filename = path.substr(index + 1);
+    return filename.empty()? "index.html" : filename;
+}
+}
+
+
+int
+main(int argc, char *argv[]) {
+    
+    if (argc != 2) {
+        std::cerr << "Usage: " << argv[0] << " url" << std::endl;
+        return 1;
+    }
+
+    try {
+        http::client client;
+        const char *uri = argv[1];
+        http::client::request request(uri);
+        http::client::response response = client.get(request);
+
+        std::string filename = get_filename(uri);
+        std::cout << "Saving to: " << filename << std::endl;
+        std::ofstream ofs(filename.c_str());
+        ofs << boost::network::body(response) << std::endl;
+    }
+    catch (std::exception &e) {
+        std::cerr << e.what() << std::endl;
+        return 1;
+    }
+
+    return 0;
+}
+
+

+

+

+

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/libs/network/doc/html/c___network_library/intro.html b/libs/network/doc/html/c___network_library/intro.html new file mode 100644 index 000000000..1c01ae1d3 --- /dev/null +++ b/libs/network/doc/html/c___network_library/intro.html @@ -0,0 +1,48 @@ + + + +Introduction + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+ Introduction +

+
+
Motivation
+
Objectives
+
History
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/libs/network/doc/html/c___network_library/intro/history.html b/libs/network/doc/html/c___network_library/intro/history.html new file mode 100644 index 000000000..26be00009 --- /dev/null +++ b/libs/network/doc/html/c___network_library/intro/history.html @@ -0,0 +1,50 @@ + + + +History + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+ History +

+

+ The C++ Network Library was founded by Dean Michael Berris in 2007. Initially + it consisted of a message template and an HTTP client. It found a home on + [[http://sourceforge.net/projectscpp-netlib][sourceforge]] + but was recently migrated to [[http://github.com/mikhailberis/cpp-netlib][github]] + where development is actively continued by a committed community. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/libs/network/doc/html/c___network_library/intro/motivation.html b/libs/network/doc/html/c___network_library/intro/motivation.html new file mode 100644 index 000000000..18b16e257 --- /dev/null +++ b/libs/network/doc/html/c___network_library/intro/motivation.html @@ -0,0 +1,56 @@ + + + +Motivation + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+ Motivation +

+

+ Modern applications that communicate over the internet have never been more + prevalent, ranging through diverse areas such as high performance servers + to embedded systems for smart phones or navigation systems. +

+

+ Currently, there are no open source network libraries available that use + modern object-oriented techniques in C++. With the introduction of Boost.Asio, developing + portable network C++ applications has become a very much easier task. What + is still lacking is a set of libraries that utilise Boost.Asio + in order to provide application level support so that C++ developers are + able to develop internet and distributed applications more effectively. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/libs/network/doc/html/c___network_library/intro/objectives.html b/libs/network/doc/html/c___network_library/intro/objectives.html new file mode 100644 index 000000000..cbbd8acd2 --- /dev/null +++ b/libs/network/doc/html/c___network_library/intro/objectives.html @@ -0,0 +1,76 @@ + + + +Objectives + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+ Objectives +

+

+ The objectives of the C++ Network Library are to: +

+
+

+ The goal of C++ Network Library has never been to build a fully-featured + web server - there are plenty of excellent options already available. The + niche that this library targets is for light-weight networking functionality + for C++ applications that have demanding performance requirements or memory + constraints, but that also need to be portable. This type of application + is becoming increasingly common as software becomes more distributed, and + applications need to communicate with services. +

+

+ While many languages provide direct library support for high level network + programming, this feature is missing in C++. Therefore, this library has + been developed with the intention of eventually being submitted to the Boost C++ Libraries, a collection + of general, high quality libraries for C++ developers. +

+

+ Eventually, C++ Network Library will be extended to support many of the application + layer protocols such as SMTP, FTP, SOAP, XMPP etc. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/libs/network/doc/html/c___network_library/intro/objectives/history.html b/libs/network/doc/html/c___network_library/intro/objectives/history.html new file mode 100644 index 000000000..b8c7d4682 --- /dev/null +++ b/libs/network/doc/html/c___network_library/intro/objectives/history.html @@ -0,0 +1,41 @@ + + + +History + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+

+ History +

+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/libs/network/doc/html/c___network_library/protocol.html b/libs/network/doc/html/c___network_library/protocol.html new file mode 100644 index 000000000..61784108e --- /dev/null +++ b/libs/network/doc/html/c___network_library/protocol.html @@ -0,0 +1,49 @@ + + + +Application Layer Protocols + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+ Application Layer Protocols +

+
HTTP
+

+ The message and URI alone don't make a useful library. This section describes + some of the common network protocols that are implemented in the C++ Network + Library. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/libs/network/doc/html/c___network_library/protocol/http.html b/libs/network/doc/html/c___network_library/protocol/http.html new file mode 100644 index 000000000..614fc73f8 --- /dev/null +++ b/libs/network/doc/html/c___network_library/protocol/http.html @@ -0,0 +1,210 @@ + + + +HTTP + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+ HTTP +

+

+ The C++ Network Library provides direct support for HTTP. As a motivating + example, here is the code again from the quick start. +

+
#include <boost/network/protocol/http.hpp>
+#include <iostream>
+
+int
+main(int argc, char *argv[]) {
+    using boost::network;
+
+    http::request request("http://www.boost.org/");
+    http::client client;
+    http::response response = client.get(request);
+
+    // print response headers
+    headers_range<http::response>::type hdrs = headers(response);
+    boost::range_iterator<headers_range<http::response>::type>::type
+        it = boost::begin(hdrs), end = boost::end(hdrs);
+    for (; it != end; ++it) {
+        std::cout << it->first << ": " << it->second << std::endl;
+    }
+
+    // print response body
+    std::cout << body(response) << std::endl;
+    return 0;
+}
+
+

+ Before walking through exactly what is happening in this example, the principle + components are described below: +

+
+ + HTTP Request +
+
namespace boost { namespace network { namespace http {
+    template <class Tag> class basic_request;
+    typedef basic_request<tags::default_> request;
+}}}
+
+

+ The request encapsulates information about the request + and the resource. It models the Message concept. +

+
+ + HTTP Client +
+
namespace boost { namespace network { namespace http {
+    template <class Tag> class basic_client;
+    typedef basic_client<tags::default_> client;
+}}}
+
+

+ The client encapsulates the connection-mapping logic between + the domain and the underlying socket. Access to a resource is managed through + the client object. +

+
+ + HTTP Response +
+
namespace boost { namespace network { namespace http {
+    template <class Tag> class basic_response;
+    typedef basic_response<tags::default_> response;
+}}}
+
+

+ The response encapsulates the data received from the server. + It also models the Message concept. +

+
+ + Walkthrough +
+
http::request request("http://www.boost.org/");
+
+

+ This line frames the request for the resource http://www.boost.org/. +

+
http::client client;
+
+

+ Then a client object is created that handles all HTTP requests and responses. +

+
http::response response = client.get(request);
+
+

+ The client simply performs the requests. The interface is trivially easy. + All HTTP methods are supported (HEAD, GET, POST, PUT, DELETE). +

+

+ There are several advantages to this design: +

+
    +
  1. + A client object manages the connection, unencumbering + the developer with this task; +
  2. +
  3. + A request can be used with any instance of the client + without binding the client to any destination; +
  4. +
  5. + By decoupling the method from the request object it + allows developers to create requests that may be re-used (e.g. perform + a HEAD first; if the the headers don't fulfil a certain criteria, perform + a GET using the same resource). +
  6. +
+
// print response headers
+headers_range<http::response>::type hdrs = headers(response);
+boost::range_iterator<headers_range<http::response>::type>::type
+    it = boost::begin(hdrs), end = boost::end(hdrs);
+for (; it != end; ++it) 
+   std::cout << it->first << ": " << it->second << std::endl;
+}
+
+// print response body
+std::cout << body(response) << std::endl;
+
+

+ Once the request has been made, and the client returns + a response object, the rest is simple. This example outputs + all the response headers and body, in this case just the Boost homepage. +

+
+ + Using + http::client +
+

+ The http::client supports the following operations: +

+
+

+ HTTP features can be enabled by using constructor arguments: +

+
+
+ + http::client::cache_resolved +
+

+ This argument enables the caching of resolved endpoints and prevents the + client from resolving IP addresses of previously resolved hostnames. +

+
+ + http::client::follow_redirect(s) +
+

+ http::client::follow_redirects / http::client::follow_redirect + follow HTTP redirect(s) (300..307) by looking at the "Location" + header provided by the response(s); headers present in the original request + are preserved in the subsequent request(s). +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/libs/network/doc/html/c___network_library/quick_start.html b/libs/network/doc/html/c___network_library/quick_start.html new file mode 100644 index 000000000..69be49e23 --- /dev/null +++ b/libs/network/doc/html/c___network_library/quick_start.html @@ -0,0 +1,123 @@ + + + +Quick Start + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+ Quick Start +

+

+

+

+ Here is an example of C++ Network Library at it's absolute simplest. It downloads + a file over HTTP from a URL given as a command line argument and prints the + response to the console. +

+

+

+

+ +

+
#include <boost/network.hpp>
+#include <iostream>
+
+int
+main(int argc, char *argv[]) {
+    namespace http = boost::network::http;
+    
+    if (argc != 2) {
+        std::cout << "Usage: " << argv[0] << " url" << std::endl;
+        return 1;
+    }
+    
+    try {
+        1http::client client;
+        2http::request request(argv[1]);
+        3http::response response = client.get(request);
+
+        4headers_range<http::response>::type hdrs = headers(response);
+        boost::range_iterator<headers_range<http::response>::type>::type
+            it = boost::begin(hdrs), end = boost::end(hdrs);
+        for (; it != end; ++it) {
+            std::cout << it->first << ": " << it->second << std::endl;
+        }
+
+        5std::cout << http::body(response) << std::endl;
+    }
+    catch (std::exception &e) {
+        std::cerr << e.what() << std::endl;
+        return 1;
+    }
+    
+    return 0;
+}
+
+

+

+

+

+

+

+
+ + + + + + + + + + + + + + + + + + + + +

1

Create the client

2

Create a request using a URI supplied on the command line +

3

Get a response

4

Iterate through the response headers and print them to the + console

5

Print the response body to the console

+

+

+

+

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/libs/network/doc/html/c___network_library/reference.html b/libs/network/doc/html/c___network_library/reference.html new file mode 100644 index 000000000..3c8576128 --- /dev/null +++ b/libs/network/doc/html/c___network_library/reference.html @@ -0,0 +1,63 @@ + + + +Reference + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+ Reference +

+
+

+
+
HTTP + 1.0
+

+ The HTTP 1.0 specification. +

+
HTTP + 1.1 (RFC 2616)
+

+ The HTTP 1.1 specification. +

+
URI + Generic Syntax RFC 2396)
+

+ Generic URI syntax specification. +

+
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/libs/network/doc/html/c___network_library/using.html b/libs/network/doc/html/c___network_library/using.html new file mode 100644 index 000000000..1f3fab0ef --- /dev/null +++ b/libs/network/doc/html/c___network_library/using.html @@ -0,0 +1,67 @@ + + + +Using The C++ Network Library + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+ Using The C++ Network Library +

+

+ + Supported Platforms +

+

+ The C++ Network Library is tested on GCC 4.3 on Linux; MSVC 9.0 on Windows + Vista. +

+

+ + Dependencies +

+

+ The C++ Network Library works with Boost 1.35.0 and greater. +

+

+ Boost is mostly header only but its necessary to build and link to Boost.System + in order to use the C++ Network Library. +

+

+ Running the tests for the library also requires Python + to be available in a directory that is present in the system path. The tests + work with Python 2.5. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/libs/network/doc/html/index.html b/libs/network/doc/html/index.html new file mode 100644 index 000000000..bb1b19c05 --- /dev/null +++ b/libs/network/doc/html/index.html @@ -0,0 +1,92 @@ + + + +C++ Network Library 0.5 + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
Next
+
+
+
+

+C++ Network Library 0.5

+
+

+Glyn Matthews +

+

+Dean Michael Berris +

+
+
+
+

+ Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +

+
+
+
+
+
+

Table of Contents

+
+
Quick Start
+
Introduction
+
+
Motivation
+
Objectives
+
History
+
+
Using The C++ Network Library
+
Architecture
+
+
The Message
+
+
+ Tag Dispatching
+
+ Concepts
+
+ Transformation layer
+
+ Rendering layer
+
+
The URI
+
+ URI Concepts
+
+
Application Layer Protocols
+
HTTP
+
Examples
+
+
HTTP Client
+
Simple 'wget' + Clone
+
+
Reference
+
Acknowledgements
+
+
+
+ + + +

Last revised: January 13, 2010 at 21:26:50 GMT

+
+
Next
+ + diff --git a/libs/network/doc/html/standalone_HTML.manifest b/libs/network/doc/html/standalone_HTML.manifest new file mode 100644 index 000000000..79474ef74 --- /dev/null +++ b/libs/network/doc/html/standalone_HTML.manifest @@ -0,0 +1,22 @@ +index.html +c___network_library/quick_start.html +c___network_library/intro.html +c___network_library/intro/motivation.html +c___network_library/intro/objectives.html +c___network_library/intro/history.html +c___network_library/using.html +c___network_library/architecture.html +c___network_library/architecture/message.html +c___network_library/architecture/message/tag_dispatching.html +c___network_library/architecture/message/message_concepts.html +c___network_library/architecture/message/transformation_layer.html +c___network_library/architecture/message/rendering_layer.html +c___network_library/architecture/uri.html +c___network_library/architecture/uri/uri_concepts.html +c___network_library/protocol.html +c___network_library/protocol/http.html +c___network_library/examples.html +c___network_library/examples/http_client.html +c___network_library/examples/simple_wget.html +c___network_library/reference.html +c___network_library/acknowledgements.html diff --git a/libs/network/doc/http.qbk b/libs/network/doc/http.qbk index b4550c276..80018c01e 100644 --- a/libs/network/doc/http.qbk +++ b/libs/network/doc/http.qbk @@ -7,7 +7,8 @@ [section:http HTTP] -The __cnl__ provides direct support for HTTP. As a motivating example, here is the code again from the __quick_start__. +The __cnl__ provides direct support for HTTP. As a motivating +example, here is the code again from the __quick_start__. #include #include @@ -33,7 +34,8 @@ The __cnl__ provides direct support for HTTP. As a motivating example, here is return 0; } -Before walking through exactly what is happening in this example, the principle components are described below: +Before walking through exactly what is happening in this example, the +principle components are described below: [heading HTTP Request] @@ -42,7 +44,8 @@ Before walking through exactly what is happening in this example, the principle typedef basic_request request; }}} -The [^request] encapsulates information about the request and the resource. It models the Message concept. +The [^request] encapsulates information about the request and the +resource. It models the Message concept. [heading HTTP Client] @@ -51,7 +54,9 @@ The [^request] encapsulates information about the request and the resource. It typedef basic_client client; }}} -The [^client] encapsulates the connection-mapping logic between the domain and the underlying socket. Access to a resource is managed through the [^client] object. +The [^client] encapsulates the connection-mapping logic between the +domain and the underlying socket. Access to a resource is managed +through the [^client] object. [heading HTTP Response] @@ -60,7 +65,8 @@ The [^client] encapsulates the connection-mapping logic between the domain and t typedef basic_response response; }}} -The [^response] encapsulates the data received from the server. It also models the Message concept. +The [^response] encapsulates the data received from the server. It +also models the Message concept. [heading Walkthrough] @@ -70,17 +76,24 @@ This line frames the request for the resource __boost_org__. http::client client; -Then a client object is created that handles all HTTP requests and responses. +Then a client object is created that handles all HTTP requests and +responses. http::response response = client.get(request); -The client simply performs the requests. The interface is trivially easy. All HTTP methods are supported (HEAD, GET, POST, PUT, DELETE). +The client simply performs the requests. The interface is trivially +easy. All HTTP methods are supported (HEAD, GET, POST, PUT, DELETE). There are several advantages to this design: -# A [^client] object manages the connection, unencumbering the developer with this task; -# A [^request] can be used with any instance of the [^client] without binding the [^client] to any destination; -# By decoupling the method from the [^request] object it allows developers to create requests that may be re-used (e.g. perform a HEAD first; if the the headers don't fulfil a certain criteria, perform a GET using the same resource). +# A [^client] object manages the connection, unencumbering the + developer with this task; +# A [^request] can be used with any instance of the [^client] without + binding the [^client] to any destination; +# By decoupling the method from the [^request] object it allows + developers to create requests that may be re-used (e.g. perform a + HEAD first; if the the headers don't fulfil a certain criteria, + perform a GET using the same resource). // print response headers headers_range::type hdrs = headers(response); @@ -93,8 +106,9 @@ There are several advantages to this design: // print response body std::cout << body(response) << std::endl; -Once the request has been made, and the [^client] returns a [^response] object, the rest is simple. This example outputs all the response headers and body, in this case just the Boost homepage. - +Once the request has been made, and the [^client] returns a +[^response] object, the rest is simple. This example outputs all the +response headers and body, in this case just the Boost homepage. [heading Using [^http::client]] @@ -112,9 +126,14 @@ HTTP features can be enabled by using constructor arguments: * [^http::client(http::client::follow_redirect)] [h5 [^http::client::cache_resolved]] -This argument enables the caching of resolved endpoints and prevents the client from resolving IP addresses of previously resolved hostnames. +This argument enables the caching of resolved endpoints and prevents +the client from resolving IP addresses of previously resolved +hostnames. [h5 [^http::client::follow_redirect(s)]] -[^http::client::follow_redirects] / [^http::client::follow_redirect] follow HTTP redirect(s) (300..307) by looking at the "Location" header provided by the response(s); headers present in the original request are preserved in the subsequent request(s). +[^http::client::follow_redirects] / [^http::client::follow_redirect] +follow HTTP redirect(s) (300..307) by looking at the "Location" header +provided by the response(s); headers present in the original request +are preserved in the subsequent request(s). [endsect] [/http] diff --git a/libs/network/doc/intro.qbk b/libs/network/doc/intro.qbk index f57df452f..11259ee01 100644 --- a/libs/network/doc/intro.qbk +++ b/libs/network/doc/intro.qbk @@ -9,9 +9,17 @@ [section:intro Introduction] [section:motivation Motivation] -Modern applications that communicate over the internet have never been more prevalent, ranging through diverse areas such as high performance servers to embedded systems for smart phones or navigation systems. +Modern applications that communicate over the internet have never been +more prevalent, ranging through diverse areas such as high performance +servers to embedded systems for smart phones or navigation systems. -Currently, there are no open source network libraries available that use modern object-oriented techniques in C++. With the introduction of __boost_asio__, developing portable network C++ applications has become a very much easier task. What is still lacking is a set of libraries that utilise __boost_asio__ in order to provide application level support so that C++ developers are able to develop internet and distributed applications more effectively. +Currently, there are no open source network libraries available that +use modern object-oriented techniques in C++. With the introduction +of __boost_asio__, developing portable network C++ applications has +become a very much easier task. What is still lacking is a set of +libraries that utilise __boost_asio__ in order to provide application +level support so that C++ developers are able to develop internet and +distributed applications more effectively. [endsect] [/motivation] @@ -20,18 +28,36 @@ The objectives of the __cnl__ are to: * develop a high quality, portable, easy to use C++ networking library * enable developers to easily extend the library -* lower the barrier to entry for cross-platform network-aware C++ applications +* lower the barrier to entry for cross-platform network-aware C++ + applications -The goal of __cnl__ has never been to build a fully-featured web server - there are plenty of excellent options already available. The niche that this library targets is for light-weight networking functionality for C++ applications that have demanding performance requirements or memory constraints, but that also need to be portable. This type of application is becoming increasingly common as software becomes more distributed, and applications need to communicate with services. +The goal of __cnl__ has never been to build a fully-featured web +server - there are plenty of excellent options already available. The +niche that this library targets is for light-weight networking +functionality for C++ applications that have demanding performance +requirements or memory constraints, but that also need to be portable. +This type of application is becoming increasingly common as software +becomes more distributed, and applications need to communicate with +services. -While many languages provide direct library support for high level network programming, this feature is missing in C++. Therefore, this library has been developed with the intention of eventually being submitted to __boost__, a collection of general, high quality libraries for C++ developers. +While many languages provide direct library support for high level +network programming, this feature is missing in C++. Therefore, this +library has been developed with the intention of eventually being +submitted to __boost__, a collection of general, high quality +libraries for C++ developers. -Eventually, __cnl__ will be extended to support many of the application layer protocols such as SMTP, FTP, SOAP, XMPP etc. +Eventually, __cnl__ will be extended to support many of the +application layer protocols such as SMTP, FTP, SOAP, XMPP etc. [endsect] [/objectives] [section:history History] -The __cnl__ was founded by Dean Michael Berris in 2007. Initially it consisted of a message template and an HTTP client. It found a home on [[http://sourceforge.net/projects/cpp-netlib/][sourceforge]] but was recently migrated to [[http://github.com/mikhailberis/cpp-netlib][github]] where development is actively continued by a committed community. +The __cnl__ was founded by Dean Michael Berris in 2007. Initially it +consisted of a message template and an HTTP client. It found a home +on [[http://sourceforge.net/projects/cpp-netlib/][sourceforge]] but +was recently migrated to +[[http://github.com/mikhailberis/cpp-netlib][github]] where +development is actively continued by a committed community. [endsect] [/history] diff --git a/libs/network/doc/message.qbk b/libs/network/doc/message.qbk index 82956fa74..044b32ba9 100644 --- a/libs/network/doc/message.qbk +++ b/libs/network/doc/message.qbk @@ -7,21 +7,31 @@ [section:message The Message] -The initial concept behind the __cnl__ is the __message__ template. The advantage of this is that __message__ can be specialized for different protocol implementations. +The initial concept behind the __cnl__ is the __message__ +template. The advantage of this is that __message__ can be specialized +for different protocol implementations. __message__ is presented below: [import message.cpp] [boost_network_message] -__message__ is the bare minimum for a class to model the Message concept. It is intended to be extended and customized according to the requirements of different protocols. +__message__ is the bare minimum for a class to model the Message +concept. It is intended to be extended and customized according to +the requirements of different protocols. [section:tag_dispatching Tag Dispatching] -The __message__ template has a single argument (Tag). Tags are useful because: +The __message__ template has a single argument (Tag). Tags are useful +because: -# It's possible to specialize the message for different storage requirements; -# It's possible to extend the message to support different network protocols. +# It's possible to specialize the message for different storage + requirements; +# It's possible to extend the message to support different network + protocols. -The storage requirements for each of these can differ depending on factors such as the string encoding type or memory usage. For different reasons, its possible to assume a string implementation might be: +The storage requirements for each of these can differ depending on +factors such as the string encoding type or memory usage. For +different reasons, its possible to assume a string implementation +might be: # [^std::string] # [^std::wstring] @@ -29,7 +39,8 @@ The storage requirements for each of these can differ depending on factors such # [@http://msdn.microsoft.com/en-us/library/ms174288.aspx [^CString]] # [@http://doc.trolltech.com/qstring.html [^QString]] -The __cnl__ uses tag dispatching to specialize the message interface at compile time. +The __cnl__ uses tag dispatching to specialize the message interface +at compile time. namespace boost { namespace network { @@ -56,7 +67,8 @@ The __cnl__ uses tag dispatching to specialize the message interface at compile } // namespace network } // namespace boost -This technique is extended to two more metafunctions that are used by __message__: +This technique is extended to two more metafunctions that are used by +__message__: namespace boost { namespace network { @@ -79,7 +91,12 @@ This technique is extended to two more metafunctions that are used by __message_ [endsect] [/tag_dispatching] [section:message_concepts Concepts] -__message__ is [@http://www.boost.org/doc/html/DefaultConstructible.html DefaultConstructible], [@http://www.boost.org/doc/html/CopyConstructible.html CopyConstructible] and [@http://www.boost.org/doc/html/Assignable.html Assignable]. +__message__ is +[@http://www.boost.org/doc/html/DefaultConstructible.html +DefaultConstructible], +[@http://www.boost.org/doc/html/CopyConstructible.html +CopyConstructible] and [@http://www.boost.org/doc/html/Assignable.html +Assignable]. [section:message_concept Message] @@ -116,7 +133,10 @@ usage semantics, and is DefaultConstructible and EqualityComparable. [endsect] [/message_concepts] [section:transformation_layer Transformation layer] -The transformation layer defines the algorithms that can be applied on messages to transform parts or whole messages into different forms or representations. Transformations should apply to any type that models the Message concept. Functions in the transform layer take the form: +The transformation layer defines the algorithms that can be applied on +messages to transform parts or whole messages into different forms or +representations. Transformations should apply to any type that models +the Message concept. Functions in the transform layer take the form: template < class Tag @@ -126,7 +146,10 @@ The transformation layer defines the algorithms that can be applied on messages [endsect] [/transformation_layer] [section:rendering_layer Rendering layer] -The rendering layer defines the algorithms used to render a message into different formats or types. Rendering functions should apply to any type that models the Message Concept. Functions in the rendering layer take the form: +The rendering layer defines the algorithms used to render a message +into different formats or types. Rendering functions should apply to +any type that models the Message Concept. Functions in the rendering +layer take the form: template < class Tag diff --git a/libs/network/doc/objectives.qbk b/libs/network/doc/objectives.qbk index ab6bfcd94..24ed11046 100644 --- a/libs/network/doc/objectives.qbk +++ b/libs/network/doc/objectives.qbk @@ -11,12 +11,25 @@ The objectives of the __cnl__ are to: * develop a high quality, portable, easy to use C++ networking library * enable developers to easily extend the library -* lower the barrier to entry for cross-platform network-aware C++ applications +* lower the barrier to entry for cross-platform network-aware C++ + applications -The goal of __cnl__ has never been to build a fully-featured web server - there are plenty of excellent options already available. The niche that this library targets is for light-weight networking functionality for C++ applications that have demanding performance requirements or memory constraints, but that also need to be portable. This type of application is becoming increasingly common as software becomes more distributed, and applications need to communicate with services. +The goal of __cnl__ has never been to build a fully-featured web +server - there are plenty of excellent options already available. The +niche that this library targets is for light-weight networking +functionality for C++ applications that have demanding performance +requirements or memory constraints, but that also need to be portable. +This type of application is becoming increasingly common as software +becomes more distributed, and applications need to communicate with +services. -While many languages provide direct library support for high level network programming, this feature is missing in C++. Therefore, this library has been developed with the intention of eventually being submitted to __boost__, a collection of general, high quality libraries for C++ developers. +While many languages provide direct library support for high level +network programming, this feature is missing in C++. Therefore, this +library has been developed with the intention of eventually being +submitted to __boost__, a collection of general, high quality +libraries for C++ developers. -Eventually, __cnl__ will be extended to support many of the application layer protocols such as SMTP, FTP, SOAP, XMPP etc. +Eventually, __cnl__ will be extended to support many of the +application layer protocols such as SMTP, FTP, SOAP, XMPP etc. [endsect] diff --git a/libs/network/doc/protocol.qbk b/libs/network/doc/protocol.qbk index 48bc03a77..8089c6fb9 100644 --- a/libs/network/doc/protocol.qbk +++ b/libs/network/doc/protocol.qbk @@ -8,5 +8,7 @@ [section:protocol Application Layer Protocols] [include http.qbk] -The message and URI alone don't make a useful library. This section describes some of the common network protocols that are implemented in the __cnl__. +The message and URI alone don't make a useful library. This section +describes some of the common network protocols that are implemented in +the __cnl__. [endsect] diff --git a/libs/network/doc/tags_and_directives.qbk b/libs/network/doc/tags_and_directives.qbk index 73fad4551..e3b9f9507 100644 --- a/libs/network/doc/tags_and_directives.qbk +++ b/libs/network/doc/tags_and_directives.qbk @@ -9,7 +9,12 @@ [section:tags_and_directives Tags and Directives] [heading Directives] -Attributes can be specialized in this way, but not class member functions. To able to do this, the __cnl__ uses directives. Directives are already familiar in the C++ world as part of the I/O streams in the standard library ([^std::endl], [^std::flush] etc.). For the __cnl__, directives are used to manipulate the message class. A tag aware directive might be implemented as such: +Attributes can be specialized in this way, but not class member +functions. To able to do this, the __cnl__ uses directives. +Directives are already familiar in the C++ world as part of the I/O +streams in the standard library ([^std::endl], [^std::flush] etc.). +For the __cnl__, directives are used to manipulate the message class. +A tag aware directive might be implemented as such: namespace boost { namespace network { @@ -19,7 +24,8 @@ Attributes can be specialized in this way, but not class member functions. To a > class basic_source { // Constructor. - basic_source(const typename Tag::string_type &source) : source_(source) { + basic_source(const typename Tag::string_type &source) + : source_(source) { } @@ -44,7 +50,8 @@ Attributes can be specialized in this way, but not class member functions. To a } } -To use directives with messages, different overloads of the free [^operator <<] are provided: +To use directives with messages, different overloads of the free +[^operator <<] are provided: template < class Tag, @@ -52,7 +59,8 @@ To use directives with messages, different overloads of the free [^operator <<] > inline basic_message & - operator << (basic_message &message, const Directive &directive) { + operator << (basic_message &message, + const Directive &directive) { directive(message); return message; } @@ -65,7 +73,11 @@ Client code looks like this: << body("Hello there chaps!") ; -This approach allows the developers of the __cnl__ to write network code, and the library users to be able to specialize the message to suit their own requirements. Run-time efficiency is good, because compilers will be able to provide optimizations. An extra advantage is the expressiveness of the code. +This approach allows the developers of the __cnl__ to write network +code, and the library users to be able to specialize the message to +suit their own requirements. Run-time efficiency is good, because +compilers will be able to provide optimizations. An extra advantage +is the expressiveness of the code. [heading Customizing __message__] @@ -75,9 +87,12 @@ __message__ can be specialized based on three traits: * [^boost::network::ostringstream] * [^boost::network::headers_container] -This means that __message__ is not bound to a particular string type. Moreover, this mechanism allows developers to provide custom conversion handlers for data compression or encryption. +This means that __message__ is not bound to a particular string type. +Moreover, this mechanism allows developers to provide custom +conversion handlers for data compression or encryption. -The fine-grained design of the tags/traits mechanism is strongly influenced by __boost_type_traits__. +The fine-grained design of the tags/traits mechanism is strongly +influenced by __boost_type_traits__. [endsect] diff --git a/libs/network/doc/using.qbk b/libs/network/doc/using.qbk index 48566fbcb..5b5dc4132 100644 --- a/libs/network/doc/using.qbk +++ b/libs/network/doc/using.qbk @@ -15,10 +15,12 @@ The __cnl__ is tested on GCC 4.3 on Linux; MSVC 9.0 on Windows Vista. The __cnl__ works with Boost 1.35.0 and greater. -Boost is mostly header only but its necessary to build and link to __boost_system__ in order to use the __cnl__. +Boost is mostly header only but its necessary to build and link to +__boost_system__ in order to use the __cnl__. -Running the tests for the library also requires __python__ to be available in a directory that is present in the system path. -The tests work with __python__ 2.5. +Running the tests for the library also requires __python__ to be +available in a directory that is present in the system path. The +tests work with __python__ 2.5. [endsect]