1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/dbms/sdbms/SD_STD.INL Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,510 @@
1.4 +// Copyright (c) 1998-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 +//
1.18 +
1.19 +
1.20 +inline TInt DbsMessage(TInt aFunction,TInt aHandle)
1.21 + {
1.22 + return (aFunction<<KDbsHandleBits)|aHandle;
1.23 + }
1.24 +
1.25 +inline TDbsFunction DbsFunction(TInt aMessage)
1.26 + {
1.27 + return TDbsFunction(aMessage>>KDbsHandleBits);
1.28 + }
1.29 +
1.30 +inline TInt DbsHandle(TInt aMessage)
1.31 + {
1.32 + return aMessage&KDbsHandleMask;
1.33 + }
1.34 +
1.35 +inline TDbsType DbsType(TInt aHandle)
1.36 + {
1.37 + return TDbsType(aHandle&KDbsTypeMask);
1.38 + }
1.39 +
1.40 +inline TInt DbsMagic(TInt aHandle)
1.41 + {
1.42 + return (aHandle>>KDbsTypeBits)&KDbsMagicMask;
1.43 + }
1.44 +
1.45 +inline TInt DbsObjectIndex(TInt aHandle)
1.46 + {
1.47 + return aHandle>>(KDbsTypeBits+KDbsMagicBits);
1.48 + }
1.49 +
1.50 +inline TInt DbsMakeHandle(TInt aIndex,TInt aMagic,TDbsType aType)
1.51 + {
1.52 + return (((aIndex<<KDbsMagicBits)|aMagic)<<KDbsTypeBits)|aType;
1.53 + }
1.54 +
1.55 +inline TInt DbsSessionHandle()
1.56 + {
1.57 + return DbsMakeHandle(1<<(KDbsIndexBits-1),0,EDbsSession);
1.58 + }
1.59 +
1.60 +// streaming functions
1.61 +inline RWriteStream& operator<<(RWriteStream& aStream,const TDbCol& aCol)
1.62 + {
1.63 + ExternalizeL(aCol,aStream);
1.64 + return aStream;
1.65 + }
1.66 +
1.67 +inline RWriteStream& operator<<(RWriteStream& aStream,const CDbColSet& aColSet)
1.68 + {
1.69 + ExternalizeL(aColSet,aStream);
1.70 + return aStream;
1.71 + }
1.72 +
1.73 +inline RReadStream& operator>>(RReadStream& aStream,CDbColSet& aColSet)
1.74 + {
1.75 + InternalizeL(aColSet,aStream);
1.76 + return aStream;
1.77 + }
1.78 +
1.79 +inline RWriteStream& operator<<(RWriteStream& aStream,const CDbKey& aKey)
1.80 + {
1.81 + ExternalizeL(aKey,aStream);
1.82 + return aStream;
1.83 + }
1.84 +
1.85 +inline RReadStream& operator>>(RReadStream& aStream,CDbKey& aKey)
1.86 + {
1.87 + InternalizeL(aKey,aStream);
1.88 + return aStream;
1.89 + }
1.90 +
1.91 +inline RWriteStream& operator<<(RWriteStream& aStream,const CDbNames& aNames)
1.92 + {
1.93 + ExternalizeL(aNames,aStream);
1.94 + return aStream;
1.95 + }
1.96 +
1.97 +inline RReadStream& operator>>(RReadStream& aStream,CDbNames& aNames)
1.98 + {
1.99 + InternalizeL(aNames,aStream);
1.100 + return aStream;
1.101 + }
1.102 +
1.103 +/**
1.104 +This operator is used for externalizing CDbStrings array to a stream.
1.105 +@internalComponent
1.106 +*/
1.107 +inline RWriteStream& operator<<(RWriteStream& aStream,const CDbStrings& aStrings)
1.108 + {
1.109 + ExternalizeL(aStrings,aStream);
1.110 + return aStream;
1.111 + }
1.112 +
1.113 +/**
1.114 +This operator is used for internalizing CDbStrings array from a stream.
1.115 +@internalComponent
1.116 +*/
1.117 +inline RReadStream& operator>>(RReadStream& aStream,CDbStrings& aStrings)
1.118 + {
1.119 + InternalizeL(aStrings,aStream);
1.120 + return aStream;
1.121 + }
1.122 +
1.123 +template <class T>
1.124 +inline TExternalizeFunction Externalizer(const T*)
1.125 + {
1.126 + return TExternalizer<T>::Function();
1.127 + }
1.128 +
1.129 +// Class TDbsParam
1.130 +inline void TDbsParam::operator=(const TDesC8& aDes)
1.131 + {
1.132 + iPtr=&aDes;
1.133 + }
1.134 +
1.135 +inline void TDbsParam::operator=(const TDesC16& aDes)
1.136 + {
1.137 + iPtr=&aDes;
1.138 + }
1.139 +
1.140 +inline void TDbsParam::operator=(TInt aVal)
1.141 + {
1.142 + iInt=aVal;
1.143 + }
1.144 +
1.145 +// Class RDbsObject
1.146 +inline RDbsObject::RDbsObject():
1.147 + iHandle(0)
1.148 + {
1.149 + }
1.150 +
1.151 +inline RDbsObject::RDbsObject(const RDbs& aDbs):
1.152 + RDbs(aDbs),
1.153 + iHandle(KDbsSessionHandle)
1.154 + {
1.155 + }
1.156 +
1.157 +inline TInt RDbsObject::Handle() const
1.158 + {
1.159 + return iHandle;
1.160 + }
1.161 +
1.162 +inline void RDbsObject::OpenL(const RDbsObject& aDbs,TDbsFunction aFunction)
1.163 + {
1.164 + OpenL(aDbs,aFunction,0);
1.165 + }
1.166 +
1.167 +inline void RDbsObject::OpenL(const RDbsObject& aDbs,TDbsFunction aFunction,const TIpcArgs& aArgs)
1.168 + {
1.169 + OpenL(aDbs,aFunction,&aArgs);
1.170 + }
1.171 +
1.172 +inline void RDbsObject::OpenL(const RDbs& aDbs,TDbsFunction aFunction,const TIpcArgs& aArgs)
1.173 + {
1.174 + OpenL(RDbsObject(aDbs),aFunction,&aArgs);
1.175 + }
1.176 +
1.177 +inline void RDbsObject::SendReceive(TDbsFunction aFunction,TRequestStatus& aStatus) const
1.178 + {
1.179 + SendReceive(aFunction,0,aStatus);
1.180 + }
1.181 +
1.182 +inline TInt RDbsObject::SendReceive(TDbsFunction aFunction,const TIpcArgs& aArgs) const
1.183 + {
1.184 + return SendReceive(aFunction,&aArgs);
1.185 + }
1.186 +
1.187 +inline TInt RDbsObject::SendReceiveL(TDbsFunction aFunction,const TIpcArgs& aArgs) const
1.188 + {
1.189 + return SendReceiveL(aFunction,&aArgs);
1.190 + }
1.191 +
1.192 +inline void RDbsObject::SendReceive(TDbsFunction aFunction,const TIpcArgs& aArgs,TRequestStatus& aStatus) const
1.193 + {
1.194 + SendReceive(aFunction,&aArgs,aStatus);
1.195 + }
1.196 +
1.197 +// Class CDbsDatabase
1.198 +inline CDbsDatabase::CDbsDatabase()
1.199 + {
1.200 + }
1.201 +
1.202 +// Class CDbsNotifier
1.203 +inline CDbsNotifier::CDbsNotifier()
1.204 + {
1.205 + }
1.206 +
1.207 +// Class CDbsIncrmental
1.208 +inline CDbsIncremental::CDbsIncremental()
1.209 + {
1.210 + }
1.211 +
1.212 +// Class CDbsConstraint
1.213 +inline CDbsConstraint::CDbsConstraint()
1.214 + {
1.215 + }
1.216 +
1.217 +// Class HDbsBuf
1.218 +inline HDbsBuf::HDbsBuf()
1.219 + {
1.220 + iBuf.iExt=-1;
1.221 + }
1.222 +
1.223 +inline HDbsBuf::~HDbsBuf()
1.224 + {
1.225 + iIpc.Close();
1.226 + }
1.227 +
1.228 +inline void HDbsBuf::SetPos(TRead,TInt aPos)
1.229 + {
1.230 + iRPos=aPos;
1.231 + }
1.232 +
1.233 +inline void HDbsBuf::SetPos(TWrite,TInt aPos)
1.234 + {
1.235 + iWPos=aPos;
1.236 + }
1.237 +
1.238 +inline TInt HDbsBuf::Pos(TRead) const
1.239 + {
1.240 + return iRPos;
1.241 + }
1.242 +
1.243 +inline TInt HDbsBuf::Pos(TWrite) const
1.244 + {
1.245 + return iWPos;
1.246 + }
1.247 +
1.248 +inline TInt HDbsBuf::MovePos(TRead,TInt anOffset)
1.249 + {
1.250 + return iRPos+=anOffset;
1.251 + }
1.252 +
1.253 +inline TInt HDbsBuf::MovePos(TWrite,TInt anOffset)
1.254 + {
1.255 + return iWPos+=anOffset;
1.256 + }
1.257 +
1.258 +inline TInt HDbsBuf::Lag(TRead) const
1.259 + {
1.260 + return Ptr(ERead)-End(ERead);
1.261 + }
1.262 +
1.263 +inline TInt HDbsBuf::Lag(TWrite) const
1.264 + {
1.265 + return Ptr(EWrite)-iBuf.iData;
1.266 + }
1.267 +
1.268 +inline TInt HDbsBuf::Mark(TRead) const
1.269 + {
1.270 + return Pos(ERead)+Lag(ERead);
1.271 + }
1.272 +
1.273 +inline TInt HDbsBuf::Mark(TWrite) const
1.274 + {
1.275 + return Pos(EWrite)+Lag(EWrite);
1.276 + }
1.277 +
1.278 +// Class CDbsSource
1.279 +inline TInt CDbsSource::LinkOffset()
1.280 + {
1.281 + return _FOFF(CDbsSource,iLink);
1.282 + }
1.283 +
1.284 +inline CDbsSource::CDbsSource(const TDbFormat& aFormat):
1.285 + iFormat(aFormat)
1.286 + {
1.287 + }
1.288 +
1.289 +inline void CDbsSource::Open()
1.290 + {
1.291 + ++iConnections;
1.292 + }
1.293 +
1.294 +inline CDbSource& CDbsSource::Source()
1.295 + {
1.296 + __ASSERT(iSource);
1.297 + return *iSource;
1.298 + }
1.299 +
1.300 +// Class CDbsDatabaseStub
1.301 +inline CDbsDatabaseStub::CDbsDatabaseStub()
1.302 + {
1.303 + }
1.304 +
1.305 +// Class CDbsConnection
1.306 +inline void CDbsConnection::Set(CDbsSource& aSource)
1.307 + {
1.308 + __ASSERT(!iSource);
1.309 + iSource=&aSource;
1.310 + aSource.Open();
1.311 + }
1.312 +
1.313 +inline CDbsSource& CDbsConnection::Source() const
1.314 + {
1.315 + __ASSERT(iSource);
1.316 + return *iSource;
1.317 + }
1.318 +
1.319 +inline const CDbsConnection& CDbsConnection::Connection(const CDbObject& aObject)
1.320 + {
1.321 + __ASSERT(aObject.Context());
1.322 + return *STATIC_CAST(const CDbsConnection*,aObject.Context());
1.323 + }
1.324 +
1.325 +inline CDbsSource& CDbsConnection::Source(const CDbObject& aObject)
1.326 + {
1.327 + return Connection(aObject).Source();
1.328 + }
1.329 +
1.330 +// Class RDbsSources
1.331 +inline RDbsSources::RDbsSources(RDbCache& aCache):
1.332 + iSources(CDbsSource::LinkOffset()),
1.333 + iDrivers(aCache)
1.334 + {
1.335 + }
1.336 +
1.337 +inline void RDbsSources::Close()
1.338 + {
1.339 + __ASSERT(iSources.IsEmpty());
1.340 + iDrivers.Close();
1.341 + }
1.342 +
1.343 +// Class CDbsServer
1.344 +inline TDes& CDbsServer::Name0()
1.345 + {
1.346 + return iName0;
1.347 + }
1.348 +
1.349 +inline TDes& CDbsServer::Name1()
1.350 + {
1.351 + return iName1;
1.352 + }
1.353 +
1.354 +inline TDes& CDbsServer::FileName()
1.355 + {
1.356 + return iFileName;
1.357 + }
1.358 +
1.359 +inline RDbsSources& CDbsServer::Sources()
1.360 + {
1.361 + return iSources;
1.362 + }
1.363 +
1.364 +inline RFs& CDbsServer::Fs()
1.365 + {
1.366 + return iFs;
1.367 + }
1.368 +
1.369 +inline RDriveSpaceCol& CDbsServer::DriveSpaceCol()
1.370 + {
1.371 + return iDriveSpaceCol;
1.372 + }
1.373 +
1.374 +inline void CDbsServer::Panic(const TDesC& aCategory,TInt aPanic)
1.375 + {
1.376 + Message().Panic(aCategory,aPanic);
1.377 + }
1.378 +
1.379 +inline CPolicyProxy& CDbsServer::PolicyProxy() const
1.380 + {
1.381 + __ASSERT(iPolicyProxy);
1.382 + return *iPolicyProxy;
1.383 + }
1.384 +
1.385 +inline RDbPropsFactory& CDbsServer::DbPropsFactory()
1.386 + {
1.387 + return iDbPropsFactory;
1.388 + }
1.389 +
1.390 +// Class CDbsSession::TEntry
1.391 +inline TDbsType CDbsSession::TEntry::Type() const
1.392 + {
1.393 + return TDbsType(iType);
1.394 + }
1.395 +
1.396 +inline CDbsDatabaseStub& CDbsSession::TEntry::DatabaseStub()
1.397 + {
1.398 + __ASSERT(Type()==EDbsDatabase);
1.399 + return *STATIC_CAST(CDbsDatabaseStub*,iObject);
1.400 + }
1.401 +
1.402 +inline CDbDatabase& CDbsSession::TEntry::Database()
1.403 + {
1.404 + __ASSERT(Type()==EDbsDatabase);
1.405 + return *STATIC_CAST(CDbDatabase*,iObject);
1.406 + }
1.407 +
1.408 +inline CDbIncremental& CDbsSession::TEntry::Incremental()
1.409 + {
1.410 + __ASSERT(Type()==EDbsIncremental);
1.411 + return *STATIC_CAST(CDbIncremental*,iObject);
1.412 + }
1.413 +
1.414 +inline CDbCursor& CDbsSession::TEntry::Cursor()
1.415 + {
1.416 + __ASSERT(Type()==EDbsCursor);
1.417 + return *STATIC_CAST(CDbCursor*,iObject);
1.418 + }
1.419 +
1.420 +inline CDbRowConstraint& CDbsSession::TEntry::Constraint()
1.421 + {
1.422 + __ASSERT(Type()==EDbsConstraint);
1.423 + return *STATIC_CAST(CDbRowConstraint*,iObject);
1.424 + }
1.425 +
1.426 +inline HDbsStream& CDbsSession::TEntry::Stream()
1.427 + {
1.428 + __ASSERT(Type()==EDbsStream);
1.429 + return *STATIC_CAST(HDbsStream*,iObject);
1.430 + }
1.431 +
1.432 +inline CDbsObserver::HObserver& CDbsSession::TEntry::Observer()
1.433 + {
1.434 + __ASSERT(Type()==EDbsObserver);
1.435 + return *STATIC_CAST(CDbsObserver::HObserver*,iObject);
1.436 + }
1.437 +
1.438 +// Class CDbsSession
1.439 +inline TInt CDbsSession::Add(CDbIncremental* aIncremental, const MPolicy* aPolicy)
1.440 + {
1.441 + return DoAdd(aIncremental,EDbsIncremental, aPolicy);
1.442 + }
1.443 +
1.444 +inline TInt CDbsSession::Add(CDbCursor* aCursor, const MPolicy* aPolicy)
1.445 + {
1.446 + return DoAdd(aCursor,EDbsCursor, aPolicy);
1.447 + }
1.448 +
1.449 +inline TInt CDbsSession::Add(CDbRowConstraint* aConstraint, const MPolicy* aPolicy)
1.450 + {
1.451 + return DoAdd(aConstraint,EDbsConstraint, aPolicy);
1.452 + }
1.453 +
1.454 +inline TInt CDbsSession::Add(HDbsStream* aStream, const MPolicy* aPolicy)
1.455 + {
1.456 + return DoAdd(aStream,EDbsStream, aPolicy);
1.457 + }
1.458 +
1.459 +inline TInt CDbsSession::Add(CDbsObserver::HObserver* aObserver, const MPolicy* aPolicy)
1.460 + {
1.461 + return DoAdd(aObserver,EDbsObserver, aPolicy);
1.462 + }
1.463 +
1.464 +inline CDbsServer& CDbsSession::Server() const
1.465 + {
1.466 + return *static_cast<CDbsServer*>(const_cast<CServer2*>(CSession2::Server()));
1.467 + }
1.468 +
1.469 +inline RDbsSources& CDbsSession::Sources()
1.470 + {
1.471 + return Server().Sources();
1.472 + }
1.473 +
1.474 +// Class HDbsStream
1.475 +inline HDbsStream::HDbsStream(MStreamBuf* aHost,TInt aReadPos):
1.476 + iHost(*aHost),
1.477 + iRPos(aReadPos),
1.478 + iWPos(0)
1.479 + {
1.480 + __ASSERT(aHost);
1.481 + }
1.482 +
1.483 +inline HDbsStream::~HDbsStream()
1.484 + {
1.485 + iHost.Release();
1.486 + }
1.487 +
1.488 +inline TInt HDbsStream::SizeL()
1.489 + {
1.490 + return iHost.SizeL();
1.491 + }
1.492 +
1.493 +inline void HDbsStream::SynchL()
1.494 + {
1.495 + iHost.SynchL();
1.496 + }
1.497 +
1.498 +// Class HBufBuf
1.499 +inline HBufBuf::HBufBuf():
1.500 + iBuf(0)
1.501 + {
1.502 + }
1.503 +
1.504 +inline HBufBuf::~HBufBuf()
1.505 + {
1.506 + delete iBuf;
1.507 + }
1.508 +
1.509 +// Class CDbsSecureDatabase
1.510 +inline CDbsSecureDatabase::CDbsSecureDatabase()
1.511 + {
1.512 + }
1.513 +