How to get all possible enum values in RFA C++?

In RFA C++, I can use
rfa::rdm::RDMFieldDictionary::displayValueFor(fieldId,enumVal) to get the
textual display value for an enum integer value ((e.g. 840 => "USD" for the
CURRENCY(15) field)).
However, I would like to find the integer value for a textual display value
(i.e. "USD" => 840) and get all the possible enum values for a FID.
How can I do this in RFA C++?
Best Answer
-
RFA C++ doesn't provide interfaces to convert a textual display string to the
integer value or get all possible enum values.However, you can modify the source code files (RDMDict.cpp, and
RDMDictDef.cpp in Examples\Common folder) in RFA C++ package to support this
behaviour.- Adding a new std::map into Examples\Common\RDMDictDef.h
file to increase the searching performance
// RFA Includes
#include "Data/DataBuffer.h"
#include <list>
#include <map>
typedef std::map< rfa::common::UInt16,
rfa::common::RFA_String > EnumValues;
typedef
std::map<rfa::common::RFA_String, rfa::common::UInt16> ExpandValues;
… - Declare
a new variable for the new map
protected:
EnumValues
_enumValMap;
ExpandValues
_exValMap; - Insert an enumeration into this map
void insertEnumVal()
{
_enumValMap.insert( EnumValues::value_type( _enumVal, _enumString ) );
_exValMap.insert(ExpandValues::value_type(_enumString,
_enumVal));
}
void insertEnumVal(
rfa::common::UInt16 enumVal, const rfa::common::RFA_String& enumString )
{
_enumString = enumString;
_enumValMap.insert( EnumValues::value_type( enumVal, _enumString ) );
_exValMap.insert(ExpandValues::value_type(_enumString,
enumVal));
} - Define a new function to search this map
class RDMEnumDef
{
public:
void
setDisplayName( rfa::common::RFA_String& s ) { _enumString = s; }
…
bool getEnumValueEx(const rfa::common::RFA_String&
s, rfa::common::UInt16& enumVal) const
{
ExpandValues::const_iterator cit = _exValMap.find( s );
if(cit != _exValMap.end())
{
enumVal = cit->second;
return true;
}else
{
return false;
}
}
…
}
To use this class, the application must include the
following headers:
#include "../Common/RDMDict.h"#include "../Common/RDMDictDef.h"
#include "../Common/RDMDictionaryDecoder.h"
Then, adding RDMDict.cpp, RDMDictDef.cpp,
and RDMDictionaryDecoder.cpp from Examples\Common directory into
your project.The following snippet shows how to use this class:
int main(int argc, char* argv[]){
RDMFieldDict
*_dict = new RDMFieldDict();RDMFileDictionaryDecoder
*_dictDecoder = new RDMFileDictionaryDecoder(*_dict);bool _ret =
_dictDecoder->load("c:\\var\\triarch\\RDMFieldDictionary",
"c:\\var\\triarch\\enumtype.def");
rfa::common::UInt16 _enum;//Find the integer value for a
textual display value_ret =
_dict->getFieldDef("RDN_EXCHID")->getEnumDef()->getEnumValueEx("CFS",
_enum);if (_ret == true)
printf("%d\n", _enum);else
printf("Not found");//Get all the possible
enum values for a FIDconst EnumValues& _enumMap
=
_dict->getFieldDef("RDN_EXCHID")->getEnumDef()->values();
for (EnumValues::const_iterator it = _enumMap.begin(); it != _enumMap.end();
++it)
std::cout << it->first << " => " <<
it->second.c_str() << '\n';…
}
You can use RDMNetworkDictionaryDecoder instead of RDMFileDictionaryDecoder
when downloading the data dictionary from the network.0 - Adding a new std::map into Examples\Common\RDMDictDef.h
Answers
-
RFA C++ does not provide any interface that would directly provide the functionality you are looking for. However, you can do it all yourself. For example, use the const RDMFidDef& getFidDef( Int32 fid ) and pass in the FID# you are interested in. Then iterate over all possible enum values using the RDMFidDef::displayValueFor( Int enumval ). Based on this iteration create a hash table of enum vals to enum strings.
Understand this may look "funny" as the range for the enum values is Int (64 bits) but from the practical point of view, the actual enum values are not larger than 2000 or so. Please see the enumtype.def file for details.
The above solution works with the network and local file dictionaries as long as RFA has loaded them.
You may also use the enumtype.def file, outside of RFA. Though the content of this file may be changing over time with some additions, the format of this file does not change at all. So your text processing tool will work with future releases.
Hope this helps.
0
Categories
- All Categories
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 684 Datastream
- 1.4K DSS
- 613 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 248 ETA
- 552 WebSocket API
- 37 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 630 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 26 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 191 TREP Infrastructure
- 228 TRKD
- 915 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 86 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