From patchwork Tue Jan 13 00:08:02 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 25750 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 5610BC32AF for ; Tue, 13 Jan 2026 00:09:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E2E4762013; Tue, 13 Jan 2026 01:09:20 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="N4h9ifE9"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CC00561FF4 for ; Tue, 13 Jan 2026 01:09:18 +0100 (CET) Received: from pendragon.ideasonboard.com (81-175-209-152.bb.dnainternet.fi [81.175.209.152]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 2FE73BCA for ; Tue, 13 Jan 2026 01:08:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1768262933; bh=swlUtzW82ngKAGHFFUN5/TSMXj/Bxv99B2kP9bfB6Bc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=N4h9ifE9ssQ79ggYRQbWYozyLs/TB+ivjdEJuYaq3kAbvAJ18gSFOE2zsal1renRT qX75JYZTqD8rGFzayGAwiZJlJj/+gRgN5yjGGq+7c6eRvii/Jxk5Yd9kLTv2b0/DEH 3i0C8W/2kg+kEwqVfeIWY0vUMJi3we/O0MQpwdWo= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH 30/36] libcamera: value_node: Support looking up nested children in one operation Date: Tue, 13 Jan 2026 02:08:02 +0200 Message-ID: <20260113000808.15395-31-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 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Signed-off-by: Laurent Pinchart --- include/libcamera/internal/value_node.h | 1 + src/libcamera/value_node.cpp | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/libcamera/internal/value_node.h b/include/libcamera/internal/value_node.h index abb0991fd87e..da72651d2161 100644 --- a/include/libcamera/internal/value_node.h +++ b/include/libcamera/internal/value_node.h @@ -235,6 +235,7 @@ public: bool contains(std::string_view key) const; ValueNode *at(std::string_view key); const ValueNode &operator[](std::string_view key) const; + const ValueNode &operator[](std::initializer_list path) const; ValueNode *add(std::unique_ptr child); ValueNode *add(std::string key, std::unique_ptr child); diff --git a/src/libcamera/value_node.cpp b/src/libcamera/value_node.cpp index 1256adf8361d..55d5a1a29991 100644 --- a/src/libcamera/value_node.cpp +++ b/src/libcamera/value_node.cpp @@ -487,6 +487,29 @@ const ValueNode &ValueNode::operator[](std::string_view key) const return *iter->second; } +/** + * \brief Retrieve a descendant node by path + * \param[in] path The path + * + * This function retrieves a descendant of a ValueNode by following a \a path. + * The path is a list of keys that index nested dictionary nodes. If any node + * along the path is not a Dictionary node, an empty node is returned. + * + * \return The ValueNode corresponding to the \a path + */ +const ValueNode &ValueNode::operator[](std::initializer_list path) const +{ + const ValueNode *node = this; + + for (const auto part : path) { + node = &(*node)[part]; + if (!*node) + return empty; + } + + return *node; +} + /** * \brief Add a child node to a list * \param[in] child The child node