From patchwork Thu Jul 15 21:14:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12982 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 F1B81C3227 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 DF8F168549; 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="rM93Dv/1"; 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 3961068549 for ; Thu, 15 Jul 2021 23:15:08 +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 C9D3D56B 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=1626383708; bh=+rgkfu9YI35jiQoxt5lY7KDJNUOCgq1UFoLMw+QYjoQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=rM93Dv/1A3IJHz/YI6ttrwrqG+pUFP7bmjvSJUjDWafy6iqkMhMQT8PCRT3n+6AeK GZsTFAn5xcDbXEAnQgccMi/KBj+NzL2bLnfzavj2qVQkTJSGLp4MKwiOJEJc2zt0YE kRRoTzk0FOh4FM4q4jL1XAwdHYb/WfKrghy5845o= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 16 Jul 2021 00:14:37 +0300 Message-Id: <20210715211459.19373-12-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 11/33] cam: options: Add empty() function to OptionValue class 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" Add a convenience helper to check if an option value is empty, based on the value type. This is useful as a shortcut syntax to check if an option has been set. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- src/cam/options.cpp | 7 +++++++ src/cam/options.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/cam/options.cpp b/src/cam/options.cpp index fda6d9764ac5..481ac189f115 100644 --- a/src/cam/options.cpp +++ b/src/cam/options.cpp @@ -583,6 +583,13 @@ void OptionValue::addValue(const OptionValue &value) * \return The value type */ +/** + * \fn OptionValue::empty() + * \brief Check if the value is empty + * \return True if the value is empty (type set to ValueType::ValueNone), or + * false otherwise + */ + /** * \brief Cast the value to 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 210e502a24e1..83c409ae4d28 100644 --- a/src/cam/options.h +++ b/src/cam/options.h @@ -135,6 +135,7 @@ public: void addValue(const OptionValue &value); ValueType type() const { return type_; } + bool empty() const { return type_ == ValueType::ValueNone; } operator int() const; operator std::string() const;