Skip to content

Commit b64608f

Browse files
committed
Merge branch 'master' into cleanup/use-std
Conflicts: CMakeLists.txt include/network/message/message.hpp include/network/message/message.ipp include/network/message/message_base.hpp include/network/protocol/http/client/connection/async_normal.ipp include/network/protocol/http/client/options.hpp include/network/protocol/http/client/options.ipp include/network/protocol/http/request/request.hpp include/network/protocol/http/request/request_base.hpp include/network/protocol/http/response/response.hpp include/network/utils/thread_pool.hpp include/network/utils/thread_pool.ipp
2 parents b78f68a + 645cc74 commit b64608f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1093
-747
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ libs/mime/test/mime-roundtrip
1010
bin/
1111
tests/
1212
_build
13+
CPP-NETLIB.*
14+
CMakeScripts/
15+
*.cmake
16+
*~

.gitignore.orig

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
*.swp
2+
*.pyc
3+
CMakeCache.txt
4+
CMakeFiles
5+
Makefile
6+
Testing
7+
*.gch
8+
libs/mime/test/mime-roundtrip
9+
*.a
10+
bin/
11+
tests/
12+
_build
13+
<<<<<<< HEAD
14+
CPP-NETLIB.*
15+
CMakeScripts/
16+
*.cmake
17+
=======
18+
*~
19+
>>>>>>> 49d3b206d9ee23ad7426c6f803d76b0deb9064d4

CMakeLists.txt

+46-13
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,25 @@
77
cmake_minimum_required(VERSION 2.8)
88
project(CPP-NETLIB)
99

10+
option(BUILD_SHARED_LIBS "Build cpp-netlib as shared libraries." OFF)
11+
option(BUILD_TESTS "Build the unit tests." ON)
12+
option(BUILD_EXAMPLES "Build the examples using cpp-netlib." ON)
13+
1014
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
1115
find_package( ICU )
1216

13-
set(Boost_USE_STATIC_LIBS ON)
17+
if(BUILD_SHARED_LIBS)
18+
set(Boost_USE_STATIC_LIBS OFF)
19+
else()
20+
set(Boost_USE_STATIC_LIBS ON)
21+
endif()
1422
set(Boost_USE_MULTITHREADED ON)
15-
find_package( Boost 1.45.0 REQUIRED unit_test_framework system regex date_time thread chrono filesystem program_options )
23+
if(BUILD_TESTS)
24+
set(Boost_COMPONENTS unit_test_framework system regex date_time thread chrono filesystem program_options )
25+
else()
26+
set(Boost_COMPONENTS system regex date_time thread chrono filesystem program_options )
27+
endif()
28+
find_package( Boost 1.51 REQUIRED ${Boost_COMPONENTS} )
1629
find_package( OpenSSL )
1730
find_package( Threads )
1831
set(CMAKE_VERBOSE_MAKEFILE true)
@@ -29,7 +42,6 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
2942
INCLUDE(CheckCXXCompilerFlag)
3043
CHECK_CXX_COMPILER_FLAG(-std=c++0x HAVE_STD0X)
3144
CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD11)
32-
3345
if (HAVE_STD11)
3446
set(CMAKE_CXX_FLAGS -std=c++11)
3547
elseif (HAVE_STD0X)
@@ -38,16 +50,23 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
3850
message(FATAL_ERROR "No advanced standard C++ support (-std=c++0x and -std=c++11 not defined).")
3951
endif()
4052
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
41-
set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++")
42-
set(CMAKE_CXX_LINK_FLAGS "-std=c++11 -stdlib=libc++")
53+
INCLUDE(CheckCXXCompilerFlag)
54+
CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD11)
55+
if (HAVE_STD11)
56+
set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++")
57+
set(CMAKE_CXX_LINK_FLAGS "-std=c++11 -stdlib=libc++")
58+
else()
59+
message(FATAL_ERROR "No C++11 support for Clang version. Please upgrade Clang to a version supporting C++11.")
60+
endif()
4361
add_definitions(
4462
-DASIO_HAS_MOVE -DASIO_HAS_VARIADIC_TEMPLATES -DASIO_HAS_STD_SYSTEM_ERROR
4563
-DASIO_ERROR_CATEGORY_NOEXCEPT=noexcept -DASIO_HAS_STD_ARRAY
4664
-DASIO_HAS_STD_SHARED_PTR -DASIO_HAS_STD_ATOMIC -DASIO_HAS_STD_CHRONO
4765
-DASIO_HAS_STD_ADDRESSOFF -DASIO_HAS_STD_FUNCTION -DASIO_HAS_STD_TYPE_TRAITS)
48-
message("C++ Flags: ${CMAKE_CXX_FLAGS} link flags: ${CMAKE_CXX_LINK_FLAGS}")
4966
endif()
5067

68+
message("C++ Compiler ID: ${CMAKE_CXX_COMPILER_ID}")
69+
message("C++ Flags: ${CMAKE_CXX_FLAGS} link flags: ${CMAKE_CXX_LINK_FLAGS}")
5170
if (Boost_FOUND)
5271
if (MSVC)
5372
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
@@ -56,13 +75,27 @@ if (Boost_FOUND)
5675
add_definitions(-D_WIN32_WINNT=0x0501)
5776
endif(WIN32)
5877
include_directories(${Boost_INCLUDE_DIRS})
59-
enable_testing()
78+
if(BUILD_TESTS)
79+
enable_testing()
80+
endif()
6081
add_subdirectory(libs/network/src)
61-
add_subdirectory(libs/network/test)
62-
if (NOT MSVC)
63-
add_subdirectory(libs/mime/test)
64-
endif(NOT MSVC)
65-
add_subdirectory(libs/network/example)
82+
if(BUILD_TESTS)
83+
enable_testing()
84+
add_subdirectory(libs/network/test)
85+
if (NOT MSVC)
86+
add_subdirectory(libs/mime/test)
87+
endif(NOT MSVC)
88+
endif()
89+
if(BUILD_EXAMPLES)
90+
add_subdirectory(libs/network/example)
91+
endif()
6692
endif(Boost_FOUND)
6793

