1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/comms-infras/trbuf.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,111 @@
1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// 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
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +
1.20 +
1.21 +/**
1.22 + @file
1.23 + @internalTechnology
1.24 +*/
1.25 +
1.26 +#if (!defined TRBUF_H)
1.27 +#define TRBUF_H
1.28 +
1.29 +#include <e32base.h>
1.30 +#include <e32std.h>
1.31 +
1.32 +namespace Elements
1.33 +{
1.34 +
1.35 +class TRBuf8 : public RBuf8
1.36 +/**
1.37 + class to provide a RBuf8 destructor
1.38 +*/
1.39 + {
1.40 + public:
1.41 + static TRBuf8* New(TInt aMaxLength)
1.42 + {
1.43 + TRBuf8* self = new TRBuf8;
1.44 + if (self!=NULL)
1.45 + {
1.46 + if (self->Create(aMaxLength)!=KErrNone)
1.47 + {
1.48 + delete self;
1.49 + self = NULL;
1.50 + }
1.51 + }
1.52 + return self;
1.53 + }
1.54 +
1.55 + static TRBuf8* NewL(TInt aMaxLength)
1.56 + {
1.57 + TRBuf8* self = new (ELeave) TRBuf8;
1.58 + CleanupStack::PushL(self);
1.59 + self->CreateL(aMaxLength);
1.60 + CleanupStack::Pop(self);
1.61 + return self;
1.62 + }
1.63 +
1.64 + ~TRBuf8()
1.65 + {
1.66 + Close();
1.67 + }
1.68 + };
1.69 +
1.70 +class TRBuf16 : public RBuf16
1.71 +/**
1.72 + class to provide a RBuf16 destructor
1.73 +*/
1.74 + {
1.75 + public:
1.76 + static TRBuf16* New(TInt aMaxLength)
1.77 + {
1.78 + TRBuf16* self = new TRBuf16;
1.79 + if (self!=NULL)
1.80 + {
1.81 + if (self->Create(aMaxLength)!=KErrNone)
1.82 + {
1.83 + delete self;
1.84 + self = NULL;
1.85 + }
1.86 + }
1.87 + return self;
1.88 + }
1.89 +
1.90 + static TRBuf16* NewL(TInt aMaxLength)
1.91 + {
1.92 + TRBuf16* self = new (ELeave) TRBuf16;
1.93 + CleanupStack::PushL(self);
1.94 + self->CreateL(aMaxLength);
1.95 + CleanupStack::Pop(self);
1.96 + return self;
1.97 + }
1.98 +
1.99 + ~TRBuf16()
1.100 + {
1.101 + Close();
1.102 + }
1.103 + };
1.104 +
1.105 +#if defined(_UNICODE)
1.106 +typedef TRBuf16 TRBuf;
1.107 +#else
1.108 +typedef TRBuf8 TRBuf;
1.109 +#endif
1.110 +
1.111 +} //namespace Elements
1.112 +
1.113 +
1.114 +#endif //TRBUF_H