os/persistentdata/persistentstorage/store/INC/S32STRM.H
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/store/INC/S32STRM.H	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,363 @@
     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 +#if !defined(__S32STRM_H__)
    1.20 +#define __S32STRM_H__
    1.21 +#if !defined(__E32BASE_H__)
    1.22 +#include <e32base.h>
    1.23 +#endif
    1.24 +
    1.25 +/** The largest integer value which can be stored as a TCardinality type. */
    1.26 +const TInt KMaxCardinality=0x1fffffff;
    1.27 +//
    1.28 +class MStreamBuf;
    1.29 +class RWriteStream;
    1.30 +
    1.31 +/**
    1.32 + * @publishedAll 
    1.33 + * @released
    1.34 + * The read stream interface. The process of internalising from a stream is 
    1.35 +achieved through a reference to an object of this type.
    1.36 +
    1.37 +A store aware class defines an implements an InternalizeL() member function 
    1.38 +which is used to internalise that object and takes a reference to an 
    1.39 +RReadStream as the interface to the read stream. 
    1.40 +*/
    1.41 +class RReadStream
    1.42 +	{
    1.43 +public:
    1.44 +	inline RReadStream();
    1.45 +	inline RReadStream(MStreamBuf* aSource);
    1.46 +	inline MStreamBuf* Source();
    1.47 +	inline void Close();
    1.48 +	IMPORT_C void Release();
    1.49 +//
    1.50 +	IMPORT_C void PushL();
    1.51 +	inline void Pop();
    1.52 +//
    1.53 +	IMPORT_C void ReadL(TDes8& aDes);
    1.54 +	IMPORT_C void ReadL(TDes8& aDes,TInt aLength);
    1.55 +	IMPORT_C void ReadL(TDes8& aDes,TChar aDelim);
    1.56 +	IMPORT_C void ReadL(TUint8* aPtr,TInt aLength);
    1.57 +	IMPORT_C void ReadL(TInt aLength);
    1.58 +	inline void ReadL(RWriteStream& aStream);
    1.59 +	inline void ReadL(RWriteStream& aStream,TInt aLength);
    1.60 +//
    1.61 +	IMPORT_C void ReadL(TDes16& aDes);
    1.62 +	IMPORT_C void ReadL(TDes16& aDes,TInt aLength);
    1.63 +	IMPORT_C void ReadL(TDes16& aDes,TChar aDelim);
    1.64 +	IMPORT_C void ReadL(TUint16* aPtr,TInt aLength);
    1.65 +//
    1.66 +	IMPORT_C TInt8 ReadInt8L();
    1.67 +	IMPORT_C TInt16 ReadInt16L();
    1.68 +	IMPORT_C TInt32 ReadInt32L();
    1.69 +	IMPORT_C TUint8 ReadUint8L();
    1.70 +	IMPORT_C TUint16 ReadUint16L();
    1.71 +	IMPORT_C TUint32 ReadUint32L();
    1.72 +	IMPORT_C TReal32 ReadReal32L() __SOFTFP;
    1.73 +	IMPORT_C TReal64 ReadReal64L() __SOFTFP;
    1.74 +protected:
    1.75 +	inline void Attach(MStreamBuf* aSource);
    1.76 +	inline void Detach();
    1.77 +private:
    1.78 +	MStreamBuf* iSrc;
    1.79 +private:
    1.80 +	friend class RWriteStream;
    1.81 +	};
    1.82 +template <class T>
    1.83 +class MExternalizer;
    1.84 +class TStreamRef;
    1.85 +
    1.86 +/**
    1.87 + * @publishedAll 
    1.88 + * @released
    1.89 + * The write stream interface. The process of externalising to a stream is 
    1.90 +achieved through a reference to an object of this type.
    1.91 +
    1.92 +A store aware class defines and implements an ExternalizeL() member function 
    1.93 +which is used to externalise that object and takes a reference to an 
    1.94 +RWriteStream as the interface to the write stream. 
    1.95 +*/
    1.96 +class RWriteStream
    1.97 +	{
    1.98 +public:
    1.99 +	inline RWriteStream();
   1.100 +	inline RWriteStream(const MExternalizer<TStreamRef>& anExter);
   1.101 +	inline RWriteStream(MStreamBuf* aSink);
   1.102 +	inline MStreamBuf* Sink();
   1.103 +	IMPORT_C void Close();
   1.104 +	IMPORT_C void Release();
   1.105 +	IMPORT_C void CommitL();
   1.106 +//
   1.107 +	IMPORT_C void PushL();
   1.108 +	inline void Pop();
   1.109 +//
   1.110 +	IMPORT_C void WriteL(const TDesC8& aDes);
   1.111 +	IMPORT_C void WriteL(const TDesC8& aDes,TInt aLength);
   1.112 +	IMPORT_C void WriteL(const TUint8* aPtr,TInt aLength);
   1.113 +	IMPORT_C void WriteL(RReadStream& aStream);
   1.114 +	IMPORT_C void WriteL(RReadStream& aStream,TInt aLength);
   1.115 +//
   1.116 +	IMPORT_C void WriteL(const TDesC16& aDes);
   1.117 +	IMPORT_C void WriteL(const TDesC16& aDes,TInt aLength);
   1.118 +	IMPORT_C void WriteL(const TUint16* aPtr,TInt aLength);
   1.119 +//
   1.120 +	IMPORT_C void WriteInt8L(TInt aValue);
   1.121 +	IMPORT_C void WriteInt16L(TInt aValue);
   1.122 +	IMPORT_C void WriteInt32L(TInt32 aValue);
   1.123 +	IMPORT_C void WriteUint8L(TUint aValue);
   1.124 +	IMPORT_C void WriteUint16L(TUint aValue);
   1.125 +	IMPORT_C void WriteUint32L(TUint32 aValue);
   1.126 +	IMPORT_C void WriteReal32L(TReal aValue) __SOFTFP;
   1.127 +	IMPORT_C void WriteReal64L(TReal64 aValue) __SOFTFP;
   1.128 +protected:
   1.129 +	inline void Attach(MStreamBuf* aSink);
   1.130 +	inline void Detach();
   1.131 +private:
   1.132 +	IMPORT_C void WriteRefL(TStreamRef aRef);
   1.133 +private:
   1.134 +	MStreamBuf* iSnk;
   1.135 +	const MExternalizer<TStreamRef>* iExterL;
   1.136 +private:
   1.137 +	friend class TStreamRef;
   1.138 +	};
   1.139 +//
   1.140 +template <class T>
   1.141 +inline RWriteStream& operator<<(RWriteStream& aStream,const T& anObject);
   1.142 +template <class T>
   1.143 +inline RReadStream& operator>>(RReadStream& aStream,T& anObject);
   1.144 +
   1.145 +/**
   1.146 + * @publishedAll 
   1.147 + * @released
   1.148 + * Compact stream format for positive integer values in the range 0 to 
   1.149 +536,870,911 ((2^29)-1). Values in the range 0-127 are stored in a single byte, 
   1.150 +128-16383 in two bytes and other values in 4 bytes.
   1.151 +
   1.152 +The class provides conversion to and from TInt, and both externalization and 
   1.153 +internalization functions. It is used to significant effect within Symbian 
   1.154 +code. 
   1.155 +*/
   1.156 +class TCardinality
   1.157 +	{
   1.158 +public:
   1.159 +	TCardinality() {}
   1.160 +	inline TCardinality(TInt aCount);
   1.161 +	inline operator TInt() const;
   1.162 +//
   1.163 +	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
   1.164 +	IMPORT_C void InternalizeL(RReadStream& aStream);
   1.165 +private:
   1.166 +	TInt iCount;
   1.167 +private:
   1.168 +	IMPORT_C static void __DbgChkRange(TInt aCount);
   1.169 +	};
   1.170 +//
   1.171 +/** Defines a function type for a function returned by TExternalizer::Function() 
   1.172 +and TStreamRef. */
   1.173 +typedef void (*TExternalizeFunction)(const TAny* aPtr,RWriteStream& aStream);
   1.174 +/** Defines a function type for a function returned by TInternalizer::Function(). */
   1.175 +typedef void (*TInternalizeFunction)(TAny* aPtr,RReadStream& aStream);
   1.176 +
   1.177 +/**
   1.178 + * @publishedAll 
   1.179 + * @released
   1.180 + * A family of classes whose instances can be used to perform externalisation 
   1.181 +on behalf of other objects.
   1.182 +
   1.183 +@see TStreamRef  
   1.184 +*/
   1.185 +template <class T>
   1.186 +class TExternalizer
   1.187 +	{
   1.188 +public:
   1.189 +	inline void operator()(const T& anObject,RWriteStream& aStream) const;
   1.190 +	inline static TExternalizeFunction Function();
   1.191 +private:
   1.192 +	static void ExternalizeAsL(const TAny* aPtr,RWriteStream& aStream);
   1.193 +	};
   1.194 +
   1.195 +/**
   1.196 + * @publishedAll 
   1.197 + * @released
   1.198 + * A specific instantiation of the family of TExternalizer<class T> classes whose 
   1.199 +instances can be used to perform externalisation on behalf of other untyped 
   1.200 +objects. 
   1.201 +*/
   1.202 +TEMPLATE_SPECIALIZATION class TExternalizer<TAny>
   1.203 +	{
   1.204 +public:
   1.205 +	/** Default constructor. */
   1.206 +	TExternalizer() {}
   1.207 +	
   1.208 +	/** Constructs the externaliser with the specified externalisation function.
   1.209 +	
   1.210 +	@param aFunction The externalisation function. */
   1.211 +	inline TExternalizer(TExternalizeFunction aFunction);
   1.212 +	inline void operator()(const TAny* aPtr,RWriteStream& aStream) const;
   1.213 +	
   1.214 +	/** Gets a pointer to the function to be used to perform externalisation.
   1.215 +	
   1.216 +	@return The externalisation function. */
   1.217 +	inline TExternalizeFunction Function() const;
   1.218 +private:
   1.219 +	TExternalizeFunction iFunc;
   1.220 +	};
   1.221 +
   1.222 +/**
   1.223 + * @publishedAll 
   1.224 + * @released
   1.225 + * A family of classes whose instances can be used to perform internalisation 
   1.226 +on behalf of other objects. 
   1.227 +*/
   1.228 +template <class T>
   1.229 +class TInternalizer
   1.230 +	{
   1.231 +public:
   1.232 +	inline void operator()(T& anObject,RReadStream& aStream) const;
   1.233 +	inline static TInternalizeFunction Function();
   1.234 +private:
   1.235 +	static void InternalizeAsL(TAny* aPtr,RReadStream& aStream);
   1.236 +	};
   1.237 +
   1.238 +/**
   1.239 + * @publishedAll 
   1.240 + * @released
   1.241 + * A specific instantiation of the family of TInternalizer<class T> classes whose 
   1.242 +instances can be used to perform internalisation on behalf of other objects. 
   1.243 +*/
   1.244 +TEMPLATE_SPECIALIZATION class TInternalizer<TAny>
   1.245 +	{
   1.246 +public:
   1.247 +	/** Default constructor. */
   1.248 +	TInternalizer() {}
   1.249 +	
   1.250 +	/** Constructs the internaliser with the specified internalisation function.
   1.251 +	
   1.252 +	@param aFunction The internalisation function. */
   1.253 +	inline TInternalizer(TInternalizeFunction aFunction);
   1.254 +	inline void operator()(TAny* aPtr,RReadStream& aStream) const;
   1.255 +	
   1.256 +	/** Gets a pointer to the function to be used to perform internalisation.
   1.257 +	
   1.258 +	@return The internalisation function. */
   1.259 +	inline TInternalizeFunction Function() const;
   1.260 +private:
   1.261 +	TInternalizeFunction iFunc;
   1.262 +	};
   1.263 +
   1.264 +/**
   1.265 + * @publishedAll 
   1.266 + * @released
   1.267 + * A family of classes defining an interface that can be implemented by classes 
   1.268 +that need to perform externalisation on behalf of others.
   1.269 +
   1.270 +@see CStoreMap 
   1.271 +*/
   1.272 +template <class T>
   1.273 +class MExternalizer
   1.274 +	{
   1.275 +public:
   1.276 +	inline void operator()(const T& anObject,RWriteStream& aStream) const;
   1.277 +private:
   1.278 +	/** Performs externalisation.
   1.279 +	
   1.280 +	The function is called by operator().
   1.281 +	
   1.282 +	@param anObject The object to be externalised.
   1.283 +	@param aStream The write stream. */
   1.284 +	virtual void ExternalizeL(const T& anObject,RWriteStream& aStream) const=0;
   1.285 +	};
   1.286 +
   1.287 +/**
   1.288 + * @publishedAll 
   1.289 + * @released
   1.290 + * A family of classes defining an interface that can be implemented by classes 
   1.291 +that need to perform internalisation on behalf of others.
   1.292 +
   1.293 +@see CStoreMap 
   1.294 +*/
   1.295 +template <class T>
   1.296 +class MInternalizer
   1.297 +	{
   1.298 +public:
   1.299 +	inline void operator()(T& anObject,RReadStream& aStream) const;
   1.300 +private:
   1.301 +	/** Performs internalisation.
   1.302 +	
   1.303 +	The function is called by operator().
   1.304 +	
   1.305 +	@param anObject The object to be the target of the internalisation process.
   1.306 +	@param aStream The read stream. */
   1.307 +	virtual void InternalizeL(T& anObject,RReadStream& aStream) const=0;
   1.308 +	};
   1.309 +
   1.310 +/**
   1.311 + * @publishedAll 
   1.312 + * @released
   1.313 + * A proxy for perfoming externalisation for classes that do not have an 
   1.314 +externalisation member. 
   1.315 +*/
   1.316 +class TStreamRef
   1.317 +	{
   1.318 +public:
   1.319 +	inline TStreamRef(const TAny* aPtr,TExternalizeFunction aFunction);
   1.320 +	inline const TAny* Ptr() const;
   1.321 +	inline TExternalizeFunction Function() const;
   1.322 +//
   1.323 +	inline void ExternalizeL(RWriteStream& aStream) const;
   1.324 +private:
   1.325 +	const TAny* iPtr;
   1.326 +	TExternalizeFunction iFunc;
   1.327 +	};
   1.328 +
   1.329 +/**
   1.330 + * @publishedAll 
   1.331 + * @released
   1.332 + * A class whose members are used to distinguish between the two variants of 
   1.333 +the Symbian OS internal function DoExternalizeL(). 
   1.334 +*/
   1.335 +class Externalize
   1.336 +	{
   1.337 +public:
   1.338 +	/** Indicates that an object will be externalized by calling its 
   1.339 +	ExternalizeL() member. */
   1.340 +	class Member {};
   1.341 +
   1.342 +	/** Indicates that an object will be externalized by calling a global 
   1.343 +	ExternalizeL() function. */
   1.344 +	class Function {};
   1.345 +	};
   1.346 +
   1.347 +/**
   1.348 + * @publishedAll 
   1.349 + * @released
   1.350 + * A class whose members are used to distinguish between the two variants of 
   1.351 +the Symbian OS internal function DoInternalizeL(). 
   1.352 +*/
   1.353 +class Internalize
   1.354 +	{
   1.355 +public:
   1.356 +	/** Indicates that an object will be internalized by calling its 
   1.357 +	InternalizeL() member. */
   1.358 +	class Member {};
   1.359 +
   1.360 +	/** Indicates that an object will be internalized by calling a global 
   1.361 +	InternalizeL() function. */
   1.362 +	class Function {};
   1.363 +	};
   1.364 +
   1.365 +#include <s32strm.inl>
   1.366 +#endif