File Coverage

/usr/local/lib/perl5/site_perl/5.26.1/x86_64-linux/Protocol/HTTP.x/i/panda/protocol/http/Body.h
Criterion Covered Total %
statement 0 2 0.0
branch n/a
condition n/a
subroutine n/a
pod n/a
total 0 2 0.0


line stmt bran cond sub pod time code
1             #pragma once
2             #include
3             #include
4             #include
5             #include
6              
7              
8             namespace panda { namespace protocol { namespace http {
9              
10 0           struct Body {
11             boost::container::small_vector parts;
12              
13 0           Body () {}
14             Body (const string& body) { parts.emplace_back(body); }
15              
16             Body (const std::initializer_list& l) { for (auto& s : l) parts.push_back(s); }
17              
18             Body (const Body&) = default;
19             Body (Body&& oth) = default;
20              
21             Body& operator= (const string& str) {
22             parts.clear();
23             if (str) parts.emplace_back(str);
24             return *this;
25             }
26              
27             Body& operator= (string&& str) {
28             parts.clear();
29             if (str) parts.emplace_back(std::move(str));
30             return *this;
31             }
32              
33             Body& operator= (const Body&) = default;
34             Body& operator= (Body&&) = default;
35              
36             size_t length () const {
37             if (!parts.size()) return 0;
38             uint64_t size = 0;
39             for (auto& s : parts) size += s.length();
40             return size;
41             }
42              
43             string to_string () const;
44             bool empty () const { return !length(); }
45              
46             void clear () { parts.clear(); }
47             };
48              
49             std::ostream& operator<< (std::ostream&, const Body&);
50              
51             }}}