#pragma once
#include
#include
#include
#include
namespace DB
{
class Context;
class Block;
/// Extracts information about where the format schema file is from passed context and keep it.
class FormatSchemaInfo
{
public:
FormatSchemaInfo(const String & format_schema, const String & format, bool require_message, bool is_server, const std::string & format_schema_path);
FormatSchemaInfo(const FormatSettings & settings, const String & format, bool require_message);
/// Returns path to the schema file.
const String & schemaPath() const { return schema_path; }
String absoluteSchemaPath() const { return schema_directory + schema_path; }
/// Returns directory containing the schema file.
const String & schemaDirectory() const { return schema_directory; }
/// Returns name of the message type.
const String & messageName() const { return message_name; }
private:
String schema_path;
String schema_directory;
String message_name;
};
template
class MaybeAutogeneratedFormatSchemaInfo
{
public:
MaybeAutogeneratedFormatSchemaInfo(const FormatSettings & settings, const String & format, const Block & header, bool use_autogenerated_schema);
~MaybeAutogeneratedFormatSchemaInfo();
const FormatSchemaInfo & getSchemaInfo() const { return *schema_info; }
private:
std::unique_ptr schema_info;
String tmp_file_path;
};
using CapnProtoSchemaInfo = MaybeAutogeneratedFormatSchemaInfo;
using ProtobufSchemaInfo = MaybeAutogeneratedFormatSchemaInfo;
}