epoc32/include/caf/metadata.h
branchSymbian2
changeset 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/caf/metadata.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,146 @@
     1.4 +/*
     1.5 +* Copyright (c) 2004-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 "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.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 +
    1.21 +
    1.22 +
    1.23 +
    1.24 +/**
    1.25 + @file
    1.26 + @publishedPartner
    1.27 + @released
    1.28 +*/
    1.29 +
    1.30 +
    1.31 +#ifndef __CAF_METADATA_H__
    1.32 +#define __CAF_METADATA_H__
    1.33 +
    1.34 +#include <e32base.h>
    1.35 +#include <f32file.h>
    1.36 +
    1.37 +class RReadStream;
    1.38 +class RWriteStream;
    1.39 +
    1.40 +namespace ContentAccess
    1.41 +	{
    1.42 +	/** Stores a field and data pair for use in a supplier import operation
    1.43 +	
    1.44 +	The field and data can be any values the application doing the import thinks 
    1.45 +	the agent will find useful. Some information that could be included here are
    1.46 +	headers, eg:
    1.47 +
    1.48 +	"Content Type", "application/vnd.oma.drm.dm"
    1.49 +
    1.50 +	The application can include anything it likes, if the agent doesn't understand
    1.51 +	the header it can just ignore it, eg:
    1.52 +
    1.53 +	"Colour", "Yellow"
    1.54 +
    1.55 +
    1.56 +	CMetaData can be used with 8-bit or unicode data and automatically performs
    1.57 +	conversions between the two. 
    1.58 +	
    1.59 +	Applications should use the unicode functions whenever possible because it 
    1.60 +	removes the risk of losing information during the unicode to 8 bit conversion.
    1.61 +
    1.62 +	@publishedPartner
    1.63 +	@released
    1.64 +	*/
    1.65 +	class CMetaData : public CBase
    1.66 +		{
    1.67 +	public:
    1.68 +		/** Construct a new CMetaData with 8 bit data 
    1.69 +		The 8-bit data will be stored in CMetaData as unicode 
    1.70 +		
    1.71 +		@param aField The name of the field
    1.72 +		@param aData The data associated with the field
    1.73 +		@return A CMetaData object populated with the given field and data		
    1.74 +		@internalComponent
    1.75 +		@released
    1.76 +		*/
    1.77 +		static CMetaData* NewL(const TDesC8& aField, const TDesC8& aData);
    1.78 +		/** Construct a new CMetaData with unicode data 
    1.79 +
    1.80 +		@param aField The name of the field
    1.81 +		@param aData The data associated with the field
    1.82 +		@return A CMetaData object populated with the given field and data		
    1.83 +
    1.84 +		@internalComponent
    1.85 +		@released
    1.86 +		*/
    1.87 +		static CMetaData* NewL(const TDesC16& aField, const TDesC16& aData);
    1.88 +
    1.89 +		/** Construct a new CMetaData from a data stream
    1.90 +
    1.91 +		@param aStream The stream to read the CMetaData object from
    1.92 +		@return A CMetaData object read from the stream
    1.93 +		
    1.94 +		@internalComponent
    1.95 +		@released
    1.96 +		*/
    1.97 +		static CMetaData* NewL(RReadStream& aStream);
    1.98 +
    1.99 +		/** destructor 
   1.100 +		*/
   1.101 +		virtual ~CMetaData();
   1.102 +
   1.103 +		/** The field name 
   1.104 +		@return The field name
   1.105 +		*/
   1.106 +		IMPORT_C const TDesC& Field() const;
   1.107 +		
   1.108 +		/** The data value 
   1.109 +		@return The data value
   1.110 +		*/
   1.111 +		IMPORT_C const TDesC& Data() const;
   1.112 +
   1.113 +		/** The field name 
   1.114 +		@return The field name
   1.115 +		*/
   1.116 +		IMPORT_C const TDesC8& Field8() const;
   1.117 +		
   1.118 +		/** The data value 
   1.119 +		@return The data value
   1.120 +		*/
   1.121 +		IMPORT_C const TDesC8& Data8() const;
   1.122 +
   1.123 +		/** Write the CMetaData to a data stream
   1.124 +		
   1.125 +		@param aStream The stream to write the CMetaData object to
   1.126 +		@internalComponent
   1.127 +		@released
   1.128 +		*/
   1.129 +		void ExternalizeL(RWriteStream& aStream) const;
   1.130 +
   1.131 +	private:
   1.132 +		CMetaData(TBool aUnicode);
   1.133 +		void ConstructL(const TDesC8& aField, const TDesC8& aData);
   1.134 +		void ConstructL(const TDesC16& aField, const TDesC16& aData);
   1.135 +
   1.136 +		/** Read the CMetaData from a data stream
   1.137 +		*/
   1.138 +		void InternalizeL(RReadStream& aStream);
   1.139 +
   1.140 +	private:
   1.141 +		HBufC* iField;
   1.142 +		HBufC* iData;
   1.143 +		HBufC8* iField8;
   1.144 +		HBufC8* iData8;
   1.145 +		TBool iUnicode;
   1.146 +		};
   1.147 +	}
   1.148 +
   1.149 +#endif