aiwvariant.h

Go to the documentation of this file.
00001 /*
00002 * ============================================================================
00003 *  Name        : AiwVariant.h
00004 *  Part of     : Application Interworking Framework / ServiceHandler
00005 *  Interface   : SDK, AIW Generic Parameter API
00006 *  Description : Variant data type for AIW generic parameters.
00007 *  Version     :
00008 *
00009 *  Copyright © 2003-2005 Nokia. All rights reserved.
00010 *  This material, including documentation and any related 
00011 *  computer programs, is protected by copyright controlled by 
00012 *  Nokia. All rights are reserved. Copying, including 
00013 *  reproducing, storing, adapting or translating, any 
00014 *  or all of this material requires the prior written consent of 
00015 *  Nokia. This material also contains confidential 
00016 *  information which may not be disclosed to others without the 
00017 *  prior written consent of Nokia.
00018 * ============================================================================
00019 */
00020 
00021 #ifndef AIW_VARIANT_H
00022 #define AIW_VARIANT_H
00023 
00024 // INCLUDES
00025 #include <e32std.h>
00026 #include <s32strm.h>
00027 #include <f32file.h>
00028 #include "aiwvarianttype.hrh"
00029 
00030 // FORWARD DECLARATIONS
00031 
00032 // CLASS DECLARATION
00033 
00043 class TAiwVariant
00044     {
00045     public:  // Constructors
00051         inline TAiwVariant();
00052         
00058         inline TAiwVariant(TInt32 aValue);
00059         
00065         inline TAiwVariant(const TUid& aValue);
00066         
00072         inline TAiwVariant(const TTime& aValue);
00073         
00079         inline TAiwVariant(const TDesC& aValue);
00080         
00086         inline TAiwVariant(const HBufC* aValue);
00087         
00093         inline TAiwVariant(const TDesC8& aValue);
00094         
00100         inline TAiwVariant(const RFile& aValue);
00101 
00107         IMPORT_C TAiwVariant(const TAiwVariant& aSrc);
00108                 
00114         IMPORT_C TAiwVariant& TAiwVariant::operator=(const TAiwVariant& aValue);
00115 
00116         // This class does not need a destructor because memory allocation
00117         // policy for variant class has been implemented by TAiwGenericParam
00118         // class.
00119 
00120     public:  // Interface
00124         inline TVariantTypeId TypeId() const;
00125 
00129         inline TBool IsEmpty() const;
00130 
00138         IMPORT_C TBool Get(TInt32& aValue) const;
00139         
00147         IMPORT_C TBool Get(TUid& aValue)   const;
00148         
00156         IMPORT_C TBool Get(TPtrC& aValue)  const;
00157         
00165         IMPORT_C TBool Get(TTime& aValue)  const;
00166         
00174         IMPORT_C TBool Get(TPtrC8& aValue) const;
00175         
00183         IMPORT_C TBool Get(RFile& aValue) const;
00184 
00191         IMPORT_C TInt32 AsTInt32() const;
00192         
00199         IMPORT_C TUid AsTUid() const;
00200         
00207         IMPORT_C TPtrC AsDes() const;
00208         
00215         IMPORT_C TTime AsTTime() const;
00216         
00223         IMPORT_C TPtrC8 AsData() const; 
00224         
00231         IMPORT_C RFile AsFileHandle() const;
00232 
00238         IMPORT_C void Reset();
00239 
00246         IMPORT_C void Set(TInt32 aValue);
00247 
00254         IMPORT_C void Set(const TUid& aValue);
00255         
00262         IMPORT_C void Set(const TTime& aValue);
00263 
00270         IMPORT_C void Set(const TDesC& aValue);
00271 
00278         inline void Set(const HBufC* aValue);
00279 
00286         IMPORT_C void Set(const TDesC8& aValue);
00287 
00294         IMPORT_C void Set(const RFile& aValue);
00295 
00301         inline TAiwVariant& operator=(const TTime& aValue);
00302 
00308         inline TAiwVariant& operator=(const TUid& aValue);
00309         
00315         inline TAiwVariant& operator=(TInt32 aValue);
00316         
00322         inline TAiwVariant& operator=(const TDesC& aValue);
00323         
00329         inline TAiwVariant& operator=(const HBufC* aValue);
00330         
00336         inline TAiwVariant& operator=(const TDesC8& aValue);
00337         
00343         inline TAiwVariant& operator=(const RFile& aValue);
00344         
00345     private:
00350         void InternalizeL(RReadStream& aStream);
00351 
00356         void ExternalizeL(RWriteStream& aStream) const;
00357 
00362         TInt Size() const; 
00363 
00370         void SetL(const TAiwVariant& aValue);
00371 
00375         void Destroy();
00376 
00378         void __DbgTestInvariant() const;
00379         
00380     private:  // Data
00382         TUint8 iTypeId;
00383 
00385         struct SInt64
00386             {
00387             TInt32 iLow;
00388             TInt32 iHigh;
00389             void InternalizeL(RReadStream& aStream);
00390             void ExternalizeL(RWriteStream& aStream) const;
00391             void Set(const TInt64& aTInt64);
00392             operator TInt64() const;
00393             TBool operator==(const SInt64& aRhs) const;
00394             };
00395 
00396         // Data value stored in this variant.
00397         // One of these are effective at a time depending on the iTypeId
00398         //
00399         union UData
00400             {
00401             TInt32 iInt32;      // 32-bit integer
00402             SInt64 iInt64;      // 64-bit integer
00403             HBufC* iBufC;       // owned string pointer 
00404             HBufC8* iBufC8;     // owned 8-bit data pointer 
00405             };
00406 
00407         UData  iData;  // Data union
00408         TPtrC  iPtrC;  // Pointer to string
00409         TPtrC8 iPtrC8; // Pointer to 8-bit data 
00410 
00411     private:  // friend declarations
00412         friend IMPORT_C TBool operator==(const TAiwVariant& aLhs, const TAiwVariant& aRhs);
00414         friend class TAiwGenericParam;
00415         
00416     };
00417 
00418 
00419 // FUNCTIONS
00420 
00428 IMPORT_C TBool operator==(const TAiwVariant& aLhs, const TAiwVariant& aRhs);
00429 
00437 inline TBool operator!=(const TAiwVariant& aLhs, const TAiwVariant& aRhs);
00438 
00444 void Dump(const TAiwVariant& aVariant);
00445 
00446 
00447 // INLINE FUNCTIONS
00448 #include "aiwvariant.inl"
00449 
00450 // AIW_VARIANT_H
00451 #endif
00452 
00453 // End of File

Copyright © Nokia Corporation 2001-2008
Back to top