blob: 0fe3e5a1ea3c1fb2a7c85f752d889332cdc6ee80 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#ifndef DIRECTION_H_42BDAFB9
#define DIRECTION_H_42BDAFB9
#include <string_view>
#include <stdexcept>
enum class Direction {
up,
down,
left,
right
};
inline Direction directionFromString(std::string_view str) {
if (str == "up") return Direction::up;
if (str == "right") return Direction::right;
if (str == "down") return Direction::down;
if (str == "left") return Direction::left;
throw std::invalid_argument("Invalid direction: " + std::string(str));
}
#endif /* end of include guard: DIRECTION_H_42BDAFB9 */
|