]>
Commit | Line | Data |
---|---|---|
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 | |
1e59de90 | 4 | #pragma once |
224ce89b WB |
5 | |
6 | #include <string> | |
7 | #include <include/types.h> | |
20effc67 | 8 | #include <map> |
224ce89b | 9 | |
224ce89b WB |
10 | class RGWObjTags |
11 | { | |
9f95a23c | 12 | public: |
20effc67 | 13 | using tag_map_t = std::multimap <std::string, std::string>; |
9f95a23c TL |
14 | |
15 | protected: | |
224ce89b | 16 | tag_map_t tag_map; |
9f95a23c TL |
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 | ||
224ce89b | 22 | public: |
9f95a23c TL |
23 | RGWObjTags() = default; |
24 | RGWObjTags(uint32_t max_obj_tags):max_obj_tags(max_obj_tags) {} | |
224ce89b WB |
25 | |
26 | void encode(bufferlist& bl) const { | |
27 | ENCODE_START(1,1,bl); | |
11fdf7f2 | 28 | encode(tag_map, bl); |
224ce89b WB |
29 | ENCODE_FINISH(bl); |
30 | } | |
31 | ||
11fdf7f2 | 32 | void decode(bufferlist::const_iterator &bl) { |
224ce89b | 33 | DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl); |
11fdf7f2 | 34 | decode(tag_map,bl); |
224ce89b WB |
35 | DECODE_FINISH(bl); |
36 | } | |
37 | ||
38 | void dump(Formatter *f) const; | |
20effc67 TL |
39 | void add_tag(const std::string& key, const std::string& val=""); |
40 | void emplace_tag(std::string&& key, std::string&& val); | |
224ce89b WB |
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); | |
11fdf7f2 TL |
44 | void clear() { tag_map.clear(); } |
45 | bool empty() const noexcept { return tag_map.empty(); } | |
224ce89b | 46 | const tag_map_t& get_tags() const {return tag_map;} |
f67539c2 | 47 | tag_map_t& get_tags() {return tag_map;} |
224ce89b WB |
48 | }; |
49 | WRITE_CLASS_ENCODER(RGWObjTags) |