![]() |
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 ) |
Converts a UtcDate to/from a string.
Definition at line 581 of file FieldConvertors.h.
static UtcDate FIX::UtcDateConvertor::convert | ( | const std::string & | value | ) | throw ( FieldConvertError ) [inline, static] |
Definition at line 597 of file FieldConvertors.h.
00599 { 00600 if( value.size() != 8 ) throw FieldConvertError(); 00601 00602 int i = 0; 00603 for( int c=0; c<8; ++c ) 00604 if( !isdigit(value[i++]) ) throw FieldConvertError(); 00605 00606 int year, mon, mday; 00607 00608 i = 0; 00609 00610 year = value[i++] - '0'; 00611 year = 10 * year + value[i++] - '0'; 00612 year = 10 * year + value[i++] - '0'; 00613 year = 10 * year + value[i++] - '0'; 00614 00615 mon = value[i++] - '0'; 00616 mon = 10 * mon + value[i++] - '0'; 00617 if( mon < 1 || 12 < mon ) 00618 throw FieldConvertError(); 00619 00620 mday = value[i++] - '0'; 00621 mday = 10 * mday + value[i++] - '0'; 00622 if( mday < 1 || 31 < mday ) 00623 throw FieldConvertError(); 00624 00625 return UtcDateOnly( mday, mon, year ); 00626 }
static std::string FIX::UtcDateConvertor::convert | ( | const UtcDate & | value | ) | throw ( FieldConvertError ) [inline, static] |
Definition at line 583 of file FieldConvertors.h.
References FIX::integer_to_string_padded().
Referenced by FIX::DataDictionary::checkValidFormat().
00585 { 00586 char result[ 9 ]; 00587 int year, month, day; 00588 00589 value.getYMD( year, month, day ); 00590 00591 integer_to_string_padded( result, 5, year, 4, '0' ); 00592 integer_to_string_padded( result + 4, 3, month, 2, '0' ); 00593 integer_to_string_padded( result + 6, 3, day, 2, '0' ); 00594 return result; 00595 }