Skip to content

Commit 5b571ad

Browse files
committed
Merge pull request cpp-netlib#181 from glynos/restructure_dirs
Restructure dirs
2 parents 5f6cce5 + 6f51e04 commit 5b571ad

File tree

254 files changed

+13623
-762
lines changed

Some content is hidden

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

254 files changed

+13623
-762
lines changed

CMakeLists.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,11 @@ endif()
4343

4444
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
4545
INCLUDE(CheckCXXCompilerFlag)
46-
CHECK_CXX_COMPILER_FLAG(-std=c++0x HAVE_STD0X)
4746
CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD11)
4847
if (HAVE_STD11)
4948
set(CMAKE_CXX_FLAGS -std=c++11)
50-
elseif (HAVE_STD0X)
51-
set(CMAKE_CXX_FLAGS -std=c++0x)
5249
else()
53-
message(FATAL_ERROR "No advanced standard C++ support (-std=c++0x and -std=c++11 not defined).")
50+
message(FATAL_ERROR "No advanced standard C++ support (-std=c++11 not defined).")
5451
endif()
5552
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
5653
INCLUDE(CheckCXXCompilerFlag)
@@ -81,10 +78,10 @@ if (Boost_FOUND)
8178
if(CPP-NETLIB_BUILD_TESTS)
8279
enable_testing()
8380
endif()
84-
add_subdirectory(libs/network/src)
81+
#add_subdirectory(libs/network/src)
8582
if(CPP-NETLIB_BUILD_TESTS)
8683
enable_testing()
87-
add_subdirectory(libs/network/test)
84+
#add_subdirectory(libs/network/test)
8885
if (NOT MSVC)
8986
#add_subdirectory(libs/mime/test)
9087
endif(NOT MSVC)
@@ -113,3 +110,6 @@ message(STATUS " CPP-NETLIB_DISABLE_LOGGING: ${CPP-NETLIB_DISABLE_LOGGING}\t(
113110
add_subdirectory(uri)
114111
add_subdirectory(message)
115112
add_subdirectory(logging)
113+
add_subdirectory(concurrency)
114+
add_subdirectory(http)
115+
add_subdirectory(mime)

concurrency/CMakeLists.txt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright (c) Glyn Matthews 2012.
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# (See accompanying file LICENSE_1_0.txt or copy at
4+
# http://www.boost.org/LICENSE_1_0.txt)
5+
6+
add_subdirectory(src)
7+
8+
if(CPP-NETLIB_BUILD_TESTS)
9+
enable_testing()
10+
add_subdirectory(test)
11+
endif(CPP-NETLIB_BUILD_TESTS)

concurrency/src/CMakeLists.txt

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright (c) Glyn Matthews 2012.
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# (See accompanying file LICENSE_1_0.txt or copy at
4+
# http://www.boost.org/LICENSE_1_0.txt)
5+
6+
include_directories(${CPP-NETLIB_SOURCE_DIR}/concurrency/src)
7+
8+
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
9+
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11")
10+
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
11+
CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD11)
12+
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11 -stdlib=libc++")
13+
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11 -stdlib=libc++")
14+
endif()
15+
16+
set(CPP-NETLIB_CONCURRENCY_SRCS thread_pool.cpp)
17+
add_library(cppnetlib-concurrency ${CPP-NETLIB_CONCURRENCY_SRCS})
18+
foreach (src_file ${CPP-NETLIB_CONCURRENCY_SRCS})
19+
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
20+
set_source_files_properties(${src_file}
21+
PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS})
22+
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
23+
set_source_files_properties(${src_file}
24+
PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS})
25+
endif()
26+
endforeach(src_file)

include/network/utils/thread_pool.hpp renamed to concurrency/src/network/concurrency/thread_pool.hpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
// Copyright 2010 Dean Michael Berris.
22
// Copyright 2012 Google, Inc.
3+
// Copyright (c) Glyn Matthews 2012.
34
// Distributed under the Boost Software License, Version 1.0.
45
// (See accompanying file LICENSE_1_0.txt or copy at
56
// http://www.boost.org/LICENSE_1_0.txt)
67

7-
#ifndef NETWORK_UTILS_THREAD_POOL_HPP_20101020
8-
#define NETWORK_UTILS_THREAD_POOL_HPP_20101020
8+
#ifndef NETWORK_CONCURRENCY_THREAD_POOL_HPP_20101020
9+
#define NETWORK_CONCURRENCY_THREAD_POOL_HPP_20101020
910

1011
#include <cstddef>
1112
#include <thread>
@@ -14,7 +15,7 @@
1415
#include <vector>
1516
#include <boost/asio/io_service.hpp>
1617

