File Coverage

src/panda/uri/encode.h
Criterion Covered Total %
statement 4 8 50.0
branch 1 2 50.0
condition n/a
subroutine n/a
pod n/a
total 5 10 50.0


line stmt bran cond sub pod time code
1             #pragma once
2             #include
3              
4             namespace panda { namespace uri {
5              
6             struct URIComponent {
7             static char scheme[256];
8             static char user_info[256];
9             static char host[256];
10             static char path[256];
11             static char path_segment[256];
12             static char query[256];
13             static char query_param[256];
14             static char query_param_plus[256];
15             static char fragment[256];
16             };
17              
18             size_t encode_uri_component (const string_view src, char* dest, const char* component = URIComponent::query_param);
19             size_t decode_uri_component (const string_view src, char* dest);
20              
21             inline void encode_uri_component (const string_view src, panda::string& dest, const char* component = URIComponent::query_param) {
22             size_t final_size = encode_uri_component(src, dest.reserve(src.length()*3), component);
23             dest.length(final_size);
24             }
25              
26 0           inline void decode_uri_component (const string_view src, panda::string& dest) {
27 0           size_t final_size = decode_uri_component(src, dest.reserve(src.length()));
28 0           dest.length(final_size);
29 0           }
30              
31             inline panda::string encode_uri_component (const string_view src, const char* component = URIComponent::query_param) {
32             panda::string ret;
33             encode_uri_component(src, ret, component);
34             return ret;
35             }
36              
37 5           inline panda::string decode_uri_component (const string_view src) {
38 5           panda::string ret;
39 5 50         decode_uri_component(src, ret);
40 5           return ret;
41             }
42              
43             }}