[{"id":37604,"web_url":"https://patchwork.libcamera.org/comment/37604/","msgid":"<e757c84c-0b6c-4c6c-9c5e-23760428859e@ideasonboard.com>","date":"2026-01-13T13:52:43","subject":"Re: [PATCH 12/36] libcamera: yaml_parser: Add function to set a\n\tYamlObject value","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2026. 01. 13. 1:07 keltezéssel, Laurent Pinchart írta:\n> Add a YamlObject::set() function to set the value of an object, with\n> specializations for scalar types.\n> \n> Signed-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(+)\n> \n> diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h\n> index 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\n   std::remove_cv_t<std::remove_reference_t<T>>\n\n?\n\n\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_;\n> diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp\n> index 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","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 7F081BDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 13 Jan 2026 13:52:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B5E7561FBC;\n\tTue, 13 Jan 2026 14:52:47 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 113F261FA0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Jan 2026 14:52:47 +0100 (CET)","from [192.168.33.30] (185.221.143.114.nat.pool.zt.hu\n\t[185.221.143.114])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DC43E316;\n\tTue, 13 Jan 2026 14:52:20 +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=\"H4gRyunH\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1768312341;\n\tbh=UKo9ydYwlKPjKOW6Q/EQxQ3X6ju13YItvmUFTTiPu6I=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=H4gRyunHHbFTJsukEaFmWW5vXRqGVP3V+Qnli73Xm2/eaAiP+TpDChJpl5+eVBayn\n\tbEGzvP+iVAjD1Bqe1iw2k5gJvDj7JJ2UhYytSjM02bfDu5SkLtGXXuBOx2RqoLwHMU\n\tnWX+VS+DIg9A6DPSJKytg0KE7BucVATe/FMKZEKM=","Message-ID":"<e757c84c-0b6c-4c6c-9c5e-23760428859e@ideasonboard.com>","Date":"Tue, 13 Jan 2026 14:52:43 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH 12/36] libcamera: yaml_parser: Add function to set a\n\tYamlObject value","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20260113000808.15395-1-laurent.pinchart@ideasonboard.com>\n\t<20260113000808.15395-13-laurent.pinchart@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20260113000808.15395-13-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","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>"}},{"id":37611,"web_url":"https://patchwork.libcamera.org/comment/37611/","msgid":"<20260113141845.GM6198@pendragon.ideasonboard.com>","date":"2026-01-13T14:18:45","subject":"Re: [PATCH 12/36] libcamera: yaml_parser: Add function to set a\n\tYamlObject value","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Tue, Jan 13, 2026 at 02:52:43PM +0100, Barnabás Pőcze wrote:\n> 2026. 01. 13. 1:07 keltezéssel, Laurent Pinchart írta:\n> > Add a YamlObject::set() function to set the value of an object, with\n> > specializations for scalar types.\n> > \n> > Signed-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(+)\n> > \n> > diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h\n> > index 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> \n>    std::remove_cv_t<std::remove_reference_t<T>>\n> \n> ?\n\nI'll do that, it won't hurt.\n\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_;\n> > diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp\n> > index 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","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 9677DBDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 13 Jan 2026 14:19:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B1E6C61FA3;\n\tTue, 13 Jan 2026 15:19:08 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8D50661FA0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Jan 2026 15:19:06 +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 3057A50A;\n\tTue, 13 Jan 2026 15:18:40 +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=\"EWStmRLO\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1768313920;\n\tbh=VAP+RKThPfOpIfvyWN8YYBNYgQWezWTg7b4KEkJtg98=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=EWStmRLO5+1tXzi1OEmvUpBkGGNBae4SJMw8CwExnfF0FNU6qwbD21xiGeFdIx3d2\n\tbVrScdCgKoa7jRa4215Kpor/BnUOJiHg65tq1/ULA5aXomJOZX9X8U4oI5TdojBeiX\n\txJTuXn6H9KK2cfWlPIzCgdDiLBL50sEVfUssT+TA=","Date":"Tue, 13 Jan 2026 16:18:45 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH 12/36] libcamera: yaml_parser: Add function to set a\n\tYamlObject value","Message-ID":"<20260113141845.GM6198@pendragon.ideasonboard.com>","References":"<20260113000808.15395-1-laurent.pinchart@ideasonboard.com>\n\t<20260113000808.15395-13-laurent.pinchart@ideasonboard.com>\n\t<e757c84c-0b6c-4c6c-9c5e-23760428859e@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<e757c84c-0b6c-4c6c-9c5e-23760428859e@ideasonboard.com>","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>"}}]