summaryrefslogtreecommitdiff
path: root/Option/OptionTab.cpp
diff options
context:
space:
mode:
authorGaspard Coulet <gaspard.coulet@mines-ales.org>2021-04-28 23:12:36 +0200
committerGaspard Coulet <gaspard.coulet@mines-ales.org>2021-04-28 23:12:36 +0200
commitb4c345e6a5fa929ba20eac19183b9c777055f52d (patch)
tree23a0232f2526c5ab7f53391609a8a0a5960865f0 /Option/OptionTab.cpp
Initial commit
Diffstat (limited to 'Option/OptionTab.cpp')
-rw-r--r--Option/OptionTab.cpp98
1 files changed, 98 insertions, 0 deletions
diff --git a/Option/OptionTab.cpp b/Option/OptionTab.cpp
new file mode 100644
index 0000000..8e35606
--- /dev/null
+++ b/Option/OptionTab.cpp
@@ -0,0 +1,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();
+}