bool Reaction::filepkg_creation() { string nature_declaration = NATURE_DECLARATION; string alias_declaration = ALIAS_DECLARATION; string pattern_syst_path = "pattern_files\\" + pattern_pkg_file_name; ifstream r_file(pattern_syst_path.c_str(), ios::in); string path = "generated_files\\biological_systems_pkg.vhd"; ofstream w_file(path.c_str(), ios::out | ios::trunc); bool res = w_file; if(r_file && w_file) { string line; size_t found = string::npos; while(r_file) { getline(r_file, line); found = line.find(nature_declaration); if(found!=string::npos) { line.erase(found,nature_declaration.size()); line.insert(found,nature_declaration_fct()); } found = line.find(alias_declaration); if(found!=string::npos) { line.erase(found,alias_declaration.size()); line.insert(found,alias_declaration_fct()); } w_file << line << endl; } w_file.close(); r_file.close(); } else { cerr << "Impossible d'ouvrir le fichier !" << endl; } return res; }
bool Reaction::file_creation() { string entity_code = ENTITY_NAME; string port_code = PORT_DECLARATION; string equ_code = LOGICAL_EQUATION; string pattern_path = "pattern_files\\" + pattern_file_name; ifstream r_file(pattern_path.c_str(), ios::in); //file_name_user += ".vhd"; string path = "generated_files\\" + file_name_user + ".vhd"; ofstream w_file(path.c_str(), ios::out | ios::trunc); bool test = r_file; bool res = w_file; if(r_file && w_file) { string line; size_t found = string::npos; while(r_file) { getline(r_file, line); found = line.find(entity_code); if(found!=string::npos) { line.erase(found,entity_code.size()); line.insert(found,entity_name_user); } found = line.find(port_code); if(found!=string::npos) { line.erase(found,port_code.size()); line.insert(found,portmap()); } found = line.find(equ_code); if(found!=string::npos) { line.erase(found,equ_code.size()); line.insert(found,log_eq()); } w_file << line << endl; } w_file.close(); r_file.close(); } else { cerr << "Impossible d'ouvrir le fichier !" << endl; } return res; }
bool Reaction::filereact_creation() { string entity_name = ENTITY_NAME; string act_nature = ACT_NATURE; string rep_nature = REP_NATURE; string arnm_nature = ARNM_NATURE; string prot_nature = PROT_NATURE; string act_cell = ACT_CELL; string rep_cell = REP_CELL; string arnm_cell = ARNM_CELL; string prot_cell = PROT_CELL; string resistor_act_name = RESISTOR_ACT_NAME; string resistor_rep_name = RESISTOR_REP_NAME; string resistor_arnm_name = RESISTOR_ARNM_NAME; string capacitor_arnm_name = CAPACITOR_ARNM_NAME; string resistor_prot_name = RESISTOR_PROT_NAME; string capacitor_prot_name = CAPACITOR_PROT_NAME; string pattern_path = "pattern_files\\" + pattern_react_file_name; ifstream r_file(pattern_path.c_str(), ios::in); //file_name_user += ".vhd"; string path = "generated_files\\" + file_name_user + ".vhd"; ofstream w_file(path.c_str(), ios::out | ios::trunc); // bool test = r_file; bool res = w_file; if(r_file && w_file) { string line; size_t found = string::npos; while(r_file) { getline(r_file, line); found = line.find(entity_name); if(found!=string::npos) { line.erase(found,entity_name.size()); line.insert(found,entity_name_user); } found = line.find(act_nature); if(found!=string::npos) { line.erase(found,act_nature.size()); line.insert(found,Act_nature_fct()); } found = line.find(rep_nature); if(found!=string::npos) { line.erase(found,rep_nature.size()); line.insert(found,Rep_nature_fct()); } found = line.find(arnm_nature); if(found!=string::npos) { line.erase(found,arnm_nature.size()); line.insert(found,arnm_nature_fct()); } found = line.find(prot_nature); if(found!=string::npos) { line.erase(found,prot_nature.size()); line.insert(found,out_nature_fct()); } found = line.find(act_cell); if(found!=string::npos) { line.erase(found,act_cell.size()); line.insert(found,Act_cell_fct()); } found = line.find(rep_cell); if(found!=string::npos) { line.erase(found,rep_cell.size()); line.insert(found,Rep_cell_fct()); } found = line.find(arnm_cell); if(found!=string::npos) { line.erase(found,arnm_cell.size()); line.insert(found,arnm_cell_fct()); } found = line.find(prot_cell); if(found!=string::npos) { line.erase(found,prot_cell.size()); line.insert(found,out_cell_fct()); } found = line.find(resistor_act_name); if(found!=string::npos) { line.erase(found,resistor_act_name.size()); line.insert(found,Act_resistor_fct()); } found = line.find(resistor_rep_name); if(found!=string::npos) { line.erase(found,resistor_rep_name.size()); line.insert(found,Rep_resistor_fct()); } found = line.find(resistor_arnm_name); if(found!=string::npos) { line.erase(found,resistor_arnm_name.size()); line.insert(found,arnm_resistor_fct()); } found = line.find(capacitor_arnm_name); if(found!=string::npos) { line.erase(found,capacitor_arnm_name.size()); line.insert(found,arnm_capacitor_fct()); } found = line.find(resistor_prot_name); if(found!=string::npos) { line.erase(found,resistor_prot_name.size()); line.insert(found,out_resistor_fct()); } found = line.find(capacitor_prot_name); if(found!=string::npos) { line.erase(found,capacitor_prot_name.size()); line.insert(found,out_capacitor_fct()); } w_file << line << endl; } w_file.close(); r_file.close(); } else { cerr << "Impossible d'ouvrir le fichier !" << endl; } return res; }