Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 13 additions & 31 deletions IPL/src/IPLProcessProperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,45 +183,27 @@ inline void deserializeValue(const std::string &data, std::vector<double> &value

inline void deserializeValue(const std::string &data, IPLColor &value)
{
std::array<float,3> color;

int i = 0;
std::smatch match;
auto pos = data.begin();
while(i < (int) color.size() && std::regex_search(pos,data.end(),match,std::regex("[-0-9.]")))
{
pos += match.position();

int charsParsed = 0;
float element = 0;
if (sscanf(&(*pos),"%f%n",&element,&charsParsed) > 0)
color[i++] = element;

pos += charsParsed;
std::regex e ("\\[([-0-9.eE]+),([-0-9.eE]+),([-0-9.eE]+)\\]");
if (!std::regex_search(data, match, e) || match.size() - 1 != 3) {
value = IPLColor(0, 0, 0);
return;
}
value = IPLColor(color[0], color[1], color[2]);
value = IPLColor(std::stof(match.str(1)),
std::stof(match.str(2)),
std::stof(match.str(3)));
}

inline void deserializeValue(const std::string &data, IPLPoint &value)
{
std::array<double,2> point;

int i = 0;
std::smatch match;
auto pos = data.begin();
while(i < (int) point.size() && std::regex_search(pos,data.end(),match,std::regex("[-0-9.]")))
{
pos += match.position();

int charsParsed = 0;
float element = 0;
if (sscanf(&(*pos),"%f%n",&element,&charsParsed) > 0)
point[i++] = element;

pos += charsParsed;
std::regex e ("\\[([-0-9.eE]+),([-0-9.eE]+)\\]");
if (!std::regex_search(data, match, e) || match.size() - 1 != 2) {
value = IPLPoint(0, 0, 0);
return;
}

value = IPLPoint(point[0], point[1]);
value = IPLPoint(std::stod(match.str(1)),
std::stod(match.str(2)));
}

inline void deserializeValue(const std::string &data, std::string &value)
Expand Down