Static Public Member Functions | List of all members
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
)
inlinestatic

Definition at line 484 of file FieldConvertors.h.

534  {
535  char ch = value[i];
536  if( !IS_DIGIT(ch)) throw FieldConvertError(value);
537  fraction = (fraction * 10) + ch - '0';
538  }
539 
540  return UtcTimeStamp (hour, min, sec, fraction,
541  mday, mon, year, len - 17 - 1);
542  }
543 };
544 
546 struct UtcTimeOnlyConvertor
547 {
548  static std::string convert( const UtcTimeOnly& value,
549  int precision = 0 )
550  throw( FieldConvertError )
551  {
552  char result[ 8+10 ]; // Maximum
553  int hour, minute, second, fraction;
554 
555  value.getHMS( hour, minute, second, fraction, precision );
556 
557  integer_to_string_padded ( result, 2, hour );
558  result[2] = ':';
559  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
)
inlinestatic

Definition at line 451 of file FieldConvertors.h.

451  :';
452  integer_to_string_padded( result + 15, 2, second);
453 
454  if( precision )
455  {
456  result[17] = '.';
457  if( integer_to_string_padded ( result + 18, precision, fraction )
458  != result + 18 )
459  {
460  throw FieldConvertError();
461  }
462  }
463 
464  return std::string(result, precision ? (17 + 1 + precision) : 17);
465  }
466 
467  static UtcTimeStamp convert( const std::string& value )
468  throw( FieldConvertError )
469  {
470  size_t len = value.size();
471  if (len < 17 || len > 27) throw FieldConvertError(value);
472 
473  size_t i = 0;
474  int c = 0;
475  for( c = 0; c < 8; ++c )
476  if( !IS_DIGIT(value[i++]) ) throw FieldConvertError(value);
477  if (value[i++] != '-') throw FieldConvertError(value);
478  for( c = 0; c < 2; ++c )
479  if( !IS_DIGIT(value[i++]) ) throw FieldConvertError(value);
480  if( value[i++] != ':' ) throw FieldConvertError(value);
481  for( c = 0; c < 2; ++c )
482  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:
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

Generated on Wed Apr 29 2020 19:41:30 for QuickFIX by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2001