summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-06-25 04:23:35 +0300
committerNiklas Söderlund <niklas.soderlund@ragnatech.se>2020-07-09 16:15:12 +0200
commitc58bec935c3adffac9d99b1675a563d7f2e9ae04 (patch)
treeacff6a88cdb591f517ab5f1ba3c44e4827401bc0 /include
parentb5f6a2ce2fae423f40c4bdaf1be43ad5070b3868 (diff)
libcamera: utils: Add map_keys() function
Add a map_keys() function to the utils namespace to extract keys from a map. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> [Niklas: change return type to std::vector instead of std::set] Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'include')
-rw-r--r--include/libcamera/internal/utils.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/libcamera/internal/utils.h b/include/libcamera/internal/utils.h
index 0953423e..8d026cc6 100644
--- a/include/libcamera/internal/utils.h
+++ b/include/libcamera/internal/utils.h
@@ -15,6 +15,7 @@
#include <string>
#include <string.h>
#include <sys/time.h>
+#include <vector>
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
@@ -36,6 +37,15 @@ const char *basename(const char *path);
char *secure_getenv(const char *name);
std::string dirname(const std::string &path);
+template<typename T>
+std::vector<typename T::key_type> map_keys(const T &map)
+{
+ std::vector<typename T::key_type> keys;
+ std::transform(map.begin(), map.end(), std::back_inserter(keys),
+ [](const auto &value) { return value.first; });
+ return keys;
+}
+
template<class InputIt1, class InputIt2>
unsigned int set_overlap(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2)