realtimenetprots/sipfw/SigComp/SigCompEngine/inc/MessageReader.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Name        : MessageReader.h
       
    16 * Part of     : SigComp / dispatcher
       
    17 * Interface   : 
       
    18 * SigComp message reader
       
    19 * Version     : 1.0
       
    20 *
       
    21 */
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 /**
       
    27  @internalComponent
       
    28 */
       
    29 
       
    30 
       
    31 #ifndef MESSAGEREADER_H
       
    32 #define MESSAGEREADER_H
       
    33 
       
    34 //  INCLUDES
       
    35 #include <e32base.h>
       
    36 
       
    37 
       
    38 // CLASS DECLARATION
       
    39 
       
    40 /**
       
    41  * @brief Class for reading from sigcomp message.
       
    42  * 
       
    43  * @class CMessageReader messagereader.h "messagereader.h"
       
    44  *
       
    45  * This class is used for reading from sigcomp message with optional 
       
    46  * record marker decoding as specified in RFC 3320, chapter 4.2.2
       
    47  */
       
    48 
       
    49 class CMessageReader : public CBase
       
    50     {
       
    51     public:
       
    52 
       
    53         /**
       
    54          * Constructs object.
       
    55          *
       
    56          * @param aMessage message to be read
       
    57          * @param aStreamBasedProtocol if ETrue, a message will be record
       
    58          *                             marker decoded.
       
    59          */
       
    60 
       
    61         CMessageReader(const TDesC8& aMessage, TBool aStreamBasedProtocol);
       
    62 
       
    63         /**
       
    64          * Read one byte from message.
       
    65          *
       
    66          * @returns If the reading is successful, the value of readed
       
    67          *          byte (0-255).
       
    68          *          If the reading fails, a negative value indicating 
       
    69          *          the cause of failure.
       
    70          *          KErrEof if delimiter is reached, or KErrTooBig if 
       
    71          *          end of buffer.
       
    72          */
       
    73 
       
    74         TInt ReadByte(TUint& aByte);
       
    75 
       
    76         /**
       
    77          * Read block of bytes from message.
       
    78          *
       
    79          * @param aBlock contains data read from the buffer; on exit, 
       
    80          *               its Length() specifies the length of readed
       
    81          *               (successful or failed) data.
       
    82          * @param aLentgh specifies the amount of data to be read.
       
    83          *
       
    84          * @returns If the reading is successful, a KErrNone.
       
    85          *          If the reading fails, a negative value indicating
       
    86          *          the cause of failure.
       
    87          *          KErrEof if delimiter is reached, or KErrTooBig if
       
    88          *          end of buffer.
       
    89          */
       
    90 
       
    91         TInt ReadBlock(TDes8& aBlock, TInt aLength);
       
    92 
       
    93         /**
       
    94          * Read block of bytes from message.
       
    95          *
       
    96          * @param aBlock contains data read from the buffer; on call, 
       
    97          *               its MaxLength()
       
    98          *               specifies the amount of data to be read; on exit,
       
    99          *               its Length() specifies the length of readed 
       
   100          *               (successful or failed) data.
       
   101          *
       
   102          * @returns If the reading is successful, a KErrNone.
       
   103          *          If the reading fails, a negative value indicating the 
       
   104          *          cause of failure.
       
   105          *          KErrEof if delimiter is reached, or KErrTooBig if end 
       
   106          *          of buffer.
       
   107          */
       
   108 
       
   109         TInt ReadBlock(TDes8& aBlock);
       
   110 
       
   111         /**
       
   112          * Check if specified number of bytes is available in buffer.
       
   113          *
       
   114          * @param aLength number of bytes to check
       
   115          *
       
   116          * @returns If the specified number of bytes is available, a KErrNone.
       
   117          *          If not, a negative value indicating the cause of failure.
       
   118          *          KErrEof if delimiter is reached, or KErrTooBig if end of 
       
   119          *          buffer.
       
   120          */
       
   121 
       
   122         TInt Avail(TInt aLength);
       
   123 
       
   124         /**
       
   125          * Get current position in message buffer.
       
   126          *
       
   127          * @returns position in message buffer.
       
   128          */
       
   129 
       
   130         TInt Pos();
       
   131 
       
   132         /**
       
   133          * If stream-based protocol, skip message delimiters.
       
   134          *
       
   135          * @param aDelToSkip number of delimiters to skip, default maximumm
       
   136          *                   possible.
       
   137          *
       
   138          * @returns KErrNone if seccesfful, error code if failure.
       
   139          */
       
   140 
       
   141         TInt SkipDelimiters(TUint aDelToSkip=KMaxTUint32);
       
   142 
       
   143     private:    // Data
       
   144 
       
   145         TPtrC8 iMessage;
       
   146         TBool iStreamBasedProtocol;
       
   147         TInt iPos;
       
   148         TInt iQuoteBytes;
       
   149 
       
   150     };
       
   151 
       
   152 #endif
       
   153             
       
   154 // End of File