Skip to content

Commit 7c80966

Browse files
trondndaverigby
authored andcommitted
Add getBuffer() methods to protocol classes
Most of the classes contains a convenience method named getBuffer() which allows the user to get a "blob" containing the encoded data. This patch adds the method to those classes which didn't have the method. Change-Id: I1cc1921e3afe58ee2e426dafc9b734cd534e1996 Reviewed-on: http://review.couchbase.org/c/kv_engine/+/138032 Tested-by: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent ef70471 commit 7c80966

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

include/memcached/protocol_binary.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,10 @@ class DcpOpenPayload {
612612
*/
613613
static const uint32_t IncludeDeletedUserXattrs = 256;
614614

615+
cb::const_byte_buffer getBuffer() const {
616+
return {reinterpret_cast<const uint8_t*>(this), sizeof(*this)};
617+
}
618+
615619
protected:
616620
uint32_t seqno = 0;
617621
uint32_t flags = 0;
@@ -728,6 +732,10 @@ class DcpStreamReqPayload {
728732
DcpStreamReqPayload::snap_end_seqno = htonll(snap_end_seqno);
729733
}
730734

735+
cb::const_byte_buffer getBuffer() const {
736+
return {reinterpret_cast<const uint8_t*>(this), sizeof(*this)};
737+
}
738+
731739
protected:
732740
uint32_t flags = 0;
733741
uint32_t reserved = 0;
@@ -748,6 +756,10 @@ class DcpStreamEndPayload {
748756
DcpStreamEndPayload::status = htonl(uint32_t(status));
749757
}
750758

759+
cb::const_byte_buffer getBuffer() const {
760+
return {reinterpret_cast<const uint8_t*>(this), sizeof(*this)};
761+
}
762+
751763
protected:
752764
/**
753765
* Note the following is maintained in network/big endian
@@ -1671,6 +1683,10 @@ struct GetMetaResponse {
16711683
seqno(seqno),
16721684
datatype(datatype) {
16731685
}
1686+
1687+
cb::const_byte_buffer getBuffer() const {
1688+
return {reinterpret_cast<const uint8_t*>(this), sizeof(*this)};
1689+
}
16741690
};
16751691

16761692
#pragma pack()
@@ -1716,6 +1732,10 @@ class ReturnMetaPayload {
17161732
ReturnMetaPayload::expiration = htonl(expiration);
17171733
}
17181734

1735+
cb::const_byte_buffer getBuffer() const {
1736+
return {reinterpret_cast<const uint8_t*>(this), sizeof(*this)};
1737+
}
1738+
17191739
protected:
17201740
uint32_t mutation_type = 0;
17211741
uint32_t flags = 0;
@@ -1783,6 +1803,10 @@ class CompactDbPayload {
17831803
return align_pad1 == 0 && align_pad3 == 0;
17841804
}
17851805

1806+
cb::const_byte_buffer getBuffer() const {
1807+
return {reinterpret_cast<const uint8_t*>(this), sizeof(*this)};
1808+
}
1809+
17861810
protected:
17871811
uint64_t purge_before_ts = 0;
17881812
uint64_t purge_before_seq = 0;

0 commit comments

Comments
 (0)