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

# FIX::UtcTimeStampConvertor Struct Reference

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

`#include <FieldConvertors.h>`

List of all members.

## Static Public Member Functions

static std::string | convert (const UtcTimeStamp &value, bool showMilliseconds=false) throw ( FieldConvertError )
static UtcTimeStamp | convert (const std::string &value, bool calculateDays=false) throw ( FieldConvertError )

## Detailed Description

Converts a UtcTimeStamp to/from a string.

Definition at line 365 of file FieldConvertors.h.

## Member Function Documentation

static UtcTimeStamp FIX::UtcTimeStampConvertor::convert | ( | const std::string & | value,
|  | bool | calculateDays = `false` |
| ) |  |  | throw ( FieldConvertError )`[inline, static]`

Definition at line 400 of file FieldConvertors.h.

References FIX::TYPE::UtcTimeStamp.

    00403   {
    00404     bool haveMilliseconds = false;
    00405
    00406     switch( value.size() )
    00407     {
    00408       case 21: haveMilliseconds = true;
    00409       case 17: break;
    00410       default: throw FieldConvertError();
    00411     }
    00412
    00413     int i = 0;
    00414     int c = 0;
    00415     for( c = 0; c < 8; ++c )
    00416       if( !isdigit(value[i++]) ) throw FieldConvertError();
    00417     if (value[i++] != '-') throw FieldConvertError();
    00418     for( c = 0; c < 2; ++c )
    00419       if( !isdigit(value[i++]) ) throw FieldConvertError();
    00420     if( value[i++] != ':' ) throw FieldConvertError();
    00421     for( c = 0; c < 2; ++c )
    00422       if( !isdigit(value[i++]) ) throw FieldConvertError();
    00423     if( value[i++] != ':' ) throw FieldConvertError();
    00424     for( c = 0; c < 2; ++c )
    00425       if( !isdigit(value[i++]) ) throw FieldConvertError();
    00426
    00427     if( haveMilliseconds )
    00428     {
    00429       if( value[i++] != '.' ) throw FieldConvertError();
    00430       for( c = 0; c < 3; ++c )
    00431               if( !isdigit(value[i++]) ) throw FieldConvertError();
    00432     }
    00433
    00434     int year, mon, mday, hour, min, sec, millis;
    00435
    00436     i = 0;
    00437
    00438     year = value[i++] - '0';
    00439     year = 10 * year + value[i++] - '0';
    00440     year = 10 * year + value[i++] - '0';
    00441     year = 10 * year + value[i++] - '0';
    00442
    00443     mon = value[i++] - '0';
    00444     mon = 10 * mon + value[i++] - '0';
    00445     if( mon < 1 || 12 < mon ) throw FieldConvertError();
    00446
    00447     mday = value[i++] - '0';
    00448     mday = 10 * mday + value[i++] - '0';
    00449     if( mday < 1 || 31 < mday ) throw FieldConvertError();
    00450
    00451     ++i; // skip '-'
    00452
    00453     hour = value[i++] - '0';
    00454     hour = 10 * hour + value[i++] - '0';
    00455     // No check for >= 0 as no '-' are converted here
    00456     if( 23 < hour ) throw FieldConvertError();
    00457
    00458     ++i; // skip ':'
    00459
    00460     min = value[i++] - '0';
    00461     min = 10 * min + value[i++] - '0';
    00462     // No check for >= 0 as no '-' are converted here
    00463     if( 59 < min ) throw FieldConvertError();
    00464
    00465     ++i; // skip ':'
    00466
    00467     sec = value[i++] - '0';
    00468     sec = 10 * sec + value[i++] - '0';
    00469
    00470     // No check for >= 0 as no '-' are converted here
    00471     if( 60 < sec ) throw FieldConvertError();
    00472
    00473     if( haveMilliseconds )
    00474     {
    00475       millis = (100 * (value[i+1] - '0')
    00476                 + 10 * (value[i+2] - '0')
    00477                 + (value[i+3] - '0'));
    00478     }
    00479     else
    00480       millis = 0;
    00481
    00482     return UtcTimeStamp (hour, min, sec, millis,
    00483                          mday, mon, year);
    00484   }

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

Definition at line 367 of file FieldConvertors.h.

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

Referenced by FIX::DataDictionary::checkValidFormat(), FIX::ScreenLog::onEvent(), FIX::FileLog::onEvent(), FIX::ScreenLog::onIncoming(), FIX::FileLog::onIncoming(), FIX::ScreenLog::onOutgoing(), FIX::FileLog::onOutgoing(), FIX::FileStore::populateCache(), and FIX::FileStore::setSession().

    00370   {
    00371     char result[ 18+4 ];
    00372     int year, month, day, hour, minute, second, millis;
    00373
    00374     value.getYMD( year, month, day );
    00375     value.getHMS( hour, minute, second, millis );
    00376
    00377     integer_to_string_padded( result, 5, year, 4, '0' );
    00378     integer_to_string_padded( result + 4, 3, month, 2, '0' );
    00379     integer_to_string_padded( result + 6, 3, day, 2, '0' );
    00380     result[8]  = '-';
    00381     integer_to_string_padded( result + 9, 3, hour, 2, '0' );
    00382     result[11] = ':';
    00383     integer_to_string_padded( result + 12, 3, minute, 2, '0' );
    00384     result[14] = ':';
    00385     integer_to_string_padded( result + 15, 3, second, 2, '0' );
    00386
    00387     if( showMilliseconds )
    00388     {
    00389       result[17] = '.';
    00390       if( integer_to_string_padded ( result + 18, 4, millis, 3, '0' )
    00391           != result + 18 )
    00392       {
    00393         throw FieldConvertError();
    00394       }
    00395     }
    00396
    00397     return result;
    00398   }

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

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