}
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;
+}
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
};
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