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