]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
include/str_map.h removed unnecessary function overloading of 7266/head
authorSahithi R V <tansy.rv@gmail.com>
Mon, 18 Jan 2016 17:23:24 +0000 (22:53 +0530)
committerSahithi R V <tansy.rv@gmail.com>
Fri, 29 Jan 2016 12:22:50 +0000 (17:52 +0530)
get_str_map()

Signed-off-by: Sahithi R V <sahithi.rv1@gmail.com>
tests successful

Signed-off-by: Sahithi R V <sahithi.rv1@gmail.com>
src/common/str_map.cc
src/include/str_map.h
src/kv/RocksDBStore.cc
src/test/common/test_str_map.cc

index bd68612aa135e42883a6c460adf3ebc0200641f4..4605302e53af33e765f037b4389b90ba7476cdb6 100644 (file)
@@ -51,7 +51,7 @@ int get_json_str_map(
   } catch (json_spirit::Error_position &e) {
     if (fallback_to_plain) {
       // fallback to key=value format
-      get_str_map(str, "\t\n ", str_map);
+      get_str_map(str, str_map, "\t\n ");
     } else {
       return -EINVAL;
     }
@@ -75,8 +75,8 @@ string trim(const string& str) {
 
 int get_str_map(
     const string &str,
-    const char *delims,
-    map<string,string> *str_map)
+    map<string,string> *str_map,
+    const char *delims)
 {
   list<string> pairs;
   get_str_list(str, delims, pairs);
@@ -94,14 +94,6 @@ int get_str_map(
   return 0;
 }
 
-int get_str_map(
-    const string &str,
-    map<string,string> *str_map)
-{
-  const char *delims = ",;\t\n ";
-  return get_str_map(str, delims, str_map);
-}
-
 string get_str_map_value(
     const map<string,string> &str_map,
     const string &key,
index 0bd9de31661e6edaf96af1038cab7e8fadfa8602..6a0370d1299cb6782d222d916e41bf073d88306e 100644 (file)
@@ -17,6 +17,8 @@
 #ifndef CEPH_STRMAP_H
 #define CEPH_STRMAP_H
 
+#define CONST_DELIMS ",;\t\n "
+
 #include <map>
 #include <string>
 #include <sstream>
@@ -89,12 +91,8 @@ extern int get_json_str_map(
  */
 extern int get_str_map(
     const std::string &str,
-    const char *delims,
-    std::map<std::string,std::string> *str_map);
-
-extern int get_str_map(
-    const std::string &str,
-    std::map<std::string,std::string> *str_map);
+    std::map<std::string,std::string> *str_map,
+    const char *delims = CONST_DELIMS);
 
 /**
  * Returns the value of **key** in **str_map** if available.
index 80f7fc4828915e2f4f60b959554ecc860b224f8f..649daf7775de12a9d5d018bff923f8f6b4e07d10 100644 (file)
@@ -118,7 +118,7 @@ int RocksDBStore::tryInterpret(const string key, const string val, rocksdb::Opti
 int RocksDBStore::ParseOptionsFromString(const string opt_str, rocksdb::Options &opt)
 {
   map<string, string> str_map;
-  int r = get_str_map(opt_str, ",\n;", &str_map);
+  int r = get_str_map(opt_str, &str_map, ",\n;");
   if (r < 0)
     return r;
   map<string, string>::iterator it;
index 5a324ba9b31e513b5eeb6ce7312340f66ef661c4..e96c792a4780e39e51dcc444f3b61c3a19e03efe 100644 (file)
@@ -58,7 +58,7 @@ TEST(str_map, plaintext) {
   }
   {
     map<string,string> str_map;
-    ASSERT_EQ(0, get_str_map(" key1=val1; key2=\tval2; key3\t = \t val3; \n ", "\n;", &str_map));
+    ASSERT_EQ(0, get_str_map(" key1=val1; key2=\tval2; key3\t = \t val3; \n ", &str_map, "\n;"));
     ASSERT_EQ(4u, str_map.size());
     ASSERT_EQ("val1", str_map["key1"]);
     ASSERT_EQ("val2", str_map["key2"]);