Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Preface

This page contains code snippets with solutions to some typical tasks for repeating groups.
Items marked "since FIX Antenna 2.19" are planned for future release.

Retrieving Repeating Group Instance

Use 'getGroup' method of corresponding parent FIXMessage or nested repeating group.

Example.cpp
#include <B2BITS_FIXMessage.h>
#include <B2BITS_FIXGroup.h>
#include <B2BITS_FIXFields.h>
//...

FIXGroup* pGroup = pMessage->getGroup(FIXFields::NoQuoteSets);

Please note, that memory of FIXGroup instance is managed by it's parent FIXMessage, you should not delete it by yourself.

Getting Repeating Group size (number of entries)

Either get FIXGroup object and get it's size:

Example.cpp

or get integer value of corresponding leading tag:

Example.cpp

Iterating over Repeating Group entries and fields

Example 1

Get access to FIXGroup instance, determine it's size,
and then access group fields same way with FIXMessage fields, except you need to specify entry index:

MyApp.cpp

Please note that entry indexing starts from zero.

Example 2

Get access to FIXGroup instance, determine it's size,
and then iterate group entries one by one; access entry content same way with FIXMessage fields.

MyApp.cpp

Example 3 (since FIX Antenna 2.19)

Use built-in iterators:

MyApp.cpp

or, if your compiler supports C++11:

MyApp.cpp

Iterating over Nested Repeating Groups entries and fields

Nested groups are accessed same way as top-level groups.

Example 1

MyApp.cpp

Example 2 (since FIX Antenna 2.19)

MyApp.cpp

or, if your compiler supports C++11:

MyApp.cpp

Resizing Repeating Group

Set corresponding leading tag to required size:

MyApp.cpp

If new size is greater than previous then new entries with empty contents will be added;
If new size is less than previous, then exceeding entries at the end of group will be discarded.
Setting size to zero efficiently deletes group from message.

Adding entries to Repeating Group without knowing their quantity ahead of time

Example 1

Increase current size by 1 manually, fill last entry with values:

MyApp.cpp

Example 2

Reserve some space in group, fill entries, shrink group to actual size.

MyApp.cpp

Example 3 (since FIX Antenna 2.19)

Use helpers from B2BITS_FIXMsgHelper.h:

MyApp.cpp

Populating FIX message with nested Repeating Groups

Populating nested repeating groups is mostly same as repeating groups in message.

Example 1

MyApp.cpp

Example 2 (since FIX Antenna 2.19)

Use helpers from B2BITS_FIXMsgHelper.h:

 

MyApp.cpp

Removing arbitrary entry from Repeating Group

Currently the following approach is recommended to remove entry under index 'i' from group with total length 'N':

  1. Clear value for every tag in target entry ({Xi,Yi,Zi}).
  2. Copy new value from last entry: ({XN-1,YN-1,ZN-1} -> {Xi,Yi,Zi})
  3. Resize group to 'N-1', so that last entry ({XN-1,YN-1,ZN-1}) will be deleted from message.
  • No labels