mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 15:00:02 +02:00
Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer
This commit is contained in:
commit
d597636c1e
@ -20,6 +20,17 @@
|
||||
|
||||
namespace sls {
|
||||
|
||||
|
||||
inline std::string ToString(const slsDetectorDefs::runStatus s){
|
||||
return slsDetectorDefs::runStatusType(s);
|
||||
}
|
||||
|
||||
// in case we already have a string
|
||||
// causes a copy but might be needed in generic code
|
||||
inline std::string ToString(const std::string& s){
|
||||
return s;
|
||||
}
|
||||
|
||||
/** Convert std::chrono::duration with specified output unit */
|
||||
template <typename T, typename Rep = double>
|
||||
typename std::enable_if<is_duration<T>::value, std::string>::type
|
||||
@ -73,6 +84,9 @@ ToString(const T &value) {
|
||||
return std::to_string(value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* For a container loop over all elements and call ToString on the element
|
||||
* Container<std::string> is excluded
|
||||
@ -177,17 +191,8 @@ ToString(const T &obj) {
|
||||
return obj.str();
|
||||
}
|
||||
|
||||
/**
|
||||
* Call ToString with a string, causes copy but might be needed
|
||||
* in generic code.
|
||||
*/
|
||||
inline std::string ToString(const std::string& s){
|
||||
return s;
|
||||
}
|
||||
|
||||
inline std::string ToString(slsDetectorDefs::runStatus s){
|
||||
return slsDetectorDefs::runStatusType(s);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace sls
|
||||
|
@ -135,3 +135,9 @@ TEST_CASE("string to detectorType"){
|
||||
REQUIRE(StringTo<dt>("Gotthard2") == dt::GOTTHARD2);
|
||||
}
|
||||
|
||||
TEST_CASE("vec"){
|
||||
using rs = slsDetectorDefs::runStatus;
|
||||
std::vector<rs> vec{rs::ERROR, rs::IDLE};
|
||||
REQUIRE(ToString(vec) == "[error, idle]");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user