From: Radoslaw Zarzynski Date: Mon, 17 Jul 2017 12:32:17 +0000 (-0400) Subject: rgw: add the get_optional() method to RGWHTTPArgs. X-Git-Tag: v12.1.3~24^2~22^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f4ea4c4f70f6ec087ee41b9d27b16e2d2b523f64;p=ceph.git rgw: add the get_optional() method to RGWHTTPArgs. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index 72891f9c376d..29d588035aaf 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -988,6 +988,18 @@ const string& RGWHTTPArgs::get(const string& name, bool *exists) const return empty_str; } +boost::optional +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::iterator iter; diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 699cd19788b7..72531755ac9b 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -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 + 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);