os/persistentdata/persistentstorage/sql/SRC/Common/SqlBufFlat.inl
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sql/SRC/Common/SqlBufFlat.inl	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,104 @@
     1.4 +// Copyright (c) 2006-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 +// //               RSqlBufFlat class          //
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +/**
    1.22 + 
    1.23 + @return Flat buffer elements count
    1.24 +*/
    1.25 +inline TInt RSqlBufFlat::Count() const
    1.26 +	{
    1.27 +	SQLFLATBUF_INVARIANT();
    1.28 +	return iBuf->iCount;
    1.29 +	}
    1.30 +
    1.31 +/**
    1.32 +@return Flat buffer size (this is not the max size. It refers only to the used part of the flat buffer)
    1.33 +*/
    1.34 +inline TInt RSqlBufFlat::Size() const
    1.35 +	{
    1.36 +	SQLFLATBUF_INVARIANT();
    1.37 +	return iBuf->iSize;
    1.38 +	}
    1.39 +
    1.40 +/**
    1.41 +@return Flat buffer max size
    1.42 +*/
    1.43 +inline TInt RSqlBufFlat::MaxSize() const
    1.44 +	{
    1.45 +	SQLFLATBUF_INVARIANT();
    1.46 +	return iMaxSize;
    1.47 +	}
    1.48 +
    1.49 +/**
    1.50 +@return A pointer to the beginning of the flat buffer header
    1.51 +*/
    1.52 +inline RSqlBufFlat::TCell* RSqlBufFlat::Header()
    1.53 +	{
    1.54 +	return reinterpret_cast <RSqlBufFlat::TCell*> (iBuf + 1);
    1.55 +	}
    1.56 +
    1.57 +/**
    1.58 +@return A const pointer to the beginning of the flat buffer header
    1.59 +*/
    1.60 +inline const RSqlBufFlat::TCell* RSqlBufFlat::Header() const 
    1.61 +	{
    1.62 +	return reinterpret_cast <const RSqlBufFlat::TCell*> (iBuf + 1);
    1.63 +	}
    1.64 +
    1.65 +/**
    1.66 +@return The avaliable space in the flat buffer
    1.67 +*/
    1.68 +inline TInt RSqlBufFlat::Available() const
    1.69 +	{
    1.70 +	return iMaxSize - iBuf->iSize;
    1.71 +	}
    1.72 +
    1.73 +/**
    1.74 +This function returns a const reference to a descriptor object pointing to the internal buffer.
    1.75 +BufDes() guarantees to return a const descriptor, whose lifetime is the same as the flat buffer lifetime.
    1.76 +(useful when making asynchronous IPC calls)
    1.77 +
    1.78 +@return A reference to a descriptor object pointing to the internal buffer.
    1.79 +*/
    1.80 +inline const TDesC8& RSqlBufFlat::BufDes() const
    1.81 +	{
    1.82 +	SQLFLATBUF_INVARIANT();
    1.83 +	iBufPtrC.Set(reinterpret_cast <const TUint8*> (iBuf), iBuf->iSize);
    1.84 +	return iBufPtrC;	
    1.85 +	}
    1.86 +
    1.87 +/**
    1.88 +This function returns a modifiable reference to a descriptor object pointing to the internal buffer.
    1.89 +BufPtr() guarantees to return a modifiable descriptor, whose lifetime is the same as the flat buffer lifetime.
    1.90 +(useful when making asynchronous IPC calls)
    1.91 +
    1.92 +@return A reference to a modifiable descriptor object pointing to the internal buffer.
    1.93 +*/
    1.94 +inline TPtr8& RSqlBufFlat::BufPtr()
    1.95 +	{
    1.96 +	SQLFLATBUF_INVARIANT();
    1.97 +	iBufPtr.Set(reinterpret_cast <TUint8*> (iBuf), iBuf->iSize, iMaxSize);
    1.98 +	return iBufPtr;	
    1.99 +	}
   1.100 +
   1.101 +/**
   1.102 +@return The minimal allowed buffer size: sizeof(TBufFlat) + size of the header
   1.103 +*/
   1.104 +inline TInt RSqlBufFlat::SysDataSize() const
   1.105 +	{
   1.106 +	return iBuf->iHeaderSize + sizeof(RSqlBufFlat::TBufFlat);
   1.107 +	}