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 namespace FIX
37 {
45 class FieldBase
46 {
47 
50  {
51  public:
52 
53  field_metrics( const size_t length, const int checksum )
54  : m_length( length )
55  , m_checksum( checksum )
56  {}
57 
58  size_t getLength() const
59  { return m_length; }
60 
61  int getCheckSum() const
62  { return m_checksum; }
63 
64  bool isValid() const
65  { return m_length > 0; }
66 
67  private:
68 
69  size_t m_length;
71  };
72 
73  friend class Message;
74 
76  FieldBase( int field,
77  std::string::const_iterator valueStart,
78  std::string::const_iterator valueEnd,
79  std::string::const_iterator tagStart,
80  std::string::const_iterator tagEnd )
81  : m_field( field )
82  , m_string( valueStart, valueEnd )
83  , m_metrics( calculateMetrics( tagStart, tagEnd ) )
84  {}
85 
86 public:
87  FieldBase( int field, const std::string& string )
88  : m_field( field ), m_string(string), m_metrics( no_metrics() )
89  {}
90 
91  virtual ~FieldBase() {}
92 
93  void setField( int field )
94  {
95  m_field = field;
97  m_data.clear();
98  }
99 
100  void setString( const std::string& string )
101  {
102  m_string = string;
103  m_metrics = no_metrics();
104  m_data.clear();
105  }
106 
108  int getField() const
109  { return m_field; }
110 
112  const std::string& getString() const
113  { return m_string; }
114 
116  const std::string& getFixString() const
117  {
118  if( m_data.empty() )
119  encodeTo( m_data );
120 
121  return m_data;
122  }
123 
125  size_t getLength() const
126  {
127  calculate();
128  return m_metrics.getLength();
129  }
130 
132  int getTotal() const
133  {
134  calculate();
135  return m_metrics.getCheckSum();
136  }
137 
139  bool operator < ( const FieldBase& field ) const
140  { return m_field < field.m_field; }
141 
142 private:
143 
144  void calculate() const
145  {
146  if( m_metrics.isValid() ) return;
147 
149  }
150 
152  void encodeTo( std::string& result ) const
153  {
154  size_t tagLength = FIX::number_of_symbols_in( m_field ) + 1;
155  size_t totalLength = tagLength + m_string.length() + 1;
156 
157  result.resize( totalLength );
158 
159  char * buf = (char*)result.c_str();
160  FIX::integer_to_string( buf, tagLength, m_field );
161 
162  buf[tagLength - 1] = '=';
163  memcpy( buf + tagLength, m_string.data(), m_string.length() );
164  buf[totalLength - 1] = '\001';
165  }
166 
168  {
169  return field_metrics( 0, 0 );
170  }
171 
174  std::string::const_iterator const start,
175  std::string::const_iterator const end )
176  {
177  int checksum = 0;
178  for ( std::string::const_iterator str = start; str != end; ++str )
179  checksum += (unsigned char)( *str );
180 
181  return field_metrics( std::distance( start, end ), checksum );
182  }
183 
184  static field_metrics calculateMetrics( const std::string& field )
185  {
186  return calculateMetrics( field.begin(), field.end() );
187  }
188 
189  int m_field;
190  std::string m_string;
191  mutable std::string m_data;
193 };
196 inline std::ostream& operator <<
197 ( std::ostream& stream, const FieldBase& field )
198 {
199  stream << field.getString();
200  return stream;
201 }
202 
207 class StringField : public FieldBase
208 {
209 public:
210  explicit StringField( int field, const std::string& data )
211 : FieldBase( field, data ) {}
212  StringField( int field )
213 : FieldBase( field, "" ) {}
214 
215  void setValue( const std::string& value )
216  { setString( value ); }
217  const std::string& getValue() const
218  { return getString(); }
219  operator const std::string&() const
220  { return getString(); }
221 
222  bool operator<( const StringField& rhs ) const
223  { return getString() < rhs.getString(); }
224  bool operator>( const StringField& rhs ) const
225  { return getString() > rhs.getString(); }
226  bool operator==( const StringField& rhs ) const
227  { return getString() == rhs.getString(); }
228  bool operator!=( const StringField& rhs ) const
229  { return getString() != rhs.getString(); }
230  bool operator<=( const StringField& rhs ) const
231  { return getString() <= rhs.getString(); }
232  bool operator>=( const StringField& rhs ) const
233  { return getString() >= rhs.getString(); }
234  friend bool operator<( const StringField&, const char* );
235  friend bool operator<( const char*, const StringField& );
236  friend bool operator>( const StringField&, const char* );
237  friend bool operator>( const char*, const StringField& );
238  friend bool operator==( const StringField&, const char* );
239  friend bool operator==( const char*, const StringField& );
240  friend bool operator!=( const StringField&, const char* );
241  friend bool operator!=( const char*, const StringField& );
242  friend bool operator<=( const StringField&, const char* );
243  friend bool operator<=( const char*, const StringField& );
244  friend bool operator>=( const StringField&, const char* );
245  friend bool operator>=( const char*, const StringField& );
246 
247  friend bool operator<( const StringField&, const std::string& );
248  friend bool operator<( const std::string&, const StringField& );
249  friend bool operator>( const StringField&, const std::string& );
250  friend bool operator>( const std::string&, const StringField& );
251  friend bool operator==( const StringField&, const std::string& );
252  friend bool operator==( const std::string&, const StringField& );
253  friend bool operator!=( const StringField&, const std::string& );
254  friend bool operator!=( const std::string&, const StringField& );
255  friend bool operator<=( const StringField&, const std::string& );
256  friend bool operator<=( const std::string&, const StringField& );
257  friend bool operator>=( const StringField&, const std::string& );
258  friend bool operator>=( const std::string&, const StringField& );
259 };
260 
261 inline bool operator<( const StringField& lhs, const char* rhs )
262  { return lhs.getValue() < rhs; }
263 inline bool operator<( const char* lhs, const StringField& rhs )
264  { return lhs < rhs.getValue(); }
265 inline bool operator>( const StringField& lhs, const char* rhs )
266  { return lhs.getValue() > rhs; }
267 inline bool operator>( const char* lhs, const StringField& rhs )
268  { return lhs > rhs.getValue(); }
269 inline bool operator==( const StringField& lhs, const char* rhs )
270  { return lhs.getValue() == rhs; }
271 inline bool operator==( const char* lhs, const StringField& rhs )
272  { return lhs == rhs.getValue(); }
273 inline bool operator!=( const StringField& lhs, const char* rhs )
274  { return lhs.getValue() != rhs; }
275 inline bool operator!=( const char* lhs, const StringField& rhs )
276  { return lhs != rhs.getValue(); }
277 inline bool operator<=( const StringField& lhs, const char* rhs )
278  { return lhs.getValue() <= rhs; }
279 inline bool operator<=( const char* lhs, const StringField& rhs )
280  { return lhs <= rhs.getValue(); }
281 inline bool operator>=( const StringField& lhs, const char* rhs )
282  { return lhs.getValue() >= rhs; }
283 inline bool operator>=( const char* lhs, const StringField& rhs )
284  { return lhs >= rhs.getValue(); }
285 
286 inline bool operator<( const StringField& lhs, const std::string& rhs )
287  { return lhs.getValue() < rhs; }
288 inline bool operator<( const std::string& lhs, const StringField& rhs )
289  { return lhs < rhs.getValue(); }
290 inline bool operator>( const StringField& lhs, const std::string& rhs )
291  { return lhs.getValue() > rhs; }
292 inline bool operator>( const std::string& lhs, const StringField& rhs )
293  { return lhs > rhs.getValue(); }
294 inline bool operator==( const StringField& lhs, const std::string& rhs )
295  { return lhs.getValue() == rhs; }
296 inline bool operator==( const std::string& lhs, const StringField& rhs )
297  { return lhs == rhs.getValue(); }
298 inline bool operator!=( const StringField& lhs, const std::string& rhs )
299  { return lhs.getValue() != rhs; }
300 inline bool operator!=( const std::string& lhs, const StringField& rhs )
301  { return lhs != rhs.getValue(); }
302 inline bool operator<=( const StringField& lhs, const std::string& rhs )
303  { return lhs.getValue() <= rhs; }
304 inline bool operator<=( const std::string& lhs, const StringField& rhs )
305  { return lhs <= rhs.getValue(); }
306 inline bool operator>=( const StringField& lhs, const std::string& rhs )
307  { return lhs.getValue() >= rhs; }
308 inline bool operator>=( const std::string& lhs, const StringField& rhs )
309  { return lhs >= rhs.getValue(); }
310 
312 class CharField : public FieldBase
313 {
314 public:
315  explicit CharField( int field, char data )
316 : FieldBase( field, CharConvertor::convert( data ) ) {}
317  CharField( int field )
318 : FieldBase( field, "" ) {}
319 
320  void setValue( char value )
321  { setString( CharConvertor::convert( value ) ); }
322  char getValue() const throw ( IncorrectDataFormat )
323  { try
324  { return CharConvertor::convert( getString() ); }
325  catch( FieldConvertError& )
326  { throw IncorrectDataFormat( getField(), getString() ); } }
327  operator char() const
328  { return getValue(); }
329 };
330 
332 class DoubleField : public FieldBase
333 {
334 public:
335  explicit DoubleField( int field, double data, int padding = 0 )
336 : FieldBase( field, DoubleConvertor::convert( data, padding ) ) {}
337  DoubleField( int field )
338 : FieldBase( field, "" ) {}
339 
340  void setValue( double value, int padding = 0 )
341  { setString( DoubleConvertor::convert( value, padding ) ); }
342  double getValue() const throw ( IncorrectDataFormat )
343  { try
344  { return DoubleConvertor::convert( getString() ); }
345  catch( FieldConvertError& )
346  { throw IncorrectDataFormat( getField(), getString() ); } }
347  operator double() const
348  { return getValue(); }
349 };
350 
352 class IntField : public FieldBase
353 {
354 public:
355  explicit IntField( int field, int data )
356 : FieldBase( field, IntConvertor::convert( data ) ) {}
357  IntField( int field )
358 : FieldBase( field, "" ) {}
359 
360  void setValue( int value )
361  { setString( IntConvertor::convert( value ) ); }
362  int getValue() const throw ( IncorrectDataFormat )
363  { try
364  { return IntConvertor::convert( getString() ); }
365  catch( FieldConvertError& )
366  { throw IncorrectDataFormat( getField(), getString() ); } }
367  operator const int() const
368  { return getValue(); }
369 };
370 
372 class BoolField : public FieldBase
373 {
374 public:
375  explicit BoolField( int field, bool data )
376 : FieldBase( field, BoolConvertor::convert( data ) ) {}
377  BoolField( int field )
378 : FieldBase( field, "" ) {}
379 
380  void setValue( bool value )
381  { setString( BoolConvertor::convert( value ) ); }
382  bool getValue() const throw ( IncorrectDataFormat )
383  { try
384  { return BoolConvertor::convert( getString() ); }
385  catch( FieldConvertError& )
386  { throw IncorrectDataFormat( getField(), getString() ); } }
387  operator bool() const
388  { return getValue(); }
389 };
390 
393 {
394 public:
395  explicit UtcTimeStampField( int field, const UtcTimeStamp& data, bool showMilliseconds = false )
396 : FieldBase( field, UtcTimeStampConvertor::convert( data, showMilliseconds ) ) {}
397  UtcTimeStampField( int field, bool showMilliseconds = false )
398 : FieldBase( field, UtcTimeStampConvertor::convert( UtcTimeStamp(), showMilliseconds ) ) {}
399 
400  void setValue( const UtcTimeStamp& value )
403  { try
405  catch( FieldConvertError& )
406  { throw IncorrectDataFormat( getField(), getString() ); } }
407  operator UtcTimeStamp() const
408  { return getValue(); }
409 
410  bool operator<( const UtcTimeStampField& rhs ) const
411  { return getValue() < rhs.getValue(); }
412  bool operator==( const UtcTimeStampField& rhs ) const
413  { return getValue() == rhs.getValue(); }
414  bool operator!=( const UtcTimeStampField& rhs ) const
415  { return getValue() != rhs.getValue(); }
416 };
417 
419 class UtcDateField : public FieldBase
420 {
421 public:
422  explicit UtcDateField( int field, const UtcDate& data )
423 : FieldBase( field, UtcDateConvertor::convert( data ) ) {}
424  UtcDateField( int field )
425 : FieldBase( field, UtcDateConvertor::convert( UtcDate() ) ) {}
426 
427  void setValue( const UtcDate& value )
428  { setString( UtcDateConvertor::convert( value ) ); }
430  { try
431  { return UtcDateConvertor::convert( getString() ); }
432  catch( FieldConvertError& )
433  { throw IncorrectDataFormat( getField(), getString() ); } }
434  operator UtcDate() const
435  { return getValue(); }
436 
437  bool operator<( const UtcDateField& rhs ) const
438  { return getValue() < rhs.getValue(); }
439  bool operator==( const UtcDateField& rhs ) const
440  { return getValue() == rhs.getValue(); }
441  bool operator!=( const UtcDateField& rhs ) const
442  { return getValue() != rhs.getValue(); }
443 };
444 
447 {
448 public:
449  explicit UtcTimeOnlyField( int field, const UtcTimeOnly& data, bool showMilliseconds = false )
450 : FieldBase( field, UtcTimeOnlyConvertor::convert( data, showMilliseconds ) ) {}
451  UtcTimeOnlyField( int field, bool showMilliseconds = false )
452 : FieldBase( field, UtcTimeOnlyConvertor::convert( UtcTimeOnly(), showMilliseconds ) ) {}
453 
454  void setValue( const UtcTimeOnly& value )
457  { try
459  catch( FieldConvertError& )
460  { throw IncorrectDataFormat( getField(), getString() ); } }
461  operator UtcTimeOnly() const
462  { return getValue(); }
463 
464  bool operator<( const UtcTimeOnlyField& rhs ) const
465  { return getValue() < rhs.getValue(); }
466  bool operator==( const UtcTimeOnlyField& rhs ) const
467  { return getValue() == rhs.getValue(); }
468  bool operator!=( const UtcTimeOnlyField& rhs ) const
469  { return getValue() != rhs.getValue(); }
470 };
471 
473 class CheckSumField : public FieldBase
474 {
475 public:
476  explicit CheckSumField( int field, int data )
477 : FieldBase( field, CheckSumConvertor::convert( data ) ) {}
478  CheckSumField( int field )
479 : FieldBase( field, "" ) {}
480 
481  void setValue( int value )
482  { setString( CheckSumConvertor::convert( value ) ); }
483  int getValue() const throw ( IncorrectDataFormat )
484  { try
485  { return CheckSumConvertor::convert( getString() ); }
486  catch( FieldConvertError& )
487  { throw IncorrectDataFormat( getField(), getString() ); } }
488  operator const int() const
489  { return getValue(); }
490 };
491 
515 }
516 
517 #define DEFINE_FIELD_CLASS_NUM( NAME, TOK, TYPE, NUM ) \
518 class NAME : public TOK##Field { public: \
519 NAME() : TOK##Field(NUM) {} \
520 NAME(const TYPE& value) : TOK##Field(NUM, value) {} \
521 }
522 
523 #define DEFINE_FIELD_CLASS( NAME, TOK, TYPE ) \
524 DEFINE_FIELD_CLASS_NUM(NAME, TOK, TYPE, FIELD::NAME)
525 
526 #define DEFINE_DEPRECATED_FIELD_CLASS( NAME, TOK, TYPE ) \
527 DEFINE_FIELD_CLASS_NUM(NAME, TOK, TYPE, DEPRECATED_FIELD::NAME)
528 
529 #define DEFINE_FIELD_TIMECLASS_NUM( NAME, TOK, TYPE, NUM ) \
530 class NAME : public TOK##Field { public: \
531 NAME() : TOK##Field(NUM, false) {} \
532 NAME(bool showMilliseconds) : TOK##Field(NUM, showMilliseconds) {} \
533 NAME(const TYPE& value) : TOK##Field(NUM, value) {} \
534 NAME(const TYPE& value, bool showMilliseconds) : TOK##Field(NUM, value, showMilliseconds) {} \
535 }
536 
537 #define DEFINE_FIELD_TIMECLASS( NAME, TOK, TYPE ) \
538 DEFINE_FIELD_TIMECLASS_NUM(NAME, TOK, TYPE, FIELD::NAME)
539 
540 #define DEFINE_DEPRECATED_FIELD_TIMECLASS( NAME, TOK, TYPE ) \
541 DEFINE_FIELD_TIMECLASS_NUM(NAME, TOK, TYPE, DEPRECATED_FIELD::NAME)
542 
543 #define DEFINE_CHECKSUM( NAME ) \
544  DEFINE_FIELD_CLASS(NAME, CheckSum, FIX::INT)
545 #define DEFINE_STRING( NAME ) \
546  DEFINE_FIELD_CLASS(NAME, String, FIX::STRING)
547 #define DEFINE_CHAR( NAME ) \
548  DEFINE_FIELD_CLASS(NAME, Char, FIX::CHAR)
549 #define DEFINE_PRICE( NAME ) \
550  DEFINE_FIELD_CLASS(NAME, Price, FIX::PRICE)
551 #define DEFINE_INT( NAME ) \
552  DEFINE_FIELD_CLASS(NAME, Int, FIX::INT)
553 #define DEFINE_AMT( NAME ) \
554  DEFINE_FIELD_CLASS(NAME, Amt, FIX::AMT)
555 #define DEFINE_QTY( NAME ) \
556  DEFINE_FIELD_CLASS(NAME, Qty, FIX::QTY)
557 #define DEFINE_CURRENCY( NAME ) \
558  DEFINE_FIELD_CLASS(NAME, Currency, FIX::CURRENCY)
559 #define DEFINE_MULTIPLEVALUESTRING( NAME ) \
560  DEFINE_FIELD_CLASS(NAME, MultipleValueString, FIX::MULTIPLEVALUESTRING)
561 #define DEFINE_MULTIPLESTRINGVALUE( NAME ) \
562  DEFINE_FIELD_CLASS(NAME, MultipleStringValue, FIX::MULTIPLESTRINGVALUE)
563 #define DEFINE_MULTIPLECHARVALUE( NAME ) \
564  DEFINE_FIELD_CLASS(NAME, MultipleCharValue, FIX::MULTIPLECHARVALUE)
565 #define DEFINE_EXCHANGE( NAME ) \
566  DEFINE_FIELD_CLASS(NAME, Exchange, FIX::EXCHANGE)
567 #define DEFINE_UTCTIMESTAMP( NAME ) \
568  DEFINE_FIELD_TIMECLASS(NAME, UtcTimeStamp, FIX::UTCTIMESTAMP)
569 #define DEFINE_BOOLEAN( NAME ) \
570  DEFINE_FIELD_CLASS(NAME, Bool, FIX::BOOLEAN)
571 #define DEFINE_LOCALMKTDATE( NAME ) \
572  DEFINE_FIELD_CLASS(NAME, String, FIX::LOCALMKTDATE)
573 #define DEFINE_DATA( NAME ) \
574  DEFINE_FIELD_CLASS(NAME, Data, FIX::DATA)
575 #define DEFINE_FLOAT( NAME ) \
576  DEFINE_FIELD_CLASS(NAME, Float, FIX::FLOAT)
577 #define DEFINE_PRICEOFFSET( NAME ) \
578  DEFINE_FIELD_CLASS(NAME, PriceOffset, FIX::PRICEOFFSET)
579 #define DEFINE_MONTHYEAR( NAME ) \
580  DEFINE_FIELD_CLASS(NAME, MonthYear, FIX::MONTHYEAR)
581 #define DEFINE_DAYOFMONTH( NAME ) \
582  DEFINE_FIELD_CLASS(NAME, DayOfMonth, FIX::DAYOFMONTH)
583 #define DEFINE_UTCDATE( NAME ) \
584  DEFINE_FIELD_CLASS(NAME, UtcDate, FIX::UTCDATE)
585 #define DEFINE_UTCDATEONLY( NAME ) \
586  DEFINE_FIELD_CLASS(NAME, UtcDateOnly, FIX::UTCDATEONLY)
587 #define DEFINE_UTCTIMEONLY( NAME ) \
588  DEFINE_FIELD_CLASS(NAME, UtcTimeOnly, FIX::UTCTIMEONLY)
589 #define DEFINE_NUMINGROUP( NAME ) \
590  DEFINE_FIELD_CLASS(NAME, NumInGroup, FIX::NUMINGROUP)
591 #define DEFINE_SEQNUM( NAME ) \
592  DEFINE_FIELD_CLASS(NAME, SeqNum, FIX::SEQNUM)
593 #define DEFINE_LENGTH( NAME ) \
594  DEFINE_FIELD_CLASS(NAME, Length, FIX::LENGTH)
595 #define DEFINE_PERCENTAGE( NAME ) \
596  DEFINE_FIELD_CLASS(NAME, Percentage, FIX::PERCENTAGE)
597 #define DEFINE_COUNTRY( NAME ) \
598  DEFINE_FIELD_CLASS(NAME, Country, FIX::COUNTRY)
599 #define DEFINE_TZTIMEONLY( NAME ) \
600  DEFINE_FIELD_CLASS(NAME, String, FIX::TZTIMEONLY)
601 #define DEFINE_TZTIMESTAMP( NAME ) \
602  DEFINE_FIELD_CLASS(NAME, String, FIX::TZTIMESTAMP)
603 #define DEFINE_XMLDATA( NAME ) \
604  DEFINE_FIELD_CLASS(NAME, String, FIX::XMLDATA)
605 #define DEFINE_LANGUAGE( NAME ) \
606  DEFINE_FIELD_CLASS(NAME, String, FIX::LANGUAGE)
607 
608 #define USER_DEFINE_STRING( NAME, NUM ) \
609  DEFINE_FIELD_CLASS_NUM(NAME, String, FIX::STRING, NUM)
610 #define USER_DEFINE_CHAR( NAME, NUM ) \
611  DEFINE_FIELD_CLASS_NUM(NAME, Char, FIX::CHAR, NUM)
612 #define USER_DEFINE_PRICE( NAME, NUM ) \
613  DEFINE_FIELD_CLASS_NUM(NAME, Price, FIX::PRICE, NUM)
614 #define USER_DEFINE_INT( NAME, NUM ) \
615  DEFINE_FIELD_CLASS_NUM(NAME, Int, FIX::INT, NUM)
616 #define USER_DEFINE_AMT( NAME, NUM ) \
617  DEFINE_FIELD_CLASS_NUM(NAME, Amt, FIX::AMT, NUM)
618 #define USER_DEFINE_QTY( NAME, NUM ) \
619  DEFINE_FIELD_CLASS_NUM(NAME, Qty, FIX::QTY, NUM)
620 #define USER_DEFINE_CURRENCY( NAME, NUM ) \
621  DEFINE_FIELD_CLASS_NUM(NAME, Currency, FIX::CURRENCY, NUM)
622 #define USER_DEFINE_MULTIPLEVALUESTRING( NAME, NUM ) \
623  DEFINE_FIELD_CLASS_NUM(NAME, MultipleValueString, FIX::MULTIPLEVALUESTRING, NUM)
624 #define USER_DEFINE_MULTIPLESTRINGVALUE( NAME, NUM ) \
625  DEFINE_FIELD_CLASS_NUM(NAME, MultipleStringValue, FIX::MULTIPLESTRINGVALUE, NUM)
626 #define USER_DEFINE_MULTIPLECHARVALUE( NAME, NUM ) \
627  DEFINE_FIELD_CLASS_NUM(NAME, MultipleCharValue, FIX::MULTIPLECHARVALUE, NUM)
628 #define USER_DEFINE_EXCHANGE( NAME, NUM ) \
629  DEFINE_FIELD_CLASS_NUM(NAME, Exchange, FIX::EXCHANGE, NUM)
630 #define USER_DEFINE_UTCTIMESTAMP( NAME, NUM ) \
631  DEFINE_FIELD_TIMECLASS_NUM(NAME, UtcTimeStamp, FIX::UTCTIMESTAMP, NUM)
632 #define USER_DEFINE_BOOLEAN( NAME, NUM ) \
633  DEFINE_FIELD_CLASS_NUM(NAME, Bool, FIX::BOOLEAN, NUM)
634 #define USER_DEFINE_LOCALMKTDATE( NAME, NUM ) \
635  DEFINE_FIELD_CLASS_NUM(NAME, String, FIX::STRING, NUM)
636 #define USER_DEFINE_DATA( NAME, NUM ) \
637  DEFINE_FIELD_CLASS_NUM(NAME, Data, FIX::DATA, NUM)
638 #define USER_DEFINE_FLOAT( NAME, NUM ) \
639  DEFINE_FIELD_CLASS_NUM(NAME, Float, FIX::FLOAT, NUM)
640 #define USER_DEFINE_PRICEOFFSET( NAME, NUM ) \
641  DEFINE_FIELD_CLASS_NUM(NAME, PriceOffset, FIX::PRICEOFFSET, NUM)
642 #define USER_DEFINE_MONTHYEAR( NAME, NUM ) \
643  DEFINE_FIELD_CLASS_NUM(NAME, MonthYear, FIX::MONTHYEAR, NUM)
644 #define USER_DEFINE_DAYOFMONTH( NAME, NUM ) \
645  DEFINE_FIELD_CLASS_NUM(NAME, DayOfMonth, FIX::DAYOFMONTH, NUM)
646 #define USER_DEFINE_UTCDATE( NAME, NUM ) \
647  DEFINE_FIELD_CLASS_NUM(NAME, UtcDate, FIX::UTCDATE, NUM)
648 #define USER_DEFINE_UTCDATEONLY( NAME, NUM ) \
649  DEFINE_FIELD_CLASS_NUM(NAME, UtcDateOnly, FIX::UTCDATEONLY, NUM)
650 #define USER_DEFINE_UTCTIMEONLY( NAME, NUM ) \
651  DEFINE_FIELD_CLASS_NUM(NAME, UtcTimeOnly, FIX::UTCTIMEONLY, NUM)
652 #define USER_DEFINE_NUMINGROUP( NAME, NUM ) \
653  DEFINE_FIELD_CLASS_NUM(NAME, NumInGroup, FIX::NUMINGROUP, NUM)
654 #define USER_DEFINE_SEQNUM( NAME, NUM ) \
655  DEFINE_FIELD_CLASS_NUM(NAME, SeqNum, FIX::SEQNUM, NUM)
656 #define USER_DEFINE_LENGTH( NAME, NUM ) \
657  DEFINE_FIELD_CLASS_NUM(NAME, Length, FIX::LENGTH, NUM)
658 #define USER_DEFINE_PERCENTAGE( NAME, NUM ) \
659  DEFINE_FIELD_CLASS_NUM(NAME, Percentage, FIX::PERCENTAGE, NUM)
660 #define USER_DEFINE_COUNTRY( NAME, NUM ) \
661  DEFINE_FIELD_CLASS_NUM(NAME, Country, FIX::COUNTRY, NUM)
662 #define USER_DEFINE_TZTIMEONLY( NAME, NUM ) \
663  DEFINE_FIELD_CLASS_NUM(NAME, String, FIX::TZTIMEONLY, NUM)
664 #define USER_DEFINE_TZTIMESTAMP( NAME, NUM ) \
665  DEFINE_FIELD_CLASS_NUM(NAME, String, FIX::TZTIMESTAMP, NUM)
666 #define USER_DEFINE_XMLDATA( NAME, NUM ) \
667  DEFINE_FIELD_CLASS_NUM(NAME, String, FIX::XMLDATA, NUM)
668 #define USER_DEFINE_LANGUAGE( NAME, NUM ) \
669  DEFINE_FIELD_CLASS_NUM(NAME, String, FIX::LANGUAGE, NUM)
670 
671 #endif
672 
bool operator==(const UtcDateField &rhs) const
Definition: Field.h:439
BoolField(int field)
Definition: Field.h:377
void setValue(const UtcTimeStamp &value)
Definition: Field.h:400
DoubleField PercentageField
Definition: Field.h:511
Unable to convert field into its native format.
Definition: Exceptions.h:66
int getValue() const
Definition: Field.h:483
static std::string convert(const UtcTimeOnly &value, bool showMilliseconds=false)
Field has a badly formatted value.
Definition: Exceptions.h:146
StringField MonthYearField
Definition: Field.h:505
int getTotal() const
Get the total value the fields characters added together.
Definition: Field.h:132
static std::string convert(char value)
BoolField(int field, bool data)
Definition: Field.h:375
void setValue(int value)
Definition: Field.h:360
static std::string convert(const UtcTimeStamp &value, bool showMilliseconds=false)
Field that contains a double value.
Definition: Field.h:332
StringField ExchangeField
Definition: Field.h:499
MSC doesn&#39;t support partial template specialization so we have this.
Definition: Field.h:207
Time only represented in UTC.
Definition: FieldTypes.h:469
const std::string & getString() const
Get the string representation of the fields value.
Definition: Field.h:112
UtcTimeOnlyField(int field, bool showMilliseconds=false)
Definition: Field.h:451
double getValue() const
Definition: Field.h:342
IntField NumInGroupField
Definition: Field.h:509
bool operator>(const StringField &rhs) const
Definition: Field.h:224
bool operator!=(const UtcTimeStampField &rhs) const
Definition: Field.h:414
Converts a UtcTimeStamp to/from a string.
int number_of_symbols_in(const signed_int value)
bool operator!=(const DatabaseConnectionID &lhs, const DatabaseConnectionID &rhs)
DoubleField FloatField
Definition: Field.h:502
size_t getLength() const
Definition: Field.h:58
Field that contains a checksum value.
Definition: Field.h:473
void encodeTo(std::string &result) const
Serializes string representation of the Field to input string.
Definition: Field.h:152
bool operator>=(const StringField &lhs, const char *rhs)
Definition: Field.h:281
static field_metrics calculateMetrics(const std::string &field)
Definition: Field.h:184
UtcTimeOnlyField(int field, const UtcTimeOnly &data, bool showMilliseconds=false)
Definition: Field.h:449
UtcDateField(int field, const UtcDate &data)
Definition: Field.h:422
char * integer_to_string(char *buf, const size_t len, signed_int t)
void setValue(const std::string &value)
Definition: Field.h:215
IntField(int field, int data)
Definition: Field.h:355
Field that contains a UTC date value.
Definition: Field.h:419
int getValue() const
Definition: Field.h:362
bool operator<(const UtcDateField &rhs) const
Definition: Field.h:437
StringField DataField
Definition: Field.h:501
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:173
Converts checksum to/from a string.
const std::string & getFixString() const
Get the string representation of the Field (i.e.) 55=MSFT[SOH].
Definition: Field.h:116
FieldBase(int field, const std::string &string)
Definition: Field.h:87
std::string m_string
Definition: Field.h:190
DoubleField(int field)
Definition: Field.h:337
void setValue(bool value)
Definition: Field.h:380
Field that contains a character value.
Definition: Field.h:312
bool operator==(const StringField &rhs) const
Definition: Field.h:226
Converts a UtcTimeOnly to/from a string.
int m_field
Definition: Field.h:189
StringField TzTimeOnlyField
Definition: Field.h:513
bool operator==(const DatabaseConnectionID &lhs, const DatabaseConnectionID &rhs)
IntField SeqNumField
Definition: Field.h:510
Field that contains a UTC time value.
Definition: Field.h:446
Field that contains a boolean value.
Definition: Field.h:372
static std::string convert(signed_int value)
IntField LengthField
Definition: Field.h:508
DoubleField AmtField
Definition: Field.h:493
void calculate() const
Definition: Field.h:144
Definition: Acceptor.cpp:34
const std::string & getValue() const
Definition: Field.h:217
CharField(int field)
Definition: Field.h:317
UtcTimeStampField(int field, const UtcTimeStamp &data, bool showMilliseconds=false)
Definition: Field.h:395
bool operator==(const UtcTimeOnlyField &rhs) const
Definition: Field.h:466
UtcDateField(int field)
Definition: Field.h:424
StringField DayOfMonthField
Definition: Field.h:506
Date only represented in UTC.
Definition: FieldTypes.h:551
bool operator<(const FieldBase &field) const
Compares fields based on their tag numbers.
Definition: Field.h:139
static std::string convert(double value, int padding=0)
field_metrics m_metrics
Definition: Field.h:192
static field_metrics no_metrics()
Definition: Field.h:167
field_metrics(const size_t length, const int checksum)
Definition: Field.h:53
StringField MultipleValueStringField
Definition: Field.h:496
bool operator!=(const UtcDateField &rhs) const
Definition: Field.h:441
std::string m_data
Definition: Field.h:191
DoubleField PriceField
Definition: Field.h:492
DoubleField(int field, double data, int padding=0)
Definition: Field.h:335
DoubleField PriceOffsetField
Definition: Field.h:503
StringField MultipleCharValueField
Definition: Field.h:498
Base class for all FIX messages.
Definition: Message.h:67
int getCheckSum() const
Definition: Field.h:61
bool getValue() const
Definition: Field.h:382
bool operator<(const StringField &rhs) const
Definition: Field.h:222
UtcDate getValue() const
Definition: Field.h:429
bool operator>(const StringField &lhs, const char *rhs)
Definition: Field.h:265
StringField MultipleStringValueField
Definition: Field.h:497
bool operator==(const UtcTimeStampField &rhs) const
Definition: Field.h:412
UtcTimeStampField(int field, bool showMilliseconds=false)
Definition: Field.h:397
int getField() const
Get the fields integer tag.
Definition: Field.h:108
static std::string convert(int value)
void setField(int field)
Definition: Field.h:93
StringField CurrencyField
Definition: Field.h:495
bool operator<=(const StringField &rhs) const
Definition: Field.h:230
void setValue(char value)
Definition: Field.h:320
Field that contains an integer value.
Definition: Field.h:352
Converts character to/from a string.
bool operator<=(const StringField &lhs, const char *rhs)
Definition: Field.h:277
static std::string convert(const UtcDate &value)
static std::string convert(bool value)
bool isValid() const
Definition: Field.h:64
Converts boolean to/from a string.
bool operator>=(const StringField &rhs) const
Definition: Field.h:232
StringField MonthField
Definition: Field.h:504
Base representation of all Field classes.
Definition: Field.h:45
StringField CountryField
Definition: Field.h:512
void setValue(const UtcTimeOnly &value)
Definition: Field.h:454
Date and Time represented in UTC.
Definition: FieldTypes.h:399
StringField TzTimeStampField
Definition: Field.h:514
Converts integer to/from a string.
CharField(int field, char data)
Definition: Field.h:315
void setValue(double value, int padding=0)
Definition: Field.h:340
StringField LocalMktDateField
Definition: Field.h:500
char getValue() const
Definition: Field.h:322
virtual ~FieldBase()
Definition: Field.h:91
UtcDateField UtcDateOnlyField
Definition: Field.h:507
void setString(const std::string &string)
Definition: Field.h:100
UtcTimeStamp getValue() const
Definition: Field.h:402
StringField(int field, const std::string &data)
Definition: Field.h:210
Converts a UtcDate to/from a string.
Field that contains a UTC time stamp value.
Definition: Field.h:392
UtcTimeOnly getValue() const
Definition: Field.h:456
bool operator!=(const StringField &rhs) const
Definition: Field.h:228
IntField(int field)
Definition: Field.h:357
FieldBase(int field, 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:76
bool operator<(const UtcTimeOnlyField &rhs) const
Definition: Field.h:464
bool operator!=(const UtcTimeOnlyField &rhs) const
Definition: Field.h:468
CheckSumField(int field, int data)
Definition: Field.h:476
Class used to store field metrics like total length and checksum.
Definition: Field.h:49
size_t getLength() const
Get the length of the fields string representation.
Definition: Field.h:125
CheckSumField(int field)
Definition: Field.h:478
DoubleField QtyField
Definition: Field.h:494
Converts double to/from a string.
bool operator<(const UtcTimeStampField &rhs) const
Definition: Field.h:410
StringField(int field)
Definition: Field.h:212
void setValue(const UtcDate &value)
Definition: Field.h:427
void setValue(int value)
Definition: Field.h:481

Generated on Thu Sep 5 2019 11:07:58 for QuickFIX by doxygen 1.8.13 written by Dimitri van Heesch, © 1997-2001