Skip to content

Commit 3faaa69

Browse files
committed
Updated Doxygen comments on almost all files. Added a response_parser class.
1 parent dc2d4cb commit 3faaa69

19 files changed

+2509
-252
lines changed

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,16 @@ if(CPP-NETLIB_BUILD_TESTS)
140140
set(IGLOO_INCLUDE_DIR ${IGLOO_ROOT})
141141
endif()
142142

143+
# Documentation
144+
find_package(Doxygen)
145+
if (DOXYGEN_FOUND)
146+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
147+
add_custom_target(doc ALL
148+
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
149+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
150+
COMMENT "Generating API documentation with Doxygen" VERBATIM)
151+
endif(DOXYGEN_FOUND)
152+
143153
if(CPP-NETLIB_BUILD_SINGLE_LIB)
144154
include_directories(
145155
${CMAKE_CURRENT_SOURCE_DIR}/config/src

Doxyfile.in

Lines changed: 1781 additions & 0 deletions
Large diffs are not rendered by default.

http/src/http/v2/client/client_errors.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@
88
namespace network {
99
namespace http {
1010
namespace v2 {
11+
12+
class client_category_impl : public std::error_category {
13+
14+
public:
15+
16+
client_category_impl() = default;
17+
18+
virtual ~client_category_impl() noexcept;
19+
20+
virtual const char *name() const noexcept;
21+
22+
virtual std::string message(int ev) const;
23+
24+
};
25+
1126
client_category_impl::~client_category_impl() noexcept {
1227

1328
}

http/src/network/http/v2/client/client.hpp

Lines changed: 153 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,173 @@
66
#ifndef __NETWORK_HTTP_V2_CLIENT_CLIENT_INC__
77
#define __NETWORK_HTTP_V2_CLIENT_CLIENT_INC__
88

9-
#include <network/http/v2/client/client_options.hpp>
10-
#include <network/http/v2/client/request.hpp>
11-
#include <network/http/v2/client/request_options.hpp>
12-
#include <network/http/v2/client/response.hpp>
13-
#include <boost/asio/io_service.hpp>
149
#include <future>
1510
#include <memory>
11+
#include <cstdint>
12+
#include <algorithm>
13+
#include <string>
14+
#include <vector>
15+
#include <chrono>
16+
#include <boost/asio/io_service.hpp>
17+
#include <boost/optional.hpp>
18+
#include "network/http/v2/client/request.hpp"
19+
#include "network/http/v2/client/response.hpp"
1620

1721
namespace network {
1822
namespace http {
1923
namespace v2 {
24+
/**
25+
* \class client_options network/http/v2/client/client_options.hpp
26+
* \brief A set of options to configure an HTTP client.
27+
*/
28+
class client_options {
29+
30+
public:
31+
32+
/**
33+
* \brief Constructor.
34+
*/
35+
client_options()
36+
: io_service_(boost::none)
37+
, follow_redirects_(false)
38+
, cache_resolved_(false)
39+
, use_proxy_(false)
40+
, timeout_(30000) { }
41+
42+
/**
43+
* \brief Copy constructor.
44+
*/
45+
client_options(client_options const &) = default;
46+
47+
/**
48+
* \brief Move constructor.
49+
*/
50+
client_options(client_options &&) = default;
51+
52+
/**
53+
* \brief Assignment operator.
54+
*/
55+
client_options &operator = (client_options other) {
56+
other.swap(*this);
57+
return *this;
58+
}
59+
60+
/**
61+
* \brief Destructor.
62+
*/
63+
~client_options() noexcept {
64+
65+
}
66+
67+
/**
68+
* \brief Swap.
69+
*/
70+
void swap(client_options &other) noexcept {
71+
std::swap(io_service_, other.io_service_);
72+
std::swap(follow_redirects_, other.follow_redirects_);
73+
std::swap(cache_resolved_, other.cache_resolved_);
74+
std::swap(use_proxy_, other.use_proxy_);
75+
std::swap(timeout_, other.timeout_);
76+
std::swap(openssl_certificate_paths_, other.openssl_certificate_paths_);
77+
std::swap(openssl_verify_paths_, other.openssl_verify_paths_);
78+
}
79+
80+
client_options &io_service(boost::asio::io_service &io_service) {
81+
io_service_ = io_service;
82+
}
83+
84+
boost::optional<boost::asio::io_service &> io_service() const {
85+
return io_service_;
86+
}
87+
88+
client_options &follow_redirects(bool follow_redirects) noexcept {
89+
follow_redirects_ = follow_redirects;
90+
return *this;
91+
}
92+
93+
bool follow_redirects() const noexcept {
94+
return follow_redirects_;
95+
}
96+
97+
client_options &cache_resolved(bool cache_resolved) noexcept {
98+
cache_resolved_ = cache_resolved;
99+
return *this;
100+
}
101+
102+
bool cache_resolved() const noexcept {
103+
return cache_resolved_;
104+
}
105+
106+
client_options &use_proxy(bool use_proxy) noexcept {
107+
use_proxy_ = use_proxy;
108+
return *this;
109+
}
110+
111+
bool use_proxy() const noexcept {
112+
return use_proxy_;
113+
}
114+
115+
client_options &timeout(std::chrono::milliseconds timeout) noexcept {
116+
timeout_ = timeout;
117+
return *this;
118+
}
119+
120+
std::chrono::milliseconds timeout() const noexcept {
121+
return timeout_;
122+
}
123+
124+
client_options &openssl_certificate_path(std::string path) {
125+
openssl_certificate_paths_.emplace_back(std::move(path));
126+
return *this;
127+
}
128+
129+
std::vector<std::string> openssl_certificate_paths() const {
130+
return openssl_certificate_paths_;
131+
}
132+
133+
client_options &openssl_verify_path(std::string path) {
134+
openssl_verify_paths_.emplace_back(std::move(path));
135+
return *this;
136+
}
137+
138+
std::vector<std::string> openssl_verify_paths() const {
139+
return openssl_verify_paths_;
140+
}
141+
142+
private:
143+
144+
boost::optional<boost::asio::io_service &> io_service_;
145+
bool follow_redirects_;
146+
bool cache_resolved_;
147+
bool use_proxy_;
148+
std::chrono::milliseconds timeout_;
149+
std::vector<std::string> openssl_certificate_paths_;
150+
std::vector<std::string> openssl_verify_paths_;
20151

152+
};
153+
154+
/**
155+
* \class client client.hpp network/http/v2/client/client.hpp
156+
* \brief An HTTP client.
157+
*/
21158
class client {
22159

160+
client(client const &) = delete;
161+
client(client &&) = delete;
162+
23163
public:
24164

25165
typedef request::string_type string_type;
26166

167+
/**
168+
* Constructor.
169+
* \params options Client options.
170+
*/
27171
explicit client(client_options options = client_options());
28-
client(client const &) = delete;
29-
client(client &&) = delete;
172+
173+
/**
174+
* Destructor.
175+
*/
30176
~client() noexcept;
31177

32178
std::future<response> get(request request_, request_options options = request_options());

http/src/network/http/v2/client/client_errors.hpp

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,22 @@
66
#ifndef __NETWORK_HTTP_V2_CLIENT_CLIENT_ERRORS_INC__
77
#define __NETWORK_HTTP_V2_CLIENT_CLIENT_ERRORS_INC__
88

9+
/**
10+
* \file
11+
* \brief Contains a set of error classes and exceptions for HTTP
12+
* clients.
13+
*/
14+
915
#include <network/config.hpp>
1016
#include <system_error>
1117

1218
namespace network {
1319
namespace http {
1420
namespace v2 {
21+
/**
22+
* \enum client_error client_errors.hpp network/http/v2/client/client_errors.hpp
23+
* \brief An enumeration of all types of client error.
24+
*/
1525
enum class client_error {
1626
// url
1727
invalid_url,
@@ -24,51 +34,73 @@ namespace network {
2434
https_not_supported,
2535
};
2636

27-
class client_category_impl : public std::error_category {
28-
29-
public:
30-
31-
client_category_impl() = default;
32-
33-
virtual ~client_category_impl() noexcept;
34-
35-
virtual const char *name() const noexcept;
36-
37-
virtual std::string message(int ev) const;
38-
39-
};
40-
37+
/**
38+
* \brief Gets the error category for HTTP client errors.
39+
*/
4140
const std::error_category &client_category();
4241

42+
/**
43+
* \brief Makes an error code object from a client_error enum.
44+
*/
4345
std::error_code make_error_code(client_error e);
4446

47+
/**
48+
* \class invalid_url network/http/v2/client/client_errors.hpp
49+
* \brief An exception thrown if the URL provides is invalid.
50+
*/
4551
class invalid_url : public std::system_error {
4652

4753
public:
4854

55+
/**
56+
* \brief Constructor.
57+
*/
4958
explicit invalid_url();
5059

60+
/**
61+
* \brief Destructor.
62+
*/
5163
virtual ~invalid_url() noexcept;
5264

5365
};
5466

55-
67+
/**
68+
* \class resolver_error network/http/v2/client/client_errors.hpp
69+
* \brief An exception thrown when there is a resolver error.
70+
*/
5671
class resolver_error : std::system_error {
5772

5873
public:
5974

75+
/**
76+
* \brief Constructor.
77+
*/
6078
explicit resolver_error();
6179

80+
/**
81+
* \brief Destructor.
82+
*/
6283
virtual ~resolver_error() noexcept;
6384

6485
};
6586

87+
/**
88+
* \class connection_error network/http/v2/client/client_errors.hpp
89+
* \brief An exception thrown when there is a connection error.
90+
*/
6691
class connection_error : public std::system_error {
6792

6893
public:
6994

95+
/**
96+
* \brief Constructor.
97+
* \param The client_error code.
98+
*/
7099
explicit connection_error(client_error error);
71100

101+
/**
102+
* \brief Destructor.
103+
*/
72104
virtual ~connection_error() noexcept;
73105

74106
};

0 commit comments

Comments
 (0)