Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update protocol-buffer-matchers.cc to support protobuf 28.2 #1

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions protobuf-matchers/protocol-buffer-matchers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ class StringErrorCollector : public google::protobuf::io::ErrorCollector {
explicit StringErrorCollector(std::string* error_text)
: error_text_(error_text) {}

void AddError(int line, int column, const std::string& message) override {
void RecordError(int line, google::protobuf::io::ColumnNumber column,
const absl::string_view message) override {
std::ostringstream stream;
stream << line << '(' << column << "): " << message << std::endl;
*error_text_ += stream.str();
}

void AddWarning(int line, int column, const std::string& message) override {
void RecordWarning(int line, google::protobuf::io::ColumnNumber column,
const absl::string_view message) override {
std::ostringstream stream;
stream << line << '(' << column << "): " << message << std::endl;
*error_text_ += stream.str();
Expand Down Expand Up @@ -196,16 +198,14 @@ ParseFieldPathOrDie(const std::string& relative_field_path,
const std::regex field_subscript_regex(R"(([^.()[\]]+)\[(\d+)\])");
const std::regex extension_regex(R"(\(([^)]+)\))");


const auto begin = std::begin(relative_field_path);
auto it = begin;
const auto end = std::end(relative_field_path);
while (it != end) {
// Consume a dot, except on the first iteration.
if (it != std::begin(relative_field_path) && *(it++) != '.') {
GTEST_LOG_(FATAL) << "Cannot parse field path '" << relative_field_path
<< "' at offset "
<< std::distance(begin, it)
<< "' at offset " << std::distance(begin, it)
<< ": expected '.'";
}
// Try to consume a field name. If that fails, consume an extension name.
Expand Down Expand Up @@ -250,8 +250,7 @@ ParseFieldPathOrDie(const std::string& relative_field_path,
}
} else {
GTEST_LOG_(FATAL) << "Cannot parse field path '" << relative_field_path
<< "' at offset "
<< std::distance(begin, it)
<< "' at offset " << std::distance(begin, it)
<< ": expected field or extension";
}
auto consume = match_results[0].length();
Expand Down