blob: 8e35606581c209c4efa11e5f20a66983a77f050c (
plain)
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
93
94
95
96
97
98
|
#include"./OptionTab.h"
#include"./Option.h"
#include<exception>
#include<string>
#include<iostream>
/**
* Constructeur par défauts
* @method OptionTab::OptionTab
*/
OptionTab::OptionTab() : m_Tab(), m_nb_options(0) {}
/**
* Ajoute une option
* @method OptionTab::AddOption
* @param opt [description]
*/
void OptionTab::addOption(const Option &opt) {
if (m_nb_options == 10) {
std::cerr << "\033[0;31m ERROR [ "<< "Error when trying to create an option, to many options created" << " IN FILE " << __FILE__ << " AT LINE " << __LINE__ << " ] \n \033[0m";
std::terminate();
}
else {
m_Tab[m_nb_options] = opt;
m_nb_options++;
}
}
/**
* Affiche les options
* @method OptionTab::PrintOptions
*/
void OptionTab::printOptions() const {
for (size_t i = 0; i < m_nb_options; i++) {
std::cout << m_Tab[i] << '\n';
}
}
/**
* @method OptionTab::GetOptionID
* @param opt Nom de l'option
* @return ID de cette option
*/
int OptionTab::getOptionID(const std::string &opt) const{
int i = 0;
bool trouve = false;
while (i < 10 && trouve == false ) {
if (m_Tab[i].getOptionInt() == opt || m_Tab[i].getOptionRac() == opt) {
trouve = true;
}
i++;
}
return m_Tab[i-1].getOptionID();
}
/**
* @method OptionTab::GetArgument
* @param opt Nom de l'option
* @return Argument de cette option
*/
Type::TypeEnum OptionTab::getArgument(const std::string &opt) const {
int i = 0;
bool trouve = false;
while (i < 10 && trouve == false ) {
if (m_Tab[i].getOptionInt() == opt || m_Tab[i].getOptionRac() == opt ) {
trouve = true;
}
i++;
}
return m_Tab[i-1].getOptionType();
}
/**
* @method OptionTab::getRaccour
* @param opt Nom de l'option
* @return Raccourci de cette option
*/
std::string OptionTab::getRaccour(const std::string &opt) const {
int i = 0;
bool trouve = false;
while (i < 10 && trouve == false ) {
if (m_Tab[i].getOptionRac() == opt || m_Tab[i].getOptionInt() == opt ) {
trouve = true;
}
i++;
}
return m_Tab[i-1].getOptionRac();
}
/**
* @method OptionTab::getIntitul
* @param opt Nom de l'option
* @return Intitulé de cette option
*/
std::string OptionTab::getIntitul(const std::string &opt) const {
int i = 0;
bool trouve = false;
while (i < 10 && trouve == false ) {
if (m_Tab[i].getOptionInt() == opt || m_Tab[i].getOptionRac() == opt) {
trouve = true;
}
i++;
}
return m_Tab[i-1].getOptionInt();
}
|