#ifndef DIRECTION_H_42BDAFB9 #define DIRECTION_H_42BDAFB9 #include #include 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 */