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

FIX::IntConvertor Struct Reference

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

#include <FieldConvertors.h>

List of all members.

Static Public Member Functions

static std::string convert (long value)
static bool convert (const std::string &value, long &result)
static long convert (const std::string &value) throw ( FieldConvertError )

Detailed Description

Converts integer to/from a string.

Definition at line 124 of file FieldConvertors.h.


Member Function Documentation

static long FIX::IntConvertor::convert ( const std::string &  value  )  throw ( FieldConvertError ) [inline, static]

Definition at line 162 of file FieldConvertors.h.

References convert().

00164   {
00165     long result = 0;
00166     if( !convert( value, result ) )
00167       throw FieldConvertError();
00168     else
00169       return result;
00170   }

static bool FIX::IntConvertor::convert ( const std::string &  value,
long &  result 
) [inline, static]

Definition at line 136 of file FieldConvertors.h.

00137   {
00138     const char* str = value.c_str();
00139     bool isNegative = false;
00140     long x = 0;
00141 
00142     if( *str == '-' )
00143     {
00144       isNegative = true;
00145       ++str;
00146     }
00147 
00148     do
00149     {
00150       const int c = *str - '0';
00151       if( c < 0 || 9 < c ) return false;
00152       x = 10 * x + c;
00153     } while (*++str);
00154 
00155     if( isNegative )
00156       x = -x;
00157 
00158     result = x;
00159     return true;
00160   }

static std::string FIX::IntConvertor::convert ( long  value  )  [inline, static]

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

Generated on Mon Apr 5 21:00:04 2010 for QuickFIX by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2001