#pragma once
#include "google/protobuf/compiler/importer.h"
#include "rust/cxx.h"
namespace protobuf_native {
namespace compiler {
using namespace google::protobuf;
using namespace google::protobuf::compiler;
struct FileLoadError;
class SimpleErrorCollector : public MultiFileErrorCollector {
public:
void RecordError(absl::string_view filename, int line, int column,
absl::string_view message) override;
void RecordWarning(absl::string_view filename, int line, int column,
absl::string_view message) override;
std::vector<FileLoadError>& Errors();
private:
void RecordErrorOrWarning(absl::string_view filename, int line, int column,
absl::string_view message, bool warning);
std::vector<FileLoadError> errors_;
};
SimpleErrorCollector* NewSimpleErrorCollector();
void DeleteSimpleErrorCollector(SimpleErrorCollector*);
rust::String SourceTreeGetLastErrorMessage(SourceTree&);
class VirtualSourceTree : public SourceTree {
public:
void AddFile(absl::string_view name, rust::Vec<rust::u8> contents);
io::ZeroCopyInputStream* Open(absl::string_view filename);
std::string GetLastErrorMessage();
private:
absl::flat_hash_map<std::string, rust::Vec<rust::u8>> files_;
};
VirtualSourceTree* NewVirtualSourceTree();
void DeleteVirtualSourceTree(VirtualSourceTree*);
DiskSourceTree* NewDiskSourceTree();
void DeleteDiskSourceTree(DiskSourceTree*);
SourceTreeDescriptorDatabase* NewSourceTreeDescriptorDatabase(SourceTree* source_tree);
void DeleteSourceTreeDescriptorDatabase(SourceTreeDescriptorDatabase* source_tree);
} }