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

# FIX::Parser Class Reference

Parses FIX messages off an input stream. More...

`#include <Parser.h>`

List of all members.

## Public Member Functions

| Parser ()
| ~Parser ()
bool | extractLength (int &length, std::string::size_type &pos, const std::string &buffer) throw ( MessageParseError )
bool | readFixMessage (std::string &str) throw ( MessageParseError )
void | addToStream (const char *str, size_t len)
void | addToStream (const std::string &str)

## Private Attributes

std::string | m_buffer
int | m_bufferSize

## Detailed Description

Parses FIX messages off an input stream.

Definition at line 36 of file Parser.h.

## Constructor & Destructor Documentation

FIX::Parser::Parser | ( |  | ) | `[inline]`

Definition at line 39 of file Parser.h.

    00040   : m_bufferSize( 0 ) {}

FIX::Parser::~Parser | ( |  | ) | `[inline]`

Definition at line 41 of file Parser.h.

    00041 {}

## Member Function Documentation

void FIX::Parser::addToStream | ( | const std::string & | str | ) | `[inline]`

Definition at line 51 of file Parser.h.

References m_buffer.

    00052   { m_buffer.append( str ); }

void FIX::Parser::addToStream | ( | const char * | str,
|  | size_t | len |
| ) |  |  | `[inline]`

Definition at line 49 of file Parser.h.

References m_buffer.

Referenced by FIX::ThreadedSocketConnection::read(), and FIX::SocketConnection::readFromSocket().

    00050   { m_buffer.append( str, len ); }

bool FIX::Parser::extractLength | ( | int & | length,
|  | std::string::size_type & | pos,
|  | const std::string & | buffer |
| ) |  |  | throw ( MessageParseError )

Definition at line 34 of file Parser.cpp.

References FIX::IntConvertor::convert(), QF_STACK_POP, and QF_STACK_PUSH.

    00037 { QF_STACK_PUSH(Parser::extractLength)
    00038
    00039   if( !buffer.size() ) return false;
    00040
    00041   std::string::size_type startPos = buffer.find( "\0019=", 0 );
    00042   if( startPos == std::string::npos ) return false;
    00043   startPos += 3;
    00044   std::string::size_type endPos = buffer.find( "\001", startPos );
    00045   if( endPos == std::string::npos ) return false;
    00046
    00047   std::string strLength( buffer, startPos, endPos - startPos );
    00048
    00049   try
    00050   {
    00051     length = IntConvertor::convert( strLength );
    00052     if( length < 0 ) throw MessageParseError();
    00053   }
    00054   catch( FieldConvertError& )
    00055   { throw MessageParseError(); }
    00056
    00057   pos = endPos + 1;
    00058   return true;
    00059
    00060   QF_STACK_POP
    00061 }

bool FIX::Parser::readFixMessage | ( | std::string & | str | ) | throw ( MessageParseError )

Definition at line 63 of file Parser.cpp.

References QF_STACK_POP, and QF_STACK_PUSH.

Referenced by FIX::SocketConnection::readMessage().

    00065 { QF_STACK_PUSH(Parser::readFixMessage)
    00066
    00067   std::string::size_type pos = 0;
    00068
    00069   if( m_buffer.length() < 2 ) return false;
    00070   pos = m_buffer.find( "8=" );
    00071   if( pos == std::string::npos ) return false;
    00072   m_buffer.erase( 0, pos );
    00073
    00074   int length = 0;
    00075
    00076   try
    00077   {
    00078     if( extractLength(length, pos, m_buffer) )
    00079     {
    00080       pos += length;
    00081       if( m_buffer.size() < pos )
    00082         return false;
    00083
    00084       pos = m_buffer.find( "\00110=", pos-1 );
    00085       if( pos == std::string::npos ) return false;
    00086       pos += 4;
    00087       pos = m_buffer.find( "\001", pos );
    00088       if( pos == std::string::npos ) return false;
    00089       pos += 1;
    00090
    00091       str = m_buffer.substr( 0, pos );
    00092       m_buffer.erase( 0, pos );
    00093       return true;
    00094     }
    00095   }
    00096   catch( MessageParseError& e )
    00097   {
    00098     if( length > 0 )
    00099       m_buffer.erase( 0, pos + length );
    00100     else
    00101       m_buffer.erase();
    00102
    00103     throw e;
    00104   }
    00105
    00106   return false;
    00107
    00108   QF_STACK_POP
    00109 }

## Member Data Documentation

std::string FIX::Parser::m_buffer`[private]`

Definition at line 55 of file Parser.h.

Referenced by addToStream().

int FIX::Parser::m_bufferSize`[private]`

Definition at line 56 of file Parser.h.

The documentation for this class was generated from the following files:

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