Static Public Member Functions | List of all members
FIX::UtcDateConvertor Struct Reference

Converts a UtcDate to/from a string. More...

#include <FieldConvertors.h>

Static Public Member Functions

static std::string convert (const UtcDate &value) throw ( FieldConvertError )
 
static UtcDate convert (const std::string &value) throw ( FieldConvertError )
 

Detailed Description

Converts a UtcDate to/from a string.

Definition at line 633 of file FieldConvertors.h.

Member Function Documentation

◆ convert() [1/2]

static std::string FIX::UtcDateConvertor::convert ( const UtcDate value)
throw (FieldConvertError
)
inlinestatic

Definition at line 635 of file FieldConvertors.h.

References FIX::integer_to_string_padded().

Referenced by FIX::DataDictionary::checkValidFormat(), FIX::UtcDateField::getValue(), and FIX::UtcDateField::setValue().

637  {
638  int year, month, day;
639  value.getYMD( year, month, day );
640 
641  char result[ 8 ];
642 
643  integer_to_string_padded( result, 4, year );
644  integer_to_string_padded( result + 4, 2, month );
645  integer_to_string_padded( result + 6, 2, day );
646 
647  return std::string( result, sizeof( result ) );
648  }
char * integer_to_string_padded(char *buf, const size_t len, signed_int t, const char paddingChar='0')

◆ convert() [2/2]

static UtcDate FIX::UtcDateConvertor::convert ( const std::string &  value)
throw (FieldConvertError
)
inlinestatic

Definition at line 650 of file FieldConvertors.h.

References IS_DIGIT.

652  {
653  if( value.size() != 8 ) throw FieldConvertError(value);
654 
655  int i = 0;
656  for( int c=0; c<8; ++c )
657  if( !IS_DIGIT(value[i++]) ) throw FieldConvertError(value);
658 
659  int year, mon, mday;
660 
661  i = 0;
662 
663  year = value[i++] - '0';
664  year = 10 * year + value[i++] - '0';
665  year = 10 * year + value[i++] - '0';
666  year = 10 * year + value[i++] - '0';
667 
668  mon = value[i++] - '0';
669  mon = 10 * mon + value[i++] - '0';
670  if( mon < 1 || 12 < mon )
671  throw FieldConvertError(value);
672 
673  mday = value[i++] - '0';
674  mday = 10 * mday + value[i++] - '0';
675  if( mday < 1 || 31 < mday )
676  throw FieldConvertError(value);
677 
678  return UtcDateOnly( mday, mon, year );
679  }
UtcDate UtcDateOnly
Definition: FieldTypes.h:873
#define IS_DIGIT(x)

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

Generated on Wed Aug 28 2019 14:13:46 for QuickFIX by doxygen 1.8.13 written by Dimitri van Heesch, © 1997-2001