Line data Source code
1 : #include "request_context.hpp"
2 :
3 : #include <stdexcept>
4 : #include <string>
5 :
6 : namespace thinger::http {
7 :
8 114 : request_context::request_context(const request_context& other) {
9 114 : entries_.reserve(other.entries_.size());
10 147 : for (const auto& source : other.entries_) {
11 39 : auto value = source.value->clone();
12 39 : if (!value) {
13 12 : throw std::logic_error(std::string("request_context: the value of key '") + source.name +
14 18 : "' cannot be copied");
15 : }
16 33 : entries_.push_back(entry{source.key, source.type, source.name, std::move(value)});
17 39 : }
18 114 : }
19 :
20 6 : request_context& request_context::operator=(const request_context& other) {
21 6 : if (this != &other) {
22 6 : request_context copy(other);
23 3 : entries_.swap(copy.entries_);
24 3 : }
25 3 : return *this;
26 : }
27 :
28 : } // namespace thinger::http
|