]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
move get_conf_str_map_helper to str_map.h (from Monitor.h)
authorSage Weil <sage@redhat.com>
Mon, 3 Nov 2014 09:32:56 +0000 (01:32 -0800)
committerSage Weil <sage@redhat.com>
Wed, 5 Nov 2014 09:06:02 +0000 (01:06 -0800)
Signed-off-by: Sage Weil <sage@redhat.com>
src/common/str_map.cc
src/include/str_map.h
src/mon/Monitor.h

index 719f94fc2cc326f996da3909b78b3926fb18cb03..b731af334d40ac71ae436d275b240c36283f6a4e 100644 (file)
@@ -128,3 +128,32 @@ string get_str_map_key(
   }
   return string();
 }
+
+// This function's only purpose is to check whether a given map has only
+// ONE key with an empty value (which would mean that 'get_str_map()' read
+// a map in the form of 'VALUE', without any KEY/VALUE pairs) and, in such
+// event, to assign said 'VALUE' to a given 'def_key', such that we end up
+// with a map of the form "m = { 'def_key' : 'VALUE' }" instead of the
+// original "m = { 'VALUE' : '' }".
+int get_conf_str_map_helper(
+    const string &str,
+    ostringstream &oss,
+    map<string,string> *m,
+    const string &def_key)
+{
+  int r = get_str_map(str, m);
+
+  if (r < 0) {
+    return r;
+  }
+
+  if (r >= 0 && m->size() == 1) {
+    map<string,string>::iterator p = m->begin();
+    if (p->second.empty()) {
+      string s = p->first;
+      m->erase(s);
+      (*m)[def_key] = s;
+    }
+  }
+  return r;
+}
index c2a8778583f15e5f7ab4d3aa6bf6667f3f6b9cfd..4b739ef584ff1778020c4c4d443494249fe9c7f7 100644 (file)
@@ -134,4 +134,17 @@ extern std::string get_str_map_key(
     const std::string &key,
     const std::string *fallback_key = NULL);
 
+
+// This function's only purpose is to check whether a given map has only
+// ONE key with an empty value (which would mean that 'get_str_map()' read
+// a map in the form of 'VALUE', without any KEY/VALUE pairs) and, in such
+// event, to assign said 'VALUE' to a given 'def_key', such that we end up
+// with a map of the form "m = { 'def_key' : 'VALUE' }" instead of the
+// original "m = { 'VALUE' : '' }".
+int get_conf_str_map_helper(
+    const std::string &str,
+    std::ostringstream &oss,
+    std::map<std::string,std::string> *m,
+    const std::string &def_key);
+
 #endif
index 1a3d98bd7abb2de5795e0964090b39240ae1d223..45a1a714238adab67268d4d8727f252053c34531 100644 (file)
@@ -1020,47 +1020,4 @@ struct MonCommand {
 };
 WRITE_CLASS_ENCODER(MonCommand)
 
-// Having this here is less than optimal, but we needed to keep it
-// somewhere as to avoid code duplication, as it will be needed both
-// on the Monitor class and the LogMonitor class.
-//
-// We are attempting to avoid code duplication in the event that
-// changing how the mechanisms currently work will lead to unnecessary
-// issues, resulting from the need of changing this function in multiple
-// places.
-//
-// This function is just a helper to perform a task that should not be
-// needed anywhere else besides the two functions that shall call it.
-//
-// This function's only purpose is to check whether a given map has only
-// ONE key with an empty value (which would mean that 'get_str_map()' read
-// a map in the form of 'VALUE', without any KEY/VALUE pairs) and, in such
-// event, to assign said 'VALUE' to a given 'def_key', such that we end up
-// with a map of the form "m = { 'def_key' : 'VALUE' }" instead of the
-// original "m = { 'VALUE' : '' }".
-static inline int get_conf_str_map_helper(
-    const string &str,
-    ostringstream &oss,
-    map<string,string> *m,
-    const string &def_key)
-{
-  int r = get_str_map(str, m);
-
-  if (r < 0) {
-    generic_derr << __func__ << " error: " << oss.str() << dendl;
-    return r;
-  }
-
-  if (r >= 0 && m->size() == 1) {
-    map<string,string>::iterator p = m->begin();
-    if (p->second.empty()) {
-      string s = p->first;
-      m->erase(s);
-      (*m)[def_key] = s;
-    }
-  }
-  return r;
-}
-
-
 #endif