From patchwork Thu Jul 15 21:14:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12973 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 10A94C3226 for ; Thu, 15 Jul 2021 21:15:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 84A946853A; Thu, 15 Jul 2021 23:15:09 +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="BRkh0kVP"; 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 2E14A6852A for ; Thu, 15 Jul 2021 23:15:05 +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 BD16F340 for ; Thu, 15 Jul 2021 23:15:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1626383704; bh=Q09DAc+EA4PbrCY0WSTGaN66bxiaHwiGUZauxDxVooY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BRkh0kVPtmxg8B82rEKsjALTgGDGaPjdb0/ezlFuD3UvbPcGXPNViCKe7DJ3HownK xDLYyMtDOvA1T1VVf8ZloHyjdbYVBJjR5scE14ZA8I63K8jqw+zVqztn7RGm5EuBcV drY+JCOWi9YK3rx1LnoX4K2Rg2dOxgMJW/XmGOxI= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 16 Jul 2021 00:14:28 +0300 Message-Id: <20210715211459.19373-3-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 02/33] cam: options: Move Option struct to options.cpp 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" The Option structure is an internal implementation detail and shouldn't be exposed in the API. Move it to options.cpp. This requires moving the inline constructors and destructors for the KeyValueParser and OptionsParser classes to options.cpp as well, as they need a full definition of the Option structure. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/cam/options.cpp | 21 +++++++++++++++++++++ src/cam/options.h | 22 ++++++---------------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/cam/options.cpp b/src/cam/options.cpp index 417c3ab49bc9..41968caa0ccb 100644 --- a/src/cam/options.cpp +++ b/src/cam/options.cpp @@ -17,6 +17,21 @@ * Option */ +struct Option { + int opt; + OptionType type; + const char *name; + OptionArgument argument; + const char *argumentName; + const char *help; + KeyValueParser *keyValueParser; + bool isArray; + + bool hasShortOption() const { return isalnum(opt); } + bool hasLongOption() const { return name != nullptr; } + const char *typeName() const; +}; + const char *Option::typeName() const { switch (type) { @@ -129,6 +144,9 @@ template class OptionsBase; * KeyValueParser */ +KeyValueParser::KeyValueParser() = default; +KeyValueParser::~KeyValueParser() = default; + bool KeyValueParser::addOption(const char *name, OptionType type, const char *help, OptionArgument argument) { @@ -349,6 +367,9 @@ std::vector OptionValue::toArray() const * OptionsParser */ +OptionsParser::OptionsParser() = default; +OptionsParser::~OptionsParser() = default; + bool OptionsParser::addOption(int opt, OptionType type, const char *help, const char *name, OptionArgument argument, const char *argumentName, bool array) diff --git a/src/cam/options.h b/src/cam/options.h index d0defb4bd665..688fe26011f8 100644 --- a/src/cam/options.h +++ b/src/cam/options.h @@ -14,6 +14,7 @@ class KeyValueParser; class OptionValue; +struct Option; enum OptionArgument { ArgumentNone, @@ -28,21 +29,6 @@ enum OptionType { OptionKeyValue, }; -struct Option { - int opt; - OptionType type; - const char *name; - OptionArgument argument; - const char *argumentName; - const char *help; - KeyValueParser *keyValueParser; - bool isArray; - - bool hasShortOption() const { return isalnum(opt); } - bool hasLongOption() const { return name != nullptr; } - const char *typeName() const; -}; - template class OptionsBase { @@ -73,7 +59,8 @@ public: { }; - virtual ~KeyValueParser() = default; + KeyValueParser(); + virtual ~KeyValueParser(); bool addOption(const char *name, OptionType type, const char *help, OptionArgument argument = ArgumentNone); @@ -133,6 +120,9 @@ public: { }; + OptionsParser(); + ~OptionsParser(); + bool addOption(int opt, OptionType type, const char *help, const char *name = nullptr, OptionArgument argument = ArgumentNone,