sl@0: // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: #ifndef LOGDYNBUF_H sl@0: #define LOGDYNBUF_H sl@0: sl@0: #include sl@0: sl@0: /** sl@0: This class manages a 16-bit resizable buffer and offers functions which can be used for constructing sl@0: SQL statements. sl@0: AppendL(), and AppendNumL() can be used to append data to the end of the buffer. sl@0: RLogDynBuf instance will try to expand the buffer if there is not enough available space for the data to be appended. sl@0: sl@0: The following code fragment shows how RLogDynBuf can be used: sl@0: @code sl@0: const TInt KGranularity = 128; sl@0: RLogDynBuf buf; sl@0: buf.CreateLC(KGranularity); sl@0: buf.AppendL(_L("some data"));//AppendL() automatically expands the buffer if there is not enough place for the string sl@0: buf.AppendNumL(1234); //AppendNumL() automatically expands the buffer if there is not enough place for the string sl@0: buf.AppendL(_L("more data"));//AppendL() automatically expands the buffer if there is not enough place for the string sl@0: ...... sl@0: CleanupStack::PopAndDestroy(buf); sl@0: @endcode sl@0: sl@0: @internalComponent sl@0: */ sl@0: NONSHARABLE_CLASS(RLogDynBuf) sl@0: { sl@0: public: sl@0: inline RLogDynBuf(); sl@0: void CreateLC(TInt aGranularity); sl@0: void Close(); sl@0: inline const TDesC& DesC() const; sl@0: inline void SetLength(TInt aLength); sl@0: inline TInt Length() const; sl@0: void AppendL(const TDesC& aStr); sl@0: sl@0: private: sl@0: void DoAllocL(TInt aLen); sl@0: sl@0: private: sl@0: TInt iGranularity; sl@0: RBuf iBuf; sl@0: sl@0: }; sl@0: sl@0: /** sl@0: Initializes RLogDynBuf data memebrs with default values. sl@0: */ sl@0: inline RLogDynBuf::RLogDynBuf() : sl@0: iGranularity(0) sl@0: { sl@0: } sl@0: sl@0: /** sl@0: @return Non-modifiable 16-bit descriptor to the data in the buffer. sl@0: */ sl@0: inline const TDesC& RLogDynBuf::DesC() const sl@0: { sl@0: return iBuf; sl@0: } sl@0: sl@0: /** sl@0: Sets the length of the data represented by the buffer to the specified value. sl@0: sl@0: @param aLength The new length of the buffer sl@0: */ sl@0: inline void RLogDynBuf::SetLength(TInt aLength) sl@0: { sl@0: __ASSERT_DEBUG(aLength >= 0, User::Invariant()); sl@0: iBuf.SetLength(aLength); sl@0: } sl@0: sl@0: /** sl@0: @return The length of the data in the buffer sl@0: */ sl@0: inline TInt RLogDynBuf::Length() const sl@0: { sl@0: return iBuf.Length(); sl@0: } sl@0: sl@0: #endif//LOGDYNBUF_H