[Assembler] Add toString() method for Errors
MODIFY
src/assembler/assemblererror.h
src/assembler/assemblererror.h
#pragma once
#include <QString>
+#include <QTextStream>
#include <iostream>
#include <map>
#include <vector>
@@ -13,10 +14,17 @@ using Error = std::pair<unsigned, QString>;
class Errors : public std::vector<Error> {
public:
void print() const {
+ std::cout << toString().toStdString();
+ std::cout << std::flush;
+ }
+
+ QString toString() const {
+ QString str;
+ auto strStream = QTextStream(&str);
for (const auto& iter : *this) {
- std::cout << "line " << iter.first << ": " << iter.second.toStdString() << "\n";
+ strStream << "line " << iter.first << ": " << iter.second << "\n";
}
- std::cout << std::flush;
+ return str;
}
/**

[Assembler] Add toString() method for Errors