os/persistentdata/loggingservices/eventlogger/LogServ/inc/LogDynBuf.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/loggingservices/eventlogger/LogServ/inc/LogDynBuf.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,95 @@
     1.4 +// Copyright (c) 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 "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.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 +#ifndef LOGDYNBUF_H
    1.19 +#define LOGDYNBUF_H
    1.20 +
    1.21 +#include <e32base.h>
    1.22 +
    1.23 +/**
    1.24 +This class manages a 16-bit resizable buffer and offers functions which can be used for constructing 
    1.25 +SQL statements. 
    1.26 +AppendL(), and AppendNumL() can be used to append data to the end of the buffer. 
    1.27 +RLogDynBuf instance will try to expand the buffer if there is not enough available space for the data to be appended.
    1.28 +
    1.29 +The following code fragment shows how RLogDynBuf can be used:
    1.30 +@code
    1.31 +const TInt KGranularity = 128;
    1.32 +RLogDynBuf buf;
    1.33 +buf.CreateLC(KGranularity);
    1.34 +buf.AppendL(_L("some data"));//AppendL() automatically expands the buffer if there is not enough place for the string
    1.35 +buf.AppendNumL(1234);		 //AppendNumL() automatically expands the buffer if there is not enough place for the string
    1.36 +buf.AppendL(_L("more data"));//AppendL() automatically expands the buffer if there is not enough place for the string
    1.37 +......
    1.38 +CleanupStack::PopAndDestroy(buf);
    1.39 +@endcode
    1.40 +
    1.41 +@internalComponent
    1.42 +*/
    1.43 +NONSHARABLE_CLASS(RLogDynBuf)
    1.44 +	{
    1.45 +public:
    1.46 +	inline RLogDynBuf();
    1.47 +	void CreateLC(TInt aGranularity);
    1.48 +	void Close();
    1.49 +	inline const TDesC& DesC() const;
    1.50 +	inline void SetLength(TInt aLength);
    1.51 +	inline TInt Length() const;
    1.52 +	void AppendL(const TDesC& aStr);
    1.53 +	
    1.54 +private:
    1.55 +	void DoAllocL(TInt aLen);
    1.56 +	
    1.57 +private:
    1.58 +	TInt				iGranularity;
    1.59 +	RBuf				iBuf;
    1.60 +	
    1.61 +	};
    1.62 +
    1.63 +/**
    1.64 +Initializes RLogDynBuf data memebrs with default values.
    1.65 +*/
    1.66 +inline RLogDynBuf::RLogDynBuf() :
    1.67 +	iGranularity(0)
    1.68 +	{
    1.69 +	}
    1.70 +
    1.71 +/**
    1.72 +@return Non-modifiable 16-bit descriptor to the data in the buffer.
    1.73 +*/
    1.74 +inline const TDesC& RLogDynBuf::DesC() const
    1.75 +	{
    1.76 +	return iBuf;
    1.77 +	}
    1.78 +
    1.79 +/**
    1.80 +Sets the length of the data represented by the buffer to the specified value.
    1.81 +
    1.82 +@param aLength The new length of the buffer
    1.83 +*/
    1.84 +inline void RLogDynBuf::SetLength(TInt aLength)
    1.85 +	{
    1.86 +	__ASSERT_DEBUG(aLength >= 0, User::Invariant());
    1.87 +	iBuf.SetLength(aLength);
    1.88 +	}
    1.89 +
    1.90 +/**
    1.91 +@return The length of the data in the buffer
    1.92 +*/
    1.93 +inline TInt RLogDynBuf::Length() const
    1.94 +	{
    1.95 +	return iBuf.Length();
    1.96 +	}
    1.97 +
    1.98 +#endif//LOGDYNBUF_H