mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-03 05:00:37 +08:00
add log function to build strings for vectors
This commit is contained in:
parent
a559c57a81
commit
ccba4d6ebf
@ -2,6 +2,8 @@
|
||||
#define slic3r_LOG_HPP
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
@ -28,6 +30,28 @@ public:
|
||||
|
||||
};
|
||||
|
||||
/// Utility debug function to transform a std::vector of anything that
|
||||
/// supports ostream& operator<<() into a std::string.
|
||||
template <typename T>
|
||||
std::string
|
||||
log_string(const std::vector<T>& in)
|
||||
{
|
||||
std::stringstream ss;
|
||||
bool first {true};
|
||||
ss << "[ ";
|
||||
for (auto& c : in) {
|
||||
if (!first) {
|
||||
ss << ", ";
|
||||
}
|
||||
ss << c;
|
||||
first = false;
|
||||
}
|
||||
|
||||
ss << " ]";
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // slic3r_LOG_HPP
|
||||
|
Loading…
x
Reference in New Issue
Block a user