]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_tag.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / rgw / rgw_tag.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
3
4 #ifndef RGW_TAG_H
5 #define RGW_TAG_H
6
7 #include <string>
8 #include <include/types.h>
9 #include <map>
10
11 class RGWObjTags
12 {
13 public:
14 using tag_map_t = std::multimap <std::string, std::string>;
15
16 protected:
17 tag_map_t tag_map;
18
19 uint32_t max_obj_tags{10};
20 static constexpr uint32_t max_tag_key_size{128};
21 static constexpr uint32_t max_tag_val_size{256};
22
23 public:
24 RGWObjTags() = default;
25 RGWObjTags(uint32_t max_obj_tags):max_obj_tags(max_obj_tags) {}
26
27 void encode(bufferlist& bl) const {
28 ENCODE_START(1,1,bl);
29 encode(tag_map, bl);
30 ENCODE_FINISH(bl);
31 }
32
33 void decode(bufferlist::const_iterator &bl) {
34 DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl);
35 decode(tag_map,bl);
36 DECODE_FINISH(bl);
37 }
38
39 void dump(Formatter *f) const;
40 void add_tag(const std::string& key, const std::string& val="");
41 void emplace_tag(std::string&& key, std::string&& val);
42 int check_and_add_tag(const std::string& key, const std::string& val="");
43 size_t count() const {return tag_map.size();}
44 int set_from_string(const std::string& input);
45 void clear() { tag_map.clear(); }
46 bool empty() const noexcept { return tag_map.empty(); }
47 const tag_map_t& get_tags() const {return tag_map;}
48 tag_map_t& get_tags() {return tag_map;}
49 };
50 WRITE_CLASS_ENCODER(RGWObjTags)
51
52 #endif /* RGW_TAG_H */