Commit 1f02df15 authored by Johnny Jazeix's avatar Johnny Jazeix

Ajout des erreurs par l'interface console.

parent 0f2ac4fd
......@@ -41,7 +41,10 @@ class Interface{
*/
virtual void information(const std::string) const =0;
/*!
\brief Return the name of the file opened.
*/
virtual const std::string get_filename() const = 0;
};
#endif
......@@ -344,3 +344,7 @@ void Interface_console::warning(const string s) const{
void Interface_console::information(const string s) const{
cerr << s <<endl;
}
const string Interface_console::get_filename() const{
return _file_opened;
}
......@@ -197,6 +197,12 @@ protected:
int run();
/*!
* \brief Get the name of the current trace file.
*
*/
const std::string get_filename() const;
/***********************************
*
......
......@@ -117,21 +117,21 @@ void Interface_graphic::load_windows(){
void Interface_graphic::error(const string s) const{
QString buf = s.c_str();
//_ui_info_trace_text->moveCursor(QTextCursor::Start);/* Insert the new text on the beginning */
_ui_info_trace_text->moveCursor(QTextCursor::End);/* Insert the new text on the beginning */
_ui_info_trace_text->insertHtml("<font color='red'>"+buf+"</font><br /><br />");
}
void Interface_graphic::warning(const string s) const{
QString buf = s.c_str();
//_ui_info_trace_text->moveCursor(QTextCursor::Start);/* Insert the new text on the beginning */
_ui_info_trace_text->moveCursor(QTextCursor::End);/* Insert the new text on the beginning */
_ui_info_trace_text->insertHtml("<font color='orange'>"+buf+"</font><br /><br />");
}
void Interface_graphic::information(const string s) const{
QString buf = s.c_str();
//_ui_info_trace_text->moveCursor(QTextCursor::Start);/* Insert the new text on the beginning */
_ui_info_trace_text->moveCursor(QTextCursor::End);/* Insert the new text on the beginning */
_ui_info_trace_text->insertHtml("<font color='green'>"+buf+"</font><br /><br />");
}
......@@ -359,3 +359,7 @@ void Interface_graphic::on_main_window_hide(){
cerr << "GoodBye"<<endl;
}
const std::string Interface_graphic::get_filename() const{
return _trace_path;
}
......@@ -191,6 +191,12 @@ public:
void information(const std::string) const;
/*!
* \brief Get the name of the current trace file.
*
*/
const std::string get_filename() const;
......
......@@ -91,15 +91,24 @@ bool Error::set_and_print_warning_if(bool condition, string kind_of_error, unsig
void Error::print_numbers_of_warning_and_errors(){
message << "Your trace has " << Error::_errors.size() << " errors and " << Error::_warnings.size() << " warnings." << endi;
message << "Your trace has " << Error::_errors.size() << " errors and " << Error::_warnings.size() << " warnings.";
if(Error::_warnings.size() == 0 && Error::_errors.size() == 0){
message << endi;
}
else if(Error::_errors.size() == 0){
message << endw;
}
else{
message << ende;
}
}
void Error::flush_in_file(const string &filename){
if(_errors.empty() && _warnings.empty()){
if(_errors.empty() && _warnings.empty()) {
return;
}
else{
else {
ofstream outfile(filename.c_str(), ios::out | ios::trunc);
const int number_of_errors = Error::_errors.size();
......@@ -110,9 +119,12 @@ void Error::flush_in_file(const string &filename){
return;
}
else{
outfile << "File " << filename << endl << endl;
outfile << "Errors :" << endl;
outfile << "File " << Message::get_interface_instance()->get_filename() << endl << endl;
if(!_errors.empty()){
outfile << "Errors :" << endl;
}
// Print the errors
while(!_errors.empty()){
outfile << _errors.front() << endl;
......@@ -120,7 +132,9 @@ void Error::flush_in_file(const string &filename){
}
// Print the warnings
outfile << endl << "Warnings :" << endl;
if(!_warnings.empty()){
outfile << endl << "Warnings :" << endl;
}
while(!_warnings.empty()){
outfile << _warnings.front() << endl;
_warnings.pop();
......
......@@ -11,6 +11,7 @@
#include <iostream>
#include <fstream>
#include "../message/message_ns.hpp"
#include "../interface/interface_graphic.hpp"
class Error{
private:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment