Skip to content

Commit a0920a8

Browse files
authored
Merge pull request #142 from etr/move_sem
Added move semantics to main classes in the library
2 parents 0bafefc + b01e308 commit a0920a8

File tree

10 files changed

+417
-8
lines changed

10 files changed

+417
-8
lines changed

src/httpserver/basic_auth_fail_response.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ class basic_auth_fail_response : public string_response
5656
{
5757
}
5858

59+
basic_auth_fail_response(basic_auth_fail_response&& other) noexcept:
60+
string_response(std::move(other)),
61+
realm(std::move(other.realm))
62+
{
63+
}
64+
5965
basic_auth_fail_response& operator=(const basic_auth_fail_response& b)
6066
{
6167
if (this == &b) return *this;
@@ -66,6 +72,16 @@ class basic_auth_fail_response : public string_response
6672
return *this;
6773
}
6874

75+
basic_auth_fail_response& operator=(basic_auth_fail_response&& b)
76+
{
77+
if (this == &b) return *this;
78+
79+
(string_response&) (*this) = std::move(b);
80+
this->realm = std::move(b.realm);
81+
82+
return *this;
83+
}
84+
6985
~basic_auth_fail_response()
7086
{
7187
}

src/httpserver/create_webserver.hpp

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,178 @@ class create_webserver
8787
{
8888
}
8989

