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 UtcDate FIX::UtcDateConvertor::convert | ( | const std::string & | value | ) |
throw | ( | FieldConvertError
| ) |  |

inline static

Definition at line 650 of file FieldConvertors.h.

{
if( value.size() != 8 ) throw FieldConvertError(value);
int i = 0;
for( int c=0; c<8; ++c )
if( !IS_DIGIT(value[i++]) ) throw FieldConvertError(value);
int year, mon, mday;
i = 0;
year = value[i++] - '0';
year = 10 * year + value[i++] - '0';
year = 10 * year + value[i++] - '0';
year = 10 * year + value[i++] - '0';
mon = value[i++] - '0';
mon = 10 * mon + value[i++] - '0';
if( mon < 1 || 12 < mon )
throw FieldConvertError(value);
mday = value[i++] - '0';
mday = 10 * mday + value[i++] - '0';
if( mday < 1 || 31 < mday )
throw FieldConvertError(value);
return UtcDateOnly( mday, mon, year );
}
IS_DIGIT
#define IS_DIGIT(x)
Definition FieldConvertors.h:49
FIX::UtcDateOnly
UtcDate UtcDateOnly
Definition FieldTypes.h:873

References IS_DIGIT.

## convert() [2/2]

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

inline static

Definition at line 635 of file FieldConvertors.h.

{
int year, month, day;
value.getYMD( year, month, day );
char result[ 8 ];
integer_to_string_padded( result, 4, year );
integer_to_string_padded( result + 4, 2, month );
integer_to_string_padded( result + 6, 2, day );
return std::string( result, sizeof( result ) );
}
FIX::integer_to_string_padded
char * integer_to_string_padded(char *buf, const size_t len, signed_int t, const char paddingChar='0')
Definition FieldConvertors.h:132

References FIX::integer_to_string_padded().

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

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

- FieldConvertors.h