17-
namespace network { namespace utils {
18+
namespace network { namespace concurrency {
1819

1920
typedef std::shared_ptr<boost::asio::io_service> io_service_ptr;
2021
typedef std::shared_ptr<std::vector<std::thread>> worker_threads_ptr;
@@ -46,7 +47,7 @@ namespace network { namespace utils {
4647
l.swap(r);
4748
}
4849

49-
} // namespace utils
50+
} // namespace concurrency
5051
} // namespace network
5152

52-
#endif /* NETWORK_UTILS_THREAD_POOL_HPP_20101020 */
53+
#endif /* NETWORK_CONCURRENCY_THREAD_POOL_HPP_20101020 */

include/network/utils/thread_pool.ipp renamed to concurrency/src/network/concurrency/thread_pool.ipp

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
// Copyright 2011 Dean Michael Berris <[email protected]>.
22
// Copyright 2011 Google, Inc.
3+
// Copyright (c) Glyn Matthews 2012.
34
// Distributed under the Boost Software License, Version 1.0.
45
// (See accompanying file LICENSE_1_0.txt or copy at
56
// http://www.boost.org/LICENSE_1_0.txt)
67

7-
#ifndef NETWORK_UTILS_THREAD_POOL_IPP_20111021
8-
#define NETWORK_UTILS_THREAD_POOL_IPP_20111021
8+
#ifndef NETWORK_CONCURRENCY_THREAD_POOL_IPP_20111021
9+
#define NETWORK_CONCURRENCY_THREAD_POOL_IPP_20111021
910

1011
#include <vector>
1112
#include <thread>
12-
#include <network/utils/thread_pool.hpp>
13+
#include <network/concurrency/thread_pool.hpp>
1314
#include <boost/scope_exit.hpp>
1415

15-
namespace network { namespace utils {
16+
namespace network { namespace concurrency {
1617

1718
struct thread_pool_pimpl {
1819
thread_pool_pimpl(std::size_t threads = 1,
@@ -109,7 +110,7 @@ namespace network { namespace utils {
109110
delete pimpl;
110111
}
111112

112-
} // namespace utils
113+
} // namespace concurrency
113114
} // namespace network
114115

115-
#endif /* NETWORK_UTILS_THREAD_POOL_IPP_20111021 */
116+
#endif /* NETWORK_CONCURRENCY_THREAD_POOL_IPP_20111021 */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) Glyn Matthews 2012.
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// (See accompanying file LICENSE_1_0.txt or copy at
4+
// http://www.boost.org/LICENSE_1_0.txt)
5+
6+
7+
#ifndef __NETWORK_UTILS_THREAD_POOL_INC__
8+
#define __NETWORK_UTILS_THREAD_POOL_INC__
9+
10+
#include <network/concurrency/thread_pool.hpp>
11+
12+
namespace network {
13+
namespace utils {
14+
typedef ::network::concurrency::thread_pool thread_pool;
15+
} // namespace utils
16+
} // namespace network
17+
18+
19+
#endif // __NETWORK_UTILS_THREAD_POOL_INC__
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Copyright 2011 Dean Michael Berris <[email protected]>.
22
// Copyright 2011 Google, Inc.
3+
// Copyright (c) Glyn Matthews 2012.
34
// Distributed under the Boost Software License, Version 1.0.
45
// (See accompanying file LICENSE_1_0.txt or copy at
56
// http://www.boost.org/LICENSE_1_0.txt)
67

7-
#include <network/utils/thread_pool.ipp>
8+
#include <network/concurrency/thread_pool.ipp>

concurrency/test/CMakeLists.txt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright (c) Glyn Matthews 2012.
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# (See accompanying file LICENSE_1_0.txt or copy at
4+
# http://www.boost.org/LICENSE_1_0.txt)
5+
6+
include_directories(${CPP-NETLIB_SOURCE_DIR}/concurrency/src)
7+
8+
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
9+
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11")
10+
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
11+
CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD11)
12+
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11 -stdlib=libc++")
13+
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11 -stdlib=libc++")
14+
endif()
15+
16+
set_source_files_properties(thread_pool_test.cpp
17+
PROPERTIES COMPILE_FLAGS "-Wall")
18+
add_executable(cpp-netlib-thread_pool_test thread_pool_test.cpp)
19+
target_link_libraries(cpp-netlib-thread_pool_test
20+
cppnetlib-concurrency
21+
${Boost_LIBRARIES}
22+
${CMAKE_THREAD_LIBS_INIT})
23+
set_target_properties(cpp-netlib-thread_pool_test
24+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests)
25+
add_test(cpp-netlib-thread_pool_test ${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-thread_pool_test)
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11

22
// Copyright 2010 Dean Michael Berris.
33
// Copyright 2012 Google, Inc.
4+
// Copyright (c) Glyn Matthews 2012.
45
// Distributed under the Boost Software License, Version 1.0.
56
// (See accompanying file LICENSE_1_0.txt or copy at
67
// http://www.boost.org/LICENSE_1_0.txt)
78

89
#ifdef BUILD_SHARED_LIBS
910
# define BOOST_TEST_DYN_LINK
1011
#endif
11-
#define BOOST_TEST_MODULE utils thread pool test
12+
#define BOOST_TEST_MODULE thread pool test
1213
#include <boost/config/warning_disable.hpp>
1314
#include <boost/test/unit_test.hpp>
14-
#include <network/utils/thread_pool.hpp>
15+
#include <network/concurrency/thread_pool.hpp>
1516
#include <boost/bind.hpp>
1617

17-
using namespace network;
18+
using network::concurrency::thread_pool;
1819

1920
// This test specifies the requirements for a thread pool interface. At the
2021
// very least any thread pool implementation should be able to pass the simple
@@ -25,29 +26,29 @@ using namespace network;
2526
//
2627

2728
BOOST_AUTO_TEST_CASE( default_constructor ) {
28-
utils::thread_pool pool;
29-
BOOST_CHECK_EQUAL(pool.thread_count(), std::size_t(1));
29+
thread_pool pool;
30+
BOOST_CHECK_EQUAL(pool.thread_count(), std::size_t(1));
3031
}
3132

3233
struct foo {
33-
foo() : val_(0) {}
34-
void bar(int val) {
35-
val_ += val;
36-
}
37-
int const val() const {
38-
return val_;
39-
}
34+
foo() : val_(0) {}
35+
void bar(int val) {
36+
val_ += val;
37+
}
38+
int const val() const {
39+
return val_;
40+
}
4041
protected:
41-
int val_;
42+
int val_;
4243
};
4344

4445
BOOST_AUTO_TEST_CASE( post_work ) {
45-
foo instance;
46-
{
47-
utils::thread_pool pool;
48-
BOOST_CHECK_NO_THROW(pool.post(boost::bind(&foo::bar, &instance, 1)));
49-
BOOST_CHECK_NO_THROW(pool.post(boost::bind(&foo::bar, &instance, 2)));
50-
// require that pool is destroyed here, RAII baby
51-
}
52-
BOOST_CHECK_EQUAL(instance.val(), 3);
46+
foo instance;
47+
{
48+
thread_pool pool;
49+
BOOST_CHECK_NO_THROW(pool.post(boost::bind(&foo::bar, &instance, 1)));
50+
BOOST_CHECK_NO_THROW(pool.post(boost::bind(&foo::bar, &instance, 2)));
51+
// require that pool is destroyed here, RAII baby
52+
}
53+
BOOST_CHECK_EQUAL(instance.val(), 3);
5354
}

http/CMakeLists.txt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright (c) Glyn Matthews 2012.
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# (See accompanying file LICENSE_1_0.txt or copy at
4+
# http://www.boost.org/LICENSE_1_0.txt)
5+
6+
add_subdirectory(src)
7+
8+
if(CPP-NETLIB_BUILD_TESTS)
9+
enable_testing()
10+
add_subdirectory(test)
11+
endif(CPP-NETLIB_BUILD_TESTS)

libs/network/src/CMakeLists.txt renamed to http/src/CMakeLists.txt

-12
Original file line numberDiff line numberDiff line change
@@ -172,18 +172,6 @@ elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
172172
endif()
173173
endforeach(src_file)
174174

175-
set(CPP-NETLIB_UTILS_THREAD_POOL_SRCS utils/thread_pool.cpp)
176-
add_library(cppnetlib-utils-thread_pool ${CPP-NETLIB_UTILS_THREAD_POOL_SRCS})
177-
foreach (src_file ${CPP-NETLIB_UTILS_THREAD_POOL_SRCS})
178-
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
179-
set_source_files_properties(${src_file}
180-
PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS})
181-
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
182-
set_source_files_properties(${src_file}
183-
PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS})
184-
endif()
185-
endforeach(src_file)
186-
187175
set(CPP-NETLIB_CONSTANTS_SRCS constants.cpp)
188176
add_library(cppnetlib-constants ${CPP-NETLIB_CONSTANTS_SRCS})
189177
foreach (src_file ${CPP-NETLIB_CONSTANTS_SRCS})
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

http/src/network/constants.hpp

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#ifndef NETWORK_CONSTANTS_HPP_20100808
2+
#define NETWORK_CONSTANTS_HPP_20100808
3+
4+
// Copyright 2010 (C) Dean Michael Berris
5+
// Copyright 2012 Google, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
namespace network {
11+
12+
struct constants {
13+
static char const * crlf();
14+
static char const * dot();
15+
static char dot_char();
16+
static char const * http_slash();
17+
static char const * space();
18+
static char space_char();
19+
static char const * slash();
20+
static char slash_char();
21+
static char const * host();
22+
static char const * colon();
23+
static char colon_char();
24+
static char const * accept();
25+
static char const * default_accept_mime();
26+
static char const * accept_encoding();
27+
static char const * default_accept_encoding();
28+
static char const * user_agent();
29+
static char const * default_user_agent();
30+
static char const * cpp_netlib_slash();
31+
static char question_mark_char();
32+
static char hash_char();
33+
static char const * connection();
34+
static char const * close();
35+
static char const * https();
36+
};
37+
38+
} // namespace network
39+
40+
#endif // NETWORK_CONSTANTS_HPP_20100808

0 commit comments

Comments
 (0)