File tree Expand file tree Collapse file tree 8 files changed +140
-3
lines changed Expand file tree Collapse file tree 8 files changed +140
-3
lines changed Original file line number Diff line number Diff line change @@ -157,6 +157,7 @@ endif(DOXYGEN_FOUND)
157
157
if (CPP-NETLIB_BUILD_SINGLE_LIB )
158
158
include_directories (
159
159
${CMAKE_CURRENT_SOURCE_DIR} /config/src
160
+ ${CMAKE_CURRENT_SOURCE_DIR} /error/src
160
161
${CMAKE_CURRENT_SOURCE_DIR} /concurrency/src
161
162
${CMAKE_CURRENT_SOURCE_DIR} /http/src
162
163
${CMAKE_CURRENT_SOURCE_DIR} /logging/src
@@ -169,6 +170,7 @@ endif()
169
170
add_subdirectory (uri )
170
171
#add_subdirectory(message)
171
172
add_subdirectory (logging )
173
+ add_subdirectory (error )
172
174
#add_subdirectory(concurrency)
173
175
add_subdirectory (http )
174
176
#add_subdirectory(mime)
@@ -182,7 +184,7 @@ if(CPP-NETLIB_BUILD_SINGLE_LIB)
182
184
${CPP-NETLIB_MESSAGE_SRCS}
183
185
${CPP-NETLIB_MESSAGE_DIRECTIVES_SRCS}
184
186
${CPP-NETLIB_MESSAGE_WRAPPERS_SRCS}
185
- ${CPP-NETLIB_LoOGGING_SRCS }
187
+ ${CPP-NETLIB_LOGGING_SRCS }
186
188
${CPP-NETLIB_HTTP_CLIENT_SRCS}
187
189
${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS}
188
190
${CPP-NETLIB_HTTP_SERVER_SRCS}
Original file line number Diff line number Diff line change 8
8
9
9
#include < gtest/gtest.h>
10
10
#include < network/concurrency/thread_pool.hpp>
11
- // #include <boost/bind.hpp>
12
11
#include < functional>
13
12
14
13
using network::concurrency::thread_pool;
@@ -42,5 +41,5 @@ TEST(concurrency_test, post_work) {
42
41
ASSERT_NO_THROW (pool.post (std::bind (&foo::bar, &instance, 2 )));
43
42
// require that pool is destroyed here, RAII baby
44
43
}
45
- ASSERT_EQ (instance.val (), 3 );
44
+ ASSERT_EQ (3 , instance.val ());
46
45
}
Original file line number Diff line number Diff line change
1
+ # Copyright (c) Glyn Matthews 2013.
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 )
12
+
13
+ # propagate sources to parent directory for one-lib-build
14
+ set (CPP-NETLIB_ERROR_SRCS ${CPP-NETLIB_ERROR_SRCS} PARENT_SCOPE )
Original file line number Diff line number Diff line change
1
+ # Copyright (c) Glyn Matthews 2013.
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}/error/src )
7
+
8
+ set (CPP-NETLIB_ERROR_SRCS
9
+ error.cpp )
10
+
11
+ if (NOT CPP-NETLIB_BUILD_SINGLE_LIB )
12
+ add_library (network_error ${CPP-NETLIB_ERROR_SRCS} )
13
+ endif ()
14
+
15
+ # prepend current directory to make paths absolute
16
+ prependToElements ( "${CMAKE_CURRENT_SOURCE_DIR} /"
17
+ CPP-NETLIB_ERROR_SRCS )
18
+
19
+ # propagate sources to parent directory for one-lib-build
20
+ set (CPP-NETLIB_ERROR_SRCS ${CPP-NETLIB_ERROR_SRCS} PARENT_SCOPE )
Original file line number Diff line number Diff line change
1
+ // Copyright (C) 2013 by Glyn Matthews
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 < network/error.hpp>
7
+ #include < cstring>
8
+
9
+ namespace network {
10
+
11
+ class network_category_impl : public std ::error_category {
12
+
13
+ public:
14
+
15
+ network_category_impl () = default ;
16
+
17
+ virtual ~network_category_impl () noexcept ;
18
+
19
+ virtual const char *name () const noexcept ;
20
+
21
+ virtual std::string message (int ev) const ;
22
+
23
+ };
24
+
25
+ network_category_impl::~network_category_impl () noexcept {
26
+
27
+ }
28
+
29
+ const char *network_category_impl::name () const noexcept {
30
+ static const char name[] = " network_error" ;
31
+ return name;
32
+ }
33
+
34
+ std::string network_category_impl::message (int ev) const {
35
+ return std::strerror (ev);
36
+ }
37
+
38
+ const std::error_category &network_category () {
39
+ static network_category_impl category;
40
+ return category;
41
+ }
42
+ } // namespace network
Original file line number Diff line number Diff line change
1
+ // Copyright (C) 2013 by Glyn Matthews
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
+ #ifndef NETWORK_ERROR_INC
7
+ #define NETWORK_ERROR_INC
8
+
9
+ /* *
10
+ * \file
11
+ * \brief Contains a set of error classes and exceptions for
12
+ * network connections.
13
+ */
14
+
15
+ #include < system_error>
16
+
17
+ namespace network {
18
+ /* *
19
+ * \brief Gets the error category for network errors.
20
+ */
21
+ const std::error_category &network_category ();
22
+ } // namespace network
23
+
24
+ #endif // NETWORK_ERROR_INC
Original file line number Diff line number Diff line change
1
+ # Copyright (c) Glyn Matthews 2013.
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}/error/src
7
+ ${GTEST_INCLUDE_DIRS}
8
+ ${CPP-NETLIB_SOURCE_DIR}
9
+ )
10
+
11
+ if (CPP-NETLIB_BUILD_TESTS )
12
+ add_executable (cpp-netlib-error_test error_test.cpp )
13
+ target_link_libraries (cpp-netlib-error_test
14
+ ${link_cppnetlib_lib}
15
+ network_error
16
+ ${Boost_LIBRARIES}
17
+ ${GTEST_BOTH_LIBRARIES}
18
+ ${CMAKE_THREAD_LIBS_INIT} )
19
+ set_target_properties (cpp-netlib-error_test PROPERTIES
20
+ RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests )
21
+ add_test (cpp-netlib-error_test
22
+ ${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-error_test )
23
+ endif ()
Original file line number Diff line number Diff line change
1
+ // Copyright (c) Glyn Matthews 2013.
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 < gtest/gtest.h>
7
+ #include < network/error.hpp>
8
+ #include < cerrno>
9
+
10
+ TEST (error_test, system_error) {
11
+ std::system_error error (EPIPE, network::network_category ());
12
+ ASSERT_EQ (EPIPE, error.code ().value ());
13
+ }
You can’t perform that action at this time.
0 commit comments