Commit a90ffaef authored by Arthur Redondy's avatar Arthur Redondy
Browse files

version plus complete du parser d evenement mais pas encore termine

parent c1b05c3a
#include "ParserEventDecoder.hpp"
#include "ParserEventDecoder.hpp"
//#define INSTANCIATE(nom_de_champPaje,type,nom_variable,nom_variable_is_initialized) if (fields[i-1].name == nom_de_champPaje) { \
// if(!String::instanciate(current_value, nom_variable)) { \
......@@ -59,6 +59,8 @@ void ParserEventDecoder::store_event(const Definition &definition,Line &line, Tr
String key;
bool key_is_initialized = false;
vector<Value> extra_fields;
int i=1;
vector<field> fields = definition.get_fields();
int number_of_values = fields.size();
......@@ -71,7 +73,7 @@ void ParserEventDecoder::store_event(const Definition &definition,Line &line, Tr
return;
}
if (fields[i-1]._name == "Alias") {
else if (fields[i-1]._name == "Alias") {
if(alias = current_value) {
cout << "warning : incompatible value" << endl;
return;
......@@ -79,7 +81,7 @@ void ParserEventDecoder::store_event(const Definition &definition,Line &line, Tr
alias_is_initialized = true;
}
if (fields[i-1]._name == "Name") {
else if (fields[i-1]._name == "Name") {
if(name = current_value) {
cout << "warning : incompatible value" << endl;
return;
......@@ -87,7 +89,7 @@ void ParserEventDecoder::store_event(const Definition &definition,Line &line, Tr
name_is_initialized = true;
}
if (fields[i-1]._name == "ContainerType") {
else if (fields[i-1]._name == "ContainerType") {
if(container_type = current_value) {
cout << "warning : incompatible value" << endl;
return;
......@@ -95,12 +97,158 @@ void ParserEventDecoder::store_event(const Definition &definition,Line &line, Tr
container_type_is_initialized = true;
}
else if (fields[i-1]._name == "SourceContainerType") {
if(source_container_type = current_value) {
cout << "warning : incompatible value" << endl;
return;
}
source_container_type_is_initialized = true;
}
else if (fields[i-1]._name == "DestContainerType") {
if(dest_container_type = current_value) {
cout << "warning : incompatible value" << endl;
return;
}
dest_container_type_is_initialized = true;
}
else if (fields[i-1]._name == "EntityType") {
if(entity_type = current_value) {
cout << "warning : incompatible value" << endl;
return;
}
entity_type_is_initialized = true;
}
else if (fields[i-1]._name == "Time") {
if(!instantiate(current_value, time_type) {
cout << "warning : incompatible value" << endl;
return;
}
time_type_is_initialized = true;
}
else if (fields[i-1]._name == "Type") {
if(type = current_value) {
cout << "warning : incompatible value" << endl;
return;
}
type_is_initialized = true;
}
else if (fields[i-1]._name == "Container") {
if(container = current_value) {
cout << "warning : incompatible value" << endl;
return;
}
container_is_initialized = true;
}
else if (fields[i-1]._name == "Value") {
if(fields[i-1]._type == "double") {
if(!instantiate(current_value, value_double) {
cout << "warning : incompatible value" << endl;
return;
}
value_double_is_initialized = true;
}
else {
if(value_string = current_value) {
cout << "warning : incompatible value" << endl;
return;
}
value_string_is_initialized = true;
}
}
else if (fields[i-1]._name == "SourceContainer") {
if(source_container = current_value) {
cout << "warning : incompatible value" << endl;
return;
}
source_container_is_initialized = true;
}
else if (fields[i-1]._name == "DestContainer") {
if(dest_container = current_value) {
cout << "warning : incompatible value" << endl;
return;
}
dest_container_is_initialized = true;
}
else if (fields[i-1]._name == "Key") {
if(key = current_value) {
cout << "warning : incompatible value" << endl;
return;
}
key_is_initialized = true;
}
else {
if(fields[i-1]._type == "string") {
String value;
if(value = current_value) {
cout << "warning : incompatible value" << endl;
return;
}
extra_fields.push_back(value)
}
else if(fields[i-1]._type == "double") {
Double value;
if(!instantiate(current_value, value) {
cout << "warning : incompatible value" << endl;
return;
}
extra_fields.push_back(value)
}
else if(fields[i-1]._type == "hex") {
Hex value;
if(!instantiate(current_value, value) {
cout << "warning : incompatible value" << endl;
return;
}
extra_fields.push_back(value)
}
else if(fields[i-1]._type == "date") {
Date value;
if(!instantiate(current_value, value) {
cout << "warning : incompatible value" << endl;
return;
}
extra_fields.push_back(value)
}
else if(fields[i-1]._type == "integer") {
Integer value;
if(!instantiate(current_value, value) {
cout << "warning : incompatible value" << endl;
return;
}
extra_fields.push_back(value)
}
else if(fields[i-1]._type == "color") {
Color value;
if(!instantiate(current_value, value) {
cout << "warning : incompatible value" << endl;
return;
}
extra_fields.push_back(value)
}
else {
cout << "warning : unknown type" << endl;
return;
}
}
i++;
}
if(line.length() > i) {
cout << "warning : extra value(s)" << endl;
}
\\A faire : remplir un "Name alias_name" avec alias et name
string event_name = definition.get_event_name();
......@@ -113,5 +261,62 @@ void ParserEventDecoder::store_event(const Definition &definition,Line &line, Tr
return;
}
}
else if(event_name == "PajeCreateContainer") {
if(time_is_initialized&&alias_name_is_initialized&&type_is_initialized&&container_is_initialized) {
trace.create_container(time, alias_name, type, container);
}
else {
cout << "warning : incompatible evenement" << endl;
return;
}
}
else if(event_name == "PajeDestroyContainer") {
if(time_is_initialized&&alias_name_is_initialized&&type_is_initialized) {
trace.destroy_container(time, alias_name, type);
}
else {
cout << "warning : incompatible evenement" << endl;
return;
}
}
else if(event_name == "PajeDefineEventType") {
if(alias_name_is_initialized&&container_type_is_initialized) {
trace.define_event_type(alias_name, container_type);
}
else {
cout << "warning : incompatible evenement" << endl;
return;
}
}
else if(event_name == "PajeDefineStateType") {
if(alias_name_is_initialized&&container_type_is_initialized) {
trace.define_state_type(alias_name, container_type);
}
else {
cout << "warning : incompatible evenement" << endl;
return;
}
}
else if(event_name == "PajeDefineVariableType") {
if(alias_name_is_initialized&&container_type_is_initialized) {
trace.define_variable_type(alias_name, container_type);
}
else {
cout << "warning : incompatible evenement" << endl;
return;
}
}
\\A faire : encore des type d'evenement a definir + chercher les parents et types des parents quand il le faut
else {
cout << "warning : unknown evenement" << endl;
return;
}
}
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