在quickfix/c++ 中重复组
我正在编写一个使用快速修复库的程序。文档很差,所以我请求SO研究员的帮助。
我在 Group 类中看到有迭代器。所以我认为有一些类似 STL 的方法来解析重复组。我错了吗? 有人可以提供一个简单的例子吗?
预先非常感谢您。
I am writing a program that uses the quickfix library. The documentation is very poor, so I am requesting the help of SO fellows.
I have seen in the Group class that there are iterators. So I suppose that there is some STL-ish way of parsing repeating groups. Am I wrong?
Can anybody provide a simple example for doing that?
Thank you very much in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 Quickfix 库以及有关如何构造 FIX 消息的文档。否则就很难破译这些消息是如何组织的。
这是来自 Quickfix 网站 的示例
您的消息是 MarketDataSnapshotFullRefresh 类对象。
您可以获取重复组的计数,即需要迭代对象消息多少次才能获取所有条目。请记住 FIX::NoMDEntries 是一个字段。
这有点棘手。您进入消息内部以获取组。这里,NoMDEntries 是 MarketDataSnapshotFullRefresh 类中的一个封闭类。请记住,这是将为您提供数据的类。现在,您可以运行一个循环,也可以多次编写相同的代码来提取每个组内的所有字段。 getGroup 为您提供从中提取字段的组。 getField 将为您提供字段数据。 Quickfix 的大部分术语都是 FIX 消息。因此,请参阅 Fiximate 等 FIX 消息网站,您的生活会轻松得多。
Use Quickfix library alongwith the documentation of how FIX messages are constructed. Else it would be very difficult to decipher how the messages are organized.
This is an example from Quickfix website
Your message is the MarketDataSnapshotFullRefresh class object.
You get the count of repeating groups, how many times you need to iterate over the object message to get all the entries. Remember FIX::NoMDEntries is a field.
This is a little tricky. You go inside a message to get the groups. Here NoMDEntries is an enclosed class inside MarketDataSnapshotFullRefresh class. Remeber this is the class which will give you the data. Now either you run through a loop or write the same code multiple times to extract all the fields inside each group. getGroup gives you the group from which you extract fields. getField will give you the field data. Most of the nomenclature of Quickfix is FIX messages. So refer a FIX message website like Fiximate and your life will be much easier.
FieldMap
类中有迭代器,它是Message
和Group
类的超类。我不确定解析重复组是什么意思。
当原始修复消息到达时,修复引擎会为您解析原始修复消息,并且您的回调会获取已解析的 FIX 消息 - 该消息具有消息头、正文和尾部标签的内部标签映射(键/值)。
查看 1.13.2 版本的代码,当引擎从网络获取新的字符串消息时,它最终会创建一个
Message
并将该字符串传递给它。然后,Message
构造函数调用自身的setString()
,从而有效地解析接收到的字符串并创建标签映射。如果您查看
Message::setString
,您可以看到首先添加了新字段,然后在setGroup
中检查该字段是否是该组的一部分。如果是,则此方法setGroup
将接管对以下标记的解析,而这些标记是该组的一部分。一旦遇到不属于该组的标签,它就会停止解析该组,然后返回并继续解析消息中的字段。现在,这一切都发生在回调到您处理收到消息的应用程序之前。
有一种方法可以迭代消息中的字段。您可以迭代标题、正文或组(以及每个组)的字段。
与正文类似:
还有组迭代器(
FieldMap::g_begin/g_end
),因此您可以迭代消息或标题中的组,并且您可以类似地迭代或搜索每个组中的标签。Group 和 Message 扩展了 FieldMap,因此所有 getField/setField 功能都可以共享。
内部...如果细节太多,请跳过。
在上面的示例中,此代码:
有效地传递来自
message.getGroup(1, group)
-> 的调用FieldMap::getGroup(1, group.field(), group)
->getGroupRef(num,field)
->m_groups.find(field)
为您提供一个组向量 (vector
) 并返回num
元素,即消息中的num
组(FieldMap
)。group.get(field)
是使用每个标签的宏创建的,它被有效地翻译为(map).getField(field)
。在初始化期间,组的 (map) 是对标签所属对象的引用,因此它从特定组返回标签(请参阅示例 src/C++/fix44/NewOrderSingle.h )有几个扩展 Group 的内部类)
希望它有一定的意义。
There are iterators in
FieldMap
class which is a super class ofMessage
andGroup
class.I'm not sure what do you mean by parsing repeating groups.
Fix engine parses raw fix messages for you when they arrive and your callback gets parsed FIX message - which has internal maps of tags (key/value) for tags in message header, body and tail.
Looking at 1.13.2 version of code, when the engine gets new string message from network it will eventually create a
Message
passing it the string.Message
constructor then callssetString()
on itself which effectively parses the received string and creates a map of tags.If you look at
Message::setString
you can see that first the new field is added and then insetGroup
it checks if the field is part of the group. If it is then this method,setGroup
, takes over parsing of the following tags while those tags are part of the group. Once it comes across of tag that is not part of the group it stops parsing the group, it returns and continues parsing fields from message.Now this all happens internally before the callback to your app where you handle received message.
There is a way to iterate over fields in a message. You can iterate over fields of header, body or over groups (and over each group).
And similarly for body:
And there is groups iterator (
FieldMap::g_begin/g_end
) as well so you could iterate over groups in msg or header and you can similarly iterate, or search, tags within each group.Group as well as Message extends FieldMap so all the getField/setField functionality is shared across.
Internals ... skip if too much detail.
In the above example this code:
Effectively passes the call from
message.getGroup(1, group)
->FieldMap::getGroup(1, group.field(), group)
->getGroupRef(num,field)
->m_groups.find(field)
which gives you a vector of groups (vector<FieldMap*>
) and returns thenum
element, aka thenum
group from the message (aFieldMap
).group.get(field)
is created using macros for each tag which is effectively translated as(map).getField(field)
.During initialization the (map) for group is a reference to the object of which the tag is member of so it returns the tag from the specific group (see example
src/C++/fix44/NewOrderSingle.h
it has couple of internal classes which extend Group)Hope that it makes some sense.