]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/rgw/rgw_tag.cc
import quincy beta 17.1.0
[ceph.git] / ceph / src / rgw / rgw_tag.cc
index f43a1824868562dc226eaf411cd031dcde1d8a31..f7e52592f7711dc9dd05aaea042f87671000b6e2 100644 (file)
 #include "rgw_tag.h"
 #include "rgw_common.h"
 
-bool RGWObjTags::add_tag(const string&key, const string& val){
-  return tag_map.emplace(std::make_pair(key,val)).second;
+using namespace std;
+
+void RGWObjTags::add_tag(const string& key, const string& val){
+  tag_map.emplace(std::make_pair(key,val));
 }
 
-bool RGWObjTags::emplace_tag(std::string&& key, std::string&& val){
-  return tag_map.emplace(std::move(key), std::move(val)).second;
+void RGWObjTags::emplace_tag(std::string&& key, std::string&& val){
+  tag_map.emplace(std::move(key), std::move(val));
 }
 
 int RGWObjTags::check_and_add_tag(const string&key, const string& val){
@@ -26,15 +28,15 @@ int RGWObjTags::check_and_add_tag(const string&key, const string& val){
     return -ERR_INVALID_TAG;
   }
 
-  // if we get a conflicting key, either the XML is malformed or the user
-  // supplied an invalid string
-  if (!add_tag(key,val))
-    return -EINVAL;
+  add_tag(key,val);
 
   return 0;
 }
 
 int RGWObjTags::set_from_string(const string& input){
+  if (input.empty()) {
+    return 0;
+  }
   int ret=0;
   vector <string> kvs;
   boost::split(kvs, input, boost::is_any_of("&"));
@@ -53,3 +55,13 @@ int RGWObjTags::set_from_string(const string& input){
   }
   return ret;
 }
+
+void RGWObjTags::dump(Formatter *f) const
+{
+  f->open_object_section("tagset");
+  for (auto& tag: tag_map){
+    f->dump_string(tag.first.c_str(), tag.second);
+  }
+  f->close_section();
+}
+