groupId RsslBuffer type to std::string

tinmyo.win
tinmyo.win Newcomer

Below is Description of groupId:

The groupId with which this information is associated.
This is typically represented as a series of 2-byte unsigned integers
(i.e. two-byte unsigned integers written directly next to each other in
the buffer). The example provided in the RANGE / EXAMPLE
column of this table shows such a series, with inserted dots to help
indicate two-byte value. When encoded into a buffer, do not include
dots.

What is the proper way to copy/convert groupId into std::string so that groupId be stored and logged with human readable format?

I have tried the following:

const std::string groupId{msg->refreshMsg.groupId.data, msg->refreshMsg.groupId.length};

const std::string_view groupId{msg->refreshMsg.groupId.data, msg->refreshMsg.groupId.length};

Best Answer

  • nick.zincone
    nick.zincone admin
    Answer ✓

    Hi @tinmyo.win,

    The buffer can contain a series of 2-byte blocks, in network byte order, representing the groupID. As such, try iterating through the buffer and assigning the 2 bytes into an unsigned short. That is

    image

    Note: ETA also has an example of how they dump the groupID using the 'xmlDumpMsgBegin' function.

    Here is an example of the output from above:

    image

Answers