Skip to content

Commit 548573c

Browse files
committed
Added some docs that came from Dean's BoostCon paper. These still need to be rewritten to better fit the rest of the docs.
1 parent 20e3e6e commit 548573c

14 files changed

+440
-15
lines changed

libs/network/doc/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
html

libs/network/doc/Jamfile.v2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
path-constant boost-images : doc/src/images ;
77

8-
xml network : network.qbk ;
8+
xml cpp-netlib : cpp-netlib.qbk ;
99

1010
boostbook standalone
1111
:
12-
network
12+
cpp-netlib
1313
:
1414
# HTML options first:
1515
# Use graphics not text for navigation:

libs/network/doc/network.qbk renamed to libs/network/doc/cpp-netlib.qbk

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
[article C++ Network Library
99
[quickbook 1.4]
10-
[version 0.6]
10+
[version 0.7]
1111
[authors [Matthews, Glyn], [Berris, Dean Michael]]
1212
[copyright 2008, 2009, 2010 Glyn Matthews, Dean Michael Berris]
1313
[purpose C++ library for general network programming]
@@ -34,24 +34,27 @@
3434
[def __libcurl__ [@http://curl.haxx.se/ libcurl]]
3535
[def __mozilla_netlib__ [@http://www.mozilla.org/projects/netlib/ mozilla-netlib]]
3636
[def __sf_cpp_netlib__ [@http://sourceforge.net/projects/cpp-netlib/ sourceforge]]
37+
[def __git__ [@http://www.git-scm.org/ Git]]
3738
[def __github__ [@http://github.com/cpp-netlib/cpp-netlib github]]
3839
[def __default_constructible__ [@http://www.boost.org/doc/html/DefaultConstructible.html DefaultConstructible]]
3940
[def __copy_constructible__ [@http://www.boost.org/doc/html/CopyConstructible.html CopyConstructible]]
4041
[def __assignable__ [@http://www.boost.org/doc/html/Assignable.html Assignable]]
41-
[def __equality_comparable__ [@http://www.boost.org/doc/html/Assignable.html Assignable]]
42+
[def __equality_comparable__ [@http://www.boost.org/doc/html/EqualityComparable.html EqualityComparable]]
4243

4344

4445
[def __quick_start__ quick start]
4546

4647

48+
[include miscellanea.qbk]
4749
[include quick_start.qbk]
4850
[include intro.qbk]
4951
[include using.qbk]
50-
[/include architecture.qbk]
52+
[include techniques.qbk]
5153
[include message.qbk]
5254
[include uri.qbk]
5355
[include protocol.qbk]
5456
[include examples.qbk]
57+
[include pitfalls.qbk]
5558
[include reference.qbk]
5659
[include acknowledgements.qbk]
5760
[include appendices.qbk]

libs/network/doc/examples.qbk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
[/ include examples/hello_world.qbk]
1111
[/ include examples/http_client.qbk]
1212
[include examples/simple_wget.qbk]
13-
[endsect]
13+
[endsect] [/ examples]

libs/network/doc/http.qbk

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,43 @@
77

88

99
[section:http HTTP]
10+
The cpp-netlib provides full support for a configurable, embedded
11+
HTTP client and server.
12+
13+
For each sub-librariy, the URI and protocol specific code belong in
14+
their own namespace and in the relevant sub-directories (i.e. `http`
15+
defined in `protocol/http/` and `uri::http` defined in `uri/http/`).
16+
17+
[section:http_uri HTTP URI]
18+
19+
Firstly, cpp-netlib provides a specialization and `typedef` for an
20+
HTTP URI:
21+
22+
namespace http {
23+
template <class T> class basic_uri;
24+
typedef basic_uri<default_> uri;
25+
}
26+
27+
`basic_uri` provides a parser which breaks down a URI string passed
28+
to it's constructor into different parts.
29+
30+
using namespace boost::network::uri;
31+
http::uri uri_("http://www.boost.org/");
32+
assert(valid(uri_));
33+
assert(scheme(uri_) == "http");
34+
assert(host(uri_) == "www.boost.org")
35+
assert(port(uri_) == 80)
36+
assert(path(uri_) == "/");
37+
38+
The syntax of the HTTP URI are defined in RFC 1738 section 3.3 and the
39+
default URI provided with cpp-netlib conforms to this. In such a way,
40+
specializations that conform to any URI scheme can be provided.
41+
[endsect] [/ http_uri]
1042

1143
[section:http_server_example HTTP Server]
1244

1345
Here is the server code again from the __quick_start__.
1446

15-
``
1647
#include <boost/network/protocol/http/server.hpp>
1748
#include <iostream>
1849

@@ -54,7 +85,6 @@ Here is the server code again from the __quick_start__.
5485

5586
return 0;
5687
}
57-
``
5888

5989
[heading HTTP Server]
6090

@@ -118,7 +148,6 @@ be implemented.
118148

119149
Here is the client code again from the __quick_start__.
120150

121-
``
122151
#include <boost/network/protocol/http/client.hpp>
123152
#include <iostream>
124153

@@ -146,7 +175,6 @@ Here is the client code again from the __quick_start__.
146175

147176
return 0;
148177
}
149-
``
150178

151179
Before walking through exactly what is happening in this example, the
152180
principal components are described below:

libs/network/doc/message.qbk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ __message__:
8888
} // namespace network
8989
} // namespace boost
9090

91-
[endsect] [/tag_dispatching]
91+
[endsect] [/ tag_dispatching]
9292

9393
[section:transformation_layer Transformation layer]
9494
The transformation layer defines the algorithms that can be applied on
@@ -101,7 +101,7 @@ the Message concept. Functions in the transform layer take the form:
101101
>
102102
basic_message<Tag> &transform(basic_message<Tag> &, ...);
103103

104-
[endsect] [/transformation_layer]
104+
[endsect] [/ transformation_layer]
105105

106106
[section:rendering_layer Rendering layer]
107107
The rendering layer defines the algorithms used to render a message
@@ -114,6 +114,6 @@ layer take the form:
114114
>
115115
unspecified &render(const basic_message<Tag> &, ...);
116116

117-
[endsect] [/rendering_layer]
117+
[endsect] [/ rendering_layer]
118118

119-
[endsect] [/message]
119+
[endsect] [/ message]

libs/network/doc/miscellanea.qbk

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[/
2+
(C) Copyright 2009, 2010 Glyn Matthews.
3+
Distributed under the Boost Software License, Version 1.0.
4+
(See accompanying file LICENSE_1_0.txt or copy at
5+
http://www.boost.org/LICENSE_1_0.txt).
6+
]
7+
8+
9+
[section:miscellanea Miscellanea]
10+
11+
[heading Where to find the __cnl__]
12+
13+
Official releases of the __cnl__ can be found [@http://github.com/cpp-netlib/cpp-netlib/downloads on github].
14+
15+
[heading How to get the source code]
16+
17+
Since this project uses __git__, there's not any single place to download the source code. However, pre-releases are prepared at =git://github.com/mikhailberis/cpp-netlib.git=. This is where the most up-to-date code can be found.
18+
19+
To clone this repository, run the following command in a shell:
20+
21+
shell$ git clone git://github.com/mikhailberis/cpp-netlib.git
22+
23+
This is already enough to start looking at the source code. __git__ is very powerful and it should be enough for now to refer to the [@http://git-scm.com/documentation documentation] to do more complex things.
24+
25+
For users of Git on Windows, more information can be found in [@http://book.git-scm.com/6_git_on_windows.html this screencast].
26+
27+
Finally, for non-users of Git, Github also offers the possibility to download the source as a zip file or tar archive.
28+
29+
[heading How to build the __cnl__]
30+
31+
Since the __cnl__ is a header-only library, it doesn't need to be built to be used (though it does need to link to [@http www.boost.org/doc/libs/release/libs/system/index.html Boost.System]. To build and run the unit tests and examples the preferred way is to use [@http://www.cmake.org/ CMake], although Jamfiles are also provided.
32+
33+
shell$ cd $CPP_NETLIB_DIR
34+
shell$ mkdir -p build
35+
shell$ cd build
36+
shell$ cmake ..
37+
shell$ make
38+
39+
[endsect] [/ miscellanea]

libs/network/doc/pitfalls.qbk

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
[/
2+
(C) Copyright 2010 Dean Michael Berris, Glyn Matthews.
3+
Distributed under the Boost Software License, Version 1.0.
4+
(See accompanying file LICENSE_1_0.txt or copy at
5+
http://www.boost.org/LICENSE_1_0.txt).
6+
]
7+
8+
[section:pitfalls Common Pitfalls]
9+
10+
There are a number of common pitfalls one gets to when implementing a
11+
header-only network library. Some of these are briefly discussed in this
12+
section.
13+
14+
[heading Linear Explosion]
15+
16+
The linear explosion comes up when you start supporting a lot of different tags
17+
through the tag dispatch mechanism. There is a temptation to implement support
18+
a whole slew of tags and the associated variations brought about by these tags.
19+
Because of this as soon as you start mixing and matching tags you get to a point
20+
where where there can be a lot of tags and a lot of specializations.
21+
22+
To manage linear explosion, using a moderately robust template metaprogramming
23+
library like Boost.MPL should be used to remove much of the repetition and
24+
manage the growth of the variations/combinations.
25+
26+
[heading Compile Time Toll]
27+
28+
Due to the nature of template metaprogramming and the current state of compiler
29+
technologies, the cost of going header-only can be considerable during
30+
compilation. It is no secret that template metaprogramming takes a lot out of
31+
the compiler because the template implementations of most of the popular
32+
compilers were not built to handle template metaprogramming. The state of the
33+
art when it comes to compiler technology is changing in C++ with the promise of
34+
faster, more efficient, and more robust template metaprogramming support.
35+
36+
Aside from doing as much as you can to optimize the compilation times of
37+
template-based programs, the only solution really is to wait for (or to actually
38+
help) compilers to get faster and better when compiling template-heavy code.
39+
40+
[heading Contribution Barrier]
41+
42+
Currently there are not a lot of C++ programmers who understand how to do
43+
template metaprogramming as well as implement efficient network utilities. There
44+
are a lot of C++ programmers who are looking for an using libraries to make
45+
network programming easier at a higher level. The disparity between the users
46+
and the developers can be considerable, and using a relatively niche technique
47+
like template metaprogramming in the implementation of the library proves to be
48+
a significant contribution barrier.
49+
50+
Because cpp-netlib is a project that has in its stated goals the implementation
51+
and the distribution of a header-only collection of network-based libraries, one
52+
solution to the issue is in the education and dissemination (and documentation)
53+
of the techniques used and the rationale for why these techniques are used in
54+
cpp-netlib. This is the goal of this paper and in the future editions of this
55+
paper.
56+
[endsect] [/ pitfalls]

libs/network/doc/reference.qbk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88

99
[section:reference Reference]
1010
[variablelist
11+
[
12+
[
13+
[@http://www.boostpro.com/mplbook/ Template Metaprogramming]
14+
]
15+
[
16+
The best guide to C++ template metaprogramming
17+
]
18+
]
1119
[
1220
[
1321
[@http://www.w3.org/Protocols/HTTP/1.0/spec.html HTTP 1.0]

libs/network/doc/techniques.qbk

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[/
2+
(C) Copyright 2010 Dean Michael Berris, Glyn Matthews.
3+
Distributed under the Boost Software License, Version 1.0.
4+
(See accompanying file LICENSE_1_0.txt or copy at
5+
http://www.boost.org/LICENSE_1_0.txt).
6+
]
7+
8+
[section:techniques Techniques]
9+
Throughout the __cnl__ implementation there are some recurring techniques
10+
used to achieve the generic approach to implementing specific ideas. This
11+
section covers these recurring techniques -- where appropriate the inspiration
12+
for the technique is also cited.
13+
14+
[include techniques/tag-metafunctions.qbk]
15+
[include techniques/directives.qbk]
16+
[include techniques/static-dynamic.qbk]
17+
[endsect] [/ techniques]

0 commit comments

Comments
 (0)