I am using Apache Thrift RPC (Compiled to C++) mechanism to communicate with Apache Flume. I have to use specific API that this platform supplies.
I want to send binary data, But the RPC function accepts only std::string as a parameter. And because of that I only able to send that binary data that comes before the first appearance of 0x00.
u_char bin[10] = {'a','b',1,'d','e',0,'2','3','4','5'};
// Takes only the first 5 bytes, and sets a length of 5
string art_test((const char *)bin);
I searched through the source code and the function I call casts the str.data() into (uint8_t*) and sends the data of length str.size().
uint32_t ssize = static_cast<uint32_t>(str.size());
trans_->write((uint8_t*)str.data(), ssize);
Is there a way to create a 'binary string', with uint8_t as a data and with specified length? Maybe even create the in memory representation of string of my own with the desired binary data.