diff options
author | 2023-01-20 14:13:16 +0000 | |
---|---|---|
committer | 2023-01-20 14:13:16 +0000 | |
commit | 53e1dac44c8267ffb454ce969d39d2f88c7f366d (patch) | |
tree | a971560f70d06e9f377e9970d68e69dde24eafce /include/input/PrintTools.h | |
parent | 6d1c002eb5764dbb716073bf2f2ff5905558bfe1 (diff) | |
parent | ea73eaa7cb640654d6cd5b423196a7beeb781416 (diff) |
Merge changes I036d0251,I7723dcba
* changes:
TouchpadInputMapper: add dump method
TouchpadInputMapper: Add gesture property provider
Diffstat (limited to 'include/input/PrintTools.h')
-rw-r--r-- | include/input/PrintTools.h | 26 |
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 |