os/persistentdata/loggingservices/eventlogger/LogServ/inc/LogDynBuf.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 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 "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 #ifndef LOGDYNBUF_H
    16 #define LOGDYNBUF_H
    17 
    18 #include <e32base.h>
    19 
    20 /**
    21 This class manages a 16-bit resizable buffer and offers functions which can be used for constructing 
    22 SQL statements. 
    23 AppendL(), and AppendNumL() can be used to append data to the end of the buffer. 
    24 RLogDynBuf instance will try to expand the buffer if there is not enough available space for the data to be appended.
    25 
    26 The following code fragment shows how RLogDynBuf can be used:
    27 @code
    28 const TInt KGranularity = 128;
    29 RLogDynBuf buf;
    30 buf.CreateLC(KGranularity);
    31 buf.AppendL(_L("some data"));//AppendL() automatically expands the buffer if there is not enough place for the string
    32 buf.AppendNumL(1234);		 //AppendNumL() automatically expands the buffer if there is not enough place for the string
    33 buf.AppendL(_L("more data"));//AppendL() automatically expands the buffer if there is not enough place for the string
    34 ......
    35 CleanupStack::PopAndDestroy(buf);
    36 @endcode
    37 
    38 @internalComponent
    39 */
    40 NONSHARABLE_CLASS(RLogDynBuf)
    41 	{
    42 public:
    43 	inline RLogDynBuf();
    44 	void CreateLC(TInt aGranularity);
    45 	void Close();
    46 	inline const TDesC& DesC() const;
    47 	inline void SetLength(TInt aLength);
    48 	inline TInt Length() const;
    49 	void AppendL(const TDesC& aStr);
    50 	
    51 private:
    52 	void DoAllocL(TInt aLen);
    53 	
    54 private:
    55 	TInt				iGranularity;
    56 	RBuf				iBuf;
    57 	
    58 	};
    59 
    60 /**
    61 Initializes RLogDynBuf data memebrs with default values.
    62 */
    63 inline RLogDynBuf::RLogDynBuf() :
    64 	iGranularity(0)
    65 	{
    66 	}
    67 
    68 /**
    69 @return Non-modifiable 16-bit descriptor to the data in the buffer.
    70 */
    71 inline const TDesC& RLogDynBuf::DesC() const
    72 	{
    73 	return iBuf;
    74 	}
    75 
    76 /**
    77 Sets the length of the data represented by the buffer to the specified value.
    78 
    79 @param aLength The new length of the buffer
    80 */
    81 inline void RLogDynBuf::SetLength(TInt aLength)
    82 	{
    83 	__ASSERT_DEBUG(aLength >= 0, User::Invariant());
    84 	iBuf.SetLength(aLength);
    85 	}
    86 
    87 /**
    88 @return The length of the data in the buffer
    89 */
    90 inline TInt RLogDynBuf::Length() const
    91 	{
    92 	return iBuf.Length();
    93 	}
    94 
    95 #endif//LOGDYNBUF_H