1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
#include "ArguLine.hpp"
#include "General.hpp"
#include <sstream>
bool CArguLine::GetArgu(int argc,char** argv){
for(int i = 1; i <argc; i++){
if(strcmp(argv[i],"-typealgo")==0){
++i;
if(strcmp(argv[i],"Dyn")==0) GENERAL.typealgo = DYNAMIQUE;
else if(strcmp(argv[i],"Sta" )==0)GENERAL.typealgo = STATIC;
else {
std::cout << "ERROR: "<< argv[i] << "NON RECONNU" << std::endl;
std::cout << "-typealgo peut prendre Dyn ou Stat" << std::endl << std:: endl;
}
}
if(strcmp(argv[i],"-create")==0){
++i;
if(strcmp(argv[i],"uniform")==0)
GENERAL.create = UNIFORM;
else if(strcmp(argv[i],"toussain" )==0)
GENERAL.create = TOUSSAIN;
else {
std::cout << "ERROR: "<< argv[i] << "NON RECONNU" << std::endl;
std::cout << "-create Uniform ou Toussain" << std::endl << std:: endl;
}
}
else if(strcmp(argv[i],"-nline")==0)
GENERAL.nline = changeStringtoN(argv[++i]);
else if(strcmp(argv[i],"-nboucle")==0)
GENERAL.nboucle = changeStringtoN(argv[++i]);
else if(strcmp(argv[i],"-export")==0)
GENERAL.path = argv[++i];
else if(strcmp(argv[i],"-algo")==0){
++i;
if(strcmp(argv[i],"graham")==0)GENERAL.algo = GRAHAM;
else if(strcmp(argv[i],"jarvis" )==0)GENERAL.algo = JARVIS;
else if(strcmp(argv[i],"chan" )==0)GENERAL.algo = CHAN;
else {
std::cout << "ERROR: "<< argv[i] << "NON RECONNU" << std::endl;
std::cout << "-algo peut prendre graham,jarvis ou chan" << std::endl << std::endl;
}
}else if(strcmp(argv[i],"-time")==0)GENERAL.time = 1 ;
else if(strcmp(argv[i],"-help")==0){
GENERAL.help = 1 ;
printHelp();
}
}
return CheckArgu();
}
void CArguLine::printHelp(){
std::cout << std::cout << "-typealgo Dyn / Stat" << std::endl << std:: endl;
std::cout << std::cout << "-nline 100" << std::endl << std:: endl;
std::cout << std::cout << "-nboucle 100" << std::endl << std:: endl;
std::cout << std::cout << "-export data.txt" << std::endl << std:: endl;
std::cout << std::cout << "-algo graham/jarvis/chan" << std::endl << std:: endl;
std::cout << std::cout << "-create uniform/toussain" << std::endl << std:: endl;
std::cout << std::cout << "-time" << std::endl << std:: endl;
}
bool CArguLine::CheckArgu(){
if( GENERAL.typealgo == -1 || GENERAL.nline == -1 ||
GENERAL.nboucle == -1 || GENERAL.algo == -1 || GENERAL.create == -1 ){
printHelp();
return false;
}
if( GENERAL.path == "" ) GENERAL.path ="data.txt";
return true;
}
int CArguLine::changeStringtoN(const std::string& n)
{
std::istringstream iss( n );
int nombre;
iss >> nombre;
return nombre;
} |
Partager