From patchwork Thu Jul 15 21:14:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12981 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 6BC0DC3226 for ; Thu, 15 Jul 2021 21:15:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 86C3368569; Thu, 15 Jul 2021 23:15:16 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="W16cyaVg"; 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 DB99B6853F for ; Thu, 15 Jul 2021 23:15:07 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 79B5F340 for ; Thu, 15 Jul 2021 23:15:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1626383707; bh=u/EKlYW1O9mTY+f8DbJqsRgDxxZ0Th5N2SH8PLdqrJE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=W16cyaVgHbLTYpCZXihKRzI3IAsnCTEDgf3ETgKVNPVIolvIiBW66pt/Dy3YV5OOC g22ed1KQmPmHMiHF6ewnNNUS2l4AtoZFTERD2ihf+6N6gBcd9SpDoIwdgcGzb5FTO2 /PDzDaLSSkKrfPmk7fGaDBGszl00T9otANTd3yZI= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 16 Jul 2021 00:14:36 +0300 Message-Id: <20210715211459.19373-11-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210715211459.19373-1-laurent.pinchart@ideasonboard.com> References: <20210715211459.19373-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 10/33] cam: options: Drop some OptionValue cast operators 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" While OptionValue cast operators to int and std::string allow useful shortcut syntaxes, the cast operators to KeyValueParser::Options and std::vector are less useful. A an explicit static_cast call would be more cumbersome to write than an explicit .toKeyValues() or toArray(), and implicit cast hide too much of what's going on. Drop those two cast operators, and replace the only implicit cast occurrence with .toKeyValues(). While at it, drop the local opts variable in StreamKeyValueParser::roles() as it isn't used. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/cam/options.cpp | 20 -------------------- src/cam/options.h | 2 -- src/cam/stream_options.cpp | 3 +-- 3 files changed, 1 insertion(+), 24 deletions(-) diff --git a/src/cam/options.cpp b/src/cam/options.cpp index 59b26be4deff..fda6d9764ac5 100644 --- a/src/cam/options.cpp +++ b/src/cam/options.cpp @@ -603,26 +603,6 @@ OptionValue::operator std::string() const return toString(); } -/** - * \brief Cast the value to a key-value list - * \return The option value as a KeyValueParser::Options, or an empty list if - * the value type isn't ValueType::ValueKeyValue - */ -OptionValue::operator KeyValueParser::Options() const -{ - return toKeyValues(); -} - -/** - * \brief Cast the value to an array - * \return The option value as a std::vector of OptionValue, or an empty vector - * if the value type isn't ValueType::ValueArray - */ -OptionValue::operator std::vector() const -{ - return toArray(); -} - /** * \brief Retrieve the value as an int * \return The option value as an int, or 0 if the value type isn't diff --git a/src/cam/options.h b/src/cam/options.h index e894822c0061..210e502a24e1 100644 --- a/src/cam/options.h +++ b/src/cam/options.h @@ -138,8 +138,6 @@ public: operator int() const; operator std::string() const; - operator KeyValueParser::Options() const; - operator std::vector() const; int toInteger() const; std::string toString() const; diff --git a/src/cam/stream_options.cpp b/src/cam/stream_options.cpp index c58272c23d25..b90dbb97f087 100644 --- a/src/cam/stream_options.cpp +++ b/src/cam/stream_options.cpp @@ -48,11 +48,10 @@ StreamRoles StreamKeyValueParser::roles(const OptionValue &values) StreamRoles roles; for (auto const &value : streamParameters) { - KeyValueParser::Options opts = value.toKeyValues(); StreamRole role; /* If role is invalid or not set default to viewfinder. */ - if (!parseRole(&role, value)) + if (!parseRole(&role, value.toKeyValues())) role = StreamRole::Viewfinder; roles.push_back(role);