]>
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 | |
224ce89b WB |
4 | #include <map> |
5 | #include <string> | |
6 | #include <iostream> | |
7 | ||
8 | #include "include/types.h" | |
9 | ||
10 | #include "rgw_tag_s3.h" | |
11 | ||
20effc67 TL |
12 | using namespace std; |
13 | ||
11fdf7f2 TL |
14 | void RGWObjTagEntry_S3::decode_xml(XMLObj *obj) { |
15 | RGWXMLDecoder::decode_xml("Key", key, obj, true); | |
16 | RGWXMLDecoder::decode_xml("Value", val, obj, true); | |
17 | } | |
224ce89b | 18 | |
11fdf7f2 TL |
19 | void RGWObjTagEntry_S3::dump_xml(Formatter *f) const { |
20 | encode_xml("Key", key, f); | |
21 | encode_xml("Value", val, f); | |
224ce89b | 22 | |
11fdf7f2 TL |
23 | if (key.empty()) { |
24 | throw RGWXMLDecoder::err("empty key"); | |
224ce89b WB |
25 | } |
26 | ||
11fdf7f2 TL |
27 | if (val.empty()) { |
28 | throw RGWXMLDecoder::err("empty val"); | |
224ce89b | 29 | } |
224ce89b WB |
30 | } |
31 | ||
11fdf7f2 TL |
32 | void RGWObjTagSet_S3::decode_xml(XMLObj *obj) { |
33 | vector<RGWObjTagEntry_S3> entries; | |
34 | ||
20effc67 TL |
35 | bool mandatory{false}; |
36 | RGWXMLDecoder::decode_xml("Tag", entries, obj, mandatory); | |
224ce89b | 37 | |
11fdf7f2 TL |
38 | for (auto& entry : entries) { |
39 | const std::string& key = entry.get_key(); | |
40 | const std::string& val = entry.get_val(); | |
20effc67 | 41 | add_tag(key,val); |
224ce89b | 42 | } |
224ce89b WB |
43 | } |
44 | ||
11fdf7f2 | 45 | int RGWObjTagSet_S3::rebuild(RGWObjTags& dest) { |
224ce89b | 46 | int ret; |
11fdf7f2 | 47 | for (const auto &it : tag_map){ |
224ce89b WB |
48 | ret = dest.check_and_add_tag(it.first, it.second); |
49 | if (ret < 0) | |
50 | return ret; | |
51 | } | |
52 | return 0; | |
53 | } | |
54 | ||
11fdf7f2 TL |
55 | void RGWObjTagging_S3::decode_xml(XMLObj *obj) { |
56 | RGWXMLDecoder::decode_xml("TagSet", tagset, obj, true); | |
224ce89b WB |
57 | } |
58 | ||
11fdf7f2 TL |
59 | void RGWObjTagSet_S3::dump_xml(Formatter *f) const { |
60 | for (const auto& tag : tag_map){ | |
61 | Formatter::ObjectSection os(*f, "Tag"); | |
62 | encode_xml("Key", tag.first, f); | |
63 | encode_xml("Value", tag.second, f); | |
224ce89b WB |
64 | } |
65 | } | |
66 |