diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/rgw/rgw_tag.h | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/rgw/rgw_tag.h')
-rw-r--r-- | src/rgw/rgw_tag.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/rgw/rgw_tag.h b/src/rgw/rgw_tag.h new file mode 100644 index 000000000..88a4e6652 --- /dev/null +++ b/src/rgw/rgw_tag.h @@ -0,0 +1,52 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab ft=cpp + +#ifndef RGW_TAG_H +#define RGW_TAG_H + +#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) + +#endif /* RGW_TAG_H */ |