persistentstorage/dbms/utable/UT_ROW.CPP
changeset 0 08ec8eefde2f
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "UT_STD.H"
       
    17 
       
    18 // Class RDbTableRow
       
    19 
       
    20 void RDbTableRow::Open(CDbTable* aTable)
       
    21 //
       
    22 // Initialise the row buffer for using the table
       
    23 //
       
    24 	{
       
    25 	__ASSERT(!iTable);
       
    26 	__ASSERT(aTable);
       
    27 	iTable=aTable;
       
    28 	iMark.Construct(aTable->Generation());
       
    29 	}
       
    30 
       
    31 void RDbTableRow::Close()
       
    32 	{
       
    33 	if (iTable)
       
    34 		iTable->Close();
       
    35 	RDbRow::Close();
       
    36 	}
       
    37 
       
    38 EXPORT_C void RDbTableRow::ReadL(TDbRecordId aRecordId)
       
    39 	{
       
    40 	if (aRecordId==KDbNullRecordId)
       
    41 		{
       
    42 		Reset();
       
    43 		iRecord=aRecordId;
       
    44 		iMark.Mark();
       
    45 		}
       
    46 	else if (aRecordId!=iRecord || iMark.Changed())
       
    47 		{
       
    48 		Reset();
       
    49 		iRecord=KDbNullRecordId;
       
    50 		iTable->ReadRowL(*this,aRecordId);
       
    51 		iRecord=aRecordId;
       
    52 		iMark.Mark();
       
    53 		}
       
    54 	}
       
    55 
       
    56 void RDbTableRow::NewL(TDbRecordId aCopyRecord)
       
    57 //
       
    58 // Set the row buffer for a new row
       
    59 //
       
    60 	{
       
    61 	ReadL(aCopyRecord);			// copy or empty the row
       
    62 	if (aCopyRecord!=KDbNullRecordId)
       
    63 		{
       
    64 		iRecord=KDbNullRecordId;
       
    65 		iTable->DuplicateBlobsL(*this);		// duplicate any Blobs
       
    66 		}
       
    67 	iTable->NewRowL(*this);
       
    68 	}
       
    69 
       
    70 void RDbTableRow::PrepareAppendL()
       
    71 	{
       
    72 	iTable->PrepareAppendL(*this);
       
    73 	}
       
    74 
       
    75 TDbRecordId RDbTableRow::AppendL()
       
    76 	{
       
    77 	iRecord=iTable->AppendRowL(*this);
       
    78 	iMark.Mark();
       
    79 	return iRecord;
       
    80 	}
       
    81 
       
    82 void RDbTableRow::PrepareReplaceL()
       
    83 	{
       
    84 	if (iMark.Changed())
       
    85 		__LEAVE(KErrAccessDenied);
       
    86 	iTable->PrepareReplaceL(*this,iRecord);
       
    87 	}
       
    88 
       
    89 TDbRecordId RDbTableRow::ReplaceL()
       
    90 	{
       
    91 	iTable->ReplaceRowL(*this,iRecord);
       
    92 	iMark.Mark();
       
    93 	return iRecord;
       
    94 	}
       
    95 
       
    96 void RDbTableRow::DeleteL(TDbRecordId aRecordId)
       
    97 	{
       
    98 	iTable->DeleteRowL(*this,aRecordId);
       
    99 	}