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 780 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 782 of file FieldConvertors.h.

References FIX::integer_to_string_padded().

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

784  {
785  char result[ 9 ];
786  int year, month, day;
787 
788  value.getYMD( year, month, day );
789 
790  integer_to_string_padded( result, 5, year, 4 );
791  integer_to_string_padded( result + 4, 3, month, 2 );
792  integer_to_string_padded( result + 6, 3, day, 2 );
793  return result;
794  }
char * integer_to_string_padded(char *buf, const size_t len, signed_int t, const size_t width=0, const char paddingChar='0')

◆ convert() [2/2]

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

Definition at line 796 of file FieldConvertors.h.

References IS_DIGIT.

798  {
799  if( value.size() != 8 ) throw FieldConvertError(value);
800 
801  int i = 0;
802  for( int c=0; c<8; ++c )
803  if( !IS_DIGIT(value[i++]) ) throw FieldConvertError(value);
804 
805  int year, mon, mday;
806 
807  i = 0;
808 
809  year = value[i++] - '0';
810  year = 10 * year + value[i++] - '0';
811  year = 10 * year + value[i++] - '0';
812  year = 10 * year + value[i++] - '0';
813 
814  mon = value[i++] - '0';
815  mon = 10 * mon + value[i++] - '0';
816  if( mon < 1 || 12 < mon )
817  throw FieldConvertError(value);
818 
819  mday = value[i++] - '0';
820  mday = 10 * mday + value[i++] - '0';
821  if( mday < 1 || 31 < mday )
822  throw FieldConvertError(value);
823 
824  return UtcDateOnly( mday, mon, year );
825  }
UtcDate UtcDateOnly
Definition: FieldTypes.h:624
#define IS_DIGIT(x)

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

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