Field.h
Go to the documentation of this file.
1/* -*- C++ -*- */
2
3/****************************************************************************
4** Copyright (c) 2001-2014
5**
6** This file is part of the QuickFIX FIX Engine
7**
8** This file may be distributed under the terms of the quickfixengine.org
9** license as defined by quickfixengine.org and appearing in the file
10** LICENSE included in the packaging of this file.
11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14**
15** See http://www.quickfixengine.org/LICENSE for licensing information.
16**
17** Contact ask@quickfixengine.org if any conditions of this licensing are
18** not clear to you.
19**
20****************************************************************************/
21
22#ifndef FIX_FIELD
23#define FIX_FIELD
24
25#ifdef _MSC_VER
26#pragma warning( disable : 4786 )
27#endif
28
29#include <sstream>
30#include <numeric>
31#include "FieldNumbers.h"
32#include "FieldConvertors.h"
33#include "FieldTypes.h"
34#include "Utility.h"
35
36#if defined(__SUNPRO_CC)
37#include <algorithm>
38#endif
39
40namespace FIX
41{
50{
51
54 {
55 public:
56
57 field_metrics( const size_t length, const int checksum )
58 : m_length( length )
59 , m_checksum( checksum )
60 {}
61
62 size_t getLength() const
63 { return m_length; }
64
65 int getCheckSum() const
66 { return m_checksum; }
67
68 bool isValid() const
69 { return m_length > 0; }
70
71 private:
72
73 size_t m_length;
75 };
76
77 friend class Message;
78
80 FieldBase( int tag,
81 std::string::const_iterator valueStart,
82 std::string::const_iterator valueEnd,
83 std::string::const_iterator tagStart,
84 std::string::const_iterator tagEnd )
85 : m_tag( tag )
86 , m_string( valueStart, valueEnd )
87 , m_metrics( calculateMetrics( tagStart, tagEnd ) )
88 {}
89
90public:
91 FieldBase( int tag, const std::string& string )
92 : m_tag( tag ), m_string(string), m_metrics( no_metrics() )
93 {}
94
95 virtual ~FieldBase() {}
96
97 FieldBase( const FieldBase& rhs )
98 : m_tag( rhs.getTag() )
99 , m_string( rhs.m_string )
100 , m_metrics( rhs.m_metrics )
101 {
102
103 }
104
106 {
107 m_tag = rhs.getTag();
108 m_string = rhs.m_string;
109 m_metrics = rhs.m_metrics;
110 m_data.clear();
111
112 return *this;
113 }
114
115 void swap( FieldBase& rhs )
116 {
117 std::swap( m_tag, rhs.m_tag );
118 std::swap( m_metrics, rhs.m_metrics );
119 m_string.swap( rhs.m_string );
120 m_data.swap( rhs.m_data );
121 }
122
123 void setTag( int tag )
124 {
125 m_tag = tag;
127 m_data.clear();
128 }
129
131 void setField( int field )
132 {
133 setTag( field );
134 }
135
136 void setString( const std::string& string )
137 {
138 m_string = string;
140 m_data.clear();
141 }
142
144 int getTag() const
145 { return m_tag; }
146
148 int getField() const
149 { return getTag(); }
150
152 const std::string& getString() const
153 { return m_string; }
154
156 const std::string& getFixString() const
157 {
158 if( m_data.empty() )
159 encodeTo( m_data );
160
161 return m_data;
162 }
163
165 size_t getLength() const
166 {
167 calculate();
168 return m_metrics.getLength();
169 }
170
172 int getTotal() const
173 {
174 calculate();
175 return m_metrics.getCheckSum();
176 }
177
179 bool operator < ( const FieldBase& field ) const
180 { return m_tag < field.m_tag; }
181
182private:
183
184 void calculate() const
185 {
186 if( m_metrics.isValid() ) return;
187
189 }
190
192 void encodeTo( std::string& result ) const
193 {
194 size_t tagLength = FIX::number_of_symbols_in( m_tag );
195 size_t totalLength = tagLength + m_string.length() + 2;
196
197 result.resize( totalLength );
198
199 char * buf = (char*)result.c_str();
200 FIX::integer_to_string( buf, tagLength, m_tag );
201
202 buf[tagLength] = '=';
203 memcpy( buf + tagLength + 1, m_string.data(), m_string.length() );
204 buf[totalLength - 1] = '\001';
205 }
206
208 {
209 return field_metrics( 0, 0 );
210 }
211
214 std::string::const_iterator const start,
215 std::string::const_iterator const end )
216 {
217 int checksum = 0;
218 for ( std::string::const_iterator str = start; str != end; ++str )
219 checksum += (unsigned char)( *str );
220
221#if defined(__SUNPRO_CC)
222 std::ptrdiff_t d;
223 std::distance(start, end, d);
224 return field_metrics( d, checksum );
225#else
226 return field_metrics( std::distance( start, end ), checksum );
227#endif
228 }
229
230 static field_metrics calculateMetrics( const std::string& field )
231 {
232 return calculateMetrics( field.begin(), field.end() );
233 }
234
235 int m_tag;
236 std::string m_string;
237 mutable std::string m_data;
239};
242inline std::ostream& operator <<
243( std::ostream& stream, const FieldBase& field )
244{
245 stream << field.getString();
246 return stream;
247}
248
249inline void swap( FieldBase& lhs, FieldBase& rhs )
250{
251 lhs.swap( rhs );
252}
253
258class StringField : public FieldBase
259{
260public:
261 explicit StringField( int field, const std::string& data )
262: FieldBase( field, data ) {}
263 StringField( int field )
264: FieldBase( field, "" ) {}
265
266 void setValue( const std::string& value )
267 { setString( value ); }
268 const std::string& getValue() const
269 { return getString(); }
270 operator const std::string&() const
271 { return getString(); }
272
273 bool operator<( const StringField& rhs ) const
274 { return getString() < rhs.getString(); }
275 bool operator>( const StringField& rhs ) const
276 { return getString() > rhs.getString(); }
277 bool operator==( const StringField& rhs ) const
278 { return getString() == rhs.getString(); }
279 bool operator!=( const StringField& rhs ) const
280 { return getString() != rhs.getString(); }
281 bool operator<=( const StringField& rhs ) const
282 { return getString() <= rhs.getString(); }
283 bool operator>=( const StringField& rhs ) const
284 { return getString() >= rhs.getString(); }
285 friend bool operator<( const StringField&, const char* );
286 friend bool operator<( const char*, const StringField& );
287 friend bool operator>( const StringField&, const char* );
288 friend bool operator>( const char*, const StringField& );
289 friend bool operator==( const StringField&, const char* );
290 friend bool operator==( const char*, const StringField& );
291 friend bool operator!=( const StringField&, const char* );
292 friend bool operator!=( const char*, const StringField& );
293 friend bool operator<=( const StringField&, const char* );
294 friend bool operator<=( const char*, const StringField& );
295 friend bool operator>=( const StringField&, const char* );
296 friend bool operator>=( const char*, const StringField& );
297
298 friend bool operator<( const StringField&, const std::string& );
299 friend bool operator<( const std::string&, const StringField& );
300 friend bool operator>( const StringField&, const std::string& );
301 friend bool operator>( const std::string&, const StringField& );
302 friend bool operator==( const StringField&, const std::string& );
303 friend bool operator==( const std::string&, const StringField& );
304 friend bool operator!=( const StringField&, const std::string& );
305 friend bool operator!=( const std::string&, const StringField& );
306 friend bool operator<=( const StringField&, const std::string& );
307 friend bool operator<=( const std::string&, const StringField& );
308 friend bool operator>=( const StringField&, const std::string& );
309 friend bool operator>=( const std::string&, const StringField& );
310};
311
312inline bool operator<( const StringField& lhs, const char* rhs )
313 { return lhs.getValue() < rhs; }
314inline bool operator<( const char* lhs, const StringField& rhs )
315 { return lhs < rhs.getValue(); }
316inline bool operator>( const StringField& lhs, const char* rhs )
317 { return lhs.getValue() > rhs; }
318inline bool operator>( const char* lhs, const StringField& rhs )
319 { return lhs > rhs.getValue(); }
320inline bool operator==( const StringField& lhs, const char* rhs )
321 { return lhs.getValue() == rhs; }
322inline bool operator==( const char* lhs, const StringField& rhs )
323 { return lhs == rhs.getValue(); }
324inline bool operator!=( const StringField& lhs, const char* rhs )
325 { return lhs.getValue() != rhs; }
326inline bool operator!=( const char* lhs, const StringField& rhs )
327 { return lhs != rhs.getValue(); }
328inline bool operator<=( const StringField& lhs, const char* rhs )
329 { return lhs.getValue() <= rhs; }
330inline bool operator<=( const char* lhs, const StringField& rhs )
331 { return lhs <= rhs.getValue(); }
332inline bool operator>=( const StringField& lhs, const char* rhs )
333 { return lhs.getValue() >= rhs; }
334inline bool operator>=( const char* lhs, const StringField& rhs )
335 { return lhs >= rhs.getValue(); }
336
337inline bool operator<( const StringField& lhs, const std::string& rhs )
338 { return lhs.getValue() < rhs; }
339inline bool operator<( const std::string& lhs, const StringField& rhs )
340 { return lhs < rhs.getValue(); }
341inline bool operator>( const StringField& lhs, const std::string& rhs )
342 { return lhs.getValue() > rhs; }
343inline bool operator>( const std::string& lhs, const StringField& rhs )
344 { return lhs > rhs.getValue(); }
345inline bool operator==( const StringField& lhs, const std::string& rhs )
346 { return lhs.getValue() == rhs; }
347inline bool operator==( const std::string& lhs, const StringField& rhs )
348 { return lhs == rhs.getValue(); }
349inline bool operator!=( const StringField& lhs, const std::string& rhs )
350 { return lhs.getValue() != rhs; }
351inline bool operator!=( const std::string& lhs, const StringField& rhs )
352 { return lhs != rhs.getValue(); }
353inline bool operator<=( const StringField& lhs, const std::string& rhs )
354 { return lhs.getValue() <= rhs; }
355inline bool operator<=( const std::string& lhs, const StringField& rhs )
356 { return lhs <= rhs.getValue(); }
357inline bool operator>=( const StringField& lhs, const std::string& rhs )
358 { return lhs.getValue() >= rhs; }
359inline bool operator>=( const std::string& lhs, const StringField& rhs )
360 { return lhs >= rhs.getValue(); }
361
363class CharField : public FieldBase
364{
365public:
366 explicit CharField( int field, char data )
367: FieldBase( field, CharConvertor::convert( data ) ) {}
368 CharField( int field )
369: FieldBase( field, "" ) {}
370
371 void setValue( char value )
372 { setString( CharConvertor::convert( value ) ); }
373 char getValue() const throw ( IncorrectDataFormat )
374 { try
375 { return CharConvertor::convert( getString() ); }
376 catch( FieldConvertError& )
377 { throw IncorrectDataFormat( getTag(), getString() ); } }
378 operator char() const
379 { return getValue(); }
380};
381
383class DoubleField : public FieldBase
384{
385public:
386 explicit DoubleField( int field, double data, int padding = 0 )
387: FieldBase( field, DoubleConvertor::convert( data, padding ) ) {}
388 DoubleField( int field )
389: FieldBase( field, "" ) {}
390
391 void setValue( double value, int padding = 0 )
392 { setString( DoubleConvertor::convert( value, padding ) ); }
393 double getValue() const throw ( IncorrectDataFormat )
394 { try
395 { return DoubleConvertor::convert( getString() ); }
396 catch( FieldConvertError& )
397 { throw IncorrectDataFormat( getTag(), getString() ); } }
398 operator double() const
399 { return getValue(); }
400};
401
403class IntField : public FieldBase
404{
405public:
406 explicit IntField( int field, int data )
407: FieldBase( field, IntConvertor::convert( data ) ) {}
408 IntField( int field )
409: FieldBase( field, "" ) {}
410
411 void setValue( int value )
412 { setString( IntConvertor::convert( value ) ); }
413 int getValue() const throw ( IncorrectDataFormat )
414 { try
415 { return IntConvertor::convert( getString() ); }
416 catch( FieldConvertError& )
417 { throw IncorrectDataFormat( getTag(), getString() ); } }
418 operator const int() const
419 { return getValue(); }
420};
421
423class BoolField : public FieldBase
424{
425public:
426 explicit BoolField( int field, bool data )
427: FieldBase( field, BoolConvertor::convert( data ) ) {}
428 BoolField( int field )
429: FieldBase( field, "" ) {}
430
431 void setValue( bool value )
432 { setString( BoolConvertor::convert( value ) ); }
433 bool getValue() const throw ( IncorrectDataFormat )
434 { try
435 { return BoolConvertor::convert( getString() ); }
436 catch( FieldConvertError& )
437 { throw IncorrectDataFormat( getTag(), getString() ); } }
438 operator bool() const
439 { return getValue(); }
440};
441
444{
445public:
446 explicit UtcTimeStampField( int field, const UtcTimeStamp& data, int precision = 0 )
447: FieldBase( field, UtcTimeStampConvertor::convert( data, precision ) ) {}
448 UtcTimeStampField( int field, int precision = 0 )
449: FieldBase( field, UtcTimeStampConvertor::convert( UtcTimeStamp(), precision ) ) {}
450
451 void setValue( const UtcTimeStamp& value )
454 { try
456 catch( FieldConvertError& )
457 { throw IncorrectDataFormat( getTag(), getString() ); } }
458 operator UtcTimeStamp() const
459 { return getValue(); }
460
461 bool operator<( const UtcTimeStampField& rhs ) const
462 { return getValue() < rhs.getValue(); }
463 bool operator==( const UtcTimeStampField& rhs ) const
464 { return getValue() == rhs.getValue(); }
465 bool operator!=( const UtcTimeStampField& rhs ) const
466 { return getValue() != rhs.getValue(); }
467};
468
471{
472public:
473 explicit UtcDateField( int field, const UtcDate& data )
474: FieldBase( field, UtcDateConvertor::convert( data ) ) {}
475 UtcDateField( int field )
476: FieldBase( field, UtcDateConvertor::convert( UtcDate() ) ) {}
477
478 void setValue( const UtcDate& value )
479 { setString( UtcDateConvertor::convert( value ) ); }
481 { try
482 { return UtcDateConvertor::convert( getString() ); }
483 catch( FieldConvertError& )
484 { throw IncorrectDataFormat( getTag(), getString() ); } }
485 operator UtcDate() const
486 { return getValue(); }
487
488 bool operator<( const UtcDateField& rhs ) const
489 { return getValue() < rhs.getValue(); }
490 bool operator==( const UtcDateField& rhs ) const
491 { return getValue() == rhs.getValue(); }
492 bool operator!=( const UtcDateField& rhs ) const
493 { return getValue() != rhs.getValue(); }
494};
495
498{
499public:
500 explicit UtcTimeOnlyField( int field, const UtcTimeOnly& data, int precision = 0 )
501: FieldBase( field, UtcTimeOnlyConvertor::convert( data, precision ) ) {}
502 UtcTimeOnlyField( int field, int precision = 0 )
503: FieldBase( field, UtcTimeOnlyConvertor::convert( UtcTimeOnly(), precision ) ) {}
504
505 void setValue( const UtcTimeOnly& value )
508 { try
510 catch( FieldConvertError& )
511 { throw IncorrectDataFormat( getTag(), getString() ); } }
512 operator UtcTimeOnly() const
513 { return getValue(); }
514
515 bool operator<( const UtcTimeOnlyField& rhs ) const
516 { return getValue() < rhs.getValue(); }
517 bool operator==( const UtcTimeOnlyField& rhs ) const
518 { return getValue() == rhs.getValue(); }
519 bool operator!=( const UtcTimeOnlyField& rhs ) const
520 { return getValue() != rhs.getValue(); }
521};
522
525{
526public:
527 explicit CheckSumField( int field, int data )
528: FieldBase( field, CheckSumConvertor::convert( data ) ) {}
529 CheckSumField( int field )
530: FieldBase( field, "" ) {}
531
532 void setValue( int value )
534 int getValue() const throw ( IncorrectDataFormat )
535 { try
537 catch( FieldConvertError& )
538 { throw IncorrectDataFormat( getTag(), getString() ); } }
539 operator const int() const
540 { return getValue(); }
541};
542
566}
567
568#define DEFINE_FIELD_CLASS_NUM( NAME, TOK, TYPE, NUM ) \
569class NAME : public TOK##Field { public: \
570NAME() : TOK##Field(NUM) {} \
571NAME(const TYPE& value) : TOK##Field(NUM, value) {} \
572}
573
574#define DEFINE_FIELD_CLASS( NAME, TOK, TYPE ) \
575DEFINE_FIELD_CLASS_NUM(NAME, TOK, TYPE, FIELD::NAME)
576
577#define DEFINE_DEPRECATED_FIELD_CLASS( NAME, TOK, TYPE ) \
578DEFINE_FIELD_CLASS_NUM(NAME, TOK, TYPE, DEPRECATED_FIELD::NAME)
579
580#define DEFINE_FIELD_TIMECLASS_NUM( NAME, TOK, TYPE, NUM ) \
581class NAME : public TOK##Field { public: \
582NAME() : TOK##Field(NUM, false) {} \
583NAME(int precision) : TOK##Field(NUM, precision) {} \
584NAME(const TYPE& value) : TOK##Field(NUM, value) {} \
585NAME(const TYPE& value, int precision) : TOK##Field(NUM, value, precision) {} \
586}
587
588#define DEFINE_FIELD_TIMECLASS( NAME, TOK, TYPE ) \
589DEFINE_FIELD_TIMECLASS_NUM(NAME, TOK, TYPE, FIELD::NAME)
590
591#define DEFINE_DEPRECATED_FIELD_TIMECLASS( NAME, TOK, TYPE ) \
592DEFINE_FIELD_TIMECLASS_NUM(NAME, TOK, TYPE, DEPRECATED_FIELD::NAME)
593
594#define DEFINE_CHECKSUM( NAME ) \
595 DEFINE_FIELD_CLASS(NAME, CheckSum, FIX::INT)
596#define DEFINE_STRING( NAME ) \
597 DEFINE_FIELD_CLASS(NAME, String, FIX::STRING)
598#define DEFINE_CHAR( NAME ) \
599 DEFINE_FIELD_CLASS(NAME, Char, FIX::CHAR)
600#define DEFINE_PRICE( NAME ) \
601 DEFINE_FIELD_CLASS(NAME, Price, FIX::PRICE)
602#define DEFINE_INT( NAME ) \
603 DEFINE_FIELD_CLASS(NAME, Int, FIX::INT)
604#define DEFINE_AMT( NAME ) \
605 DEFINE_FIELD_CLASS(NAME, Amt, FIX::AMT)
606#define DEFINE_QTY( NAME ) \
607 DEFINE_FIELD_CLASS(NAME, Qty, FIX::QTY)
608#define DEFINE_CURRENCY( NAME ) \
609 DEFINE_FIELD_CLASS(NAME, Currency, FIX::CURRENCY)
610#define DEFINE_MULTIPLEVALUESTRING( NAME ) \
611 DEFINE_FIELD_CLASS(NAME, MultipleValueString, FIX::MULTIPLEVALUESTRING)
612#define DEFINE_MULTIPLESTRINGVALUE( NAME ) \
613 DEFINE_FIELD_CLASS(NAME, MultipleStringValue, FIX::MULTIPLESTRINGVALUE)
614#define DEFINE_MULTIPLECHARVALUE( NAME ) \
615 DEFINE_FIELD_CLASS(NAME, MultipleCharValue, FIX::MULTIPLECHARVALUE)
616#define DEFINE_EXCHANGE( NAME ) \
617 DEFINE_FIELD_CLASS(NAME, Exchange, FIX::EXCHANGE)
618#define DEFINE_UTCTIMESTAMP( NAME ) \
619 DEFINE_FIELD_TIMECLASS(NAME, UtcTimeStamp, FIX::UTCTIMESTAMP)
620#define DEFINE_BOOLEAN( NAME ) \
621 DEFINE_FIELD_CLASS(NAME, Bool, FIX::BOOLEAN)
622#define DEFINE_LOCALMKTDATE( NAME ) \
623 DEFINE_FIELD_CLASS(NAME, String, FIX::LOCALMKTDATE)
624#define DEFINE_DATA( NAME ) \
625 DEFINE_FIELD_CLASS(NAME, Data, FIX::DATA)
626#define DEFINE_FLOAT( NAME ) \
627 DEFINE_FIELD_CLASS(NAME, Float, FIX::FLOAT)
628#define DEFINE_PRICEOFFSET( NAME ) \
629 DEFINE_FIELD_CLASS(NAME, PriceOffset, FIX::PRICEOFFSET)
630#define DEFINE_MONTHYEAR( NAME ) \
631 DEFINE_FIELD_CLASS(NAME, MonthYear, FIX::MONTHYEAR)
632#define DEFINE_DAYOFMONTH( NAME ) \
633 DEFINE_FIELD_CLASS(NAME, DayOfMonth, FIX::DAYOFMONTH)
634#define DEFINE_UTCDATE( NAME ) \
635 DEFINE_FIELD_CLASS(NAME, UtcDate, FIX::UTCDATE)
636#define DEFINE_UTCDATEONLY( NAME ) \
637 DEFINE_FIELD_CLASS(NAME, UtcDateOnly, FIX::UTCDATEONLY)
638#define DEFINE_UTCTIMEONLY( NAME ) \
639 DEFINE_FIELD_CLASS(NAME, UtcTimeOnly, FIX::UTCTIMEONLY)
640#define DEFINE_NUMINGROUP( NAME ) \
641 DEFINE_FIELD_CLASS(NAME, NumInGroup, FIX::NUMINGROUP)
642#define DEFINE_SEQNUM( NAME ) \
643 DEFINE_FIELD_CLASS(NAME, SeqNum, FIX::SEQNUM)
644#define DEFINE_LENGTH( NAME ) \
645 DEFINE_FIELD_CLASS(NAME, Length, FIX::LENGTH)
646#define DEFINE_PERCENTAGE( NAME ) \
647 DEFINE_FIELD_CLASS(NAME, Percentage, FIX::PERCENTAGE)
648#define DEFINE_COUNTRY( NAME ) \
649 DEFINE_FIELD_CLASS(NAME, Country, FIX::COUNTRY)
650#define DEFINE_TZTIMEONLY( NAME ) \
651 DEFINE_FIELD_CLASS(NAME, String, FIX::TZTIMEONLY)
652#define DEFINE_TZTIMESTAMP( NAME ) \
653 DEFINE_FIELD_CLASS(NAME, String, FIX::TZTIMESTAMP)
654#define DEFINE_XMLDATA( NAME ) \
655 DEFINE_FIELD_CLASS(NAME, String, FIX::XMLDATA)
656#define DEFINE_LANGUAGE( NAME ) \
657 DEFINE_FIELD_CLASS(NAME, String, FIX::LANGUAGE)
658
659#define USER_DEFINE_STRING( NAME, NUM ) \
660 DEFINE_FIELD_CLASS_NUM(NAME, String, FIX::STRING, NUM)
661#define USER_DEFINE_CHAR( NAME, NUM ) \
662 DEFINE_FIELD_CLASS_NUM(NAME, Char, FIX::CHAR, NUM)
663#define USER_DEFINE_PRICE( NAME, NUM ) \
664 DEFINE_FIELD_CLASS_NUM(NAME, Price, FIX::PRICE, NUM)
665#define USER_DEFINE_INT( NAME, NUM ) \
666 DEFINE_FIELD_CLASS_NUM(NAME, Int, FIX::INT, NUM)
667#define USER_DEFINE_AMT( NAME, NUM ) \
668 DEFINE_FIELD_CLASS_NUM(NAME, Amt, FIX::AMT, NUM)
669#define USER_DEFINE_QTY( NAME, NUM ) \
670 DEFINE_FIELD_CLASS_NUM(NAME, Qty, FIX::QTY, NUM)
671#define USER_DEFINE_CURRENCY( NAME, NUM ) \
672 DEFINE_FIELD_CLASS_NUM(NAME, Currency, FIX::CURRENCY, NUM)
673#define USER_DEFINE_MULTIPLEVALUESTRING( NAME, NUM ) \
674 DEFINE_FIELD_CLASS_NUM(NAME, MultipleValueString, FIX::MULTIPLEVALUESTRING, NUM)
675#define USER_DEFINE_MULTIPLESTRINGVALUE( NAME, NUM ) \
676 DEFINE_FIELD_CLASS_NUM(NAME, MultipleStringValue, FIX::MULTIPLESTRINGVALUE, NUM)
677#define USER_DEFINE_MULTIPLECHARVALUE( NAME, NUM ) \
678 DEFINE_FIELD_CLASS_NUM(NAME, MultipleCharValue, FIX::MULTIPLECHARVALUE, NUM)
679#define USER_DEFINE_EXCHANGE( NAME, NUM ) \
680 DEFINE_FIELD_CLASS_NUM(NAME, Exchange, FIX::EXCHANGE, NUM)
681#define USER_DEFINE_UTCTIMESTAMP( NAME, NUM ) \
682 DEFINE_FIELD_TIMECLASS_NUM(NAME, UtcTimeStamp, FIX::UTCTIMESTAMP, NUM)
683#define USER_DEFINE_BOOLEAN( NAME, NUM ) \
684 DEFINE_FIELD_CLASS_NUM(NAME, Bool, FIX::BOOLEAN, NUM)
685#define USER_DEFINE_LOCALMKTDATE( NAME, NUM ) \
686 DEFINE_FIELD_CLASS_NUM(NAME, String, FIX::STRING, NUM)
687#define USER_DEFINE_DATA( NAME, NUM ) \
688 DEFINE_FIELD_CLASS_NUM(NAME, Data, FIX::DATA, NUM)
689#define USER_DEFINE_FLOAT( NAME, NUM ) \
690 DEFINE_FIELD_CLASS_NUM(NAME, Float, FIX::FLOAT, NUM)
691#define USER_DEFINE_PRICEOFFSET( NAME, NUM ) \
692 DEFINE_FIELD_CLASS_NUM(NAME, PriceOffset, FIX::PRICEOFFSET, NUM)
693#define USER_DEFINE_MONTHYEAR( NAME, NUM ) \
694 DEFINE_FIELD_CLASS_NUM(NAME, MonthYear, FIX::MONTHYEAR, NUM)
695#define USER_DEFINE_DAYOFMONTH( NAME, NUM ) \
696 DEFINE_FIELD_CLASS_NUM(NAME, DayOfMonth, FIX::DAYOFMONTH, NUM)
697#define USER_DEFINE_UTCDATE( NAME, NUM ) \
698 DEFINE_FIELD_CLASS_NUM(NAME, UtcDate, FIX::UTCDATE, NUM)
699#define USER_DEFINE_UTCDATEONLY( NAME, NUM ) \
700 DEFINE_FIELD_CLASS_NUM(NAME, UtcDateOnly, FIX::UTCDATEONLY, NUM)
701#define USER_DEFINE_UTCTIMEONLY( NAME, NUM ) \
702 DEFINE_FIELD_CLASS_NUM(NAME, UtcTimeOnly, FIX::UTCTIMEONLY, NUM)
703#define USER_DEFINE_NUMINGROUP( NAME, NUM ) \
704 DEFINE_FIELD_CLASS_NUM(NAME, NumInGroup, FIX::NUMINGROUP, NUM)
705#define USER_DEFINE_SEQNUM( NAME, NUM ) \
706 DEFINE_FIELD_CLASS_NUM(NAME, SeqNum, FIX::SEQNUM, NUM)
707#define USER_DEFINE_LENGTH( NAME, NUM ) \
708 DEFINE_FIELD_CLASS_NUM(NAME, Length, FIX::LENGTH, NUM)
709#define USER_DEFINE_PERCENTAGE( NAME, NUM ) \
710 DEFINE_FIELD_CLASS_NUM(NAME, Percentage, FIX::PERCENTAGE, NUM)
711#define USER_DEFINE_COUNTRY( NAME, NUM ) \
712 DEFINE_FIELD_CLASS_NUM(NAME, Country, FIX::COUNTRY, NUM)
713#define USER_DEFINE_TZTIMEONLY( NAME, NUM ) \
714 DEFINE_FIELD_CLASS_NUM(NAME, String, FIX::TZTIMEONLY, NUM)
715#define USER_DEFINE_TZTIMESTAMP( NAME, NUM ) \
716 DEFINE_FIELD_CLASS_NUM(NAME, String, FIX::TZTIMESTAMP, NUM)
717#define USER_DEFINE_XMLDATA( NAME, NUM ) \
718 DEFINE_FIELD_CLASS_NUM(NAME, String, FIX::XMLDATA, NUM)
719#define USER_DEFINE_LANGUAGE( NAME, NUM ) \
720 DEFINE_FIELD_CLASS_NUM(NAME, String, FIX::LANGUAGE, NUM)
721
722#endif
723
Field that contains a boolean value.
Definition Field.h:424
BoolField(int field)
Definition Field.h:428
BoolField(int field, bool data)
Definition Field.h:426
bool getValue() const
Definition Field.h:433
void setValue(bool value)
Definition Field.h:431
Field that contains a character value.
Definition Field.h:364
char getValue() const
Definition Field.h:373
void setValue(char value)
Definition Field.h:371
CharField(int field, char data)
Definition Field.h:366
CharField(int field)
Definition Field.h:368
Field that contains a checksum value.
Definition Field.h:525
CheckSumField(int field, int data)
Definition Field.h:527
int getValue() const
Definition Field.h:534
CheckSumField(int field)
Definition Field.h:529
void setValue(int value)
Definition Field.h:532
Field that contains a double value.
Definition Field.h:384
void setValue(double value, int padding=0)
Definition Field.h:391
DoubleField(int field, double data, int padding=0)
Definition Field.h:386
DoubleField(int field)
Definition Field.h:388
double getValue() const
Definition Field.h:393
Class used to store field metrics like total length and checksum.
Definition Field.h:54
size_t getLength() const
Definition Field.h:62
field_metrics(const size_t length, const int checksum)
Definition Field.h:57
Base representation of all Field classes.
Definition Field.h:50
field_metrics m_metrics
Definition Field.h:238
const std::string & getString() const
Get the string representation of the fields value.
Definition Field.h:152
void setField(int field)
Definition Field.h:131
int getTag() const
Get the fields integer tag.
Definition Field.h:144
void setString(const std::string &string)
Definition Field.h:136
FieldBase(int tag, std::string::const_iterator valueStart, std::string::const_iterator valueEnd, std::string::const_iterator tagStart, std::string::const_iterator tagEnd)
Constructor which also calculates field metrics.
Definition Field.h:80
void setTag(int tag)
Definition Field.h:123
FieldBase & operator=(const FieldBase &rhs)
Definition Field.h:105
bool operator<(const FieldBase &field) const
Compares fields based on their tag numbers.
Definition Field.h:179
static field_metrics calculateMetrics(std::string::const_iterator const start, std::string::const_iterator const end)
Calculate metrics for any input string.
Definition Field.h:213
std::string m_string
Definition Field.h:236
void calculate() const
Definition Field.h:184
const std::string & getFixString() const
Get the string representation of the Field (i.e.) 55=MSFT[SOH].
Definition Field.h:156
int getField() const
Definition Field.h:148
void encodeTo(std::string &result) const
Serializes string representation of the Field to input string.
Definition Field.h:192
size_t getLength() const
Get the length of the fields string representation.
Definition Field.h:165
int getTotal() const
Get the total value the fields characters added together.
Definition Field.h:172
static field_metrics calculateMetrics(const std::string &field)
Definition Field.h:230
FieldBase(const FieldBase &rhs)
Definition Field.h:97
static field_metrics no_metrics()
Definition Field.h:207
virtual ~FieldBase()
Definition Field.h:95
void swap(FieldBase &rhs)
Definition Field.h:115
std::string m_data
Definition Field.h:237
FieldBase(int tag, const std::string &string)
Definition Field.h:91
Field that contains an integer value.
Definition Field.h:404
IntField(int field)
Definition Field.h:408
IntField(int field, int data)
Definition Field.h:406
void setValue(int value)
Definition Field.h:411
int getValue() const
Definition Field.h:413
Base class for all FIX messages.
Definition Message.h:118
MSC doesn't support partial template specialization so we have this.
Definition Field.h:259
friend bool operator<=(const StringField &, const char *)
Definition Field.h:328
StringField(int field, const std::string &data)
Definition Field.h:261
bool operator!=(const StringField &rhs) const
Definition Field.h:279
const std::string & getValue() const
Definition Field.h:268
StringField(int field)
Definition Field.h:263
bool operator<=(const StringField &rhs) const
Definition Field.h:281
friend bool operator>=(const StringField &, const char *)
Definition Field.h:332
bool operator<(const StringField &rhs) const
Definition Field.h:273
bool operator>=(const StringField &rhs) const
Definition Field.h:283
friend bool operator!=(const StringField &, const char *)
Definition Field.h:324
friend bool operator==(const StringField &, const char *)
Definition Field.h:320
bool operator==(const StringField &rhs) const
Definition Field.h:277
void setValue(const std::string &value)
Definition Field.h:266
friend bool operator>(const StringField &, const char *)
Definition Field.h:316
bool operator>(const StringField &rhs) const
Definition Field.h:275
friend bool operator<(const StringField &, const char *)
Definition Field.h:312
Field that contains a UTC date value.
Definition Field.h:471
bool operator==(const UtcDateField &rhs) const
Definition Field.h:490
UtcDateField(int field)
Definition Field.h:475
bool operator<(const UtcDateField &rhs) const
Definition Field.h:488
void setValue(const UtcDate &value)
Definition Field.h:478
UtcDateField(int field, const UtcDate &data)
Definition Field.h:473
UtcDate getValue() const
Definition Field.h:480
bool operator!=(const UtcDateField &rhs) const
Definition Field.h:492
Date only represented in UTC.
Definition FieldTypes.h:801
Field that contains a UTC time value.
Definition Field.h:498
UtcTimeOnlyField(int field, int precision=0)
Definition Field.h:502
UtcTimeOnly getValue() const
Definition Field.h:507
void setValue(const UtcTimeOnly &value)
Definition Field.h:505
bool operator<(const UtcTimeOnlyField &rhs) const
Definition Field.h:515
bool operator!=(const UtcTimeOnlyField &rhs) const
Definition Field.h:519
UtcTimeOnlyField(int field, const UtcTimeOnly &data, int precision=0)
Definition Field.h:500
bool operator==(const UtcTimeOnlyField &rhs) const
Definition Field.h:517
Time only represented in UTC.
Definition FieldTypes.h:685
Field that contains a UTC time stamp value.
Definition Field.h:444
UtcTimeStampField(int field, const UtcTimeStamp &data, int precision=0)
Definition Field.h:446
bool operator!=(const UtcTimeStampField &rhs) const
Definition Field.h:465
UtcTimeStampField(int field, int precision=0)
Definition Field.h:448
UtcTimeStamp getValue() const
Definition Field.h:453
void setValue(const UtcTimeStamp &value)
Definition Field.h:451
bool operator<(const UtcTimeStampField &rhs) const
Definition Field.h:461
bool operator==(const UtcTimeStampField &rhs) const
Definition Field.h:463
Date and Time represented in UTC.
Definition FieldTypes.h:583
bool operator==(const DatabaseConnectionID &lhs, const DatabaseConnectionID &rhs)
void swap(FieldBase &lhs, FieldBase &rhs)
Definition Field.h:249
StringField DataField
Definition Field.h:552
DoubleField AmtField
Definition Field.h:544
StringField TzTimeStampField
Definition Field.h:565
StringField TzTimeOnlyField
Definition Field.h:564
StringField MultipleCharValueField
Definition Field.h:549
StringField MonthYearField
Definition Field.h:556
StringField DayOfMonthField
Definition Field.h:557
StringField CurrencyField
Definition Field.h:546
bool operator>(const StringField &lhs, const char *rhs)
Definition Field.h:316
IntField LengthField
Definition Field.h:559
StringField MultipleStringValueField
Definition Field.h:548
StringField MultipleValueStringField
Definition Field.h:547
StringField ExchangeField
Definition Field.h:550
bool operator<(const DatabaseConnectionID &lhs, const DatabaseConnectionID &rhs)
UtcDateField UtcDateOnlyField
Definition Field.h:558
StringField CountryField
Definition Field.h:563
char * integer_to_string(char *buf, const size_t len, signed_int t)
bool operator<=(const StringField &lhs, const char *rhs)
Definition Field.h:328
IntField SeqNumField
Definition Field.h:561
StringField LocalMktDateField
Definition Field.h:551
bool operator!=(const DatabaseConnectionID &lhs, const DatabaseConnectionID &rhs)
DoubleField PriceOffsetField
Definition Field.h:554
bool operator>=(const StringField &lhs, const char *rhs)
Definition Field.h:332
DoubleField QtyField
Definition Field.h:545
int number_of_symbols_in(const signed_int value)
StringField MonthField
Definition Field.h:555
DoubleField FloatField
Definition Field.h:553
DoubleField PriceField
Definition Field.h:543
IntField NumInGroupField
Definition Field.h:560
DoubleField PercentageField
Definition Field.h:562
Converts boolean to/from a string.
static std::string convert(bool value)
Converts character to/from a string.
static std::string convert(char value)
Converts checksum to/from a string.
static std::string convert(int value)
Converts double to/from a string.
static std::string convert(double value, int padding=0)
Unable to convert field into its native format.
Definition Exceptions.h:67
Field has a badly formatted value.
Definition Exceptions.h:147
Converts integer to/from a string.
static std::string convert(signed_int value)
Converts a UtcDate to/from a string.
static std::string convert(const UtcDate &value)
Converts a UtcTimeOnly to/from a string.
static std::string convert(const UtcTimeOnly &value, int precision=0)
Converts a UtcTimeStamp to/from a string.
static std::string convert(const UtcTimeStamp &value, int precision=0)

Generated on Thu Feb 29 2024 22:38:19 for QuickFIX by doxygen 1.9.8 written by Dimitri van Heesch, © 1997-2001