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

Use RecordError and RecordWarning #1012

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
31 changes: 16 additions & 15 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(QString::fromStdString(std::string{ message }));
}
16 changes: 8 additions & 8 deletions plotjuggler_plugins/ParserProtobuf/error_collectors.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
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 +27,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
Loading