remove override from adjacent_tokens_only
[folly.git] / folly / experimental / ProgramOptions.cpp
index 8146722e5192b7c28063433f2f98bf225f90ea3b..73c471ffd2d3d5d493251733ff735a6b35c0ac3f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include <unordered_set>
 
 #include <boost/version.hpp>
-#include <gflags/gflags.h>
 #include <glog/logging.h>
+
 #include <folly/Conv.h>
 #include <folly/Portability.h>
+#include <folly/portability/GFlags.h>
 
 namespace po = ::boost::program_options;
 
@@ -82,12 +83,14 @@ class GFlagValueSemanticBase : public po::value_semantic {
 
   std::string name() const override { return "arg"; }
 #if BOOST_VERSION >= 105900
-  bool adjacent_tokens_only() const override { return false; }
+  bool adjacent_tokens_only() const {
+    return false;
+  }
 #endif
   bool is_composing() const override { return false; }
   bool is_required() const override { return false; }
   // We handle setting the GFlags from parse(), so notify() does nothing.
-  void notify(const boost::any& valueStore) const override { }
+  void notify(const boost::any& /* valueStore */) const override {}
   bool apply_default(boost::any& valueStore) const override {
     // We're using the *current* rather than *default* value here, and
     // this is intentional; GFlags-using programs assign to FLAGS_foo
@@ -101,11 +104,11 @@ class GFlagValueSemanticBase : public po::value_semantic {
 
   void parse(boost::any& valueStore,
              const std::vector<std::string>& tokens,
-             bool utf8) const override;
+             bool /* utf8 */) const override;
 
  private:
   virtual T parseValue(const std::vector<std::string>& tokens) const = 0;
-  virtual void transform(T& val) const { }
+  virtual void transform(T& /* val */) const {}
 
   mutable std::shared_ptr<GFlagInfo<T>> info_;
 };
@@ -113,12 +116,12 @@ class GFlagValueSemanticBase : public po::value_semantic {
 template <class T>
 void GFlagValueSemanticBase<T>::parse(boost::any& valueStore,
                                       const std::vector<std::string>& tokens,
-                                      bool utf8) const {
+                                      bool /* utf8 */) const {
   T val;
   try {
     val = this->parseValue(tokens);
     this->transform(val);
-  } catch (const std::exception& e) {
+  } catch (const std::exception&) {
     throw po::invalid_option_value(
         tokens.empty() ? std::string() : tokens.front());
   }
@@ -166,29 +169,11 @@ class NegativeBoolGFlagValueSemantic : public BoolGFlagValueSemantic {
   }
 };
 
-static const std::unordered_set<std::string> gSkipFlags {
-  "flagfile",
-  "fromenv",
-  "tryfromenv",
-  "undefok",
-  "help",
-  "helpfull",
-  "helpshort",
-  "helpon",
-  "helpmatch",
-  "helppackage",
-  "helpxml",
-  "version",
-  "tab_completion_columns",
-  "tab_completion_word",
-};
-
-static const std::unordered_map<std::string, std::string> gFlagOverrides {
-  // Allow -v in addition to --v
-  {"v", "v,v"},
-};
-
 const std::string& getName(const std::string& name) {
+  static const std::unordered_map<std::string, std::string> gFlagOverrides{
+      // Allow -v in addition to --v
+      {"v", "v,v"},
+  };
   auto pos = gFlagOverrides.find(name);
   return pos != gFlagOverrides.end() ? pos->second : name;
 }
@@ -261,6 +246,23 @@ const std::unordered_map<std::string, FlagAdder> gFlagAdders = {
 }  // namespace
 
 po::options_description getGFlags(ProgramOptionsStyle style) {
+  static const std::unordered_set<std::string> gSkipFlags{
+      "flagfile",
+      "fromenv",
+      "tryfromenv",
+      "undefok",
+      "help",
+      "helpfull",
+      "helpshort",
+      "helpon",
+      "helpmatch",
+      "helppackage",
+      "helpxml",
+      "version",
+      "tab_completion_columns",
+      "tab_completion_word",
+  };
+
   po::options_description desc("GFlags");
 
   std::vector<gflags::CommandLineFlagInfo> allFlags;