Copy operator not working in Quick Fast C ++

I am currently working on a copy operator. What I understand from the whole document and other material available on the net is that Quickfast maintains a dictionary that is used to enter short entries in a UDP message to validate the previous value.

for example: Let's say that in the below template we can have multiple MDEntries depending on the value of the NoMDEntries tag. Let's say we have a value of 2. What I did was I put the MDEntryType (with a copy of the oprerator) as 1 (some random value) in the first record, but for the second I didn't put any value. After I decode the message, the MDEntryType value should be 1 for both entries.

Do I understand correctly?

<template dictionary="1" id="1" name="MDIncRefreshSample_1">
 <string id="35" name="MessageType">
    <constant value="X"></constant>
 </string>     <string id="49" name="SenderCompID">
    <constant value="Client"></constant>
</string>     <string id="56" name="TargetCompID">
    <constant value="Server"></constant>
</string>     <uint32 id="34" name="MsgSeqNum"></uint32>
<uint64 id="52" name="SendingTime"></uint64>
<sequence name="MDEntries">
    <length id="268" name="NoMDEntries"></length>
    <uint32 id="279" name="MDUpdateAction">
        <copy value="1"></copy>
    </uint32>
    <string id="269" name="MDEntryType">
        <copy value="0"></copy>
    </string>
    <uint32 id="278" name="MDEntryID"></uint32>
    <uint32 id="48" name="SecurityID">
        <delta></delta>
    </uint32>
    <decimal id="270" name="MDEntryPx">
        <exponent>
            <default value="-2"></default>
        </exponent>
        <mantissa>
            <delta></delta>
        </mantissa>
    </decimal>
    <int32 id="271" name="MDEntrySize">
        <delta></delta>
    </int32>
    <string id="37" name="OrderID"></string>
    <uint32 id="273" name="MDEntryTime">
        <copy></copy>
    </uint32>
 </sequence>
 </template>

      

Now when I try to implement the above in my code, I cannot copy the value to the second entry. Here is the code snippet I used (help taken from testRoundTrip.cpp)

Created template:

  <templates> 
    <template dictionary="InstrumentReferenceData" 
     name="InstrumentReferenceData" id="3">  
     <typeRef name="instrumentreferencedata"/>  
     <uInt32 name="timestamp" id="52"> <delta/>    </uInt32>  
     <uInt32 name="srcId" id="50">      <copy/>    </uInt32>   
     <uInt32 name="seqNum" id="34">      <increment value="1"/>    </uInt32> 
     <uInt32 name="isix" id="48">      <delta/>    </uInt32>  
    <string name="isin" id="455">      <delta/>    </string> 
    <string name="exchId" id="207">      <copy/>    </string>  
    <string name="instGrp" id="1151">      <copy/>    </string>
    <string name="instTypCod" id="461">      <copy/>    </string>    
    <string name="currCode" id="15">      <copy/>    </string>    
    <decimal name="ticSiz" id="969">      <delta/>    </decimal>   
    <uInt32 name="setId" id="TBD">      <copy/>    </uInt32>  
     <sequence name="MDFeedTypes">    
     <length name="noOfStreams" id="1141"/>     
     <string name="streamType" id="1022">      <copy dictionary="template" />      
    </string>   
    <string name="streamService">      <copy/>      </string>        
     <string name="inetAddr">        <delta/>      </string>       
  <uInt32 name="port" id="TBD">        <delta/>      </uInt32>        
  <uInt32 name="mktDepth" id="264" presence="optional"/>   </uInt32>       
  <uInt32 name="mdBookType" id="1021" presence="optional"/>   </uInt32>
    </sequence>
    </template>
    </templates>

      

