Skip to content

Commit

Permalink
Use RecordError and RecordWarning
Browse files Browse the repository at this point in the history
AddError and AddWarning have been deprecated: protocolbuffers/protobuf@543fbcd.

Instead RecordError and RecordWarning shall be used.
  • Loading branch information
joajfreitas committed Sep 23, 2024
1 parent f4f9d41 commit bd832c0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
33 changes: 17 additions & 16 deletions plotjuggler_plugins/ParserProtobuf/error_collectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,39 @@
#include <QMessageBox>
#include <QDebug>

void FileErrorCollector::AddError(const std::string& filename, int line, int,
const std::string& message)
void FileErrorCollector::RecordError(const absl::string_view filename, int line, int,
const absl::string_view message)
{
auto msg = QString("File: [%1] Line: [%2] Message: %3\n\n")
.arg(QString::fromStdString(filename))
.arg(QString::fromStdString(std::string{filename}))
.arg(line)
.arg(QString::fromStdString(message));
.arg(QString::fromStdString(std::string{message}));

_errors.push_back(msg);
}

void FileErrorCollector::AddWarning(const std::string& filename, int line, int,
const std::string& message)
void FileErrorCollector::RecordWarning(const absl::string_view filename, int line, int,
const absl::string_view message)
{
auto msg = QString("Warning [%1] line %2: %3")
.arg(QString::fromStdString(filename))
.arg(QString::fromStdString(std::string{filename}))
.arg(line)
.arg(QString::fromStdString(message));
.arg(QString::fromStdString(std::string{message}));
qDebug() << msg;
}

void IoErrorCollector::AddError(int line, google::protobuf::io::ColumnNumber,
const std::string& message)
void IoErrorCollector::RecordError(int line, google::protobuf::io::ColumnNumber,
const absl::string_view message)
{
_errors.push_back(
QString("Line: [%1] Message: %2\n").arg(line).arg(QString::fromStdString(message)));
_errors.push_back(QString("Line: [%1] Message: %2\n")
.arg(line)
.arg(QString::fromStdString(std::string{message})));
}

void IoErrorCollector::AddWarning(int line, google::protobuf::io::ColumnNumber column,
const std::string& message)
void IoErrorCollector::RecordWarning(int line, google::protobuf::io::ColumnNumber column,
const absl::string_view message)
{
qDebug() << QString("Line: [%1] Message: %2\n")
.arg(line)
.arg(QString::fromStdString(message));
.arg(line)
.arg(QString::fromStdString(std::string{message}));
}
18 changes: 10 additions & 8 deletions plotjuggler_plugins/ParserProtobuf/error_collectors.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@

#include <QStringList>

#include "absl/strings/string_view.h"

class IoErrorCollector : public google::protobuf::io::ErrorCollector
{
public:
void AddError(int line, google::protobuf::io::ColumnNumber column,
const std::string& message) override;
void RecordError(int line, google::protobuf::io::ColumnNumber column,
const absl::string_view message) override;

void AddWarning(int line, google::protobuf::io::ColumnNumber column,
const std::string& message) override;
void RecordWarning(int line, google::protobuf::io::ColumnNumber column,
const absl::string_view message) override;

const QStringList& errors()
{
Expand All @@ -27,11 +29,11 @@ class IoErrorCollector : public google::protobuf::io::ErrorCollector
class FileErrorCollector : public google::protobuf::compiler::MultiFileErrorCollector
{
public:
void AddError(const std::string& filename, int line, int,
const std::string& message) override;
void RecordError(const absl::string_view filename, int line, int,
const absl::string_view message) override;

void AddWarning(const std::string& filename, int line, int,
const std::string& message) override;
void RecordWarning(const absl::string_view filename, int line, int,
const absl::string_view message) override;

const QStringList& errors()
{
Expand Down

0 comments on commit bd832c0

Please sign in to comment.