Commit bb356348 authored by Arthur Redondy's avatar Arthur Redondy
Browse files

correction temporaire pour parser aussi les couleurs definies par des points virgules

parent 498a277c
......@@ -13,17 +13,23 @@ Color::Color(double r, double g, double b) {
_b = b;
}
bool Color::instantiate(const std::string &in, Color &out) {
bool Color::instantiate(std::string &in, Color &out) {
double r, g, b;
size_t position;
while((position = in.find(',')) != -1) {
std::string part1 = in.substr(0,position);
std::string part2 = in.substr(position+1);
in.assign(part1.append(".").append(part2));
}
if(sscanf(in.c_str(), "%lf %lf %lf", &r, &g, &b) != 3){
return false;
}
out = Color(r, g, b);
return true;
}
std::string Color::to_string() const {
std::ostringstream oss;
oss << _r << " " << _g << " " << _b;
return oss.str();
return oss.str();
}
......@@ -5,9 +5,9 @@
*
* \file Color.hpp
* \author Johnny Jazeix
* \brief
* \brief
* \date 2009 January 30th
*
*
*/
#include <sstream>
......@@ -17,7 +17,7 @@
*
* \class Color
* \brief Store a color in the trace
*
*
*/
class Color: public Value {
private :
......@@ -25,21 +25,21 @@ private :
double _g;
double _b;
public:
public:
/*!
*
* \brief Constructor
*
*
*/
Color();
/*!
*
* \brief Constructor
*
*
*/
Color(double, double, double);
/*!
*
* \fn instantiate(const std::string &in, Color &out)
......@@ -47,18 +47,18 @@ public:
* \param in String to convert
* \param out Color to be initialized
* \return true, if the conversion succeeded
*
*/
static bool instantiate(const std::string &in, Color &out);
*
*/
static bool instantiate(std::string &in, Color &out);
/*!
*
* \fn to_string() const
* \return a string of the color in the format "r g b".
*
*/
*
*/
std::string to_string() const;
};
......
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