epoc32/include/comms-infras/trbuf.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 
    17 
    18 /**
    19  @file
    20  @internalTechnology
    21 */
    22 
    23 #if (!defined TRBUF_H)
    24 #define TRBUF_H
    25 
    26 #include <e32base.h>
    27 #include <e32std.h>
    28 
    29 namespace Elements
    30 {
    31 
    32 class TRBuf8 : public RBuf8
    33 /**
    34 	class to provide a RBuf8 destructor
    35 */
    36 	{
    37 	public:
    38 		static TRBuf8* New(TInt aMaxLength)
    39 			{
    40 			TRBuf8* self = new TRBuf8;
    41 			if (self!=NULL)
    42 				{
    43 				if (self->Create(aMaxLength)!=KErrNone)
    44 					{
    45 					delete self;
    46 					self = NULL;
    47 					}
    48 				}
    49 			return self;
    50 			}
    51 
    52 		static TRBuf8* NewL(TInt aMaxLength)
    53 			{
    54 			TRBuf8* self = new (ELeave) TRBuf8;
    55 			CleanupStack::PushL(self);
    56 			self->CreateL(aMaxLength);
    57 			CleanupStack::Pop(self);
    58 			return self;
    59 			}
    60 
    61 		~TRBuf8()
    62 			{
    63 			Close();
    64 			}
    65 	};
    66 
    67 class TRBuf16 : public RBuf16
    68 /**
    69 	class to provide a RBuf16 destructor
    70 */
    71 	{
    72 	public:
    73 		static TRBuf16* New(TInt aMaxLength)
    74 			{
    75 			TRBuf16* self = new TRBuf16;
    76 			if (self!=NULL)
    77 				{
    78 				if (self->Create(aMaxLength)!=KErrNone)
    79 					{
    80 					delete self;
    81 					self = NULL;
    82 					}
    83 				}
    84 			return self;
    85 			}
    86 
    87 		static TRBuf16* NewL(TInt aMaxLength)
    88 			{
    89 			TRBuf16* self = new (ELeave) TRBuf16;
    90 			CleanupStack::PushL(self);
    91 			self->CreateL(aMaxLength);
    92 			CleanupStack::Pop(self);
    93 			return self;
    94 			}
    95 
    96 		~TRBuf16()
    97 			{
    98 			Close();
    99 			}
   100 	};
   101 
   102 #if defined(_UNICODE)
   103 typedef TRBuf16 TRBuf;
   104 #else
   105 typedef TRBuf8 TRBuf;
   106 #endif
   107 
   108 } //namespace Elements
   109 
   110 
   111 #endif //TRBUF_H