QuickFIX: FIX::message_order Struct Reference

Index Source Files Annotated Class List Alphabetical Class List Class Hierarchy Graphical Class Hierarchy

# FIX::message_order Struct Reference

Sorts fields in header, normal, or trailer order. More...

`#include <MessageSorters.h>`

List of all members.

## Public Types
enum | cmp_mode { header, trailer, normal, group }
## Public Member Functions
| message_order (cmp_mode mode=normal)
| message_order (int first,...)
| message_order (const int order[])
| message_order (const message_order &copy)
virtual | ~message_order ()
bool | operator() (const int &x, const int &y) const
message_order & | operator= (const message_order &rhs)
## Private Member Functions
void | setOrder (int size, const int order[])
## Private Attributes
cmp_mode | m_mode
int | m_delim
int * | m_groupOrder
int | m_largest

## Detailed Description

Sorts fields in header, normal, or trailer order.

Used as a dynamic sorter to create Header, Trailer, and Message FieldMaps while maintaining the same base type.

Definition at line 112 of file MessageSorters.h.

## Member Enumeration Documentation

enum FIX::message_order::cmp_mode

Enumerator:

  header |
  trailer |
  normal |
  group |

Definition at line 115 of file MessageSorters.h.

    00115 { header, trailer, normal, group };

## Constructor & Destructor Documentation

FIX::message_order::message_order | ( | cmp_mode | mode = `normal` | ) | `[inline]`

Definition at line 117 of file MessageSorters.h.

    00117 : m_mode( mode ), m_groupOrder( 0 ) {}

FIX::message_order::message_order | ( | int | first,
|  |  | ... |
| ) |  |  |

Definition at line 31 of file MessageSorters.cpp.

References setOrder().

    00032 : m_mode( group ), m_delim( 0 ), m_groupOrder( 0 ), m_largest( 0 )
    00033 {
    00034   int field = first;
    00035   int size = 0;
    00036
    00037   va_list arguments;
    00038   va_start( arguments, first );
    00039   while( field != 0 )
    00040   {
    00041     size++;
    00042     field = va_arg( arguments, int );
    00043   }
    00044
    00045   va_start( arguments, first );
    00046   int* order = new int[size];
    00047   order[0] = first;
    00048   for ( int i = 1; i < size; ++i )
    00049     order[ i ] = va_arg( arguments, int );
    00050   setOrder(size, order);
    00051   delete [] order;
    00052
    00053   va_end( arguments );
    00054 }

FIX::message_order::message_order | ( | const int | order[] | ) |

Definition at line 56 of file MessageSorters.cpp.

References setOrder().

    00057 : m_mode( group ), m_delim( 0 ), m_groupOrder( 0 ), m_largest( 0 )
    00058 {
    00059   int size = 0;
    00060   while( order[size] != 0 ) { ++size; }
    00061   setOrder(size, order);
    00062 }

FIX::message_order::message_order | ( | const message_order & | copy | ) | `[inline]`

Definition at line 120 of file MessageSorters.h.

    00120                                              : m_groupOrder( 0 )
    00121   { *this = copy; }

virtual FIX::message_order::~message_order | ( |  | ) | `[inline, virtual]`

Definition at line 123 of file MessageSorters.h.

References m_groupOrder.

    00124   {
    00125     if ( m_groupOrder )
    00126       delete [] m_groupOrder;
    00127   }

## Member Function Documentation

bool FIX::message_order::operator() | ( | const int & | x,
|  | const int & | y |
| ) |  |  | const`[inline]`

Definition at line 129 of file MessageSorters.h.

References FIX::group_order::compare(), FIX::trailer_order::compare(), FIX::header_order::compare(), group, header, m_groupOrder, m_largest, m_mode, normal, and trailer.

    00130   {
    00131     switch ( m_mode )
    00132     {
    00133       case header:
    00134       return header_order::compare( x, y );
    00135       case trailer:
    00136       return trailer_order::compare( x, y );
    00137       case group:
    00138       return group_order::compare( x, y, m_groupOrder, m_largest );
    00139       case normal: default:
    00140       return x < y;
    00141     }
    00142   }

message_order & FIX::message_order::operator= | ( | const message_order & | rhs | ) |

Definition at line 64 of file MessageSorters.cpp.

References m_delim, m_groupOrder, m_largest, m_mode, QF_STACK_POP, and QF_STACK_PUSH.

    00065 { QF_STACK_PUSH(message_order::operator=)
    00066
    00067   m_mode = rhs.m_mode;
    00068   m_delim = rhs.m_delim;
    00069   m_largest = rhs.m_largest;
    00070   if ( rhs.m_groupOrder )
    00071   {
    00072     if ( m_groupOrder ) delete [] m_groupOrder;
    00073     m_groupOrder = new int[ m_largest + 1 ];
    00074     memcpy( m_groupOrder, rhs.m_groupOrder,
    00075             ( m_largest + 1 ) * sizeof( int ) );
    00076   }
    00077   return *this;
    00078
    00079   QF_STACK_POP
    00080 }

void FIX::message_order::setOrder | ( | int | size,
|  | const int | order[] |
| ) |  |  | `[private]`

Definition at line 82 of file MessageSorters.cpp.

References m_delim, m_groupOrder, m_largest, QF_STACK_POP, and QF_STACK_PUSH.

Referenced by message_order().

    00083 { QF_STACK_PUSH(message_order::operator=)
    00084
    00085   if(size < 1) return;
    00086   m_largest = m_delim = order[0];
    00087
    00088   int* fields = new int[ size + 1 ];
    00089   fields[ 1 ] = m_delim;
    00090   // collect all fields and find the largest field number
    00091   int i;
    00092   for ( i = 2; i <= size; ++i )
    00093   {
    00094     int field = order[i-1];
    00095     m_largest = m_largest > field ? m_largest : field;
    00096     fields[ i ] = field;
    00097   }
    00098
    00099   // populate array with field number as key and position as value
    00100   m_groupOrder = new int[ m_largest + 1 ];
    00101   memset( m_groupOrder, 0, ( m_largest + 1 ) * sizeof( int ) );
    00102   for ( i = 1; i <= size; ++i )
    00103     m_groupOrder[ fields[ i ] ] = i;
    00104   delete [] fields;
    00105
    00106   QF_STACK_POP
    00107 }

## Member Data Documentation

int FIX::message_order::m_delim`[private]`

Definition at line 150 of file MessageSorters.h.

Referenced by operator=(), and setOrder().

int* FIX::message_order::m_groupOrder`[private]`

Definition at line 151 of file MessageSorters.h.

Referenced by operator()(), operator=(), setOrder(), and ~message_order().

int FIX::message_order::m_largest`[private]`

Definition at line 152 of file MessageSorters.h.

Referenced by operator()(), operator=(), and setOrder().

cmp_mode FIX::message_order::m_mode`[private]`

Definition at line 149 of file MessageSorters.h.

Referenced by operator()(), and operator=().

The documentation for this struct was generated from the following files:

- /home/omiller/Development/autobuild/quickfix/src/C++/MessageSorters.h
- /home/omiller/Development/autobuild/quickfix/src/C++/MessageSorters.cpp