Maze Builder Docs 8.10.23
Loading...
Searching...
No Matches
output_formats.h File Reference
#include <algorithm>
#include <array>
#include <cctype>
#include <iterator>
#include <ranges>
#include <stdexcept>
#include <string>
#include <string_view>
Include dependency graph for output_formats.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum class  mazes::output_format : unsigned int {
  JPG = 0 , JPEG = 1 , BMP = 2 , PLAIN_TEXT = 3 ,
  PLAIN_TEXT_ALT = 4 , PNG = 5 , JSON = 6 , OBJ = 7 ,
  STDOUT = 8 , B64 = 9 , TOTAL = 10
}
 Enum class for output_format types.

Functions

std::string_view mazes::to_sv_from_output_format (output_format of)
 Convert an output_format enum to a string.
output_format mazes::to_output_format_from_sv (const std::string_view sv)
 Convert a string to an output_format enum.
output_format mazes::stdout_format_from_sv (const std::string_view sv) noexcept
 Check whether a bare format keyword (no file extension) targets stdout.
output_format mazes::output_format_or_default (const std::string_view sv, const output_format fallback=output_format::PLAIN_TEXT) noexcept
 Converts a string to an output_format enum, or returns a fallback if invalid.

Variables

constexpr std::array< std::string_view, static_cast< size_t >(output_format::TOTAL)> mazes::OUTPUT_FORMAT_LABELS_LOWERCASE

Function Documentation

◆ output_format_or_default()

output_format mazes::output_format_or_default ( const std::string_view sv,
const output_format fallback = output_format::PLAIN_TEXT )
inlinenoexcept

Converts a string to an output_format enum, or returns a fallback if invalid.

Parameters
svThe string representation of the output format.
fallbackThe fallback output_format to return if the string is invalid.
Returns
The corresponding output_format enum, or the fallback if invalid.

◆ stdout_format_from_sv()

output_format mazes::stdout_format_from_sv ( const std::string_view sv)
inlinenoexcept

Check whether a bare format keyword (no file extension) targets stdout.

"stdout" prints the regular string, "obj" a Wavefront OBJ, and "b64" a base64-encoded string

Parameters
svThe output argument value
Returns
The matching output_format, or output_format::TOTAL if sv is not a stdout keyword

◆ to_output_format_from_sv()

output_format mazes::to_output_format_from_sv ( const std::string_view sv)
inline

Convert a string to an output_format enum.

Parameters
sv
Returns

◆ to_sv_from_output_format()

std::string_view mazes::to_sv_from_output_format ( output_format of)
inline

Convert an output_format enum to a string.

Parameters
of
Returns

Variable Documentation

◆ OUTPUT_FORMAT_LABELS_LOWERCASE

std::array<std::string_view, static_cast<size_t>(output_format::TOTAL)> mazes::OUTPUT_FORMAT_LABELS_LOWERCASE
constexpr
Initial value:
= {
"jpg",
"jpeg",
"bmp",
"text",
"txt",
"png",
"json",
"obj",
"stdout",
"b64"}