{"id":25732,"url":"https://patchwork.libcamera.org/api/1.1/patches/25732/?format=json","web_url":"https://patchwork.libcamera.org/patch/25732/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260113000808.15395-13-laurent.pinchart@ideasonboard.com>","date":"2026-01-13T00:07:44","name":"[12/36] libcamera: yaml_parser: Add function to set a YamlObject value","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"cf9631cf26e8cca9a196b759daf0f72b63de90f1","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/25732/mbox/","series":[{"id":5703,"url":"https://patchwork.libcamera.org/api/1.1/series/5703/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5703","date":"2026-01-13T00:07:32","name":"libcamera: Global configuration file improvements","version":1,"mbox":"https://patchwork.libcamera.org/series/5703/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/25732/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/25732/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 4BB5DC3284\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 13 Jan 2026 00:08:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F293861FE2;\n\tTue, 13 Jan 2026 01:08:50 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1397861FA0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Jan 2026 01:08:48 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-152.bb.dnainternet.fi\n\t[81.175.209.152])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 6B9C8F06\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Jan 2026 01:08:22 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"dx6EVZrF\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1768262902;\n\tbh=g9l2EBZ7FVe+T4rOJU5XoOl6FlcCCHc/MA8OBHMJAew=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=dx6EVZrFtia/1BXrH40FrztA39J9tC8rGCg0QeeX13TyG2m20lYJLkz/nrjkOnkoL\n\tygyV9orhhHunwEQ0kz3KtRA/suMB2i/ofQJJWlueb/QYoCdRYfssK059SRZigk5AgG\n\to2B7itilHvzOiZoASQW9XQ4A5w9O6PXD1Xhq/YhI=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[PATCH 12/36] libcamera: yaml_parser: Add function to set a\n\tYamlObject value","Date":"Tue, 13 Jan 2026 02:07:44 +0200","Message-ID":"<20260113000808.15395-13-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.51.2","In-Reply-To":"<20260113000808.15395-1-laurent.pinchart@ideasonboard.com>","References":"<20260113000808.15395-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---\n include/libcamera/internal/yaml_parser.h |  7 +++\n src/libcamera/yaml_parser.cpp            | 59 ++++++++++++++++++++++++\n 2 files changed, 66 insertions(+)","diff":"diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h\nindex 7953befe11e2..c98fe003c877 100644\n--- a/include/libcamera/internal/yaml_parser.h\n+++ b/include/libcamera/internal/yaml_parser.h\n@@ -182,6 +182,12 @@ 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_reference_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 +213,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 2b3723287051..9b61d3e8fc50 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":["12/36"]}