Commit 39d7ebde authored by Arthur Redondy's avatar Arthur Redondy
Browse files

debut du code du parser d evenements

parent e03944e5
......@@ -2,10 +2,78 @@
ParserEventDecoder::ParserEventDecoder(){
}
//void ParserEventDecoder::sort_definition(Definition& d,Line& line){
void ParserEventDecoder::store_event(const Definition &definition,Line &line, Trace &trace){
String alias;
bool alias_is_initialized;
String name;
bool name_is_initialized;
String container_type;
bool container_type_is_initialized;
String source_container_type;
bool source_container_type_is_initialized;
String dest_container_type;
bool dest_container_type_is_initialized;
String entity_type;
bool entity_type_is_initialized;
Date time;
bool time_is_initialized;
String type;
bool type_is_initialized;
String container;
bool container_is_initialized;
String value_string;
bool value_string_is_initialized;
Double value_double;
bool value_double_is_initialized;
String source_container;
bool source_container_is_initialized;
String dest_container;
bool dest_container_is_initialized;
String key;
bool key_is_initialized;
int i=1;
vector<field> fields = definition.get_fields();
int number_of_values fields.size();
while(i < number_of_values) {
string current_value;
if (!line.item(i,current_value)) {
cout << "warning : missing values" << endl;
return;
}
if (fields[i-1].name == "Alias") {
if((fields[i-1].type != "string") || (fields[i-1].type != "integer")) {
cout << "warning : type not suitable" << endl;
return;
}
if(!Date::instanciate(current_value, alias)) {
cout << "warning : incompatible value" << endl;
return;
}
}
i++;
}
}
//}
......@@ -27,8 +27,7 @@ private:
public:
ParserEventDecoder();
void store_event(Definition &, Line &// , Trace &
);
void store_event(const Definition &, Line &, Trace &);
......
#algorithme pour convertion
convertir(String type, String valeur) : Type
{
if (type=="int")
return new Integer(valeur)
else if (type=="String")
return new Str(valeur)
else if (type=="Color")
return new Color(valeur)
}
#algorithme pour EventParser
E : Hash des evenements (constuit dans le parserDef), ligne
S : Trace
Event & e = Hash(atoi(liretoken(ligne)))
if (e.name = "PajedefineContainer" )
{
int i = 0;
String token;
Map facultatif<int, Type>;
while (token = liretoken(ligne))
{
String typeattendu = e.vector[i].type;
String champattendu = e.vector[i].champ;
i++;
if (champattendu=="name")
{
String parametre1 = token;
}
else if (champattendu=="couleur")
{
Couleur parametre2(typeattendu,token);
}
else //facultatif
{
facultatif += convertir(typeattendu,token);
}
}
trace.storePajedefineContainer(parametre1,parametre2,facultatif);
}
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