summaryrefslogtreecommitdiff
path: root/Option/Type.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/Type.cpp
Initial commit
Diffstat (limited to 'Option/Type.cpp')
-rw-r--r--Option/Type.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/Option/Type.cpp b/Option/Type.cpp
new file mode 100644
index 0000000..3fa2052
--- /dev/null
+++ b/Option/Type.cpp
@@ -0,0 +1,63 @@
+#include"./Type.h"
+#include<iostream>
+#include<string>
+/**
+* Constructeur par défaut
+* @method Type::Type
+*/
+Type::Type() : m_type() {}
+
+/**
+* Constructeur avec arguments
+* @method Type::Type
+* @param type Nom du type
+*/
+Type::Type(Type::TypeEnum type) {
+ m_type = type;
+}
+
+/**
+ * Affiche dans le flux une chaine de caractére décrivant le type
+ * @method Type::print
+ * @param os Flux
+ */
+void Type::print(std::ostream& os) const {
+ switch (m_type) {
+ case NONE:
+ os << "NONE";
+ break;
+ case INT:
+ os << "ENTIER";
+ break;
+ case FLOAT:
+ os << "REEL";
+ break;
+ case STRING:
+ os << "STRING";
+ break;
+ default :
+ std::cerr << "\033[0;31m ERROR [ "<< "Can't recognize option type" << " IN FILE " << __FILE__ << " AT LINE " << __LINE__ << " ] \n \033[0m";
+ break;
+ };
+}
+
+/**
+* @method Type::setType
+* @param type Nouveau type
+*/
+void Type::setType(Type::TypeEnum type) {
+ m_type = type;
+}
+
+/**
+* @method Type::getType
+* @return Type
+*/
+Type::TypeEnum Type::getType() const {
+ return m_type;
+}
+
+std::ostream& operator<<(std::ostream& os, Type t){
+ t.print(os);
+ return os;
+}