Skip to content
Snippets Groups Projects
Commit e50e9415 authored by Stefano Di Frischia's avatar Stefano Di Frischia
Browse files

L2SS-711: align boolean function with Tango value function

parent f83ebea6
Branches
No related tags found
No related merge requests found
...@@ -323,6 +323,17 @@ public: ...@@ -323,6 +323,17 @@ public:
// testing only. Copy the str into a std::string so we can work // testing only. Copy the str into a std::string so we can work
// with it more easily. // with it more easily.
std::string in(str + 1, str + (strlen(str) - 1)); std::string in(str + 1, str + (strlen(str) - 1));
// count commas and add one to deduce elements in the string,
// note we reduce string size to remove the brace at each end
auto items = std::count(in.begin(), in.end(), ',');
value.clear();
// preallocate all the items in the vector, we can then
// simply set each in turn
value.resize(items + 1);
auto element = 0;
std::string::size_type comma = 0; std::string::size_type comma = 0;
// loop and copy out each value from between the separators // loop and copy out each value from between the separators
...@@ -349,8 +360,30 @@ public: ...@@ -349,8 +360,30 @@ public:
return {}; return {};
// simply use the pqxx utilities for this, rather than reinvent the wheel // simply use the pqxx utilities for this, rather than reinvent the wheel
if(value.dim_y < 2)
{
return "{" + separated_list(",", value.begin(), value.end()) + "}"; return "{" + separated_list(",", value.begin(), value.end()) + "}";
} }
// In case of image, unwrap the vector.
assert(value.dim_x != 0);
assert(value.dim_x * value.dim_y <= value.size());
std::stringstream result;
result << "{";
for(std::size_t i = 0; i != value.dim_y; ++i)
{
if (i > 0)
{
result << ",";
}
result << "{" << separated_list(",", std::next(value.begin(), i * value.dim_x), std::next(value.begin(), (i+1) * value.dim_x)) << "}";
}
result << "}";
return result.str();
}
}; };
// This specialisation is for bool, since it is not a normal container class, but // This specialisation is for bool, since it is not a normal container class, but
......
  • Maintainer

    This line (#352) now needs indenting 4 spaces. Rest looks ok (should, since it's the same as for the regular types and you tested it as well)

    Edited by Jan David Mol
  • Jan David Mol @mol

    mentioned in merge request tango!308 (merged)

    ·

    mentioned in merge request tango!308 (merged)

    Toggle commit list
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment