Commit ebf18210 authored by Valerio Bertone's avatar Valerio Bertone
Browse files

introducing vectors of doubles as possible parameters

parent 2da06cf3
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <cstddef> #include <cstddef>
#include <vector>
namespace ElemUtils { namespace ElemUtils {
...@@ -86,6 +87,8 @@ public: ...@@ -86,6 +87,8 @@ public:
size_t toSize_t() const; size_t toSize_t() const;
std::vector<double> toVectorDouble() const;
/** /**
* Convert stream to string * Convert stream to string
* @return std::string * @return std::string
......
...@@ -86,6 +86,27 @@ unsigned short GenericType::toUShort() const { ...@@ -86,6 +86,27 @@ unsigned short GenericType::toUShort() const {
return us; return us;
} }
std::vector<double> GenericType::toVectorDouble() const {
//create a temporary object to avoid empty m_stream after use of >> operator ; for multiple use of the same GenericType object
std::stringstream sstream;
sstream << m_stream.str();
std::vector<double> vd{};
double d;
while (sstream >> d) {
vd.push_back(d);
}
while(sstream >> d || !sstream.eof()) {
if(sstream.fail()) {
throw std::runtime_error("[GenericType::toUInt] cast from std::string to unsigned short failed ! ");
}
vd.push_back(d);
}
return vd;
}
std::string GenericType::getString() const { std::string GenericType::getString() const {
return m_stream.str(); return m_stream.str();
} }
......
Supports Markdown
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