{"id":12918,"url":"https://patchwork.libcamera.org/api/patches/12918/?format=json","web_url":"https://patchwork.libcamera.org/patch/12918/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210712215645.30478-6-laurent.pinchart@ideasonboard.com>","date":"2021-07-12T21:56:20","name":"[libcamera-devel,v2,05/30] cam: options: Add optionName() function to Option structure","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"076f06ff3fe01cc09c7bd31720aaffb6b557fbe5","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/12918/mbox/","series":[{"id":2229,"url":"https://patchwork.libcamera.org/api/series/2229/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2229","date":"2021-07-12T21:56:15","name":"Multi-camera support in the cam application","version":2,"mbox":"https://patchwork.libcamera.org/series/2229/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/12918/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/12918/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id F2816C3226\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 12 Jul 2021 21:57:43 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 100BF68539;\n\tMon, 12 Jul 2021 23:57:43 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 977AF6852C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Jul 2021 23:57:37 +0200 (CEST)","from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2D6AA3F1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Jul 2021 23:57:37 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"DlIOVnLn\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1626127057;\n\tbh=MrcoK9ETCZ9MY++9sd/Nevj0m43NJwjorkwqpdEd6b0=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=DlIOVnLn5WcplnRwwvqoiOWxRNiKjhO3wEviC7C6Bfj5zi9Jf4o7ND1O1YRVX3ZI7\n\t5ZLFsXoAeVtsX+WcAUH6hhz/+w+5c5mD600Rf60w2I7oX4C3z70D1VKELzaMI4+uKC\n\tGhzNUFkyFZ9wv7zA2O4SyqK10/xpHxK4SNnGFQD8=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 13 Jul 2021 00:56:20 +0300","Message-Id":"<20210712215645.30478-6-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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 05/30] cam: options: Add optionName()\n\tfunction to Option structure","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add an Option::optionName() function that returns a string describing\nthe option name, with leading dashes. As a result,\nOptionsParser::parseValueError() function becomes a single-line function\nand can be inlined in its caller.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/cam/options.cpp | 32 ++++++++++++++++++--------------\n src/cam/options.h   |  2 --\n 2 files changed, 18 insertions(+), 16 deletions(-)","diff":"diff --git a/src/cam/options.cpp b/src/cam/options.cpp\nindex 135dd7622e48..721a808ac859 100644\n--- a/src/cam/options.cpp\n+++ b/src/cam/options.cpp\n@@ -100,6 +100,7 @@ struct Option {\n \tbool hasShortOption() const { return isalnum(opt); }\n \tbool hasLongOption() const { return name != nullptr; }\n \tconst char *typeName() const;\n+\tstd::string optionName() const;\n };\n \n /**\n@@ -125,6 +126,20 @@ const char *Option::typeName() const\n \treturn \"unknown\";\n }\n \n+/**\n+ * \\brief Retrieve a string describing the option name, with leading dashes\n+ * \\return A string describing the option name, as a long option identifier\n+ * (double dash) if the option has a name, or a short option identifier (single\n+ * dash) otherwise\n+ */\n+std::string Option::optionName() const\n+{\n+\tif (name)\n+\t\treturn \"--\" + std::string(name);\n+\telse\n+\t\treturn \"-\" + std::string(1, opt);\n+}\n+\n /* -----------------------------------------------------------------------------\n  * OptionBase<T>\n  */\n@@ -865,7 +880,9 @@ OptionsParser::Options OptionsParser::parse(int argc, char **argv)\n \n \t\tconst Option &option = *optionsMap_[c];\n \t\tif (!options.parseValue(c, option, optarg)) {\n-\t\t\tparseValueError(option);\n+\t\t\tstd::cerr << \"Can't parse \" << option.typeName()\n+\t\t\t\t  << \" argument for option \" << option.optionName()\n+\t\t\t\t  << std::endl;\n \t\t\tusage();\n \t\t\treturn options;\n \t\t}\n@@ -952,16 +969,3 @@ void OptionsParser::usage()\n \t\t\toption.keyValueParser->usage(indent);\n \t}\n }\n-\n-void OptionsParser::parseValueError(const Option &option)\n-{\n-\tstd::string optionName;\n-\n-\tif (option.name)\n-\t\toptionName = \"--\" + std::string(option.name);\n-\telse\n-\t\toptionName = \"-\" + std::string(1, option.opt);\n-\n-\tstd::cerr << \"Can't parse \" << option.typeName()\n-\t\t  << \" argument for option \" << optionName << std::endl;\n-}\ndiff --git a/src/cam/options.h b/src/cam/options.h\nindex a3b18bb6c4ea..0b8bb172d184 100644\n--- a/src/cam/options.h\n+++ b/src/cam/options.h\n@@ -95,8 +95,6 @@ public:\n \tvoid usage();\n \n private:\n-\tvoid parseValueError(const Option &option);\n-\n \tstd::list<Option> options_;\n \tstd::map<unsigned int, Option *> optionsMap_;\n };\n","prefixes":["libcamera-devel","v2","05/30"]}