forked from cpp-netlib/cpp-netlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mikhail_beris
committed
May 20, 2007
0 parents
commit ec2dd88
Showing
23 changed files
with
444 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
# Copyright Dean Michael Berris 2007. | ||
# 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) | ||
|
||
import modules ; | ||
|
||
local BOOST_ROOT = [ modules.peek : BOOST_ROOT ] ; | ||
|
||
use-project /boost : $(BOOST_ROOT) ; | ||
|
||
using testing ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Boost Software License - Version 1.0 - August 17th, 2003 | ||
|
||
Permission is hereby granted, free of charge, to any person or organization | ||
obtaining a copy of the software and accompanying documentation covered by | ||
this license (the "Software") to use, reproduce, display, distribute, | ||
execute, and transmit the Software, and to prepare derivative works of the | ||
Software, and to permit third-parties to whom the Software is furnished to | ||
do so, all subject to the following: | ||
|
||
The copyright notices in the Software and this entire statement, including | ||
the above license grant, this restriction and the following disclaimer, | ||
must be included in all copies of the Software, in whole or in part, and | ||
all derivative works of the Software, unless such copies or derivative | ||
works are solely in the form of machine-executable object code generated by | ||
a source language processor. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | ||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | ||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
C++ Network Library | ||
|
||
This is a collection of network related routines/implementations | ||
geared towards providing a robust cross-platform networking library. | ||
This offers the following implementations: | ||
|
||
o Common Message Type -- A generic message type which can be used | ||
to encapsulate and store message related information, used by all | ||
network implementations as the primary means of data exchange. | ||
o Network protocol message parsers -- A collection of parsers which | ||
generate message objects from strings. | ||
o Adapters and Wrappers -- A collection of Adapters and wrappers aimed | ||
towards making the message type STL friendly. | ||
|
||
This library is released under the Boost Software License (please see | ||
http://boost.org/LICENSE_1_0.txt or the accompanying LICENSE_1_0.txt file | ||
for the full text. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
// Copyright Dean Michael Berris 2007. | ||
// 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) | ||
|
||
#ifndef __NETWORK_HPP__ | ||
#define __NETWORK_HPP__ | ||
|
||
// Include all headers in network/ | ||
// Author: Dean Michael Berris | ||
// Date: May 20, 2007 | ||
|
||
#include <boost/network/message.hpp> // message type implementation | ||
|
||
#endif // __NETWORK_HPP__ | ||
|
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
// Copyright Dean Michael Berris 2007. | ||
// 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) | ||
|
||
#ifndef __NETWORK_DETAIL_DIRECTIVE_BASE_HPP__ | ||
#define __NETWORK_DETAIL_DIRECTIVE_BASE_HPP__ | ||
|
||
/** Defines the base type from which all directives inherit | ||
* to allow friend access to message and other types' internals. | ||
*/ | ||
namespace boost { namespace network { namespace detail { | ||
|
||
template <class Tag> | ||
struct directive_base { | ||
typedef Tag tag ; | ||
//explicit directive_base(basic_message<tag> & message_) | ||
// : _message(message_) | ||
protected: | ||
virtual ~directive_base() | ||
{ }; // can only be extended | ||
|
||
// mutable basic_message<tag> & _message; | ||
}; | ||
|
||
}; // namespace detail | ||
|
||
}; // namespace network | ||
|
||
}; // namespace boost | ||
|
||
#endif // __NETWORK_DETAIL_DIRECTIVE_BASE_HPP__ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
// Copyright Dean Michael Berris 2007. | ||
// 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) | ||
|
||
#ifndef __NETWORK_DETAIL_WRAPPER_BASE_HPP__ | ||
#define __NETWORK_DETAIL_WRAPPER_BASE_HPP__ | ||
|
||
namespace boost { namespace network { namespace detail { | ||
|
||
template <class Tag> | ||
struct wrapper_base { | ||
typedef Tag tag; | ||
explicit wrapper_base(basic_message<tag> & message_) | ||
: _message(message_) | ||
{ }; | ||
|
||
protected: | ||
virtual ~wrapper_base() | ||
{ }; // for extending only | ||
|
||
mutable basic_message<tag> & _message; | ||
}; | ||
|
||
}; // namespace detail | ||
|
||
}; // namespace network | ||
|
||
}; // namespace boost | ||
|
||
#endif // __NETWORK_DETAIL_WRAPPER_BASE_HPP__ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
|
||
// Copyright Dean Michael Berris 2007. | ||
// 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) | ||
|
||
#ifndef __NETWORK_MESSAGE_HPP__ | ||
#define __NETWORK_MESSAGE_HPP__ | ||
|
||
#include <map> | ||
#include <string> | ||
|
||
// forward declarations | ||
namespace boost { namespace network { | ||
template <class tag> | ||
class basic_message; | ||
}; // namespace network | ||
|
||
}; // namespace boost | ||
|
||
#include <boost/network/detail/directive_base.hpp> | ||
#include <boost/network/detail/wrapper_base.hpp> | ||
|
||
/** message.hpp | ||
* | ||
* This header file implements the common message type which | ||
* all networking implementations under the boost::network | ||
* namespace. The common message type allows for easy message | ||
* construction and manipulation suited for networked | ||
* application development. | ||
*/ | ||
namespace boost { namespace network { | ||
|
||
struct tags { | ||
struct default_ { }; | ||
}; | ||
|
||
/** The common message type. | ||
*/ | ||
template <class tag=tags::default_> | ||
class basic_message { | ||
public: | ||
typedef std::multimap<std::string, std::string> headers_container_type; | ||
|
||
headers_container_type & headers() const { | ||
return _headers; | ||
}; | ||
|
||
private: | ||
|
||
friend struct detail::directive_base<tag> ; | ||
friend struct detail::wrapper_base<tag> ; | ||
|
||
mutable headers_container_type _headers; | ||
}; | ||
|
||
typedef basic_message<> message; // default message type | ||
|
||
}; // namespace network | ||
}; // namespace boost | ||
|
||
#include <boost/network/message/directives.hpp> | ||
// pull in directives header file | ||
|
||
#include <boost/network/message/wrappers.hpp> | ||
// pull in wrappers header file | ||
|
||
#endif // __NETWORK_MESSAGE_HPP__ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
// Copyright Dean Michael Berris 2007. | ||
// 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) | ||
|
||
#ifndef __NETWORK_MESSAGE_DIRECTIVES_HPP__ | ||
#define __NETWORK_MESSAGE_DIRECTIVES_HPP__ | ||
|
||
/** Include all the various directive headers. | ||
*/ | ||
|
||
#include <boost/network/message/directives/header.hpp> | ||
|
||
namespace boost { namespace network { | ||
|
||
template <class Tag, template <class> class Directive> | ||
inline basic_message<Tag> & | ||
operator<< (basic_message<Tag> & message_, Directive<Tag> const & directive) { | ||
directive(message_); | ||
return message_; | ||
}; | ||
|
||
}; // namespace network | ||
|
||
}; // namespace boost | ||
|
||
#endif // __NETWORK_MESSAGE_DIRECTIVES_HPP__ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
|
||
// Copyright Dean Michael Berris 2007. | ||
// 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) | ||
|
||
#ifndef __NETWORK_MESSAGE_DIRECTIVES_HEADER_HPP__ | ||
#define __NETWORK_MESSAGE_DIRECTIVES_HEADER_HPP__ | ||
|
||
/** header.hpp | ||
* | ||
* Defines the types involved and the semantics of adding | ||
* header information into message objects. | ||
* | ||
* WARNING: DO NOT INCLUDE THIS HEADER DIRECTLY. THIS REQUIRES | ||
* TYPES TO BE DEFINED FROM EARLIER FILES THAT INCLUDE THIS | ||
* HEADER. | ||
*/ | ||
namespace boost { namespace network { | ||
|
||
namespace impl { | ||
template <class Tag> | ||
struct header_directive : public detail::directive_base<Tag> { | ||
typedef Tag tag; | ||
|
||
explicit header_directive( | ||
std::string const & header_name, | ||
std::string const & header_value | ||
) : | ||
_header_name(header_name), | ||
_header_value(header_value) | ||
{ }; | ||
|
||
void operator() (basic_message<tag> & msg) const { | ||
msg.headers().insert( | ||
typename basic_message<tag>::headers_container_type::value_type( | ||
_header_name, | ||
_header_value | ||
) | ||
); | ||
}; | ||
|
||
private: | ||
|
||
mutable std::string _header_name; | ||
mutable std::string _header_value; | ||
}; | ||
}; // namespace impl | ||
|
||
inline impl::header_directive<tags::default_> | ||
header(std::string const & header_name, | ||
std::string const & header_value) { | ||
return impl::header_directive<tags::default_>(header_name, | ||
header_value); | ||
}; | ||
|
||
}; | ||
|
||
}; | ||
|
||
#endif // __NETWORK_MESSAGE_DIRECTIVES_HEADER_HPP__ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
// Copyright Dean Michael Berris 2007. | ||
// 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) | ||
|
||
#ifndef __NETWORK_MESSAGE_WRAPPERS_HPP__ | ||
#define __NETWORK_MESSAGE_WRAPPERS_HPP__ | ||
|
||
/** wrappers.hpp | ||
* | ||
* Pulls in all the wrapper header files. | ||
*/ | ||
#include <boost/network/message/wrappers/headers.hpp> | ||
|
||
#endif // __NETWORK_MESSAGE_WRAPPERS_HPP__ |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
|
||
// Copyright Dean Michael Berris 2007. | ||
// 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) | ||
|
||
#ifndef __NETWORK_MESSAGE_WRAPPERS_HEADERS_HPP__ | ||
#define __NETWORK_MESSAGE_WRAPPERS_HEADERS_HPP__ | ||
|
||
namespace boost { namespace network { | ||
|
||
// Forward declaration | ||
template <class Message> | ||
struct headers_range ; | ||
|
||
/** headers wrapper for messages. | ||
* | ||
* This exposes an interface similar to a map, indexable | ||
* using operator[] taking a string as the index and returns | ||
* a range of iterators (std::pair<iterator, iterator>) | ||
* whose keys are all equal to the index string. | ||
*/ | ||
namespace impl { | ||
template <class Tag> | ||
struct headers_wrapper : public detail::wrapper_base<Tag> { | ||
typedef Tag tag; | ||
typedef basic_message<tag> message_type; | ||
typedef typename headers_range<message_type>::type range_type; | ||
|
||
explicit headers_wrapper(basic_message<tag> & message_) | ||
: detail::wrapper_base<tag>(message_) | ||
{ }; | ||
|
||
range_type operator[] (std::string const & key) const { | ||
return _message.headers().equal_range(key); | ||
}; | ||
|
||
typename message_type::headers_container_type::size_type count(std::string const & key) const { | ||
return _message.headers().count(key); | ||
}; | ||
|
||
}; | ||
}; // namespace impl | ||
|
||
/// Factory method to create the right wrapper object | ||
template <class Tag, template <class> class Message> | ||
inline impl::headers_wrapper<Tag> | ||
headers(Message<Tag> & message_) { | ||
return impl::headers_wrapper<Tag>(message_); | ||
}; | ||
|
||
/// Template metaprogram to get the range type for a message | ||
template <class Message> | ||
struct headers_range { | ||
typedef typename | ||
std::pair< | ||
typename Message::headers_container_type::const_iterator, | ||
typename Message::headers_container_type::const_iterator> | ||
type; | ||
}; | ||
|
||
}; // namespace network | ||
|
||
}; // namespace boost | ||
|
||
#endif // __NETWORK_MESSAGE_WRAPPERS_HEADERS_HPP__ | ||
|
Oops, something went wrong.