-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandlers.cxx
More file actions
48 lines (38 loc) · 923 Bytes
/
handlers.cxx
File metadata and controls
48 lines (38 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "handlers.hxx"
#include <stdexcept>
#include <algorithm>
#include <cctype>
std::ostream& operator<< (std::ostream& stream, const Handlers& handler)
{
switch (handler) {
case Handlers::ECHO:
return stream << "ECHO";
break;
case Handlers::H401:
return stream << "401";
break;
default:
throw new std::logic_error("Unknown type of Handlers.");
}
}
std::istream& operator>> (std::istream& stream, Handlers& handler)
{
std::string input;
stream >> input;
std::transform (input.begin(), input.end(), input.begin(), ::tolower);
if(input == "echo")
{
handler = Handlers::ECHO;
return stream;
}
else if (input == "401" || input == "h401")
{
handler = Handlers::H401;
return stream;
}
throw new std::runtime_error(
"Unsupported value for Handlers: "
+ input);
}
/* vim:set tabstop=4 shiftwidth=4 fo=cqwan autoindent : */
/* makeprg=make\ -C\ ~/tmp/build-try-https */