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