1#ifndef OUTPUT_FORMATS_H
2#define OUTPUT_FORMATS_H
12 constexpr std::string_view JSON_FILE_FORMAT_STR =
"json";
13 constexpr std::string_view WAVEFRONT_OBJECT_FILE_FORMAT_STR =
"obj";
14 constexpr std::string_view STDOUT_FORMAT_STR =
"stdout";
15 constexpr std::string_view PLAIN_TEXT_FORMAT_STR =
"txt";
22 WAVEFRONT_OBJECT_FILE = 2,
34 case output_format::PLAIN_TEXT:
35 return PLAIN_TEXT_FORMAT_STR;
36 case output_format::JSON_FILE:
37 return JSON_FILE_FORMAT_STR;
38 case output_format::WAVEFRONT_OBJECT_FILE:
39 return WAVEFRONT_OBJECT_FILE_FORMAT_STR;
40 case output_format::STDOUT:
41 return STDOUT_FORMAT_STR;
43 throw std::invalid_argument(
"Invalid output_format: " + std::to_string(
static_cast<unsigned int>(of)));
52 if (sv == PLAIN_TEXT_FORMAT_STR)
54 return output_format::PLAIN_TEXT;
56 if (sv == JSON_FILE_FORMAT_STR)
58 return output_format::JSON_FILE;
60 if (sv == WAVEFRONT_OBJECT_FILE_FORMAT_STR)
62 return output_format::WAVEFRONT_OBJECT_FILE;
64 if (sv == STDOUT_FORMAT_STR)
66 return output_format::STDOUT;
68 throw std::invalid_argument(
"Invalid output_format: " + std::string{sv});