FIX::UtcTimeStampConvertor Struct Reference

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

`#include <FieldConvertors.h>`

## Static Public Member Functions

static std::string | convert (const UtcTimeStamp &value, int precision=0) throw ( FieldConvertError )
static UtcTimeStamp | convert (const std::string &value) throw ( FieldConvertError )

## Detailed Description

Converts a UtcTimeStamp to/from a string.

Definition at line 449 of file FieldConvertors.h.

## Member Function Documentation

## convert() [1/2]

static UtcTimeStamp FIX::UtcTimeStampConvertor::convert | ( | const std::string & | value | ) |
throw | ( | FieldConvertError
| ) |  |

inline static

Definition at line 484 of file FieldConvertors.h.

{
char ch = value[i];
if( !IS_DIGIT(ch)) throw FieldConvertError(value);
fraction = (fraction * 10) + ch - '0';
}
return UtcTimeStamp (hour, min, sec, fraction,
mday, mon, year, len - 17 - 1);
}
};
struct UtcTimeOnlyConvertor
{
static std::string convert( const UtcTimeOnly& value,
int precision = 0 )
throw( FieldConvertError )
{
char result[ 8+10 ]; // Maximum
int hour, minute, second, fraction;
value.getHMS( hour, minute, second, fraction, precision );
integer_to_string_padded ( result, 2, hour );
result[2] = ':';
integer_to_string_padded ( result + 3, 2, minute );

## convert() [2/2]

static std::string FIX::UtcTimeStampConvertor::convert | ( | const UtcTimeStamp & | value,
|  | int | precision = `0`
| ) |  |
throw | ( | FieldConvertError
| ) |  |

inline static

Definition at line 451 of file FieldConvertors.h.

:';
integer_to_string_padded( result + 15, 2, second);
if( precision )
{
result[17] = '.';
if( integer_to_string_padded ( result + 18, precision, fraction )
!= result + 18 )
{
throw FieldConvertError();
}
}
return std::string(result, precision ? (17 + 1 + precision) : 17);
}
static UtcTimeStamp convert( const std::string& value )
throw( FieldConvertError )
{
size_t len = value.size();
if (len < 17 || len > 27) throw FieldConvertError(value);
size_t i = 0;
int c = 0;
for( c = 0; c < 8; ++c )
if( !IS_DIGIT(value[i++]) ) throw FieldConvertError(value);
if (value[i++] != '-') throw FieldConvertError(value);
for( c = 0; c < 2; ++c )
if( !IS_DIGIT(value[i++]) ) throw FieldConvertError(value);
if( value[i++] != ':' ) throw FieldConvertError(value);
for( c = 0; c < 2; ++c )
if( !IS_DIGIT(value[i++]) ) throw FieldConvertError(value);

Referenced by FIX::FileLogFactory::FileLogFactory(), FIX::BoolField::getValue(), and FIX::BoolField::operator bool().

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

- FieldConvertors.h

FIX::TYPE::UtcTimeStamp
@ UtcTimeStamp
Definition: FieldTypes.h:940
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:149
FIX::TYPE::UtcTimeOnly
@ UtcTimeOnly
Definition: FieldTypes.h:950
FIX::UtcTimeStampConvertor::convert
static std::string convert(const UtcTimeStamp &value, int precision=0)
Definition: FieldConvertors.h:451
IS_DIGIT
#define IS_DIGIT(x)
Definition: FieldConvertors.h:66