Loading...
Searching...
No Matches
yaml_input_format.hpp
Go to the documentation of this file.
1#pragma once
2
3/**
4 * YAMLInputFormat — Q3's own YAML input, and the fallback format.
5 *
6 * Any path that is not a directory is a YAML input unless a more specific
7 * format claims it, which is how inputs have always been read: a file with no
8 * recognised extension goes to the YAML parser, and a parse error there says
9 * what is wrong with it.
10 */
11
12#include <filesystem>
13#include <memory>
14#include <string>
15#include <vector>
16
19
20namespace q3 {
21
22/// Q3's own YAML input, the fallback for any file nothing more specific claims.
24 public:
25 /// Ranked lowest: the fallback answers only when nothing more specific does.
26 static constexpr int fallback_detection_priority = 0;
27
28 /// "yaml", and the "yml" extension spelling.
29 [[nodiscard]] std::vector<std::string> names() const override {
30 return {"yaml", "yml"};
31 }
32
33 /// How a log line names a YAML input.
34 [[nodiscard]] std::string display_name() const override {
35 return "a Q3 YAML input";
36 }
37
38 /// The lowest rank, fallback_detection_priority.
39 [[nodiscard]] int detection_priority() const override {
41 }
42
43 /// Any path that is not a directory.
44 [[nodiscard]] bool recognizes(const std::filesystem::path& path) const override {
45 return !std::filesystem::is_directory(path);
46 }
47
48 /// A YAMLInputParser.
49 [[nodiscard]] std::unique_ptr<InputParser> create_parser() const override {
50 return std::make_unique<YAMLInputParser>();
51 }
52};
53
54} // namespace q3
One input format a run can be read from; see the file comment.
Q3's own YAML input, the fallback for any file nothing more specific claims.
std::unique_ptr< InputParser > create_parser() const override
A YAMLInputParser.
std::string display_name() const override
How a log line names a YAML input.
bool recognizes(const std::filesystem::path &path) const override
Any path that is not a directory.
int detection_priority() const override
The lowest rank, fallback_detection_priority.
std::vector< std::string > names() const override
"yaml", and the "yml" extension spelling.
static constexpr int fallback_detection_priority
Ranked lowest: the fallback answers only when nothing more specific does.