Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
ParserFactory.h
Go to the documentation of this file.
1#ifndef PARSERFACTORY_H
2#define PARSERFACTORY_H
3
4#include <memory>
5#include "IParser.h"
6#include "JsonParser.h"
7#include "YamlParser.h"
8#include "LhaParser.h"
9
14public:
15 enum class Type { JSON, YAML, LHA };
16
22 static std::shared_ptr<IParser> createParser(Type type);
23};
24
25inline std::shared_ptr<IParser> ParserFactory::createParser(Type type) {
26 switch (type) {
27 case Type::JSON:
28 return std::make_shared<JSONParser>();
29 case Type::YAML:
30 return std::make_shared<YAMLParser>();
31 case Type::LHA:
32 return std::make_shared<LhaParser>();
33 default:
34 throw std::invalid_argument("Unknown parser type");
35 }
36}
37
38#endif // PARSERFACTORY_H
Abstract interface for (de)serializing data as DBNode trees.
Lightweight JSON parser/serializer for DBNode trees.
Parser for LHA / FLHA-style files into LhaBlock structures and DBNode trees.
Lightweight YAML parser/serializer for DBNode trees.
Factory for creating IParser instances.
static std::shared_ptr< IParser > createParser(Type type)
Creates a parser instance of the specified type.