Show a patch.

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

{
    "id": 26452,
    "url": "https://patchwork.libcamera.org/api/patches/26452/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/26452/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20260407153427.1825999-13-laurent.pinchart@ideasonboard.com>",
    "date": "2026-04-07T15:33:57",
    "name": "[v2,12/42] libcamera: yaml_parser: Add function to set a YamlObject value",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "2b9e535d2cf0a3c42731e3c354fb21483aace7c6",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/26452/mbox/",
    "series": [
        {
            "id": 5873,
            "url": "https://patchwork.libcamera.org/api/series/5873/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5873",
            "date": "2026-04-07T15:33:45",
            "name": "libcamera: Global configuration file improvements",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/5873/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/26452/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/26452/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>",
        "X-Original-To": "parsemail@patchwork.libcamera.org",
        "Delivered-To": "parsemail@patchwork.libcamera.org",
        "Received": [
            "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 9BC35C32FC\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  7 Apr 2026 15:34:49 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BBC1D62DE0;\n\tTue,  7 Apr 2026 17:34:48 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D3C4262DA2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Apr 2026 17:34:44 +0200 (CEST)",
            "from killaraus.ideasonboard.com\n\t(2001-14ba-703d-e500--2a1.rev.dnainternet.fi\n\t[IPv6:2001:14ba:703d:e500::2a1])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 243C4596\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Apr 2026 17:33:17 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"HZMsb4XP\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1775575997;\n\tbh=7v9XADkIcESoBajheMtbeQniMG8/jRV6V+0ZQ5dVybk=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=HZMsb4XPhih9F0lKgfGYwtVzQwH7JMXknu1cIFakhzfjB3cfa9N+TCRkoKsgO25gi\n\tWM54SNB1YaZ02qqPuzBA+WK5Isd9GPzht21nTgCkFkjAFGYJhYjGgRGeb/fKPRVC3t\n\tdGz7tfkuj4e8yotyQj2mVVtdqvOhxUH4wCZqyhao=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Subject": "[PATCH v2 12/42] libcamera: yaml_parser: Add function to set a\n\tYamlObject value",
        "Date": "Tue,  7 Apr 2026 18:33:57 +0300",
        "Message-ID": "<20260407153427.1825999-13-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.52.0",
        "In-Reply-To": "<20260407153427.1825999-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20260407153427.1825999-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Add a YamlObject::set() function to set the value of an object, with\nspecializations for scalar types.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nChanges since v1:\n\n- Remove cv in addition to reference in YamlObject::set()\n---\n include/libcamera/internal/yaml_parser.h |  8 ++++\n src/libcamera/yaml_parser.cpp            | 59 ++++++++++++++++++++++++\n 2 files changed, 67 insertions(+)",
    "diff": "diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h\nindex 7953befe11e2..0666762308ac 100644\n--- a/include/libcamera/internal/yaml_parser.h\n+++ b/include/libcamera/internal/yaml_parser.h\n@@ -182,6 +182,13 @@ public:\n \t\treturn get<T>().value_or(std::forward<U>(defaultValue));\n \t}\n \n+\ttemplate<typename T>\n+\tvoid set(T &&value)\n+\t{\n+\t\treturn Accessor<std::remove_cv_t<std::remove_reference_t<T>>>{}\n+\t\t\t.set(*this, std::forward<T>(value));\n+\t}\n+\n \tDictAdapter asDict() const { return DictAdapter{ list_ }; }\n \tListAdapter asList() const { return ListAdapter{ list_ }; }\n \n@@ -207,6 +214,7 @@ private:\n \ttemplate<typename T, typename Enable = void>\n \tstruct Accessor {\n \t\tstd::optional<T> get(const YamlObject &obj) const;\n+\t\tvoid set(YamlObject &obj, T value);\n \t};\n \n \tType type_;\ndiff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp\nindex 399e7529385f..3119ab41d89e 100644\n--- a/src/libcamera/yaml_parser.cpp\n+++ b/src/libcamera/yaml_parser.cpp\n@@ -137,6 +137,20 @@ std::size_t YamlObject::size() const\n  * \\return The YamlObject value, or \\a defaultValue if parsing failed\n  */\n \n+/**\n+ * \\fn template<typename T> YamlObject::set<T>(T &&value)\n+ * \\brief Set the value of a YamlObject\n+ * \\param[in] value The value\n+ *\n+ * This function sets the value stored in a YamlObject to \\a value. The value is\n+ * converted to a string in an implementation-specific way that guarantees that\n+ * subsequent calls to get<T>() will return the same value.\n+ *\n+ * Values can only be set on YamlObject of Type::Value type or empty YamlObject.\n+ * Attempting to set a value on an object of type Type::Dict or Type::List does\n+ * not modify the YamlObject.\n+ */\n+\n #ifndef __DOXYGEN__\n \n template<>\n@@ -154,6 +168,16 @@ YamlObject::Accessor<bool>::get(const YamlObject &obj) const\n \treturn std::nullopt;\n }\n \n+template<>\n+void YamlObject::Accessor<bool>::set(YamlObject &obj, bool value)\n+{\n+\tif (obj.type_ != Type::Empty && obj.type_ != Type::Value)\n+\t\treturn;\n+\n+\tobj.type_ = Type::Value;\n+\tobj.value_ = value ? \"true\" : \"false\";\n+}\n+\n template<typename T>\n struct YamlObject::Accessor<T, std::enable_if_t<\n \tstd::is_same_v<int8_t, T> ||\n@@ -178,6 +202,15 @@ struct YamlObject::Accessor<T, std::enable_if_t<\n \n \t\treturn value;\n \t}\n+\n+\tvoid set(YamlObject &obj, T value)\n+\t{\n+\t\tif (obj.type_ != Type::Empty && obj.type_ != Type::Value)\n+\t\t\treturn;\n+\n+\t\tobj.type_ = Type::Value;\n+\t\tobj.value_ = std::to_string(value);\n+\t}\n };\n \n template struct YamlObject::Accessor<int8_t>;\n@@ -194,6 +227,12 @@ YamlObject::Accessor<float>::get(const YamlObject &obj) const\n \treturn obj.get<double>();\n }\n \n+template<>\n+void YamlObject::Accessor<float>::set(YamlObject &obj, float value)\n+{\n+\tobj.set<double>(std::forward<float>(value));\n+}\n+\n template<>\n std::optional<double>\n YamlObject::Accessor<double>::get(const YamlObject &obj) const\n@@ -215,6 +254,16 @@ YamlObject::Accessor<double>::get(const YamlObject &obj) const\n \treturn value;\n }\n \n+template<>\n+void YamlObject::Accessor<double>::set(YamlObject &obj, double value)\n+{\n+\tif (obj.type_ != Type::Empty && obj.type_ != Type::Value)\n+\t\treturn;\n+\n+\tobj.type_ = Type::Value;\n+\tobj.value_ = std::to_string(value);\n+}\n+\n template<>\n std::optional<std::string>\n YamlObject::Accessor<std::string>::get(const YamlObject &obj) const\n@@ -225,6 +274,16 @@ YamlObject::Accessor<std::string>::get(const YamlObject &obj) const\n \treturn obj.value_;\n }\n \n+template<>\n+void YamlObject::Accessor<std::string>::set(YamlObject &obj, std::string value)\n+{\n+\tif (obj.type_ != Type::Empty && obj.type_ != Type::Value)\n+\t\treturn;\n+\n+\tobj.type_ = Type::Value;\n+\tobj.value_ = std::move(value);\n+}\n+\n template<>\n std::optional<Size>\n YamlObject::Accessor<Size>::get(const YamlObject &obj) const\n",
    "prefixes": [
        "v2",
        "12/42"
    ]
}