-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsynchronicity.cxx
More file actions
48 lines (38 loc) · 1.03 KB
/
synchronicity.cxx
File metadata and controls
48 lines (38 loc) · 1.03 KB
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 "synchronicity.hxx"
#include <stdexcept>
#include <algorithm>
#include <cctype>
std::ostream& operator<< (std::ostream& stream, const Synchronicity& s)
{
switch (s) {
case Synchronicity::ASYNCHRONE:
return stream << "ASynchrone";
break;
case Synchronicity::SYNCHRONE:
return stream << "Synchrone";
break;
default:
throw new std::logic_error("Unknown type of Synchronicity.");
}
}
std::istream& operator>> (std::istream& stream, Synchronicity& s)
{
std::string input;
stream >> input;
std::transform (input.begin(), input.end(), input.begin(), ::tolower);
if (input == "asynchrone" || input == "async" || input == "asynchronous")
{
s = Synchronicity::ASYNCHRONE;
return stream;
}
else if (input == "synchrone" || input == "sync" || input == "synchronous")
{
s = Synchronicity::SYNCHRONE;
return stream;
}
throw new std::runtime_error(
"Unsupported value for Synchronicity: "
+ input);
}
/* vim:set tabstop=4 shiftwidth=4 fo=cqwan autoindent : */
/* makeprg=make\ -C\ ~/tmp/build-try-https */