FIX::message_order Struct Reference

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

`#include <MessageSorters.h>`

Collaboration diagram for FIX::message_order:
[legend]

## 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)
bool | operator() (const int x, const int y) const
message_order & | operator= (const message_order &rhs)
| operator bool () const

## Private Member Functions

void | setOrder (int size, const int order[])

## Private Attributes

cmp_mode | m_mode
int | m_delim
shared_array< 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 113 of file MessageSorters.h.

## Member Enumeration Documentation

## cmp_mode

enum FIX::message_order::cmp_mode

Enumerator
header |
trailer |
normal |
group |

Definition at line 116 of file MessageSorters.h.

{ header, trailer, normal, group };
FIX::message_order::normal
Definition: MessageSorters.h:116
FIX::message_order::header
Definition: MessageSorters.h:116
FIX::message_order::trailer
Definition: MessageSorters.h:116
FIX::message_order::group
Definition: MessageSorters.h:116

## Constructor & Destructor Documentation

## message_order() [1/4]

FIX::message_order::message_order | ( | cmp_mode | mode = `normal` | ) |

inline

Definition at line 118 of file MessageSorters.h.

: m_mode( mode ), m_delim( 0 ), m_largest( 0 ) {}
FIX::message_order::m_largest
int m_largest
Definition: MessageSorters.h:151
FIX::message_order::m_delim
int m_delim
Definition: MessageSorters.h:149
FIX::message_order::m_mode
cmp_mode m_mode
Definition: MessageSorters.h:148

## message_order() [2/4]

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

Definition at line 32 of file MessageSorters.cpp.

References FIX::shared_array< T >::create(), m_delim, m_groupOrder, and m_largest.

: m_mode( group ), m_delim( 0 ), m_largest( 0 )
{
int field = first;
int size = 0;
m_largest = m_delim = first;
va_list arguments;
va_start( arguments, first );
while( field != 0 )
{
m_largest = m_largest > field ? m_largest : field;
size++;
field = va_arg( arguments, int );
}
if(size)
{
m_groupOrder = shared_array<int>::create(m_largest + 1);
va_start( arguments, first );
field = first;
int i = 0;
while( field != 0 )
{
m_groupOrder[ field ] = ++i;
field = va_arg( arguments, int );
}
}
else
{
m_largest = 0;
m_delim = 0;
}
va_end( arguments );
}
FIX::message_order::m_largest
int m_largest
Definition: MessageSorters.h:151
FIX::message_order::m_groupOrder
shared_array< int > m_groupOrder
Definition: MessageSorters.h:150
FIX::message_order::m_delim
int m_delim
Definition: MessageSorters.h:149
FIX::message_order::group
Definition: MessageSorters.h:116
FIX::message_order::m_mode
cmp_mode m_mode
Definition: MessageSorters.h:148
FIX::shared_array::create
static shared_array create(const std::size_t nSize)
Definition: SharedArray.h:73

## message_order() [3/4]

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

Definition at line 71 of file MessageSorters.cpp.

References setOrder().

: m_mode( group ), m_delim( 0 ), m_largest( 0 )
{
int size = 0;
while( order[size] != 0 ) { ++size; }
setOrder(size, order);
}
FIX::message_order::setOrder
void setOrder(int size, const int order[])
Definition: MessageSorters.cpp:89
FIX::message_order::m_largest
int m_largest
Definition: MessageSorters.h:151
FIX::message_order::m_delim
int m_delim
Definition: MessageSorters.h:149
FIX::message_order::group
Definition: MessageSorters.h:116
FIX::message_order::m_mode
cmp_mode m_mode
Definition: MessageSorters.h:148

## message_order() [4/4]

FIX::message_order::message_order | ( | const message_order & | copy | ) |

inline

Definition at line 122 of file MessageSorters.h.

{ *this = copy; }

## Member Function Documentation

## operator bool()

FIX::message_order::operator bool | ( |  | ) | const

inline

Definition at line 142 of file MessageSorters.h.

