]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add the get_optional() method to RGWHTTPArgs.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Mon, 17 Jul 2017 12:32:17 +0000 (08:32 -0400)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Mon, 17 Jul 2017 12:32:17 +0000 (08:32 -0400)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/rgw/rgw_common.cc
src/rgw/rgw_common.h

index 72891f9c376d0b740ecea46d4ff95b2ce4a30eb5..29d588035aafb3006e194d68bd45c1f45471c0ba 100644 (file)
@@ -988,6 +988,18 @@ const string& RGWHTTPArgs::get(const string& name, bool *exists) const
   return empty_str;
 }
 
+boost::optional<const std::string&>
+RGWHTTPArgs::get_optional(const std::string& name) const
+{
+  bool exists;
+  const std::string& value = get(name, &exists);
+  if (exists) {
+    return value;
+  } else {
+    return boost::none;
+  }
+}
+
 int RGWHTTPArgs::get_bool(const string& name, bool *val, bool *exists)
 {
   map<string, string>::iterator iter;
index 699cd19788b7a33d2b6ab4839925283c72549402..72531755ac9b2ee236da8750b684cc80ced99fff 100644 (file)
@@ -334,6 +334,8 @@ class RGWHTTPArgs
   void append(const string& name, const string& val);
   /** Get the value for a specific argument parameter */
   const string& get(const string& name, bool *exists = NULL) const;
+  boost::optional<const std::string&>
+  get_optional(const std::string& name) const;
   int get_bool(const string& name, bool *val, bool *exists);
   int get_bool(const char *name, bool *val, bool *exists);
   void get_bool(const char *name, bool *val, bool def_val);