Mise à jour terminée. Pour connaître les apports de la version 13.8.4 par rapport à notre ancienne version vous pouvez lire les "Release Notes" suivantes :
https://about.gitlab.com/releases/2021/02/11/security-release-gitlab-13-8-4-released/
https://about.gitlab.com/releases/2021/02/05/gitlab-13-8-3-released/

Commit 441f570d authored by Johnny Jazeix's avatar Johnny Jazeix

Ajout de corrections d'erreurs. Modif du doxyfile pour qu'il prenne en

compte le bon main. Ajout de la precision lors du to_string() des 
valeurs (avant ca tronquait mais la valeur stockee etait la bonne).
Ajout de la partie raccourcis dans le manuel user.
parent 83334493
......@@ -31,7 +31,7 @@ PROJECT_NAME = ViTE
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 1.0
PROJECT_NUMBER = 2.0
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
......@@ -513,7 +513,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
INPUT = src/interface/ src/message/ src/parser/ src/trace/ src/trace/values/ main.cpp main_resource.hpp tests/interface tests/message tests/parser tests/trace
INPUT = src/interface/ src/message/ src/parser/ src/trace/ src/trace/values/ src/main.cpp src/main_resource.hpp tests/interface tests/message tests/parser tests/trace
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
......
......@@ -84,9 +84,14 @@ bool Interface_console::draw_trace(const string & filename, Render_area* render_
ParserPaje parser;
DrawTrace<Render_area> drawing;
parser.parse(filename, trace);
try{
parser.parse(filename, trace);
}
catch (const string &error){
//message << "unable to parse " << filename << ende;
message << "Reason : " << error << ende;
return false;
}
drawing.build(render_area, &trace);
return true;
......
......@@ -18,80 +18,71 @@ const string Error::_EMPTY_DEF = "a definition line is empty";
const string Error::_INCOMPATIBLE_VALUE_IN_EVENT = "incompatible value : ";
const string Error::_UNKNOWN_TYPE_IN_EVENT = "unknown type : ";
const string Error::_UNKNOWN_EVENT_IN_PARSER_DEF_NOT_FOUND = "unknown field for the event. Should have been found on the definition parser : ";
const string Error::_UNKNOWN_LINE = "the content of the line is unknown, must quit";
const string Error::_BAD_FILE_EXTENSION = "the extension of the file is not .trace";
const string Error::_LINE_TOO_LONG_EVENT = "extra token(s)";
string Error::_content = "";
void Error::set_error(string kind_of_error, unsigned int line_number){
//_number_of_errors ++;
char line[10];
sprintf(line, "%d", line_number);
Error::_content = kind_of_error + " on line " + line;
Error::_errors.push(Error::_content);
void Error::set(const string kind_of_error, const int priority){
Error::_content = kind_of_error;
switch(priority){
case _WARNING:
Error::_warnings.push(Error::_content);
break;
default: // Include the _ERROR
Error::_errors.push(Error::_content);
break;
}
}
void Error::set_warning(string kind_of_error, unsigned int line_number){
//_number_of_warnings ++;
char line[10];
sprintf(line, "%d", line_number);
Error::_content = kind_of_error + " on line " + line;
Error::_warnings.push(Error::_content);
void Error::set_and_print(const string kind_of_error, const int priority){
set(kind_of_error, priority);
print(priority);
}
void Error::set_and_print_error(string kind_of_error, unsigned int line_number){
set_error(kind_of_error, line_number);
print_error();
void Error::set_and_print(const string kind_of_error, const unsigned int line_number, const int priority){
char line[10];
sprintf(line, "%d", line_number);
set(kind_of_error + " on line " + line, priority);
print(priority);
}
void Error::set_and_print_warning(string kind_of_error, unsigned int line_number){
set_warning(kind_of_error, line_number);
print_warning();
}
bool Error::set_error_if(bool condition, string kind_of_error, unsigned int line_number){
bool Error::set_if(bool condition, const string kind_of_error, const unsigned int line_number, const int priority){
if(condition){
set_error(kind_of_error, line_number);
char line[10];
sprintf(line, "%d", line_number);
set(kind_of_error + " on line " + line, priority);
return true;
}
return false;
}
bool Error::set_warning_if(bool condition, string kind_of_error, unsigned int line_number){
if(condition){
set_warning(kind_of_error, line_number);
return true;
}
return false;
}
void Error::print_error(){
message << _content << ende;
}
void Error::print_warning(){
message << _content << endw;
}
bool Error::set_and_print_error_if(bool condition, string kind_of_error, unsigned int line_number){
if(condition){
set_error(kind_of_error, line_number);
print_error();
return true;
void Error::print(const int priority){
message << _content ;
switch(priority){
case _WARNING:
message << endw;
break;
default: // Include the _ERROR
message << ende;
break;
}
return false;
}
bool Error::set_and_print_warning_if(bool condition, string kind_of_error, unsigned int line_number){
if(condition){
set_warning(kind_of_error, line_number);
print_warning();
bool Error::set_and_print_if(bool condition, const string kind_of_error, const unsigned int line_number, const int priority){
if(set_if(condition, kind_of_error, line_number, priority)){
print(priority);
return true;
}
return false;
}
void Error::print_numbers_of_warning_and_errors(){
message << "Your trace has " << Error::_errors.size() << " errors and " << Error::_warnings.size() << " warnings.";
void Error::print_numbers(){
message << "The trace has " << Error::_errors.size() << " errors and " << Error::_warnings.size() << " warnings.";
if(Error::_warnings.size() == 0 && Error::_errors.size() == 0){
message << endi;
}
......
......@@ -20,11 +20,19 @@ private:
static std::queue<std::string> _errors;
static std::queue<std::string> _warnings;
static unsigned int _number_of_warnings;
static unsigned int _number_of_errors;
static std::string _content;
public:
/*
* Priorities of errors
*/
const static int _ERROR = 1;
const static int _WARNING = 2;
/*
* Kind of errors known
*/
const static std::string _EXPECT_END_DEF;
const static std::string _EXPECT_EVENT_DEF;
const static std::string _EXPECT_NAME_DEF;
......@@ -37,25 +45,25 @@ public:
const static std::string _INCOMPATIBLE_VALUE_IN_EVENT;
const static std::string _UNKNOWN_TYPE_IN_EVENT;
const static std::string _UNKNOWN_EVENT_IN_PARSER_DEF_NOT_FOUND;
static void set_error(std::string kind_of_error, unsigned int line_number);
static void set_warning(std::string kind_of_error, unsigned int line_number);
const static std::string _UNKNOWN_LINE;
const static std::string _BAD_FILE_EXTENSION;
const static std::string _LINE_TOO_LONG_EVENT;
static void set_and_print_error(std::string kind_of_error, unsigned int line_number);
static void set_and_print_warning(std::string kind_of_error, unsigned int line_number);
static void set(const std::string kind_of_error, const int priority);
static void set_and_print(const std::string kind_of_error, const int priority);
static void set_and_print(const std::string kind_of_error, const unsigned int line_number, const int priority);
static void print_error();
static void print_warning();
static void print(const int priority);
static bool set_error_if(bool condition, std::string kind_of_error, unsigned int line_number);
static bool set_warning_if(bool condition, std::string kind_of_error, unsigned int line_number);
static bool set_if(bool condition, const std::string kind_of_error, const unsigned int line_number, const int priority);
static bool set_and_print_error_if(bool condition, std::string kind_of_error, unsigned int line_number);
static bool set_and_print_warning_if(bool condition, std::string kind_of_error, unsigned int line_number);
static bool set_and_print_if(bool condition, const std::string kind_of_error, const unsigned int line_number, const int priority);
static void print_numbers_of_warning_and_errors();
static void print_numbers();
static void flush_in_file(const std::string &filename);
};
......
......@@ -12,23 +12,24 @@ int ParserDefinitionDecoder::definitions_number(){
void ParserDefinitionDecoder::enter_definition(Line &line){
Error::set_and_print_error_if(_state == _IN_A_DEFINITION, Error::_EXPECT_EVENT_DEF, line.get_line_count());
Error::set_and_print_if(_state == _IN_A_DEFINITION, Error::_EXPECT_EVENT_DEF, line.get_line_count(), Error::_ERROR);
string definition_name;
Error::set_and_print_error_if(!line.item(2, definition_name), Error::_EXPECT_NAME_DEF, line.get_line_count());
Error::set_and_print_if(!line.item(2, definition_name), Error::_EXPECT_NAME_DEF, line.get_line_count(), Error::_ERROR);
//DIE_IF(!line.item(2, definition_name), "Error : a definition need a name");
unsigned int definition_identity;
string definition_identity_string;
if(Error::set_and_print_error_if(!line.item(3, definition_identity_string), Error::_EXPECT_ID_DEF, line.get_line_count())){
if(Error::set_and_print_if(!line.item(3, definition_identity_string),
Error::_EXPECT_ID_DEF, line.get_line_count(), Error::_ERROR)){
return;
}
//DIE_IF(!line.item(3, definition_identity_string), "Error : definition has no identifier");
if(Error::set_and_print_error_if(sscanf(definition_identity_string.c_str(), "%d", &definition_identity) != 1,
Error::_EXPECT_ID_DEF, line.get_line_count())){
if(Error::set_and_print_if(sscanf(definition_identity_string.c_str(), "%d", &definition_identity) != 1,
Error::_EXPECT_ID_DEF, line.get_line_count(), Error::_ERROR)){
return;
}
//DIE_IF(sscanf(definition_identity_string.c_str(), "%d", &definition_identity) != 1, "Error : expected identifier for a definition");
......@@ -37,7 +38,7 @@ void ParserDefinitionDecoder::enter_definition(Line &line){
_definitions.insert(pair<unsigned int,Definition>(definition_identity, current_definition));
_current_definition = definition_identity;
Error::set_and_print_warning_if(line.length() > 4, Error::_EXTRA_TOKEN_IN_DEF, line.get_line_count());
Error::set_and_print_if(line.length() > 4, Error::_EXTRA_TOKEN_IN_DEF, line.get_line_count(), Error::_WARNING);
//WARN_IF((line.length() > 4), Error::_EXPECT_EVENT_DEF + line_number);
//"Warning : extra token in %EventDef on line << line_number << endl");
......@@ -48,38 +49,41 @@ void ParserDefinitionDecoder::enter_definition(Line &line){
void ParserDefinitionDecoder::leave_definition(Line &line){
if(Error::set_and_print_error_if(_state != _IN_A_DEFINITION, Error::_EXPECT_EVENT_DEF, line.get_line_count())){
if(Error::set_and_print_if(_state != _IN_A_DEFINITION, Error::_EXPECT_EVENT_DEF, line.get_line_count(), Error::_ERROR)){
return;
}
// DIE_IF(_state != _IN_A_DEFINITION, "Error : expected %EventDef");
_state = _OUT_A_DEFINITION;
if(Error::set_and_print_error_if(!_definitions[_current_definition].check_definition(), Error::_UNKNOWN_EVENT + _definitions[_current_definition].get_event_name(), line.get_line_count())){
if(Error::set_and_print_if(!_definitions[_current_definition].check_definition(),
Error::_UNKNOWN_EVENT + _definitions[_current_definition].get_event_name(),
line.get_line_count(), Error::_ERROR)){
return;
}
//DIE_IF(!_definitions[_current_definition].check_definition(), "Error : unknown event : " + _definitions[_current_definition].get_event_name());
Error::set_and_print_warning_if(line.length() > 2, Error::_EXTRA_TOKEN_IN_DEF, line.get_line_count());
Error::set_and_print_if(line.length() > 2, Error::_EXTRA_TOKEN_IN_DEF, line.get_line_count(), Error::_WARNING);
//WARN_IF(line.length() > 2, "Warning : extra token in %EventDef");
}
void ParserDefinitionDecoder::add_field_to_definition(std::string& first_token,Line& line){
if(Error::set_and_print_error_if(_state == _OUT_A_DEFINITION, Error::_EXPECT_EVENT_DEF, line.get_line_count())){
if(Error::set_and_print_if(_state == _OUT_A_DEFINITION, Error::_EXPECT_EVENT_DEF, line.get_line_count(), Error::_ERROR)){
return;
}
//DIE_IF(_state == _OUT_A_DEFINITION, "Error : expected %EventDef");
string field_type;
if(Error::set_and_print_error_if(!line.item(2, field_type), Error::_FIELD_TYPE_MISSING, line.get_line_count())){
if(Error::set_and_print_if(!line.item(2, field_type), Error::_FIELD_TYPE_MISSING, line.get_line_count(), Error::_ERROR)){
return;
}
// DIE_IF(!line.item(2, field_type), "Error : a field type is missing");
if(Error::set_and_print_error_if(field_type != "string" && field_type != "int" &&
if(Error::set_and_print_if(field_type != "string" && field_type != "int" &&
field_type != "hex" && field_type != "date" &&
field_type != "double" && field_type != "color",
Error::_FIELD_TYPE_UNKNOWN, line.get_line_count())){
Error::_FIELD_TYPE_UNKNOWN, line.get_line_count(),
Error::_ERROR)){
return;
}
// DIE_IF(field_type != "string" && field_type != "int" &&
......@@ -93,7 +97,7 @@ void ParserDefinitionDecoder::add_field_to_definition(std::string& first_token,L
void ParserDefinitionDecoder::store_definition(Line &line){
string first_token;
if(Error::set_and_print_warning_if(!line.item(1, first_token), Error::_EMPTY_DEF, line.get_line_count())){
if(Error::set_and_print_if(!line.item(1, first_token), Error::_EMPTY_DEF, line.get_line_count(), Error::_WARNING)){
return;
}
//DIE_IF(!line.item(1, first_token), "Warning : a definition line is empty");
......
......@@ -35,8 +35,7 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
string current_value;
if (!line.item(i, current_value)) {
Error::set_and_print_warning(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value, line.get_line_count());
//message << "warning : missing values" << endl;
Error::set_and_print(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value, line.get_line_count(), Error::_WARNING);
return;
}
......@@ -68,8 +67,7 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
else if (fields[i-1]._name == "Time") {
if(!Date::instantiate(current_value, time)) {
Error::set_and_print_warning(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value, line.get_line_count());
//cerr << "warning : incompatible value : " << current_value << endl;
Error::set_and_print(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value, line.get_line_count(), Error::_WARNING);
return;
}
}
......@@ -85,8 +83,7 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
else if (fields[i-1]._name == "Value") {
if(fields[i-1]._type == "double") {
if(!Double::instantiate(current_value, value_double)) {
Error::set_and_print_warning(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value, line.get_line_count());
// cerr << "warning : incompatible value : " << current_value << endl;
Error::set_and_print(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value, line.get_line_count(), Error::_WARNING);
return;
}
}
......@@ -114,8 +111,7 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
else if(fields[i-1]._type == "double") {
Double value;
if(!Double::instantiate(current_value, value)) {
Error::set_and_print_warning(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value, line.get_line_count());
//cerr << "warning : incompatible value : " << current_value << endl;
Error::set_and_print(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value, line.get_line_count(), Error::_WARNING);
return;
}
extra_fields[fields[i-1]._name] = new Double(value);
......@@ -123,8 +119,7 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
else if(fields[i-1]._type == "hex") {
Hex value;
if(!Hex::instantiate(current_value, value)) {
Error::set_and_print_warning(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value, line.get_line_count());
//cerr << "warning : incompatible value : " << current_value << endl;
Error::set_and_print(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value, line.get_line_count(), Error::_WARNING);
return;
}
extra_fields[fields[i-1]._name] = new Hex(value);
......@@ -132,8 +127,7 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
else if(fields[i-1]._type == "date") {
Date value;
if(!Date::instantiate(current_value, value)) {
Error::set_and_print_warning(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value, line.get_line_count());
//cerr << "warning : incompatible value : " << current_value << endl;
Error::set_and_print(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value, line.get_line_count(), Error::_WARNING);
return;
}
extra_fields[fields[i-1]._name] = new Date(value);
......@@ -141,8 +135,7 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
else if(fields[i-1]._type == "int") {
Integer value;
if(!Integer::instantiate(current_value, value)) {
Error::set_and_print_warning(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value, line.get_line_count());
//cerr << "warning : incompatible value : " << current_value << endl;
Error::set_and_print(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value, line.get_line_count(), Error::_WARNING);
return;
}
extra_fields[fields[i-1]._name] = new Integer(value);
......@@ -150,15 +143,13 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
else if(fields[i-1]._type == "color") {
Color value;
if(!Color::instantiate(current_value, value)) {
Error::set_and_print_warning(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value, line.get_line_count());
//cerr << "warning : incompatible value : " << current_value << endl;
Error::set_and_print(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value, line.get_line_count(), Error::_WARNING);
return;
}
extra_fields[fields[i-1]._name] = new Color(value);
}
else {
Error::set_and_print_warning(Error::_UNKNOWN_TYPE_IN_EVENT + current_value, line.get_line_count());
//cerr << "warning : unknown type" << endl;
Error::set_and_print(Error::_UNKNOWN_TYPE_IN_EVENT + current_value, line.get_line_count(), Error::_WARNING);
return;
}
}
......@@ -167,7 +158,7 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
}
if(line.length() > i+1) {
cerr << "warning : extra value(s)" << endl;
Error::set_and_print(Error::_LINE_TOO_LONG_EVENT, line.get_line_count(), Error::_WARNING);
}
Name alias_name;
......@@ -251,8 +242,7 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
}
else {
Error::set_and_print_warning(Error::_UNKNOWN_EVENT_IN_PARSER_DEF_NOT_FOUND + event_name, line.get_line_count());
//cerr << "BUG PARSER BIS" << endl;
Error::set_and_print(Error::_UNKNOWN_EVENT_IN_PARSER_DEF_NOT_FOUND + event_name, line.get_line_count(), Error::_WARNING);
return;
}
}
......
......@@ -4,6 +4,14 @@ using namespace std;
void ParserPaje::parse(string filename, Trace &trace){
// If the file must have the extension .trace
//
const unsigned int position_of_dot = filename.find_last_of('.');
if(position_of_dot == string::npos || filename.substr(position_of_dot) != ".trace"){
Error::set_and_print(Error::_BAD_FILE_EXTENSION, Error::_WARNING);
//throw Error::_BAD_FILE_EXTENSION;
}
ParserDefinitionDecoder *parserdefinition = new ParserDefinitionDecoder();
ParserEventDecoder *parserevent = new ParserEventDecoder();
......@@ -14,31 +22,32 @@ void ParserPaje::parse(string filename, Trace &trace){
unsigned int event_identity;
while(!line.is_eof()){
line.newline();
if(line.starts_with(PERCENT)){
parserdefinition->store_definition(line);
parserdefinition->store_definition(line);
}
else if (!line.item(0, event_identity_string)){
continue; // We have \n
}
else{
if(Error::set_and_print_error_if (sscanf(event_identity_string.c_str(), "%d", &event_identity) != 1,
Error::_EXPECT_ID_DEF, line.get_line_count())){
return;
}
// DIE_IF(sscanf(event_identity_string.c_str(), "%d", &event_identity) != 1, "expected identifier for a definition");
parserevent->store_event(
parserdefinition->get_definition(event_identity),
// We check if we have an event identifier
if(Error::set_and_print_if (sscanf(event_identity_string.c_str(), "%d", &event_identity) != 1,
Error::_EXPECT_ID_DEF, line.get_line_count(), Error::_ERROR)){
// The line can not be recognised by the parser Paje, we can not continue.
throw Error::_UNKNOWN_LINE;
//return ;
}
parserevent->store_event(parserdefinition->get_definition(event_identity),
line,
trace);
}
}
// We print the warnings
Error::print_numbers_of_warning_and_errors();
// We print the warnings and errors
Error::print_numbers();
Error::flush_in_file("log.txt");
delete parserdefinition;
......
#include "Color.hpp"
Color::Color() {
_r = 0;
_g = 0;
_b = 0;
}
Color::Color(double r, double g, double b) {
_r = r;
_g = g;
_b = b;
}
bool Color::instantiate(std::string &in, Color &out) {
double r, g, b;
if(sscanf(in.c_str(), "%lf %lf %lf", &r, &g, &b) == 3){
out = Color(r, g, b);
return true;
}
// The error could occur because this is not the good format for decimal.
// Dots instead of commas or the contrary
bool commas_first = false;
if(replace_in_string(in, ',', '.')){
commas_first = true;
}
if(!commas_first){ // We had dots initially, we need to change them in commas
replace_in_string(in, '.', ',');
}
if(sscanf(in.c_str(), "%lf %lf %lf", &r, &g, &b) != 3){
return false;
}
else{
out = Color(r, g, b);
return true;
}
}
std::string Color::to_string() const {
std::ostringstream oss;
oss << _r << " " << _g << " " << _b;
return oss.str();
}
bool Color::replace_in_string(std::string &characters, char to_replace, char replace_by) {
size_t position;
bool has_change = false;
while((position = characters.find(to_replace)) != std::string::npos) { // We had commas
std::string part1 = characters.substr(0, position);
std::string part2 = characters.substr(position+1);
characters = part1 + replace_by + part2;
has_change = true;
}
return has_change;
#include "Color.hpp"
Color::Color() {
_r = 0;
_g = 0;
_b = 0;
}
Color::Color(double r, double g, double b) {
_r = r;
_g = g;
_b = b;
}
bool Color::instantiate(std::string &in, Color &out) {
double r, g, b;
if(sscanf(in.c_str(), "%lf %lf %lf", &r, &g, &b) == 3){
out = Color(r, g, b);
return true;
}
// The error could occur because this is not the good format for decimal.
// Dots instead of commas or the contrary
bool commas_first = false;
if(replace_in_string(in, ',', '.')){
commas_first = true;
}
if(!commas_first){ // We had dots initially, we need to change them in commas
replace_in_string(in, '.', ',');
}
if(sscanf(in.c_str(), "%lf %lf %lf", &r, &g, &b) != 3){
return false;
}
else{
out = Color(r, g, b);
return true;
}
}
std::string Color::to_string() const {
std::ostringstream oss;
oss << std::setprecision(Value::_PRECISION) << _r << " " << _g << " " << _b;
return oss.str();
}
bool Color::replace_in_string(std::string &characters, char to_replace, char replace_by) {
bool has_change = false;