Re: [Quickfix-developers] getGroup
Brought to you by:
orenmnero
|
From: Brian E. <azz...@ya...> - 2005-10-10 18:47:08
|
Alvin -
I don't know the Java side very well (I've coded to the C++ and .NET
versions), but the getGroup function is pretty simple.
First, you need to know the name of the field that acts as the group's
enumerator/designator. These almost always start with "No" (as in
"number"). You should check for the existence of that field - if it
isn't there, there won't be any group members either.
One example of this is the Legs group in NewOrderMultileg. This group
begins with a "NoLegs" field (defined as an IntField) that contains the
number of legs.
In C++ -
FIX::NoLegs noLegs;
if (message.isSetField(noLegs))
{
message.getField(noLegs);
for (int i=0; i<noLegs.getValue(); i++)
...
In C#, we'd use the built-in field getters -
if (message.isSetNoLegs())
{
for (int i=0; i<message.getNoLegs().getValue(); i++)
...
Second, you need to create a group object of the type you wish to
extract. In the C++ and .NET versions, these are defined as sub-classes
of the parent message type with a class name that is the same as the
field name of the enumeration field mentioned above.
In C++ -
FIX::NewOrderMultileg::NoLegs leg;
In C# -
QuickFix43.NewOrderMultileg.NoLegs leg = new
QuickFix43.NewOrderMultileg.NoLegs();
Third, you use the "getGroup" method of the Message object to retrieve
a single element of the repeating group list. These elements are
indexed starting at "1", not "0".
In C++ -
message.getGroup(1, leg);
In C# -
message.getGroup(1, leg);
Full example, C++:
FIX::NoLegs noLegs;
if (message.isSetField(noLegs))
{
FIX::NewOrderMultileg::NoLegs leg;
FIX::LegSide legSide;
message.getField(noLegs);
for (int i=0; i<noLegs.getValue(); i++)
{
message.getGroup(i+1, leg);
leg.get(legSide);
if (legSide.getValue() == FIX::Side_BUY)
...
}
}
Full example, C#:
if (message.isSetNoLegs())
{
QuickFix43.NewOrderMultileg.NoLegs leg = new
QuickFix43.NewOrderMultileg.NoLegs();
for (int i=0; i<message.getNoLegs().getValue(); i++)
{
message.getGroup(i+1, leg);
if (leg.getLegSide().getValue() == QuickFix.Side.BUY)
...
}
}
Hope this helps.
- Brian Erst
Thynk Software, Inc.
--- Alvin Wang <AW...@FF...> wrote:
> public native Group getGroup(int int0, Group group) throws
> FieldNotFound;
>
> Hi, Can anyone tell me how to use the getGroup method in Message
> class?
> What are the 2 parameters? what does it return?
>
> BTW, quickfix is wonderful. Hopefully its document is as good as it.
>
> Thanks
> Alvin
>
>
>
>
>
>
>
**********************************************************************
> This e-mail message is intended solely for the use of the addressee.
> The message may contain information that is privileged and
> confidential.
> Disclosure to anyone other than the intended recipient is
> prohibited. If you are not the intended recipient, please do not
> disseminate, distribute or copy this communication, by e-mail or
> otherwise. Instead, please notify us immediately by return e-mail
> (including the original message with your reply) and then delete
> and discard all copies of the message. We have taken precautions to
> minimize the risk of transmitting software viruses but nevertheless
> advise you to carry out your own virus checks on any attachment to
> this message. We accept no liability for any loss or damage caused
> by software viruses.
>
**********************************************************************
>
>
|