public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
From: Jon Turney <jon.turney@dronecode.org.uk>
To: cygwin-apps@cygwin.com
Cc: Jon Turney <jon.turney@dronecode.org.uk>
Subject: [PATCH setup 4/9] Add Option::isPresent() method
Date: Tue, 06 Jun 2017 11:54:00 -0000	[thread overview]
Message-ID: <20170606115432.105020-5-jon.turney@dronecode.org.uk> (raw)
In-Reply-To: <20170606115432.105020-1-jon.turney@dronecode.org.uk>

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

  parent reply	other threads:[~2017-06-06 11:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-06 11:54 [PATCH setup 0/9] Setup patches Jon Turney
2017-06-06 11:54 ` [PATCH setup 2/9] Alphabetically sort options in usage help Jon Turney
2017-06-06 11:54 ` Jon Turney [this message]
2017-06-06 11:55 ` [PATCH setup 6/9] Allow click-to-activate in PickView list control Jon Turney
2017-06-06 11:55 ` [PATCH setup 1/9] Allow options which only have long names Jon Turney
2017-06-06 11:55 ` [PATCH setup 3/9] Access StringOption's value by reference Jon Turney
2017-06-06 11:55 ` [PATCH setup 7/9] Fix that clicking on any column changes "Keep" to "Uninstall" Jon Turney
2017-06-06 11:55 ` [PATCH setup 9/9] Avoid messagebox spam with file:// protocol URLs Jon Turney
2017-06-06 11:55 ` [PATCH setup 5/9] Allow user-agent string to be customized Jon Turney
2017-06-06 11:55 ` [PATCH setup 8/9] Fix useless error message Jon Turney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170606115432.105020-5-jon.turney@dronecode.org.uk \
    --to=jon.turney@dronecode.org.uk \
    --cc=cygwin-apps@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).