Msrp/MsrpHeader/inc/CMsrpByteRangeHeader.h
branchMSRP_FrameWork
changeset 25 505ad3f0ce5c
equal deleted inserted replaced
22:f1578314b8da 25:505ad3f0ce5c
       
     1 /*
       
     2 * Copyright (c) 2009-2010 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 * Initial Contributors:
       
     9 * Nokia Corporation - initial contribution.
       
    10 * Contributors:
       
    11 *
       
    12 * Description:
       
    13 * MSRP Implementation
       
    14 *
       
    15 */
       
    16 
       
    17 
       
    18 #ifndef CMSRPBYTERANGEHEADER_H
       
    19 #define CMSRPBYTERANGEHEADER_H
       
    20 
       
    21 // INTERNAL INCLUDES
       
    22 #include "CMsrpHeaderBase.h"
       
    23 
       
    24 // CONSTANTS
       
    25 
       
    26 const TInt KMaxLengthOfNumbers = 50;
       
    27 _LIT8( KByteRangeSeparator, "-" );
       
    28 _LIT8( KByteRangeTotalSeparator, "/" );
       
    29 
       
    30 // CLASS DECLARATION
       
    31 /**
       
    32 * @publishedAll
       
    33 *
       
    34 * Class provides functions for setting and getting MSRP "Byte-Range" header field
       
    35 *
       
    36 * @lib msrpclient.lib
       
    37 */
       
    38 class CMSRPByteRangeHeader : public CMSRPHeaderBase
       
    39 	{
       
    40 	public:	// Constructors and destructor
       
    41 
       
    42 		/**
       
    43 		* Creates a new instance of CMSRMessageIdHeader
       
    44 		* @param aStart start position of the bytes in data
       
    45 		* @param aEnd end position of bytes in the data
       
    46 		* @param aTotal Total length of the data
       
    47 		* @return a new instance of CMSRPByteRangeHeader
       
    48 		*/
       
    49 		IMPORT_C static CMSRPByteRangeHeader* NewL(
       
    50 			TInt aStart, TInt aEnd, TInt aTotal );
       
    51 
       
    52 		/**
       
    53 		* Creates a new instance of CMSRPByteRangeHeader and puts it to CleanupStack
       
    54 		* @param aStart start position of the bytes in data
       
    55 		* @param aEnd end position of bytes in the data
       
    56 		* @param aTotal Total length of the data
       
    57 		* @return a new instance of CMSRPByteRangeHeader
       
    58 		*/
       
    59 		IMPORT_C static CMSRPByteRangeHeader* NewLC(
       
    60 			TInt aStart, TInt aEnd, TInt aTotal );
       
    61 
       
    62 		/**
       
    63 		* Creates a new instance of CMSRMessageIdHeader
       
    64 		* @return a new instance of CMSRPByteRangeHeader
       
    65 		*/
       
    66 		static CMSRPByteRangeHeader* NewL( );
       
    67 
       
    68 		/**
       
    69 		* Destructor, deletes the resources of CMSRPByteRangeHeader.
       
    70 		*/
       
    71 		IMPORT_C ~CMSRPByteRangeHeader();
       
    72 
       
    73 	public: // New functions
       
    74 
       
    75 		/**
       
    76 		* Constructs an instance of a CMSRPByteRangeHeader from a RReadStream
       
    77 		* @param aReadStream a stream containing the value of the
       
    78 		*        externalized object (header name not included).
       
    79 		* @return an instance of a CMSRPByteRangeHeader
       
    80 		*/
       
    81 		IMPORT_C static CMSRPByteRangeHeader*
       
    82 			InternalizeValueL( RReadStream& aReadStream );
       
    83 
       
    84 		/**
       
    85 		* Sets the start position of the bytes in data
       
    86 		* @param aStartPos start position of bytes
       
    87 		*/
       
    88 		IMPORT_C void SetStartPosition( TInt aStartPos );
       
    89 
       
    90 		/**
       
    91 		* Gets the start position of the bytes in data
       
    92 		*/
       
    93 		IMPORT_C TInt StartPosition( ) const;
       
    94 
       
    95 		/**
       
    96 		* Sets the end position of the bytes in data
       
    97 		* @param aEndPos start position of bytes
       
    98 		*/
       
    99 		IMPORT_C void SetEndPosition( TInt aEndPos );
       
   100 
       
   101 		/**
       
   102 		* Gets the end position of the bytes in data
       
   103 		*/
       
   104 		IMPORT_C TInt EndPosition( ) const;
       
   105 
       
   106 		/**
       
   107 		* Sets the total length of bytes in data
       
   108 		* @param aTotal total number of bytes
       
   109 		*/
       
   110 		IMPORT_C void SetTotalLength( TInt aTotal );
       
   111 
       
   112 		/**
       
   113 		* Gets the total number of the bytes in data
       
   114 		*/
       
   115 		IMPORT_C TInt TotalLength( ) const;
       
   116 
       
   117 	public: // From CMSRPHeaderBase
       
   118 
       
   119 		IMPORT_C void ExternalizeValueL( RWriteStream& aWriteStream ) const;
       
   120 
       
   121 	protected: // From CMSRPHeaderBase
       
   122 
       
   123 		RStringF Name() const;
       
   124 		HBufC8* ToTextValueL() const;
       
   125 
       
   126 	private: // Constructors
       
   127 
       
   128         /**
       
   129         * Contructor.
       
   130         */
       
   131 		CMSRPByteRangeHeader( );
       
   132         /**
       
   133         * Contructor.
       
   134 		* @param aStart start position of the bytes in data
       
   135 		* @param aEnd end position of bytes in the data
       
   136 		* @param aTotal Total length of the data
       
   137         */
       
   138 		CMSRPByteRangeHeader(
       
   139 			TInt aStart, TInt aEnd, TInt aTotal );
       
   140         /**
       
   141         * two-phased contructor.
       
   142         */
       
   143         void ConstructL( ) const;
       
   144 
       
   145 	private: // new functions
       
   146 	    /**
       
   147 		* Internalize external object data
       
   148 		* @param aReadStream a stream containing the value of the
       
   149 		*        externalized object (header name not included).
       
   150 		*/
       
   151 		void DoInternalizeValueL( RReadStream& aReadStream );
       
   152 
       
   153   	private: // variables
       
   154 
       
   155 		// byte range values
       
   156 		TInt iStartPosition;
       
   157 		TInt iEndPosition;
       
   158 		TInt iTotalBytes;
       
   159 
       
   160 	};
       
   161 
       
   162 #endif // CMSRPBYTERANGEHEADER_H
       
   163 
       
   164 // End of File