question

Upvotes
Accepted
35 3 3 9

Field length VS String Null terminator

Hi,

I have a custom application (EMA C++ based) sending a post request containing a field value as follows:

<fieldEntry fieldId="393" data="4154 3030 3030 3338 3338 3634 00"/>

The definition of the field in concern is as follows:

OFFCL_CODE "OFFICIAL CODE" 78 NULL ALPHANUMERIC 12 RMTES_STRING 12

The length of the string is 12, but the payload contains 13 bytes, because of the null terminating character.

I'm quite sure I am using the EMA library in an incorrect way, would you please confirm?

My approach is as follows:

  • emaBuff is of type refinitiv::ema::access::EmaBuffer
  • value is of type refinitiv::ema::access::EmaString
  • res is of type refinitiv::ema::access::FieldList
emaBuff.append(value.c_str(), value.length() + 1);
res->addRmtes(393, emaBuff);

From the EMA samples, I see that EMABuffer is built in different ways, so I'm not sure about the correct one. Example:

Elektron-SDK-1.3.0.L1.linux\setup\Cpp-C\Ema\TestTools\QATools\Series100Provider100-ProvFunc-002\IProvider.cpp, line 139

EmaBuffer("5", 2)

In other cases (the majority), the length passed to the buffer is the string length without the null terminating character.

Thanks

Best Regards,

Paolo

elektronrefinitiv-realtimeelektron-sdkrrtema-apifieldsc++posting
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

1 Answer

Upvotes
Accepted
20.3k 73 10 20

Hi @Paolo Parlapiano

Looking at the EMACPP_DevGuide, for a similar usage scenario, I can see the EmaBuffer length is specified as equal to the string length - not +1.

In the code snippet for section 5.1.7 Interactive Provider Example: Working with the OmmProvider Class and section 5.2.3 Interactive Example: OmmProviderClient

addRmtes( 212, EmaBuffer( "Market Maker", 12 ) )

Likewise in several examples too including e.g. example IProvider\200_Series\280_MP_Perf\

addRmtes( 296, EmaBuffer("BOS", 3) )


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Thanks for the answer.
Click below to post an Idea Post Idea