MessageSorters.cpp
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (c) 2001-2014
3**
4** This file is part of the QuickFIX FIX Engine
5**
6** This file may be distributed under the terms of the quickfixengine.org
7** license as defined by quickfixengine.org and appearing in the file
8** LICENSE included in the packaging of this file.
9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12**
13** See http://www.quickfixengine.org/LICENSE for licensing information.
14**
15** Contact ask@quickfixengine.org if any conditions of this licensing are
16** not clear to you.
17**
18****************************************************************************/
19
20#ifdef _MSC_VER
21#include "stdafx.h"
22#else
23#include "config.h"
24#endif
25
26#include "MessageSorters.h"
27
28#include <string.h>
29
30namespace FIX
31{
33: m_mode( group ), m_delim( 0 ), m_largest( 0 )
34{
35 int field = first;
36 int size = 0;
37 m_largest = m_delim = first;
38
39 va_list arguments;
40 va_start( arguments, first );
41 while( field != 0 )
42 {
43 m_largest = m_largest > field ? m_largest : field;
44
45 size++;
46 field = va_arg( arguments, int );
47 }
48
49 if(size)
50 {
52
53 va_start( arguments, first );
54 field = first;
55 int i = 0;
56 while( field != 0 )
57 {
58 m_groupOrder[ field ] = ++i;
59 field = va_arg( arguments, int );
60 }
61 }
62 else
63 {
64 m_largest = 0;
65 m_delim = 0;
66 }
67
68 va_end( arguments );
69}
70
71message_order::message_order( const int order[] )
72: m_mode( group ), m_delim( 0 ), m_largest( 0 )
73{
74 int size = 0;
75 while( order[size] != 0 ) { ++size; }
76 setOrder(size, order);
77}
78
80{
81 m_mode = rhs.m_mode;
82 m_delim = rhs.m_delim;
83 m_largest = rhs.m_largest;
85
86 return *this;
87}
88
89void message_order::setOrder( int size, const int order[] )
90{
91 if(size < 1) return;
92 m_largest = m_delim = order[0];
93
94 // collect all fields and find the largest field number
95 for (int i = 1; i < size; ++i )
96 {
97 int field = order[i];
98 m_largest = m_largest > field ? m_largest : field;
99 }
100
102 for (int i = 0; i < size; ++i )
103 m_groupOrder[ order[ i ] ] = i + 1;
104}
105}
static shared_array create(const std::size_t nSize)
Sorts fields in header, normal, or trailer order.
message_order & operator=(const message_order &rhs)
shared_array< int > m_groupOrder
message_order(cmp_mode mode=normal)
void setOrder(int size, const int order[])

Generated on Fri Sep 27 2024 13:45:21 for QuickFIX by doxygen 1.9.8 written by Dimitri van Heesch, © 1997-2001