{ return !m_groupOrder.empty(); }
FIX::message_order::m_groupOrder
shared_array< int > m_groupOrder
Definition: MessageSorters.h:150
FIX::shared_array::empty
bool empty() const
Definition: SharedArray.h:66

## operator()()

bool FIX::message_order::operator() | ( | const int | x,
|  | const int | y
| ) |  | const

inline

Definition at line 125 of file MessageSorters.h.

References FIX::header_order::compare(), FIX::trailer_order::compare(), and FIX::group_order::compare().

{
switch ( m_mode )
{
case header:
return header_order::compare( x, y );
case trailer:
return trailer_order::compare( x, y );
case group:
return group_order::compare( x, y, m_groupOrder, m_largest );
case normal: default:
return x < y;
}
}
FIX::group_order::compare
static bool compare(const int x, const int y, int *order, int largest)
Definition: MessageSorters.h:84
FIX::message_order::normal
Definition: MessageSorters.h:116
FIX::header_order::compare
static bool compare(const int x, const int y)
Definition: MessageSorters.h:40
FIX::message_order::header
Definition: MessageSorters.h:116
FIX::trailer_order::compare
static bool compare(const int x, const int y)
Definition: MessageSorters.h:72
FIX::message_order::m_largest
int m_largest
Definition: MessageSorters.h:151
FIX::message_order::m_groupOrder
shared_array< int > m_groupOrder
Definition: MessageSorters.h:150
FIX::message_order::trailer
Definition: MessageSorters.h:116
FIX::message_order::group
Definition: MessageSorters.h:116
FIX::message_order::m_mode
cmp_mode m_mode
Definition: MessageSorters.h:148

## operator=()

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

Definition at line 79 of file MessageSorters.cpp.

References m_delim, m_groupOrder, m_largest, and m_mode.

{
m_mode = rhs.m_mode;
m_delim = rhs.m_delim;
m_largest = rhs.m_largest;
m_groupOrder = rhs.m_groupOrder;
return *this;
}
FIX::message_order::m_largest
int m_largest
Definition: MessageSorters.h:151
FIX::message_order::m_groupOrder
shared_array< int > m_groupOrder
Definition: MessageSorters.h:150
FIX::message_order::m_delim
int m_delim
Definition: MessageSorters.h:149
FIX::message_order::m_mode
cmp_mode m_mode
Definition: MessageSorters.h:148

## setOrder()

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

private

Definition at line 89 of file MessageSorters.cpp.

References FIX::shared_array< T >::create(), m_delim, m_groupOrder, and m_largest.

Referenced by message_order().

{
if(size < 1) return;
m_largest = m_delim = order[0];
// collect all fields and find the largest field number
for (int i = 1; i < size; ++i )
{
int field = order[i];
m_largest = m_largest > field ? m_largest : field;
}
m_groupOrder = shared_array<int>::create(m_largest + 1);
for (int i = 0; i < size; ++i )
m_groupOrder[ order[ i ] ] = i + 1;
}
FIX::message_order::m_largest
int m_largest
Definition: MessageSorters.h:151
FIX::message_order::m_groupOrder
shared_array< int > m_groupOrder
Definition: MessageSorters.h:150
FIX::message_order::m_delim
int m_delim
Definition: MessageSorters.h:149
FIX::shared_array::create
static shared_array create(const std::size_t nSize)
Definition: SharedArray.h:73

## Member Data Documentation

## m_delim

int FIX::message_order::m_delim

private

Definition at line 149 of file MessageSorters.h.

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

## m_groupOrder

shared_array<int> FIX::message_order::m_groupOrder

private

Definition at line 150 of file MessageSorters.h.

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

## m_largest

int FIX::message_order::m_largest

private

Definition at line 151 of file MessageSorters.h.

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

## m_mode

cmp_mode FIX::message_order::m_mode

private

Definition at line 148 of file MessageSorters.h.

Referenced by operator=().

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

- MessageSorters.h
- MessageSorters.cpp