question

Upvotes
Accepted
40 2 1 7

Are enumtype.def DISPLAY strings case sensitive?

I'm using RTSDK EMA C++ library to post data to the RCC. For ENUM type FIDs I call the FieldList::addEnum method which takes a short int as the value. To get the int value from an ENUM string I preprocess the data with a Python program that converts enumtype.def into a nested dictionary structure that can be used to lookup the VALUE integer from a FID and a DISPLAY string, where VALUE and DISPLAY refer to the column headers used in enumtype.def conversion tables. This all works.

My question is, when matching an ENUM string to values in the DISPLAY column, should the matching be case-sensitive or case-insensitive?

-----

Also, is there a better way to do this? Does the EMA lib have a way to convert an ENUM string into an integer?

Thanks,

Jeff



#technologyema-apienum
icon clock
10 |1500

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

Upvote
Accepted
23.1k 60 15 21
Jeff, I still don't understand why you would need to match String value to a value in enum file - since a better way would be to match the raw integer value to the enum. Either ways, the DISPLAY values are case sensitive.
icon clock
10 |1500

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

Upvotes
23.1k 60 15 21

Hi @jeff.birkel,

The data for enums is carried on the wire as in integer - its the SDK or application which converts the integer to a string. Here is a sample dump from EMA consumer application without any conversion:

RefreshMsg
  streamId="5"
  domain="MarketPrice Domain"
  solicited
  RefreshComplete
  state="Open / Ok / None / ''"
  itemGroup="00 02"
  permissionData="03 01 01 52 6c"
  name="CAD="
  nameType="1"
  serviceId="257"
  serviceName="ELEKTRON_DD"
  Payload dataType="FieldList"
    FieldList FieldListNum="99" DictionaryId="1"
       FieldEntry fid="1" name="PROD_PERM" dataType="UInt" value="526"
       FieldEntry fid="2" name="RDNDISPLAY" dataType="UInt" value="153"
       FieldEntry fid="3" name="DSPLY_NAME" dataType="Rmtes" value="BARCLAYS     LON"
       FieldEntry fid="5" name="TIMACT" dataType="Time" value="17:19:00:000:000:000"
       FieldEntry fid="11" name="NETCHNG_1" dataType="Real" value="0.0036"
       FieldEntry fid="12" name="HIGH_1" dataType="Real" value="1.3804"
       FieldEntry fid="13" name="LOW_1" dataType="Real" value="1.3709"
       FieldEntry fid="15" name="CURRENCY" dataType="Enum" value="124"
       FieldEntry fid="17" name="ACTIV_DATE" dataType="Date" value="24 MAR 2023"
       FieldEntry fid="19" name="OPEN_PRC" dataType="Real" value="1.3715"
       FieldEntry fid="23" name="BID_1" dataType="Real" value="1.3748"
       FieldEntry fid="24" name="BID_2" dataType="Real" value="1.3750"
       FieldEntry fid="25" name="ASK" dataType="Real" value="1.3753"
       FieldEntry fid="26" name="ASK_1" dataType="Real" value="1.3752"
       FieldEntry fid="27" name="ASK_2" dataType="Real" value="1.3751"
       FieldEntry fid="32" name="ACVOL_1" dataType="Real" value="61584.0"
       FieldEntry fid="53" name="TRD_UNITS" dataType="Enum" value="4"
       FieldEntry fid="56" name="PCTCHNG" dataType="Real" value="0.26"
       FieldEntry fid="105" name="BCKGRNDPAG" dataType="Rmtes" value="BCFX"
       FieldEntry fid="114" name="BID_NET_CH" dataType="Real" value="0.0036"
       FieldEntry fid="115" name="BID_TICK_1" dataType="Enum" value="1"
       FieldEntry fid="134" name="MID_PRICE" dataType="Real" value="1.3751"
...
icon clock
10 |1500

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

Upvotes
40 2 1 7

Hi Gurpreet,

Thank you for your response.

Yes, I know the integer value goes over the wire. Currently my application converts ENUM strings to integers. My question is when I do the conversion by matching the unconverted ENUM string, for example "MID", to a DISPLAY string in enumtype.def, should the matching be case-sensitive or case-insensitive?

Currently I do it case-sensitive and I am wondering if that will fail in some cases?

Thanks,

Jeff


icon clock
10 |1500

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

Upvotes
40 2 1 7

Case-sensitive. Thank you.

Just to explain what I am doing, my company collects data from public web pages for Refintiv, and then we submit the data to the Refinitiv Contribution Channel (RCC) through a program I wrote using EMA classes in the RTSDK. When we collect a string value like "MID" I need to convert it to an integer before sending it. So that's what I am doing. For ENUM types I match a collected string to a DISPLAY value, then I send the associated integer to Refinitiv via the RCC.

Thank you for your answer.

Jeff


icon clock
10 |1500

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

Upvote
80.9k 264 53 75

@jeff.birkel

EMA provides the refinitiv::ema::rdm::DataDictionary class used to parse the dictionary files (RDMFieldDictionary and enumtype.def). You can use it to retrieve dictionary and enum definitions.

For example, you can use it to retrieve an enum value from a display string. The sample code looks like this:

bool FindEnumValue(DataDictionary& dictionary, int fieldId, EmaString& display, int& enumValue) {
        const EnumTypeTable& enumTable = dictionary.getEntry(fieldId).getEnumTypeTable();
        const EmaVector<EnumType>& table = enumTable.getEnumTypes();
        bool found = false;
        for (int i = 0; i < table.size(); i++) {
            const EnumType& enumData = table[i];
            //printf("%d: %s\n", enumData.getValue(), enumData.getDisplay().c_str());            
            if (display == enumData.getDisplay()) {
                found = true;
                enumValue = enumData.getValue();
                break;
            }
        }
        return found;
}
//Main
DataDictionary dictionary;

dictionary.loadEnumTypeDictionary("enumtype.def");
dictionary.loadFieldDictionary("RDMFieldDictionary");
int enumValue;
bool found = FindEnumValue(dictionary, 4, EmaString("SET"), enumValue);
if (found == true) {
    cout << enumValue << endl;
}
else {
    cout << "not found" << endl;
}

It uses the for loop to iterate the EnumType vector to find an enum value for a display string.

Because it returns a vector, the performance is not good. You can create a hash table or a map from those enum values and use the hash table or map instead.

icon clock
10 |1500

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

@Jirapongse Thank you for the sample code!

Upvotes
40 2 1 7

@raksina.samasiri The answer to my question was "case-sensitive" but I no longer see that comment in the thread so I am unable to accept it. The comments about enum format over the wire and the sample code were helpful but do not directly respond to the question.

icon clock
10 |1500

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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