90+
create_webserver(const create_webserver& b):
91+
_port(b._port),
92+
_start_method(b._start_method),
93+
_max_threads(b._max_threads),
94+
_max_connections(b._max_connections),
95+
_memory_limit(b._memory_limit),
96+
_content_size_limit(b._content_size_limit),
97+
_connection_timeout(b._connection_timeout),
98+
_per_IP_connection_limit(b._per_IP_connection_limit),
99+
_log_access(b._log_access),
100+
_log_error(b._log_error),
101+
_validator(b._validator),
102+
_unescaper(b._unescaper),
103+
_bind_address(b._bind_address),
104+
_bind_socket(b._bind_socket),
105+
_max_thread_stack_size(b._max_thread_stack_size),
106+
_use_ssl(b._use_ssl),
107+
_use_ipv6(b._use_ipv6),
108+
_debug(b._debug),
109+
_pedantic(b._pedantic),
110+
_https_mem_key(b._https_mem_key),
111+
_https_mem_cert(b._https_mem_cert),
112+
_https_mem_trust(b._https_mem_trust),
113+
_https_priorities(b._https_priorities),
114+
_cred_type(b._cred_type),
115+
_digest_auth_random(b._digest_auth_random),
116+
_nonce_nc_size(b._nonce_nc_size),
117+
_default_policy(b._default_policy),
118+
_basic_auth_enabled(b._basic_auth_enabled),
119+
_digest_auth_enabled(b._digest_auth_enabled),
120+
_regex_checking(b._regex_checking),
121+
_ban_system_enabled(b._ban_system_enabled),
122+
_post_process_enabled(b._post_process_enabled),
123+
_deferred_enabled(b._deferred_enabled),
124+
_single_resource(b._single_resource),
125+
_not_found_resource(b._not_found_resource),
126+
_method_not_allowed_resource(b._method_not_allowed_resource),
127+
_internal_error_resource(b._internal_error_resource)
128+
{
129+
}
130+
131+
create_webserver(create_webserver&& b):
132+
_port(b._port),
133+
_start_method(b._start_method),
134+
_max_threads(b._max_threads),
135+
_max_connections(b._max_connections),
136+
_memory_limit(b._memory_limit),
137+
_content_size_limit(b._content_size_limit),
138+
_connection_timeout(b._connection_timeout),
139+
_per_IP_connection_limit(b._per_IP_connection_limit),
140+
_log_access(std::move(b._log_access)),
141+
_log_error(std::move(b._log_error)),
142+
_validator(std::move(b._validator)),
143+
_unescaper(std::move(b._unescaper)),
144+
_bind_address(std::move(b._bind_address)),
145+
_bind_socket(b._bind_socket),
146+
_max_thread_stack_size(b._max_thread_stack_size),
147+
_use_ssl(b._use_ssl),
148+
_use_ipv6(b._use_ipv6),
149+
_debug(b._debug),
150+
_pedantic(b._pedantic),
151+
_https_mem_key(std::move(b._https_mem_key)),
152+
_https_mem_cert(std::move(b._https_mem_cert)),
153+
_https_mem_trust(std::move(b._https_mem_trust)),
154+
_https_priorities(std::move(b._https_priorities)),
155+
_cred_type(b._cred_type),
156+
_digest_auth_random(std::move(b._digest_auth_random)),
157+
_nonce_nc_size(b._nonce_nc_size),
158+
_default_policy(b._default_policy),
159+
_basic_auth_enabled(b._basic_auth_enabled),
160+
_digest_auth_enabled(b._digest_auth_enabled),
161+
_regex_checking(b._regex_checking),
162+
_ban_system_enabled(b._ban_system_enabled),
163+
_post_process_enabled(b._post_process_enabled),
164+
_deferred_enabled(b._deferred_enabled),
165+
_single_resource(b._single_resource),
166+
_not_found_resource(std::move(b._not_found_resource)),
167+
_method_not_allowed_resource(std::move(b._method_not_allowed_resource)),
168+
_internal_error_resource(std::move(b._internal_error_resource))
169+
{
170+
}
171+
172+
create_webserver& operator=(const create_webserver& b)
173+
{
174+
if (this == &b) return *this;
175+
176+
this->_port = b._port;
177+
this->_start_method = b._start_method;
178+
this->_max_threads = b._max_threads;
179+
this->_max_connections = b._max_connections;
180+
this->_memory_limit = b._memory_limit;
181+
this->_content_size_limit = b._content_size_limit;
182+
this->_connection_timeout = b._connection_timeout;
183+
this->_per_IP_connection_limit = b._per_IP_connection_limit;
184+
this->_log_access = b._log_access;
185+
this->_log_error = b._log_error;
186+
this->_validator = b._validator;
187+
this->_unescaper = b._unescaper;
188+
this->_bind_address = b._bind_address;
189+
this->_bind_socket = b._bind_socket;
190+
this->_max_thread_stack_size = b._max_thread_stack_size;
191+
this->_use_ssl = b._use_ssl;
192+
this->_use_ipv6 = b._use_ipv6;
193+
this->_debug = b._debug;
194+
this->_pedantic = b._pedantic;
195+
this->_https_mem_key = b._https_mem_key;
196+
this->_https_mem_cert = b._https_mem_cert;
197+
this->_https_mem_trust = b._https_mem_trust;
198+
this->_https_priorities = b._https_priorities;
199+
this->_cred_type = b._cred_type;
200+
this->_digest_auth_random = b._digest_auth_random;
201+
this->_nonce_nc_size = b._nonce_nc_size;
202+
this->_default_policy = b._default_policy;
203+
this->_basic_auth_enabled = b._basic_auth_enabled;
204+
this->_digest_auth_enabled = b._digest_auth_enabled;
205+
this->_regex_checking = b._regex_checking;
206+
this->_ban_system_enabled = b._ban_system_enabled;
207+
this->_post_process_enabled = b._post_process_enabled;
208+
this->_deferred_enabled = b._deferred_enabled;
209+
this->_single_resource = b._single_resource;
210+
this->_not_found_resource = b._not_found_resource;
211+
this->_method_not_allowed_resource = b._method_not_allowed_resource;
212+
this->_internal_error_resource = b._internal_error_resource;
213+
214+
return *this;
215+
}
216+
217+
create_webserver& operator=(create_webserver&& b)
218+
{
219+
if (this == &b) return *this;
220+
221+
this->_port = b._port;
222+
this->_start_method = b._start_method;
223+
this->_max_threads = b._max_threads;
224+
this->_max_connections = b._max_connections;
225+
this->_memory_limit = b._memory_limit;
226+
this->_content_size_limit = b._content_size_limit;
227+
this->_connection_timeout = b._connection_timeout;
228+
this->_per_IP_connection_limit = b._per_IP_connection_limit;
229+
this->_log_access = std::move(b._log_access);
230+
this->_log_error = std::move(b._log_error);
231+
this->_validator = std::move(b._validator);
232+
this->_unescaper = std::move(b._unescaper);
233+
this->_bind_address = std::move(b._bind_address);
234+
this->_bind_socket = b._bind_socket;
235+
this->_max_thread_stack_size = b._max_thread_stack_size;
236+
this->_use_ssl = b._use_ssl;
237+
this->_use_ipv6 = b._use_ipv6;
238+
this->_debug = b._debug;
239+
this->_pedantic = b._pedantic;
240+
this->_https_mem_key = std::move(b._https_mem_key);
241+
this->_https_mem_cert = std::move(b._https_mem_cert);
242+
this->_https_mem_trust = std::move(b._https_mem_trust);
243+
this->_https_priorities = std::move(b._https_priorities);
244+
this->_cred_type = b._cred_type;
245+
this->_digest_auth_random = std::move(b._digest_auth_random);
246+
this->_nonce_nc_size = b._nonce_nc_size;
247+
this->_default_policy = b._default_policy;
248+
this->_basic_auth_enabled = b._basic_auth_enabled;
249+
this->_digest_auth_enabled = b._digest_auth_enabled;
250+
this->_regex_checking = b._regex_checking;
251+
this->_ban_system_enabled = b._ban_system_enabled;
252+
this->_post_process_enabled = b._post_process_enabled;
253+
this->_deferred_enabled = b._deferred_enabled;
254+
this->_single_resource = b._single_resource;
255+
this->_not_found_resource = std::move(b._not_found_resource);
256+
this->_method_not_allowed_resource = std::move(b._method_not_allowed_resource);
257+
this->_internal_error_resource = std::move(b._internal_error_resource);
258+
259+
return *this;
260+
}
261+
90262
explicit create_webserver(uint16_t port):
91263
_port(port),
92264
_start_method(http::http_utils::INTERNAL_SELECT),

