]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_basic_types.h
1 #ifndef CEPH_RGW_BASIC_TYPES_H
2 #define CEPH_RGW_BASIC_TYPES_H
6 #include "include/types.h"
13 // cppcheck-suppress noExplicitConstructor
14 rgw_user(const std::string
& s
) {
17 rgw_user(const std::string
& tenant
, const std::string
& id
)
22 void encode(bufferlist
& bl
) const {
23 ENCODE_START(1, 1, bl
);
28 void decode(bufferlist::iterator
& bl
) {
35 void to_str(std::string
& str
) const {
36 if (!tenant
.empty()) {
37 str
= tenant
+ '$' + id
;
52 string
to_str() const {
58 void from_str(const std::string
& str
) {
59 size_t pos
= str
.find('$');
60 if (pos
!= std::string::npos
) {
61 tenant
= str
.substr(0, pos
);
62 id
= str
.substr(pos
+ 1);
69 rgw_user
& operator=(const string
& str
) {
74 int compare(const rgw_user
& u
) const {
75 int r
= tenant
.compare(u
.tenant
);
79 return id
.compare(u
.id
);
81 int compare(const string
& str
) const {
86 bool operator!=(const rgw_user
& rhs
) const {
87 return (compare(rhs
) != 0);
89 bool operator==(const rgw_user
& rhs
) const {
90 return (compare(rhs
) == 0);
92 bool operator<(const rgw_user
& rhs
) const {
93 if (tenant
< rhs
.tenant
) {
95 } else if (tenant
> rhs
.tenant
) {
101 WRITE_CLASS_ENCODER(rgw_user
)
106 void decode_json_obj(rgw_user
& val
, JSONObj
*obj
);
107 void encode_json(const char *name
, const rgw_user
& val
, Formatter
*f
);
109 inline ostream
& operator<<(ostream
& out
, const rgw_user
&u
) {