CAPIO-CL 1.2.0
CAPIO-CL: Cross Application Programmable I/O - Coordination Language
Loading...
Searching...
No Matches
parser.h
1#ifndef CAPIO_CL_PARSER_H
2#define CAPIO_CL_PARSER_H
3#include <jsoncons/basic_json.hpp>
4#include <jsoncons_ext/jsonschema/jsonschema.hpp>
5
7namespace capiocl::parser {
8
12class ParserException final : public std::exception {
13 std::string message;
14
15 public:
20 explicit ParserException(const std::string &msg);
21
26 [[nodiscard]] const char *what() const noexcept override { return message.c_str(); }
27};
28
30class Parser final {
31
33 struct available_parsers {
42 static engine::Engine *parse_v1(const std::filesystem::path &source,
43 const std::filesystem::path &resolve_prefix,
44 bool store_only_in_memory);
45
54 static engine::Engine *parse_v1_1(const std::filesystem::path &source,
55 const std::filesystem::path &resolve_prefix,
56 bool store_only_in_memory);
57 };
58
64 static jsoncons::jsonschema::json_schema<jsoncons::json> loadSchema(const char *data);
65
66 protected:
73 static std::filesystem::path resolve(std::filesystem::path path,
74 const std::filesystem::path &prefix);
75
76 public:
82 static void validate_json(const jsoncons::json &doc, const char *str_schema);
83
93 static engine::Engine *parse(const std::filesystem::path &source,
94 const std::filesystem::path &resolve_prefix = "",
95 bool store_only_in_memory = false);
96};
97} // namespace capiocl::parser
98
99#endif // CAPIO_CL_PARSER_H
Engine for managing CAPIO-CL configuration entries. The CapioCLEngine class stores and manages config...
Definition engine.h:26
ParserException(const std::string &msg)
Construct a new CAPIO-CL Exception.
Definition Parser.cpp:9
const char * what() const noexcept override
Definition parser.h:26
Contains the code to parse a JSON based CAPIO-CL configuration file.
Definition parser.h:30
static std::filesystem::path resolve(std::filesystem::path path, const std::filesystem::path &prefix)
Definition Parser.cpp:18
static engine::Engine * parse(const std::filesystem::path &source, const std::filesystem::path &resolve_prefix="", bool store_only_in_memory=false)
Perform the parsing of the capio_server configuration file.
Definition Parser.cpp:46
static void validate_json(const jsoncons::json &doc, const char *str_schema)
Definition Parser.cpp:35
Namespace containing the CAPIO-CL parsers components.
Definition parser.h:7