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