Post creation plus encoding and decoding: (I crossed out the value in the streamtype field only once)

 Messages::MessagePtr msg(new Messages::Message(templateRegistry->maxFieldCount()));
  msg->addField(identity_timestamp, Messages::FieldUInt32::create(1));

  msg->addField(identity_srcId, Messages::FieldUInt32::create(2));

  msg->addField(identity_seqNum, Messages::FieldUInt32::create(3));

  msg->addField(identity_isix, Messages::FieldUInt32::create(4));

  msg->addField(identity_isin, Messages::FieldAscii::create("isin"));

  msg->addField(identity_exchId, Messages::FieldAscii::create("exchId"));

  msg->addField(identity_instGrp, Messages::FieldAscii::create("instGrp"));

  msg->addField(identity_instTypCod, Messages::FieldAscii::create("instTypCod"));

  msg->addField(identity_currCode, Messages::FieldAscii::create("currCode"));

  msg->addField(identity_ticSiz, Messages::FieldDecimal::create(Decimal(123, -1)));

  msg->addField(identity_setId, Messages::FieldUInt32::create(5));

  lengthIdentity.setId("1141");
  Messages::SequencePtr sequence_MDFeedTypes(new Messages::Sequence(lengthIdentity, 2));
  Messages::FieldSetPtr entry(new Messages::FieldSet(6)); // todo Hardcoded 6?

  entry->addField(identity_streamType, Messages::FieldAscii::create("streamType"));    // Populated the value 1st time

  entry->addField(identity_streamService, Messages::FieldAscii::create("streamService"));

  entry->addField(identity_inetAddr, Messages::FieldAscii::create("inetAddr.com"));

  entry->addField(identity_port, Messages::FieldUInt32::create(2222));

  entry->addField(identity_mktDepth, Messages::FieldUInt32::create(10));



  sequence_MDFeedTypes->addEntry(Messages::FieldSetCPtr(entry));

  entry.reset(new Messages::FieldSet(6));

  entry->addField(identity_streamType, Messages::FieldAscii::create(""));     // Did not Populate the value 2nd time

  entry->addField(identity_streamService, Messages::FieldAscii::create(""));

  entry->addField(identity_inetAddr, Messages::FieldAscii::create("inetAddr.org"));

  entry->addField(identity_port, Messages::FieldUInt32::create(2224));

  entry->addField(identity_mdBookType, Messages::FieldUInt32::create(3));



  sequence_MDFeedTypes->addEntry(Messages::FieldSetCPtr(entry));

  msg->addField(identity_MDFeedTypes, Messages::FieldSequence::create(sequence_MDFeedTypes));

  Codecs::Encoder encoder(templateRegistry);
  Codecs::DataDestination destination;
  template_id_t templId = 3; // from the XML above
  encoder.encodeMessage(destination, templId, *msg);
  std::string fastString;
  destination.toString(fastString);
  std::cout<<"fastString is "<<fastString<<std::endl;

  destination.clear();

  Codecs::Decoder decoder(templateRegistry);
  Codecs::DataSourceString source(fastString);
  Codecs::SingleMessageConsumer consumer;
  Codecs::GenericMessageBuilder builder(consumer);
  decoder.decodeMessage(source, builder);

  Messages::Message & msgOut(consumer.message());

        Messages::MessageFormatter formatter(std::cout);
        formatter.formatMessage(msgOut);                                   // I have made some printing changes to print the ouptut per tag 

  validateMessage1(msgOut);


  encoder.reset();
  encoder.encodeMessage(destination, templId, msgOut);
  std::string reencoded;
  destination.toString(reencoded);

  destination.clear();

      

I can encode and decode the message successfully, but the value is not copied in the second entry (streamType tag). Here is my decoded output:

 1st entry:
 streamType[1022]=streamType                  
 streamService[]=streamService
 inetAddr[]=inetAddr.com
 port[TBD]= 2045


 2nd entry:
streamType[1022]=                     //value not copied
streamService[]=
 inetAddr[]=inetAddr.org
 port[TBD]= 2046

      

Could you please let us know if we are wrong somewhere. I'm new to this :)

I also have the following requests:

1 / Do I need to explicitly specify / disable the dictionary in quickfast? (In FIX, we can do this with DataDictionary = Y / N flag). Also in the template I created above I found this line:

<string name="streamType" id="1022">      <copy dictionary="template" />      </string>

      

Do I need to specify a dictionary name when using operators and how are they related?

2 / Do I also need to explicitly state that the PMAP bits are needed?

Codecs :: PresenceMap pmap (1); // I came across this function, so I was so doubtful about whether to explicitly mention pmap.

+3


source to share





All Articles