Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
partons
core
elementary-utils
Commits
efc46172
Commit
efc46172
authored
Jul 20, 2021
by
Valerio Bertone
Browse files
Merge branch 'InterfaceToApfel' into 'master'
Interface to apfel See merge request
!5
parents
2da06cf3
8a2074d6
Changes
5
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
efc46172
...
...
@@ -89,4 +89,4 @@ install(TARGETS ElementaryUtils
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/static
)
install
(
DIRECTORY include DESTINATION include
)
install
(
DIRECTORY include
/
DESTINATION include
)
include/ElementaryUtils/parameters/GenericType.h
View file @
efc46172
...
...
@@ -13,6 +13,7 @@
#include <sstream>
#include <string>
#include <cstddef>
#include <vector>
namespace
ElemUtils
{
...
...
@@ -86,6 +87,10 @@ public:
size_t
toSize_t
()
const
;
std
::
vector
<
double
>
toVectorDouble
()
const
;
std
::
vector
<
int
>
toVectorInt
()
const
;
/**
* Convert stream to string
* @return std::string
...
...
include/ElementaryUtils/string_utils/Formatter.h
View file @
efc46172
...
...
@@ -13,6 +13,8 @@
#include <limits>
#include <sstream>
#include <string>
#include <clocale>
#include <iostream>
#include "StringUtils.h"
...
...
@@ -27,6 +29,15 @@ public:
Formatter
()
{
// use to print full precision double
m_stream
<<
std
::
setprecision
(
std
::
numeric_limits
<
double
>::
digits10
);
//c
std
::
setlocale
(
LC_ALL
,
"en_US.UTF-8"
);
//c++ (global)
std
::
locale
::
global
(
std
::
locale
(
"en_US.UTF-8"
));
//c++ (cout)
std
::
cout
.
imbue
(
std
::
locale
(
"en_US.UTF-8"
));
}
~
Formatter
()
{
...
...
src/ElementaryUtils/parameters/GenericType.cpp
View file @
efc46172
...
...
@@ -86,6 +86,40 @@ 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
||
!
sstream
.
eof
())
{
if
(
sstream
.
fail
())
{
throw
std
::
runtime_error
(
"[GenericType::toVectorDouble] cast from std::string to std::vector<double> failed ! "
);
}
vd
.
push_back
(
d
);
}
return
vd
;
}
std
::
vector
<
int
>
GenericType
::
toVectorInt
()
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
<
int
>
vi
{};
int
i
;
while
(
sstream
>>
i
||
!
sstream
.
eof
())
{
if
(
sstream
.
fail
())
{
throw
std
::
runtime_error
(
"[GenericType::toVectorInt] cast from std::string to std::vector<int> failed ! "
);
}
vi
.
push_back
(
i
);
}
return
vi
;
}
std
::
string
GenericType
::
getString
()
const
{
return
m_stream
.
str
();
}
...
...
src/ElementaryUtils/string_utils/StringUtils.cpp
View file @
efc46172
#include "../../../include/ElementaryUtils/string_utils/StringUtils.h"
#include <algorithm> // pour transform #include <cctype> #include <cstdlib> #include <cctype> #include <cctype> #include <cctype> #include <cctype> #include <cctype> #include <cctype> #include <cctype> #include <cctype> #include <cctype> #include <iterator> #include <cctype> #include <iterator> #include <cctype> #include <iterator> #include "../../../include/ElementaryUtils/logger/CustomException.h" #include <cctype> #include <iterator>
#include <algorithm> // pour transform
#include <cctype>
#include <cstdlib>
#include <iterator>
#include "../../../include/ElementaryUtils/logger/CustomException.h"
#include "../../../include/ElementaryUtils/logger/CustomException.h"
#include "../../../include/ElementaryUtils/logger/LoggerManager.h"
#include "../../../include/ElementaryUtils/string_utils/Formatter.h"
...
...
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