私はプロジェクトに取り組んでおり、Qpid を介してバイト配列を送信できるようにする必要がありますが、Variant は配列が何であるかわかりません。unit8 の Variant::list や Variant::string などの Variant にバイト配列を変換する方法はありますか?その後、応答を取得したら、文字列またはリストをバイトに戻すことができます。 []?
ありがとう、
を使用しqpid::types::Variant::List
ます。すべてのバイト (を使用していると思いますunsigned char
) を変換uint8_t
してから、リストに追加します。
例:
unsigned char bytesToSend[] = {104, 101, 108, 108, 111}; /* "hello" */
int lengthOfArray = sizeof(bytesToSend)/sizeof(byteToSend[0]);
qpid::types::Variant::List lstToSend;
for(int i = 0; i < lengthOfArray; i++){
uint8_t thisByte = (uint8_t)bytesToSend[i];
lstToSend.push_back(qpid::types::Variant(thisByte));
}
qpid::messaging::Message msg;
qpid::messaging::encode(lstToSend, msg);
yourSender.send(msg, false); /* change false to true if you want to sync with the broker. */
私はこれをテストしていませんが、一般的な概要を提供する必要があります。
他にご不明な点がございましたら、お気軽にお問い合わせください。できる限りお答えいたします。
参考文献: