Commit 0acd7941 authored by Johnny Jazeix's avatar Johnny Jazeix
Browse files

Ajout du makefile et de la compilation

parent 7ddc3b0a
......@@ -8,7 +8,7 @@ Color::Color(double r, double g, double b) {
bool Color::instantiate(const std::string &in, Color &out) {
double r, g, b;
if(sscanf(in, "%lf %lf %lf", &r, &g, &b) != 3)
if(sscanf(in.c_str(), "%lf %lf %lf", &r, &g, &b) != 3)
return false;
out = Color(r, g, b);
return true;
......
......@@ -10,6 +10,7 @@
*
*/
#include <sstream>
#include "value.hpp"
/*!
......
......@@ -7,10 +7,11 @@ Date::Date(double value){
bool Date::instantiate(const std::string &in, Date &out){
double value = 0.0;
if(sscanf(in, "%lf", &value) != 1){
if(sscanf(in.c_str(), "%lf", &value) != 1){
return false;
};
out = Date(value);
return true;
}
std::string Date::to_string() const{
......
......@@ -7,10 +7,11 @@ Double::Double(double value){
bool Double::instantiate(const std::string &in, Double &out){
double value = 0.0;
if(sscanf(in, "%lf", &value) != 1){
if(sscanf(in.c_str(), "%lf", &value) != 1){
return false;
};
out = Double(value);
return true;
}
std::string Double::to_string() const{
......
......@@ -6,15 +6,15 @@ Hex::Hex(int n) {
bool Hex::instantiate(const std::string &in, Hex &out) {
int n;
if(sscanf(in, "%X", &n) != 1)
if(sscanf(in.c_str(), "%X", &n) != 1)
return false;
out = Integer(n);
out = Hex(n);
return true;
}
std::string Hex::to_string() const {
std::ostringstream oss;
oss.flags(ios::hex);
oss.flags(std::ios::hex);
oss << _value;
return oss.str();
}
......@@ -11,6 +11,8 @@
*/
#include <sstream>
#include <iostream>
#include <fstream>
#include <cstdio>
#include "value.hpp"
......
......@@ -6,7 +6,7 @@ Integer::Integer(int n) {
bool Integer::instantiate(const std::string &in, Integer &out) {
int n;
if(sscanf(in, "%d", &n) != 1)
if(sscanf(in.c_str(), "%d", &n) != 1)
return false;
out = Integer(n);
return true;
......
LD = g++
OBJ = color.o date.o double.o hex.o integer.o name.o string.o
OPT = -g -Wall -W
LIBS =
all: $(OBJ)
$(OBJ):%.o: %.cpp %.hpp value.hpp
$(LD) -c $< $(OPT)
clean:
$(RM) *.o *.*~ makefile~
......@@ -13,7 +13,7 @@ Name::Name(name_only_t name_only, std::string name) {
_alias.clear();
}
Name::Name(alias_only_t, std::string alias) {
Name::Name(alias_only_t alias_only, std::string alias) {
_name.clear();
_alias = alias;
}
......@@ -26,5 +26,5 @@ std::string Name::to_string() const {
}
bool Name::operator== (String &s) const {
return _name == s || _alias == s;
return (s == _name || s == _alias);
}
......@@ -11,6 +11,7 @@
*/
#include <string>
/*!
*
* \class Value
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment