]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_tag.h
bump version to 18.2.2-pve1
[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 #pragma once
5
6 #include <string>
7 #include <include/types.h>
8 #include <map>
9
10 class RGWObjTags
11 {
12 public:
13 using tag_map_t = std::multimap <std::string, std::string>;
14
15 protected:
16 tag_map_t tag_map;
17
18 uint32_t max_obj_tags{10};
19 static constexpr uint32_t max_tag_key_size{128};
20 static constexpr uint32_t max_tag_val_size{256};
21
22 public:
23 RGWObjTags() = default;
24 RGWObjTags(uint32_t max_obj_tags):max_obj_tags(max_obj_tags) {}
25
26 void encode(bufferlist& bl) const {
27 ENCODE_START(1,1,bl);
28 encode(tag_map, bl);
29 ENCODE_FINISH(bl);
30 }
31
32 void decode(bufferlist::const_iterator &bl) {
33 DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl);
34 decode(tag_map,bl);
35 DECODE_FINISH(bl);
36 }
37
38 void dump(Formatter *f) const;
39 void add_tag(const std::string& key, const std::string& val="");
40 void emplace_tag(std::string&& key, std::string&& val);
41 int check_and_add_tag(const std::string& key, const std::string& val="");
42 size_t count() const {return tag_map.size();}
43 int set_from_string(const std::string& input);
44 void clear() { tag_map.clear(); }
45 bool empty() const noexcept { return tag_map.empty(); }
46 const tag_map_t& get_tags() const {return tag_map;}
47 tag_map_t& get_tags() {return tag_map;}
48 };
49 WRITE_CLASS_ENCODER(RGWObjTags)