syncmlfw/common/wbxml/src/XMLStaticWorkspace.cpp
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Static workspace class implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // ------------------------------------------------------------------------------------------------
       
    20 // Includes
       
    21 // ------------------------------------------------------------------------------------------------
       
    22 #include "XMLStaticWorkspace.h"
       
    23 
       
    24 // ------------------------------------------------------------------------------------------------
       
    25 // CXMLStaticWorkspace
       
    26 // ------------------------------------------------------------------------------------------------
       
    27 CXMLStaticWorkspace::CXMLStaticWorkspace()
       
    28 	{
       
    29 	}
       
    30 
       
    31 // ------------------------------------------------------------------------------------------------
       
    32 EXPORT_C CXMLStaticWorkspace* CXMLStaticWorkspace::NewL( TInt aBufferSize )
       
    33 	{
       
    34 	CXMLStaticWorkspace* self = new (ELeave) CXMLStaticWorkspace();
       
    35 	CleanupStack::PushL(self);
       
    36 	self->ConstructL(aBufferSize);
       
    37 	CleanupStack::Pop(); // self
       
    38 	return self;
       
    39 	}
       
    40 
       
    41 // ------------------------------------------------------------------------------------------------
       
    42 void CXMLStaticWorkspace::ConstructL( TInt aBufferSize )
       
    43 	{
       
    44 	iMaxLength = aBufferSize;
       
    45 	iBuffer = HBufC8::NewL(aBufferSize);
       
    46 	CXMLWorkspace::ConstructL();
       
    47 	}
       
    48 
       
    49 // ------------------------------------------------------------------------------------------------
       
    50 EXPORT_C CXMLStaticWorkspace::~CXMLStaticWorkspace()
       
    51 	{
       
    52 	delete iBuffer;
       
    53 	}
       
    54 
       
    55 // ------------------------------------------------------------------------------------------------
       
    56 EXPORT_C void CXMLStaticWorkspace::Reset()
       
    57 	{
       
    58 	Ptr().Zero();
       
    59 	}
       
    60 
       
    61 // ------------------------------------------------------------------------------------------------
       
    62 EXPORT_C void CXMLStaticWorkspace::WriteL( const TDesC8& aData )
       
    63 	{
       
    64 	if( FreeSize() < aData.Length() )
       
    65 		{
       
    66 		User::Leave(KErrTooBig);
       
    67 		}
       
    68 	Ptr().Append(aData);
       
    69 	}
       
    70 
       
    71 // ------------------------------------------------------------------------------------------------
       
    72 EXPORT_C void CXMLStaticWorkspace::WriteL( const TUint8 aData )
       
    73 	{
       
    74 	WriteL(TPtrC8(&aData, 1));
       
    75 	}
       
    76 
       
    77 // ------------------------------------------------------------------------------------------------
       
    78 EXPORT_C TPtrC8 CXMLStaticWorkspace::Buffer() const
       
    79 	{
       
    80 	return *iBuffer;
       
    81 	}
       
    82 
       
    83 // ------------------------------------------------------------------------------------------------
       
    84 EXPORT_C TInt CXMLStaticWorkspace::FreeSize() const
       
    85 	{
       
    86 	return iMaxLength - Ptr().Length();
       
    87 	}
       
    88 
       
    89 // ------------------------------------------------------------------------------------------------
       
    90 EXPORT_C TInt CXMLStaticWorkspace::MaxSize() const
       
    91 	{
       
    92 	return iMaxLength;
       
    93 	}
       
    94 
       
    95 // ------------------------------------------------------------------------------------------------
       
    96 EXPORT_C TInt CXMLStaticWorkspace::Size() const
       
    97 	{
       
    98 	return Ptr().Length();
       
    99 	}
       
   100 
       
   101 // ------------------------------------------------------------------------------------------------
       
   102 void CXMLStaticWorkspace::Delete( TInt aPos, TInt aLength )
       
   103 	{
       
   104 	Ptr().Delete(aPos, aLength);
       
   105 	}
       
   106 
       
   107 // End of file