summaryrefslogtreecommitdiff
path: root/include/input/PrintTools.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/input/PrintTools.h')
-rw-r--r--include/input/PrintTools.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/include/input/PrintTools.h b/include/input/PrintTools.h
index a20544b5fd..02bc2010db 100644
--- a/include/input/PrintTools.h
+++ b/include/input/PrintTools.h
@@ -21,6 +21,7 @@
#include <optional>
#include <set>
#include <string>
+#include <vector>
namespace android {
@@ -34,6 +35,16 @@ inline std::string constToString(const T& v) {
return std::to_string(v);
}
+template <>
+inline std::string constToString(const bool& value) {
+ return value ? "true" : "false";
+}
+
+template <>
+inline std::string constToString(const std::vector<bool>::reference& value) {
+ return value ? "true" : "false";
+}
+
inline std::string constToString(const std::string& s) {
return s;
}
@@ -76,6 +87,19 @@ std::string dumpMap(const std::map<K, V>& map, std::string (*keyToString)(const
return out;
}
+/**
+ * Convert a vector to a string. The values of the vector should be of a type supported by
+ * constToString.
+ */
+template <typename T>
+std::string dumpVector(std::vector<T> values) {
+ std::string dump = constToString(values[0]);
+ for (size_t i = 1; i < values.size(); i++) {
+ dump += ", " + constToString(values[i]);
+ }
+ return dump;
+}
+
const char* toString(bool value);
/**
@@ -87,4 +111,4 @@ const char* toString(bool value);
*/
std::string addLinePrefix(std::string str, const std::string& prefix);
-} // namespace android \ No newline at end of file
+} // namespace android