add log function to build strings for vectors

This commit is contained in:
Joseph Lenox 2018-05-06 19:36:28 -05:00 committed by Joseph Lenox
parent a559c57a81
commit ccba4d6ebf

View File

@ -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