From 7f854199a3c00c729c4c0cefd6001a9fbe1e60da Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 28 Oct 2025 17:56:44 +0200 Subject: [PATCH] libcamera: value_node: Add constructor with value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new constructor takes a value, allowing creation of a leaf ValueNode with a value in a single operation instead of having to call set() on an empty node. Signed-off-by: Laurent Pinchart Reviewed-by: Barnabás Pőcze Reviewed-by: Isaac Scott --- include/libcamera/internal/value_node.h | 8 ++++++++ src/libcamera/value_node.cpp | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/include/libcamera/internal/value_node.h b/include/libcamera/internal/value_node.h index d4533df1..bcf2c8ec 100644 --- a/include/libcamera/internal/value_node.h +++ b/include/libcamera/internal/value_node.h @@ -143,6 +143,14 @@ public: #endif /* __DOXYGEN__ */ ValueNode(); + + template + ValueNode(T &&value) + : type_(Type::Empty) + { + set(std::forward(value)); + } + ~ValueNode(); bool isValue() const diff --git a/src/libcamera/value_node.cpp b/src/libcamera/value_node.cpp index f22f4de9..cb43fa9c 100644 --- a/src/libcamera/value_node.cpp +++ b/src/libcamera/value_node.cpp @@ -44,6 +44,13 @@ ValueNode::ValueNode() { } +/** + * \fn template ValueNode::ValueNode(T &&value) + * \brief Construct a ValueNode instance with a value + * \tparam T Type of the value + * \param[in] value The value + */ + ValueNode::~ValueNode() = default; /**