From patchwork Thu Jan 31 23:47:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 461 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4B93E60DB8 for ; Fri, 1 Feb 2019 00:47:36 +0100 (CET) Received: from pendragon.ideasonboard.com (85-76-34-136-nat.elisa-mobile.fi [85.76.34.136]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3646F320; Fri, 1 Feb 2019 00:47:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1548978454; bh=oN48vyoiG7zLROp3gmz5rlpuRw9mHzuQ6euWvlppLJc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tv3mTV2bz/G9JrKXLHjlGeHVbu3XAJR/4bTrtt1rQg25em6qoUxdesPKSRe2Dyi/B A1D8zhHL3pQc8IokYo9X6XQLk6iwz4C5OlhyFkHHSatXGLPDBSmquM6SgxhCQ5mhXH EnRG6ACC59EH+ExQ7PeuCyBMlsJcXs4//GvQsjqE= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 1 Feb 2019 01:47:14 +0200 Message-Id: <20190131234721.22606-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190131234721.22606-1-laurent.pinchart@ideasonboard.com> References: <20190131234721.22606-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/8] cam: options: Move enum OptionArgument X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Jan 2019 23:47:36 -0000 From: Niklas Söderlund The enumeration of the different possibilities for arguments can be used by other parser then OptionsParser. Move it outside the class to make it ready to be used by other parsers. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- src/cam/main.cpp | 3 +-- src/cam/options.h | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/cam/main.cpp b/src/cam/main.cpp index cb98d302dcf3..bde47a8f1798 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -38,8 +38,7 @@ static int parseOptions(int argc, char *argv[]) OptionsParser parser; parser.addOption(OptCamera, "Specify which camera to operate on", - "camera", OptionsParser::ArgumentRequired, - "camera"); + "camera", ArgumentRequired, "camera"); parser.addOption(OptHelp, "Display this help message", "help"); parser.addOption(OptList, "List all cameras", "list"); diff --git a/src/cam/options.h b/src/cam/options.h index f99ea7300a71..491f6a316fff 100644 --- a/src/cam/options.h +++ b/src/cam/options.h @@ -11,15 +11,15 @@ #include #include +enum OptionArgument { + ArgumentNone, + ArgumentRequired, + ArgumentOptional, +}; + class OptionsParser { public: - enum OptionArgument { - ArgumentNone, - ArgumentRequired, - ArgumentOptional, - }; - class Options { public: Options(); From patchwork Thu Jan 31 23:47:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 462 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 545E360DBB for ; Fri, 1 Feb 2019 00:47:36 +0100 (CET) Received: from pendragon.ideasonboard.com (85-76-34-136-nat.elisa-mobile.fi [85.76.34.136]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 69B9241; Fri, 1 Feb 2019 00:47:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1548978455; bh=s1qlEfEwpCpQPl9CEYvMUJVqLPjuycDiB/CiAU4HOTQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WMfpaUg10KOjUQcKzFbmrPrDemMCKlGjQsvk5/Eu+VaQ30HrmHrPUjs2ixPwQtUH8 zi0KDZBc+926eTl7kZ9lgGgbkD271AiuSXiFuB6KfWPMnxa5MPcQcmG2Jg4iYX2fov Cja/sKBJyLIPwjUyd9K5jgfBunyuzXVzCAqHVt5w= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 1 Feb 2019 01:47:15 +0200 Message-Id: <20190131234721.22606-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190131234721.22606-1-laurent.pinchart@ideasonboard.com> References: <20190131234721.22606-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/8] cam: options: Move struct Option X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Jan 2019 23:47:36 -0000 The Option structure is declared within the OptionsParser, but will later be needed by other parsers. Move it outside the OptionsParser class. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/cam/options.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/cam/options.h b/src/cam/options.h index 491f6a316fff..6d1b12d235d8 100644 --- a/src/cam/options.h +++ b/src/cam/options.h @@ -17,6 +17,17 @@ enum OptionArgument { ArgumentOptional, }; +struct Option { + int opt; + const char *name; + OptionArgument argument; + const char *argumentName; + const char *help; + + bool hasShortOption() const { return isalnum(opt); } + bool hasLongOption() const { return name != nullptr; } +}; + class OptionsParser { public: @@ -42,17 +53,6 @@ public: void usage(); private: - struct Option { - int opt; - const char *name; - OptionArgument argument; - const char *argumentName; - const char *help; - - bool hasShortOption() const { return isalnum(opt); } - bool hasLongOption() const { return name != nullptr; } - }; - std::vector