]> git.proxmox.com Git - ceph.git/blame - ceph/src/rgw/rgw_tag.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / rgw / rgw_tag.h
CommitLineData
11fdf7f2 1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
9f95a23c 2// vim: ts=8 sw=2 smarttab ft=cpp
11fdf7f2 3
224ce89b
WB
4#ifndef RGW_TAG_H
5#define RGW_TAG_H
6
7#include <string>
8#include <include/types.h>
9#include <boost/container/flat_map.hpp>
10
224ce89b
WB
11class RGWObjTags
12{
9f95a23c 13public:
224ce89b 14 using tag_map_t = boost::container::flat_map <std::string, std::string>;
9f95a23c
TL
15
16protected:
224ce89b 17 tag_map_t tag_map;
9f95a23c
TL
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
224ce89b 23 public:
9f95a23c
TL
24 RGWObjTags() = default;
25 RGWObjTags(uint32_t max_obj_tags):max_obj_tags(max_obj_tags) {}
224ce89b
WB
26
27 void encode(bufferlist& bl) const {
28 ENCODE_START(1,1,bl);
11fdf7f2 29 encode(tag_map, bl);
224ce89b
WB
30 ENCODE_FINISH(bl);
31 }
32
11fdf7f2 33 void decode(bufferlist::const_iterator &bl) {
224ce89b 34 DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl);
11fdf7f2 35 decode(tag_map,bl);
224ce89b
WB
36 DECODE_FINISH(bl);
37 }
38
39 void dump(Formatter *f) const;
40 bool add_tag(const std::string& key, const std::string& val="");
11fdf7f2 41 bool emplace_tag(std::string&& key, std::string&& val);
224ce89b
WB
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);
11fdf7f2
TL
45 void clear() { tag_map.clear(); }
46 bool empty() const noexcept { return tag_map.empty(); }
224ce89b 47 const tag_map_t& get_tags() const {return tag_map;}
f67539c2 48 tag_map_t& get_tags() {return tag_map;}
224ce89b
WB
49};
50WRITE_CLASS_ENCODER(RGWObjTags)
51
52#endif /* RGW_TAG_H */