syncmlfw/common/wbxml/src/XMLDynamicWorkspace.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:  Dynamic workspace class implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // ------------------------------------------------------------------------------------------------
       
    20 // Includes
       
    21 // ------------------------------------------------------------------------------------------------
       
    22 #include <s32mem.h>
       
    23 
       
    24 #include "XMLDynamicWorkspace.h"
       
    25 
       
    26 // ------------------------------------------------------------------------------------------------
       
    27 // CXMLDynamicWorkspace
       
    28 // ------------------------------------------------------------------------------------------------
       
    29 CXMLDynamicWorkspace::CXMLDynamicWorkspace()
       
    30 	{
       
    31 	}
       
    32 
       
    33 // ------------------------------------------------------------------------------------------------
       
    34 EXPORT_C CXMLDynamicWorkspace* CXMLDynamicWorkspace::NewL()
       
    35 	{
       
    36 	CXMLDynamicWorkspace* self = new (ELeave) CXMLDynamicWorkspace();
       
    37 	CleanupStack::PushL(self);
       
    38 	self->ConstructL();
       
    39 	CleanupStack::Pop(); // self
       
    40 	return self;
       
    41 	}
       
    42 
       
    43 // ------------------------------------------------------------------------------------------------
       
    44 void CXMLDynamicWorkspace::ConstructL()
       
    45 	{
       
    46 	iBuffer = CBufFlat::NewL(32);
       
    47 	CXMLWorkspace::ConstructL();
       
    48 	}
       
    49 
       
    50 // ------------------------------------------------------------------------------------------------
       
    51 EXPORT_C CXMLDynamicWorkspace::~CXMLDynamicWorkspace()
       
    52 	{
       
    53 	delete iBuffer;
       
    54 	}
       
    55 
       
    56 // ------------------------------------------------------------------------------------------------
       
    57 EXPORT_C void CXMLDynamicWorkspace::Reset()
       
    58 	{
       
    59 	iBuffer->Reset();
       
    60 	}
       
    61 
       
    62 // ------------------------------------------------------------------------------------------------
       
    63 EXPORT_C void CXMLDynamicWorkspace::WriteL( const TDesC8& aData )
       
    64 	{
       
    65 	TRAPD(err, iBuffer->InsertL(iBuffer->Size(), aData));
       
    66 	if( err != KErrNone )
       
    67 		{
       
    68 		User::Leave(KErrTooBig);
       
    69 		}
       
    70 	}
       
    71 
       
    72 // ------------------------------------------------------------------------------------------------
       
    73 EXPORT_C void CXMLDynamicWorkspace::WriteL( const TUint8 aData )
       
    74 	{
       
    75 	WriteL(TPtrC8(&aData, 1));
       
    76 	}
       
    77 
       
    78 // ------------------------------------------------------------------------------------------------
       
    79 EXPORT_C TPtrC8 CXMLDynamicWorkspace::Buffer() const
       
    80 	{
       
    81 	return iBuffer->Ptr(0);
       
    82 	}
       
    83 
       
    84 // ------------------------------------------------------------------------------------------------
       
    85 EXPORT_C TInt CXMLDynamicWorkspace::FreeSize() const
       
    86 	{
       
    87 	return (KMaxTInt32 - Size());
       
    88 	}
       
    89 
       
    90 // ------------------------------------------------------------------------------------------------
       
    91 EXPORT_C TInt CXMLDynamicWorkspace::MaxSize() const
       
    92 	{
       
    93 	return KMaxTInt32;
       
    94 	}
       
    95 
       
    96 // ------------------------------------------------------------------------------------------------
       
    97 EXPORT_C TInt CXMLDynamicWorkspace::Size() const
       
    98 	{
       
    99 	return iBuffer->Size();
       
   100 	}
       
   101 
       
   102 // ------------------------------------------------------------------------------------------------
       
   103 void CXMLDynamicWorkspace::Delete( TInt aPos, TInt aLength )
       
   104 	{
       
   105 	iBuffer->Delete(aPos, aLength);
       
   106 	}