68-
enable_testing()
94+
if(BUILD_TESTS)
95+
enable_testing()
96+
endif()
97+
98+
message(STATUS "Options selected:")
99+
message(STATUS " BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}\t(Build cpp-netlib as shared libraries: OFF, ON)")
100+
message(STATUS " BUILD_TESTS: ${BUILD_TESTS}\t(Build the unit tests: ON, OFF)")
101+
message(STATUS " BUILD_EXAMPLES: ${BUILD_EXAMPLES}\t(Build the examples using cpp-netlib: ON, OFF)")

Jamroot

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import os ;
88

9-
local BOOST_ROOT = [ os.environ BOOST_ROOT ] ;
9+
path-constant BOOST_ROOT : [ os.environ BOOST_ROOT ] ;
1010

1111
use-project /boost : $(BOOST_ROOT) ;
1212
use-project /cpp-netlib : libs/network/build ;

include/network/message/message.hpp

+44-47
Original file line numberDiff line numberDiff line change
@@ -15,65 +15,62 @@
1515

1616
namespace network {
1717

18-
struct message_pimpl;
18+
struct message_pimpl;
1919

20-
// The common message type.
21-
struct message : message_base {
22-
// Nested types
23-
typedef boost::iterator_range<
20+
// The common message type.
21+
struct message : message_base {
22+
// Nested types
23+
typedef boost::iterator_range<
2424
std::multimap<std::string, std::string>::const_iterator>
2525
headers_range;
2626

27-
// Constructors
28-
message();
29-
message(message const & other);
27+
// Constructors
28+
message();
29+
message(message const & other);
30+
message(message && other) = default;
3031

31-
// Assignment
32-
message & operator=(message other);
32+
// Assignment
33+
message& operator=(message const &other);
34+
message& operator=(message &&other);
3335

34-
// Mutators
35-
virtual void set_destination(std::string const & destination);
36-
virtual void set_source(std::string const & source);
37-
virtual void append_header(std::string const & name,
38-
std::string const & value);
39-
virtual void remove_headers(std::string const & name);
40-
virtual void remove_headers();
41-
virtual void set_body(std::string const & body);
42-
virtual void append_body(std::string const & data);
36+
// Mutators
37+
virtual void set_destination(std::string const & destination);
38+
virtual void set_source(std::string const & source);
39+
virtual void append_header(std::string const & name,
40+
std::string const & value);
41+
virtual void remove_headers(std::string const & name);
42+
virtual void remove_headers();
43+
virtual void set_body(std::string const & body);
44+
virtual void append_body(std::string const & data);
4345

44-
// Retrievers
45-
virtual void get_destination(std::string & destination) const;
46-
virtual void get_source(std::string & source) const;
47-
virtual void get_headers(
48-
std::function<void(std::string const &, std::string const &)> inserter) const;
49-
virtual void get_headers(
50-
std::string const & name,
51-
std::function<void(std::string const &, std::string const &)> inserter) const;
52-
virtual void get_headers(
53-
std::function<bool(std::string const &, std::string const &)> predicate,
54-
std::function<void(std::string const &, std::string const &)> inserter) const;
55-
virtual void get_body(std::string & body) const;
56-
virtual void get_body(
57-
std::function<void(boost::iterator_range<char const *>)> chunk_reader,
58-
size_t size) const;
46+
// Retrievers
47+
virtual void get_destination(std::string & destination) const;
48+
virtual void get_source(std::string & source) const;
49+
virtual void get_headers(std::function<void(std::string const &, std::string const &)> inserter) const;
50+
virtual void get_headers(std::string const & name,
51+
std::function<void(std::string const &, std::string const &)> inserter) const;
52+
virtual void get_headers(std::function<bool(std::string const &, std::string const &)> predicate,
53+
std::function<void(std::string const &, std::string const &)> inserter) const;
54+
virtual void get_body(std::string & body) const;
55+
virtual void get_body(std::function<void(std::string::const_iterator, size_t)> chunk_reader, size_t size) const;
5956

60-
void swap(message & other);
57+
void swap(message & other);
6158

62-
// Destructor
63-
virtual ~message();
64-
private:
65-
message_pimpl * pimpl;
66-
};
59+
// Destructor
60+
virtual ~message();
61+
private:
62+
message_pimpl * pimpl;
63+
};
6764

68-
inline void swap(message & left, message & right) {
65+
inline void swap(message & left, message & right) {
6966
left.swap(right);
70-
}
67+
}
7168

72-
template <class Directive>
73-
message_base & operator<< (message_base & msg, Directive directive) {
74-
directive(msg);
75-
return msg;
76-
}
69+
template <class Directive>
70+
message_base & operator<< (message_base & msg, Directive directive) {
71+
directive(msg);
72+
return msg;
73+
}
7774

7875
} // namespace network
7976

0 commit comments

Comments
 (0)