Show a patch.

GET /api/1.1/patches/3210/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 3210,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/3210/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3210/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20200320014839.14683-3-laurent.pinchart@ideasonboard.com>",
    "date": "2020-03-20T01:48:30",
    "name": "[libcamera-devel,v3,02/11] libcamera: utils: Add string join function",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "23aa4f8a18cfb59774bf392f8d2dfc45b87103b4",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/3210/mbox/",
    "series": [
        {
            "id": 749,
            "url": "https://patchwork.libcamera.org/api/1.1/series/749/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=749",
            "date": "2020-03-20T01:48:28",
            "name": "Simple pipeline handler",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/749/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3210/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3210/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 87CA5629C1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 Mar 2020 02:48:52 +0100 (CET)",
            "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E977EA54;\n\tFri, 20 Mar 2020 02:48:51 +0100 (CET)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1584668932;\n\tbh=qGX8KRUB4wyrHASlGDEloCOnVda6YjB/+0cHBXeBjyk=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=RHL0JzmX3xRXQrS7tJG3rv6fh0w0DMY5x/oS9DX33vR1tv9qKTaSuiNf2PhB8nY0I\n\troav70TIfDQeiCW9Nn+mw7HCs2GULx7UxAEc/w2thaS9H2HJgD/D3uowonT8TjuDqC\n\t/z+dZpvJIZ0ILV6ASaaTwyCk4Qmzy1txNxY3xUOQ=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Martijn Braam <martijn@brixit.nl>,\n\tBenjamin GAIGNARD <benjamin.gaignard@st.com>,\n\tAndrey Konovalov <andrey.konovalov@linaro.org>",
        "Date": "Fri, 20 Mar 2020 03:48:30 +0200",
        "Message-Id": "<20200320014839.14683-3-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.24.1",
        "In-Reply-To": "<20200320014839.14683-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20200320014839.14683-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 02/11] libcamera: utils: Add string\n\tjoin function",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "<libcamera-devel.lists.libcamera.org>",
        "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>",
        "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>",
        "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>",
        "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>",
        "X-List-Received-Date": "Fri, 20 Mar 2020 01:48:52 -0000"
    },
    "content": "Add a utils::join() function to join elements of a container into a\nstring, with a separator and an optional conversion function if the\nelements are not implicitly convertible to std::string.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/include/utils.h | 44 +++++++++++++++++++++++++++++++++++\n src/libcamera/utils.cpp       | 16 +++++++++++++\n test/utils.cpp                |  7 +++++-\n 3 files changed, 66 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h\nindex cfa620f24581..242eeded9d50 100644\n--- a/src/libcamera/include/utils.h\n+++ b/src/libcamera/include/utils.h\n@@ -11,6 +11,7 @@\n #include <chrono>\n #include <memory>\n #include <ostream>\n+#include <sstream>\n #include <string>\n #include <string.h>\n #include <sys/time.h>\n@@ -109,6 +110,49 @@ inline _hex hex<uint64_t>(uint64_t value, unsigned int width)\n \n size_t strlcpy(char *dst, const char *src, size_t size);\n \n+#ifndef __DOXYGEN__\n+template<typename Container, typename UnaryOp>\n+std::string join(const Container &items, const std::string &sep, UnaryOp op)\n+{\n+\tstd::ostringstream ss;\n+\tbool first = true;\n+\n+\tfor (typename Container::const_iterator it = std::begin(items);\n+\t     it != std::end(items); ++it) {\n+\t\tif (!first)\n+\t\t\tss << sep;\n+\t\telse\n+\t\t\tfirst = false;\n+\n+\t\tss << op(*it);\n+\t}\n+\n+\treturn ss.str();\n+}\n+\n+template<typename Container>\n+std::string join(const Container &items, const std::string &sep)\n+{\n+\tstd::ostringstream ss;\n+\tbool first = true;\n+\n+\tfor (typename Container::const_iterator it = std::begin(items);\n+\t     it != std::end(items); ++it) {\n+\t\tif (!first)\n+\t\t\tss << sep;\n+\t\telse\n+\t\t\tfirst = false;\n+\n+\t\tss << *it;\n+\t}\n+\n+\treturn ss.str();\n+}\n+#else\n+template<typename Container, typename UnaryOp>\n+std::string join(const Container &items, const std::string &sep, UnaryOp op = nullptr);\n+#endif\n+\n namespace details {\n \n class StringSplitter\ndiff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\nindex 58ee7cc19c8c..97f9b632e45b 100644\n--- a/src/libcamera/utils.cpp\n+++ b/src/libcamera/utils.cpp\n@@ -297,6 +297,22 @@ details::StringSplitter::iterator details::StringSplitter::end() const\n \treturn iterator(this, std::string::npos);\n }\n \n+/**\n+ * \\fn template<typename Container, typename UnaryOp> \\\n+ * std::string utils::join(const Container &items, const std::string &sep, UnaryOp op)\n+ * \\brief Join elements of a container in a string with a separator\n+ * \\param[in] items The container\n+ * \\param[in] sep The separator to add between elements\n+ * \\param[in] op A function that converts individual elements to strings\n+ *\n+ * This function joins all elements in the \\a items container into a string and\n+ * returns it. The \\a sep separator is added between elements. If the container\n+ * elements are not implicitly convertible to std::string, the \\a op function\n+ * shall be provided to perform conversion of elements to std::string.\n+ *\n+ * \\return A string that concatenates all elements in the container\n+ */\n+\n /**\n  * \\fn split(const std::string &str, const std::string &delim)\n  * \\brief Split a string based on a delimiter\ndiff --git a/test/utils.cpp b/test/utils.cpp\nindex 58816f153066..2fca89ef3278 100644\n--- a/test/utils.cpp\n+++ b/test/utils.cpp\n@@ -99,7 +99,7 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n-\t\t/* utils::split() test. */\n+\t\t/* utils::join() and utils::split() test. */\n \t\tstd::vector<std::string> elements = {\n \t\t\t\"/bin\",\n \t\t\t\"/usr/bin\",\n@@ -111,6 +111,11 @@ protected:\n \t\tfor (const auto &element : elements)\n \t\t\tpath += (path.empty() ? \"\" : \":\") + element;\n \n+\t\tif (path != utils::join(elements, \":\")) {\n+\t\t\tcerr << \"utils::join() test failed\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n \t\tstd::vector<std::string> dirs;\n \n \t\tfor (const auto &dir : utils::split(path, \":\"))\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "02/11"
    ]
}