objectcomputing / mFAST

A FAST (FIX Adapted for STreaming) encoder/decoder
http://objectcomputing.github.io/mFAST
BSD 3-Clause "New" or "Revised" License
220 stars 114 forks source link

Order of decoded fields #26

Closed gampx closed 10 years ago

gampx commented 10 years ago

When I decode W_OLS_CURR message and access MessageType field, I get "FIXT.1.1" instead of "W". If I print this message with message_printer taken from examples I get: BeginString: FIXT.1.1 MessageType: W SenderCompID: MOEX ApplVerID: 9 MsgSeqNum: 123 SendingTime: 20140402145218210 LastMsgSeqNumProcessed: 448 RptSeq: 1 LastFragment: 1 TradSesStatus: 100 Symbol: USDEURBASKET MDSecurityTradingStatus: 18 GroupMDEntries: [0]: MDEntryType: J TradingSessionID: CNGD Template can be taken from here: ftp://ftp.moex.ru/pub/FAST/ASTS/template/FIX50SP2-ALL.xml UPDATE: I have made some research and found that in generated template.cpp BeginString_instruction and MessageType_instruction are in wrong order(not as they are in templates.xml): const static field_instruction* W_OLS_CURRsubinstructions[] = { &W_OLS_CURRBeginString_instruction, &W_OLS_CURR__MessageType_instruction, ...

huangminghuang commented 10 years ago

I am not sure I understand your problem. Are you saying something like

msg.get_MessageType().value() ==  "FIXT.1.1"

I can hardly believe it would ever happen. The generated code is intentionally ordered like that because I want to facilitate writing FIX decoder/encoder. The FIX protocol requires the BeginString to appear first. For FAST protocol, the order shouldn't be a concern because those fields are constant and never appear in the encoded stream.

gampx commented 10 years ago

Yes, I'm saying that msg.get_MessageType().value() == "FIXT.1.1" The fact is, get_MessageType() is return static_cast<mfast::ascii_string_cref>((*this)[0]); which takes &W_OLS_CURR__BeginString_instruction instead of &W_OLS_CURR__MessageType_instruction If I reorder them in templates.cpp I got correct result "W" (and "FIXT.1.1" for get_BeginString()) If you need I can record a packet for you to reproduce issue.

huangminghuang commented 10 years ago

fixed on commit da07be5d49c0a821107ba31640bd525c179a8cad