From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 113823 invoked by alias); 6 Jun 2017 11:54:58 -0000 Mailing-List: contact cygwin-apps-help@cygwin.com; run by ezmlm Precedence: bulk Sender: cygwin-apps-owner@cygwin.com List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Mail-Followup-To: cygwin-apps@cygwin.com Received: (qmail 113414 invoked by uid 89); 6 Jun 2017 11:54:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= X-HELO: rgout06.bt.lon5.cpcloud.co.uk Received: from rgout06.bt.lon5.cpcloud.co.uk (HELO rgout06.bt.lon5.cpcloud.co.uk) (65.20.0.183) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 06 Jun 2017 11:54:55 +0000 X-OWM-Source-IP: 86.141.128.130 (GB) X-OWM-Env-Sender: jonturney@btinternet.com X-Junkmail-Premium-Raw: score=8/50,refid=2.7.2:2017.6.2.221216:17:8.707,ip=,rules=NO_URI_FOUND, NO_CTA_URI_FOUND, NO_MESSAGE_ID, NO_URI_HTTPS, TO_MALFORMED Received: from localhost.localdomain (86.141.128.130) by rgout06.bt.lon5.cpcloud.co.uk (9.0.019.13-1) (authenticated as jonturney@btinternet.com) id 58F7952B052245CB; Tue, 6 Jun 2017 12:54:59 +0100 From: Jon Turney To: cygwin-apps@cygwin.com Cc: Jon Turney Subject: [PATCH setup 4/9] Add Option::isPresent() method Date: Tue, 06 Jun 2017 11:54:00 -0000 Message-Id: <20170606115432.105020-5-jon.turney@dronecode.org.uk> In-Reply-To: <20170606115432.105020-1-jon.turney@dronecode.org.uk> References: <20170606115432.105020-1-jon.turney@dronecode.org.uk> X-SW-Source: 2017-06/txt/msg00008.txt.bz2 Add Option::isPresent() method, so we can distinguish between the cases of an option which is present with the default value, and an option which is absent. --- libgetopt++/include/getopt++/Option.h | 4 ++++ libgetopt++/src/Option.cc | 2 +- libgetopt++/src/OptionSet.cc | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libgetopt++/include/getopt++/Option.h b/libgetopt++/include/getopt++/Option.h index 7ea0786..a32f949 100644 --- a/libgetopt++/include/getopt++/Option.h +++ b/libgetopt++/include/getopt++/Option.h @@ -46,8 +46,12 @@ public: }; virtual Argument argument () const = 0; + void setPresent(bool _present) { present = _present; } + bool isPresent() { return present; } + protected: Option (); + bool present; }; #endif // _OPTION_H_ diff --git a/libgetopt++/src/Option.cc b/libgetopt++/src/Option.cc index ac13ab9..7c61eba 100644 --- a/libgetopt++/src/Option.cc +++ b/libgetopt++/src/Option.cc @@ -15,7 +15,7 @@ #include "getopt++/Option.h" -Option::Option () +Option::Option () : present(false) { } diff --git a/libgetopt++/src/OptionSet.cc b/libgetopt++/src/OptionSet.cc index 82e1253..f57b89a 100644 --- a/libgetopt++/src/OptionSet.cc +++ b/libgetopt++/src/OptionSet.cc @@ -229,7 +229,8 @@ OptionSet::doOption(string &option, string::size_type const &pos) optionValue = value.c_str(); } break; - } + } + theOption->setPresent(true); lastResult = theOption->Process(optionValue); } -- 2.12.3