1#pragma once
2
3#include "config_formats.h"
4#if USE_PROTOBUF
5
6#include <memory>
7#include <unordered_map>
8#include <Core/Types.h>
9#include <boost/noncopyable.hpp>
10
11
12namespace google
13{
14namespace protobuf
15{
16 class Descriptor;
17}
18}
19
20namespace DB
21{
22class FormatSchemaInfo;
23
24/** Keeps parsed google protobuf schemas parsed from files.
25 * This class is used to handle the "Protobuf" input/output formats.
26 */
27class ProtobufSchemas : private boost::noncopyable
28{
29public:
30 static ProtobufSchemas & instance();
31
32 ProtobufSchemas();
33 ~ProtobufSchemas();
34
35 /// Parses the format schema, then parses the corresponding proto file, and returns the descriptor of the message type.
36 /// The function never returns nullptr, it throws an exception if it cannot load or parse the file.
37 const google::protobuf::Descriptor * getMessageTypeForFormatSchema(const FormatSchemaInfo & info);
38
39private:
40 class ImporterWithSourceTree;
41 std::unordered_map<String, std::unique_ptr<ImporterWithSourceTree>> importers;
42};
43
44}
45
46#endif
47