Main Page Class Hierarchy Compound List File List Compound Members File Members

# mutableservermessage.cpp

Go to the documentation of this file.

    00001 // mutableserverresult.cpp: implementation of the MutableServerResult class.
    00002 //
    00004
    00005 #include "mutableservermessage.h"
    00006
    00008 // Construction/Destruction
    00010
    00011 MutableServerMessage::MutableServerMessage()
    00012 {
    00013 }
    00014 //
    00015 // --------------------------------------------------------------------
    00016 //
    00017 void MutableServerMessage::FormatBuffer()
    00018 {
    00019    MessageBuffer.resize(0);
    00020    MessageBuffer.reserve( BufferInitAlloc() );
    00021    FormatDerivativeData();
    00022    MessageBuffer.append( "\n" );
    00023 }
    00024 //
    00025 //-------------------------------------------------------------------
    00026 //
    00027 long MutableServerMessage::GetBufferLength() const
    00028 {
    00029    return MessageBuffer.size();
    00030 }
    00031 //
    00032 //-------------------------------------------------------------------
    00033 //
    00034 const char * MutableServerMessage::GetBuffer() const
    00035 {
    00036    return MessageBuffer.c_str();
    00037 }
    00038 //
    00039 //-------------------------------------------------------------------
    00040 //
    00041 bool MutableServerMessage::ParseMessageLine( const char * p_buffer
    00042                                            ,       bool   p_append_nl   /* = true  */
    00043                                            ,       bool   p_clearbuffer /* = false */
    00044                                            )
    00045 {
    00046    if ( p_buffer == NULL )
    00047    {
    00048       throw worm_exception("MutableServerMessage::ParseMessageLine() Error: buffer parameter NULL");
    00049    }
    00050
    00051    if ( p_clearbuffer )
    00052    {
    00053       MessageBuffer.reserve( BufferInitAlloc() );
    00054       MessageBuffer = "";
    00055    }
    00056
    00057    if ( strlen(p_buffer) == 0 )
    00058    {
    00059       if ( p_append_nl )
    00060       {
    00061          MessageBuffer.append( "\n" );
    00062       }
    00063       ParseDerivativeData();
    00064       return true;
    00065    }
    00066    else
    00067    {
    00068       MessageBuffer.append( p_buffer );
    00069       if ( p_append_nl )
    00070       {
    00071          MessageBuffer.append( "\n" );
    00072       }
    00073       return false;
    00074    }
    00075 }
    00076 //
    00077 //-------------------------------------------------------------------
    00078 //
    00079 void MutableServerMessage::ParseFromBuffer( const char * p_buffer )
    00080 {
    00081    if ( p_buffer == NULL )
    00082    {
    00083       throw worm_exception("MutableServerMessage::ParseFromBuffer() Error: buffer parameter NULL");
    00084    }
    00085
    00086    MessageBuffer = p_buffer;
    00087    MessageBuffer.append( "\n" );
    00088    ParseDerivativeData();
    00089 }
    00090 //
    00091 // --------------------------------------------------------------------
    00092 //