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 8d9495a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 29 deletions.
39 changes: 20 additions & 19 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(line)
.arg(QString::fromStdString(message));
.arg(QString::fromStdString(std::string{filename}))
.arg(line)
.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(line)
.arg(QString::fromStdString(message));
.arg(QString::fromStdString(std::string{filename}))
.arg(line)
.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));
qDebug() << QString("Line: [%1] Message: %2\n")
.arg(line)
.arg(QString::fromStdString(std::string{message}));
}
26 changes: 16 additions & 10 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>

class IoErrorCollector : public google::protobuf::io::ErrorCollector
#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 @@ -24,14 +26,14 @@ class IoErrorCollector : public google::protobuf::io::ErrorCollector
QStringList _errors;
};

class FileErrorCollector : public google::protobuf::compiler::MultiFileErrorCollector
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 All @@ -42,4 +44,8 @@ class FileErrorCollector : public google::protobuf::compiler::MultiFileErrorColl
QStringList _errors;
};

<<<<<<< HEAD
#endif // ERROR_COLLECTORS_H
=======
#endif // ERROR_COLLECTORS_H
>>>>>>> 93616d01 (Use RecordError and RecordWarning)

0 comments on commit 8d9495a

Please sign in to comment.