MCPcopy Create free account
hub / github.com/apache/qpid-proton / encode

Method encode

cpp/src/encoder.cpp:54–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54bool encoder::encode(char* buffer, size_t& size) {
55 internal::state_guard sg(*this); // In case of error
56 ssize_t result = pn_data_encode(pn_object(), buffer, size);
57 if (result == PN_OVERFLOW) {
58 result = pn_data_encoded_size(pn_object());
59 if (result >= 0) {
60 size = size_t(result);
61 return false;
62 }
63 }
64 check(result);
65 size = size_t(result);
66 sg.cancel(); // Don't restore state, all is well.
67 pn_data_clear(pn_object());
68 return true;
69}
70
71void encoder::encode(std::string& s) {
72 s.resize(std::max(s.capacity(), size_t(1))); // Use full capacity, ensure not empty

Callers 5

message_encodeMethod · 0.45
test_encoder_primitivesFunction · 0.45
test_message_reuseFunction · 0.45
message_encodeMethod · 0.45
pni_sasl_impl_encodeFunction · 0.45

Calls 8

pn_data_encoded_sizeFunction · 0.85
pn_data_clearFunction · 0.85
capacityMethod · 0.80
checkFunction · 0.70
pn_data_encodeFunction · 0.50
cancelMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by 2

test_encoder_primitivesFunction · 0.36
test_message_reuseFunction · 0.36