From patchwork Mon Jul 12 21:56:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12915 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 0BF91C3227 for ; Mon, 12 Jul 2021 21:57:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 40B8D68545; Mon, 12 Jul 2021 23:57:40 +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="lxWJTN6H"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7D27968521 for ; Mon, 12 Jul 2021 23:57:36 +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 2872ACC for ; Mon, 12 Jul 2021 23:57:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1626127056; bh=Q09DAc+EA4PbrCY0WSTGaN66bxiaHwiGUZauxDxVooY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=lxWJTN6HIaNIICA9GGOiNleprJksZh61Gmxn+UX6jBOH6Y78jEkgb2BDXkWSFXZv6 9L5OBhqlu6cKU7JC6v7Fh6E5qZbBRGOIzDu2iXbNkc3JMGzgBc2FeSAqecD0+pqGEb 8KGzx5Ha2jaJXO6l2JevesMCfrNSedgZB3rn+EGc= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 13 Jul 2021 00:56:17 +0300 Message-Id: <20210712215645.30478-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210712215645.30478-1-laurent.pinchart@ideasonboard.com> References: <20210712215645.30478-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 02/30] 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,