src/httpserver/deferred_response.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,31 @@ class deferred_response : public string_response
5959
{
6060
}
6161

62+
deferred_response(deferred_response&& other) noexcept:
63+
string_response(std::move(other)),
64+
cycle_callback(std::move(other.cycle_callback)),
65+
completed(other.completed)
66+
{
67+
}
68+
6269
deferred_response& operator=(const deferred_response& b)
6370
{
6471
if (this == &b) return *this;
6572

6673
(string_response&) (*this) = b;
6774
this->cycle_callback = b.cycle_callback;
75+
this->completed = b.completed;
76+
77+
return *this;
78+
}
79+
80+
deferred_response& operator=(deferred_response&& b)
81+
{
82+
if (this == &b) return *this;
83+
84+
(string_response&) (*this) = std::move(b);
85+
this->cycle_callback = std::move(b.cycle_callback);
86+
this->completed = b.completed;
6887

6988
return *this;
7089
}

src/httpserver/details/modded_request.hpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,55 @@ struct modded_request
5353
second(false)
5454
{
5555
}
56+
57+
modded_request(const modded_request& b):
58+
pp(b.pp),
59+
complete_uri(b.complete_uri),
60+
standardized_url(b.standardized_url),
61+
ws(b.ws),
62+
dhr(b.dhr),
63+
second(b.second)
64+
{
65+
}
66+
67+
modded_request(modded_request&& b):
68+
pp(std::move(b.pp)),
69+
complete_uri(std::move(b.complete_uri)),
70+
standardized_url(std::move(b.standardized_url)),
71+
ws(std::move(b.ws)),
72+
dhr(std::move(b.dhr)),
73+
second(b.second)
74+
{
75+
}
76+
77+
modded_request& operator=(const modded_request& b)
78+
{
79+
if (this == &b) return *this;
80+
81+
this->pp = b.pp;
82+
this->complete_uri = b.complete_uri;
83+
this->standardized_url = b.standardized_url;
84+
this->ws = b.ws;
85+
this->dhr = b.dhr;
86+
this->second = b.second;
87+
88+
return *this;
89+
}
90+
91+
modded_request& operator=(modded_request&& b)
92+
{
93+
if (this == &b) return *this;
94+
95+
this->pp = std::move(b.pp);
96+
this->complete_uri = std::move(b.complete_uri);
97+
this->standardized_url = std::move(b.standardized_url);
98+
this->ws = std::move(b.ws);
99+
this->dhr = std::move(b.dhr);
100+
this->second = b.second;
101+
102+
return *this;
103+
}
104+
56105
~modded_request()
57106
{
58107
if (NULL != pp)

src/httpserver/digest_auth_fail_response.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ class digest_auth_fail_response : public string_response
6464
{
6565
}
6666

67+
digest_auth_fail_response(digest_auth_fail_response&& other) noexcept:
68+
string_response(std::move(other)),
69+
realm(std::move(other.realm)),
70+
opaque(std::move(other.opaque)),
71+
reload_nonce(other.reload_nonce)
72+
{
73+
}
74+
6775
digest_auth_fail_response& operator=(const digest_auth_fail_response& b)
6876
{
6977
if (this == &b) return *this;
@@ -76,6 +84,18 @@ class digest_auth_fail_response : public string_response
7684
return *this;
7785
}
7886

87+
digest_auth_fail_response& operator=(digest_auth_fail_response&& b)
88+
{
89+
if (this == &b) return *this;
90+
91+
(string_response&) (*this) = std::move(b);
92+
this->realm = std::move(b.realm);
93+
this->opaque = std::move(b.opaque);
94+
this->reload_nonce = b.reload_nonce;
95+
96+
return *this;
97+
}
98+
7999
~digest_auth_fail_response()
80100
{
81101
}

src/httpserver/file_response.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ class file_response : public http_response
5555
{
5656
}
5757

58+
file_response(file_response&& other) noexcept:
59+
http_response(std::move(other)),
60+
filename(std::move(other.filename))
61+
{
62+
}
63+
5864
file_response& operator=(const file_response& b)
5965
{
6066
if (this == &b) return *this;
@@ -65,6 +71,16 @@ class file_response : public http_response
6571
return *this;
6672
}
6773

74+
file_response& operator=(file_response&& b)
75+
{
76+
if (this == &b) return *this;
77+
78+
(http_response&) (*this) = std::move(b);
79+
this->filename = std::move(b.filename);
80+
81+
return *this;
82+
}
83+
6884
~file_response()
6985
{
7086
}

0 commit comments

Comments
 (0)