Go to the documentation of this file.
43 #include <sys/types.h>
70 using google::protobuf::io::win32::open;
77 #if defined(_WIN32) || defined(__CYGWIN__)
78 return text.size() >= 3 && text[1] ==
':' && isalpha(text[0]) &&
79 (text[2] ==
'/' || text[2] ==
'\\') && text.find_last_of(
':') == 1;
122 fallback_database_(nullptr),
124 using_validation_error_collector_(
false),
125 validation_error_collector_(this) {}
130 fallback_database_(fallback_database),
132 using_validation_error_collector_(
false),
133 validation_error_collector_(this) {}
158 parser.RecordErrorsTo(&file_error_collector);
165 output->set_name(filename);
175 const std::string& containing_type,
int field_number,
193 if (owner_->error_collector_ ==
NULL)
return;
202 owner_->error_collector_->AddError(filename, line, column,
message);
209 if (owner_->error_collector_ ==
NULL)
return;
218 owner_->error_collector_->AddWarning(filename, line, column,
message);
225 : database_(source_tree),
257 return str[
str.size() - 1];
292 std::vector<std::string> canonical_parts;
293 std::vector<std::string> parts =
Split(
295 for (
int i = 0;
i < parts.size();
i++) {
296 if (parts[
i] ==
".") {
299 canonical_parts.push_back(parts[
i]);
303 if (!
path.empty() &&
path[0] ==
'/') {
305 result =
'/' + result;
340 if (old_prefix.empty()) {
350 result->assign(new_prefix);
351 if (!result->empty()) result->push_back(
'/');
352 result->append(filename);
356 if (filename.size() == old_prefix.size()) {
358 *result = new_prefix;
364 int after_prefix_start = -1;
365 if (filename[old_prefix.size()] ==
'/') {
366 after_prefix_start = old_prefix.size() + 1;
367 }
else if (filename[old_prefix.size() - 1] ==
'/') {
370 after_prefix_start = old_prefix.size();
372 if (after_prefix_start != -1) {
375 std::string after_prefix = filename.substr(after_prefix_start);
380 result->assign(new_prefix);
381 if (!result->empty()) result->push_back(
'/');
382 result->append(after_prefix);
400 int mapping_index = -1;
413 if (mapping_index == -1) {
419 for (
int i = 0;
i < mapping_index;
i++) {
421 mappings_[
i].disk_path, shadowing_disk_file)) {
422 if (
access(shadowing_disk_file->c_str(), F_OK) >= 0) {
428 shadowing_disk_file->clear();
443 std::unique_ptr<io::ZeroCopyInputStream>
stream(
464 "Backslashes, consecutive slashes, \".\", or \"..\" "
465 "are not allowed in the virtual path";
475 if (disk_file !=
NULL) {
476 *disk_file = temp_disk_file;
484 "Read access is denied for file: " + temp_disk_file;
497 file_descriptor = open(filename.c_str(), O_RDONLY);
498 }
while (file_descriptor < 0 &&
errno ==
EINTR);
499 if (file_descriptor >= 0) {
SourceLocationTable source_locations_
const FileDescriptor * FindFileByName(const std::string &name) const
void ClearUnusedImportTrackFiles()
SourceTreeDescriptorDatabase database_
static bool ContainsParentReference(const std::string &path)
static bool IsWindowsAbsolutePath(const std::string &text)
virtual io::ZeroCopyInputStream * Open(const std::string &filename)=0
static std::string CanonicalizePath(std::string path)
std::vector< Mapping > mappings_
std::string GetLastErrorMessage() override
bool FindFileByName(const std::string &filename, FileDescriptorProto *output) override
~SingleFileErrorCollector()
GLsizei const GLchar *const * string
void EnforceWeakDependencies(bool enforce)
std::string last_error_message_
virtual std::string GetLastErrorMessage()
SourceTreeDescriptorDatabase(SourceTree *source_tree)
io::ZeroCopyInputStream * OpenVirtualFile(const std::string &virtual_file, std::string *disk_file)
DiskFileToVirtualFileResult
GLuint GLint GLboolean GLint GLenum access
MockSourceTree source_tree_
ValidationErrorCollector(SourceTreeDescriptorDatabase *owner)
void AddWarning(const std::string &filename, const std::string &element_name, const Message *descriptor, ErrorLocation location, const std::string &message) override
Importer(SourceTree *source_tree, MultiFileErrorCollector *error_collector)
void AddError(int line, int column, const std::string &message) override
GLsizei const GLchar ** path
DiskFileToVirtualFileResult DiskFileToVirtualFile(const std::string &disk_file, std::string *virtual_file, std::string *shadowing_disk_file)
~SourceTreeDescriptorDatabase()
DescriptorPool::ErrorCollector * GetValidationErrorCollector()
void MapPath(const std::string &virtual_path, const std::string &disk_path)
bool FindFileContainingSymbol(const std::string &symbol_name, FileDescriptorProto *output) override
virtual void AddError(const std::string &filename, int line, int column, const std::string &message)=0
bool HasPrefixString(const string &str, const string &prefix)
const FileDescriptor * Import(const std::string &filename)
MockErrorCollector error_collector_
void AddError(const std::string &filename, const std::string &element_name, const Message *descriptor, ErrorLocation location, const std::string &message) override
void StringReplace(const string &s, const string &oldsub, const string &newsub, bool replace_all, string *res)
bool using_validation_error_collector_
MultiFileErrorCollector * multi_file_error_collector_
DescriptorDatabase * fallback_database_
std::vector< string > Split(const string &full, const char *delim, bool skip_empty=true)
static char LastChar(const std::string &str)
~ValidationErrorCollector()
static bool ApplyMapping(const std::string &filename, const std::string &old_prefix, const std::string &new_prefix, std::string *result)
io::ZeroCopyInputStream * OpenDiskFile(const std::string &filename)
void RecordErrorsTo(MultiFileErrorCollector *error_collector)
SourceTree * source_tree_
void AddUnusedImportTrackFile(const std::string &file_name)
bool HasSuffixString(const string &str, const string &suffix)
virtual bool FindFileByName(const std::string &filename, FileDescriptorProto *output)=0
virtual ~MultiFileErrorCollector()
void Join(Iterator start, Iterator end, const char *delim, string *result)
io::ZeroCopyInputStream * Open(const std::string &filename) override
void ClearUnusedImportTrackFiles()
const upb_json_parsermethod const upb_symtab upb_sink * output
SingleFileErrorCollector(const std::string &filename, MultiFileErrorCollector *multi_file_error_collector)
MultiFileErrorCollector * error_collector_
GLenum GLuint GLenum GLsizei const GLchar * message
bool VirtualFileToDiskFile(const std::string &virtual_file, std::string *disk_file)
void AddUnusedImportTrackFile(const std::string &file_name)
bool FindFileContainingExtension(const std::string &containing_type, int field_number, FileDescriptorProto *output) override
libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:54