summaryrefslogtreecommitdiff
path: root/src/libcamera/utils.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-03-13 19:59:57 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-04-15 01:07:24 +0300
commit79ce121b6bd33cc90e0a6645ef7391291792986f (patch)
tree0fb9e1f297eb62a5ca41f754c0041767c8e9f0bb /src/libcamera/utils.cpp
parentebd0cae455ef1605a39b00dec79770f3d52de88f (diff)
libcamera: utils: Add string join function
Add a utils::join() function to join elements of a container into a string, with a separator and an optional conversion function if the elements are not implicitly convertible to std::string. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/libcamera/utils.cpp')
-rw-r--r--src/libcamera/utils.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp
index 58ee7cc1..97f9b632 100644
--- a/src/libcamera/utils.cpp
+++ b/src/libcamera/utils.cpp
@@ -298,6 +298,22 @@ details::StringSplitter::iterator details::StringSplitter::end() const
}
/**
+ * \fn template<typename Container, typename UnaryOp> \
+ * std::string utils::join(const Container &items, const std::string &sep, UnaryOp op)
+ * \brief Join elements of a container in a string with a separator
+ * \param[in] items The container
+ * \param[in] sep The separator to add between elements
+ * \param[in] op A function that converts individual elements to strings
+ *
+ * This function joins all elements in the \a items container into a string and
+ * returns it. The \a sep separator is added between elements. If the container
+ * elements are not implicitly convertible to std::string, the \a op function
+ * shall be provided to perform conversion of elements to std::string.
+ *
+ * \return A string that concatenates all elements in the container
+ */
+
+/**
* \fn split(const std::string &str, const std::string &delim)
* \brief Split a string based on a delimiter
* \param[in] str The string to split