File: nasty.cpp

package info (click to toggle)
actor-framework 0.18.7-1~exp1
  • links: PTS
  • area: main
  • in suites: experimental
  • size: 8,740 kB
  • sloc: cpp: 85,162; sh: 491; python: 187; makefile: 11
file content (54 lines) | stat: -rw-r--r-- 1,089 bytes parent folder | download
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
47
48
49
50
51
52
53
54
#include "nasty.hpp"

std::string to_string(weekday x) {
  switch (x) {
    default:
      return "???";
    case weekday::monday:
      return "monday";
    case weekday::tuesday:
      return "tuesday";
    case weekday::wednesday:
      return "wednesday";
    case weekday::thursday:
      return "thursday";
    case weekday::friday:
      return "friday";
    case weekday::saturday:
      return "saturday";
    case weekday::sunday:
      return "sunday";
  }
}

bool parse(caf::string_view input, weekday& dest) {
  if (input == "monday") {
    dest = weekday::monday;
    return true;
  }
  if (input == "tuesday") {
    dest = weekday::tuesday;
    return true;
  }
  if (input == "wednesday") {
    dest = weekday::wednesday;
    return true;
  }
  if (input == "thursday") {
    dest = weekday::thursday;
    return true;
  }
  if (input == "friday") {
    dest = weekday::friday;
    return true;
  }
  if (input == "saturday") {
    dest = weekday::saturday;
    return true;
  }
  if (input == "sunday") {
    dest = weekday::sunday;
    return true;
  }
  return false;
}