QuickFIX: FIX::UtcTimeOnlyConvertor Struct Reference

Index Source Files Annotated Class List Alphabetical Class List Class Hierarchy Graphical Class Hierarchy

# FIX::UtcTimeOnlyConvertor Struct Reference

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

`#include <FieldConvertors.h>`

List of all members.

## Static Public Member Functions
static std::string | convert (const UtcTimeOnly &value, bool showMilliseconds=false) throw ( FieldConvertError )
static UtcTimeOnly | convert (const std::string &value) throw ( FieldConvertError )

## Detailed Description

Converts a UtcTimeOnly to/from a string.

Definition at line 488 of file FieldConvertors.h.

## Member Function Documentation

static UtcTimeOnly FIX::UtcTimeOnlyConvertor::convert | ( | const std::string & | value | ) | throw ( FieldConvertError )`[inline, static]`

Definition at line 516 of file FieldConvertors.h.

References FIX::TYPE::UtcTimeOnly.

    00518   {
    00519     bool haveMilliseconds = false;
    00520
    00521     switch( value.size() )
    00522     {
    00523       case 12: haveMilliseconds = true;
    00524       case 8: break;
    00525       default: throw FieldConvertError();
    00526     }
    00527
    00528     int i = 0;
    00529     int c = 0;
    00530     for( c = 0; c < 2; ++c )
    00531       if( !isdigit(value[i++]) ) throw FieldConvertError();
    00532     if( value[i++] != ':' ) throw FieldConvertError();
    00533     for( c = 0; c < 2; ++c )
    00534       if( !isdigit(value[i++]) ) throw FieldConvertError();
    00535     if( value[i++] != ':' ) throw FieldConvertError();
    00536     for( c = 0; c < 2; ++c )
    00537       if( !isdigit(value[i++]) ) throw FieldConvertError();
    00538
    00539     if( haveMilliseconds )
    00540     {
    00541       // ++i instead of i++ skips the '.' separator
    00542       for( c = 0; c < 3; ++c )
    00543               if( !isdigit(value[++i]) ) throw FieldConvertError();
    00544     }
    00545
    00546     int hour, min, sec, millis;
    00547
    00548     i = 0;
    00549
    00550     hour = value[i++] - '0';
    00551     hour = 10 * hour + value[i++] - '0';
    00552     // No check for >= 0 as no '-' are converted here
    00553     if( 23 < hour ) throw FieldConvertError();
    00554     ++i; // skip ':'
    00555
    00556     min = value[i++] - '0';
    00557     min = 10 * min + value[i++] - '0';
    00558     // No check for >= 0 as no '-' are converted here
    00559     if( 59 < min ) throw FieldConvertError();
    00560     ++i; // skip ':'
    00561
    00562     sec = value[i++] - '0';
    00563     sec = 10 * sec + value[i++] - '0';
    00564     // No check for >= 0 as no '-' are converted here
    00565     if( 60 < sec ) throw FieldConvertError();
    00566
    00567     if( haveMilliseconds )
    00568     {
    00569       millis = (100 * (value[i+1] - '0')
    00570                 + 10 * (value[i+2] - '0')
    00571                 + (value[i+3] - '0'));
    00572     }
    00573     else
    00574       millis = 0;
    00575
    00576     return UtcTimeOnly( hour, min, sec, millis );
    00577   }

static std::string FIX::UtcTimeOnlyConvertor::convert | ( | const UtcTimeOnly & | value,
|  | bool | showMilliseconds = `false` |
| ) |  |  | throw ( FieldConvertError )`[inline, static]`

Definition at line 490 of file FieldConvertors.h.

References FIX::DateTime::getHMS(), and FIX::integer_to_string_padded().

Referenced by FIX::DataDictionary::checkValidFormat(), and FIX::SessionFactory::create().

    00493   {
    00494     char result[ 9+4 ];
    00495     int hour, minute, second, millis;
    00496
    00497     value.getHMS( hour, minute, second, millis );
    00498
    00499     integer_to_string_padded ( result, 3, hour, 2, '0' );
    00500     result[2] = ':';
    00501     integer_to_string_padded ( result + 3, 3, minute,  2, '0' );
    00502     result[5] = ':';
    00503     integer_to_string_padded ( result + 6, 3, second,  2, '0' );
    00504
    00505     if( showMilliseconds )
    00506     {
    00507       result[8] = '.';
    00508       if( integer_to_string_padded ( result + 9, 4, millis, 3, '0' )
    00509           != result + 9 )
    00510           throw FieldConvertError();
    00511     }
    00512
    00513     return result;
    00514   }

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

- /home/omiller/Development/autobuild/quickfix/src/C++/FieldConvertors.h