Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / rgw / rgw_tag.h
1 #ifndef RGW_TAG_H
2 #define RGW_TAG_H
3
4 #include <string>
5 #include <include/types.h>
6 #include <boost/container/flat_map.hpp>
7
8 #include "rgw_common.h"
9
10 class RGWObjTags
11 {
12  protected:
13   using tag_map_t = boost::container::flat_map <std::string, std::string>;
14   tag_map_t tag_map;
15  public:
16   RGWObjTags() {}
17   ~RGWObjTags() {}
18
19   void encode(bufferlist& bl) const {
20     ENCODE_START(1,1,bl);
21     ::encode(tag_map, bl);
22     ENCODE_FINISH(bl);
23   }
24
25   void decode(bufferlist::iterator &bl) {
26     DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl);
27     ::decode(tag_map,bl);
28     DECODE_FINISH(bl);
29   }
30
31   void dump(Formatter *f) const;
32   bool add_tag(const std::string& key, const std::string& val="");
33   int check_and_add_tag(const std::string& key, const std::string& val="");
34   size_t count() const {return tag_map.size();}
35   int set_from_string(const std::string& input);
36   const tag_map_t& get_tags() const {return tag_map;}
37 };
38 WRITE_CLASS_ENCODER(RGWObjTags)
39
40 #endif /* RGW_TAG_H */