From ccba4d6ebf5fd8b405e1183247a9f2625c3ed1db Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sun, 6 May 2018 19:36:28 -0500 Subject: [PATCH] add log function to build strings for vectors --- xs/src/libslic3r/Log.hpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/xs/src/libslic3r/Log.hpp b/xs/src/libslic3r/Log.hpp index 5eddac995..255b2e7a6 100644 --- a/xs/src/libslic3r/Log.hpp +++ b/xs/src/libslic3r/Log.hpp @@ -2,6 +2,8 @@ #define slic3r_LOG_HPP #include +#include +#include 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 +std::string +log_string(const std::vector& 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