Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
partons
core
elementary-utils
Commits
ebf18210
Commit
ebf18210
authored
Jul 27, 2020
by
Valerio Bertone
Browse files
introducing vectors of doubles as possible parameters
parent
2da06cf3
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/ElementaryUtils/parameters/GenericType.h
View file @
ebf18210
...
...
@@ -13,6 +13,7 @@
#include <sstream>
#include <string>
#include <cstddef>
#include <vector>
namespace
ElemUtils
{
...
...
@@ -86,6 +87,8 @@ public:
size_t
toSize_t
()
const
;
std
::
vector
<
double
>
toVectorDouble
()
const
;
/**
* Convert stream to string
* @return std::string
...
...
src/ElementaryUtils/parameters/GenericType.cpp
View file @
ebf18210
...
...
@@ -86,6 +86,27 @@ unsigned short GenericType::toUShort() const {
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
{
return
m_stream
.
str
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment