epoc32/include/caf/metadata.h
branchSymbian2
changeset 2 2fe1408b6811
child 4 837f303aceeb
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
       
     1 /*
       
     2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  @file
       
    23  @publishedPartner
       
    24  @released
       
    25 */
       
    26 
       
    27 
       
    28 #ifndef __CAF_METADATA_H__
       
    29 #define __CAF_METADATA_H__
       
    30 
       
    31 #include <e32base.h>
       
    32 #include <f32file.h>
       
    33 
       
    34 class RReadStream;
       
    35 class RWriteStream;
       
    36 
       
    37 namespace ContentAccess
       
    38 	{
       
    39 	/** Stores a field and data pair for use in a supplier import operation
       
    40 	
       
    41 	The field and data can be any values the application doing the import thinks 
       
    42 	the agent will find useful. Some information that could be included here are
       
    43 	headers, eg:
       
    44 
       
    45 	"Content Type", "application/vnd.oma.drm.dm"
       
    46 
       
    47 	The application can include anything it likes, if the agent doesn't understand
       
    48 	the header it can just ignore it, eg:
       
    49 
       
    50 	"Colour", "Yellow"
       
    51 
       
    52 
       
    53 	CMetaData can be used with 8-bit or unicode data and automatically performs
       
    54 	conversions between the two. 
       
    55 	
       
    56 	Applications should use the unicode functions whenever possible because it 
       
    57 	removes the risk of losing information during the unicode to 8 bit conversion.
       
    58 
       
    59 	@publishedPartner
       
    60 	@released
       
    61 	*/
       
    62 	class CMetaData : public CBase
       
    63 		{
       
    64 	public:
       
    65 		/** Construct a new CMetaData with 8 bit data 
       
    66 		The 8-bit data will be stored in CMetaData as unicode 
       
    67 		
       
    68 		@param aField The name of the field
       
    69 		@param aData The data associated with the field
       
    70 		@return A CMetaData object populated with the given field and data		
       
    71 		@internalComponent
       
    72 		@released
       
    73 		*/
       
    74 		static CMetaData* NewL(const TDesC8& aField, const TDesC8& aData);
       
    75 		/** Construct a new CMetaData with unicode data 
       
    76 
       
    77 		@param aField The name of the field
       
    78 		@param aData The data associated with the field
       
    79 		@return A CMetaData object populated with the given field and data		
       
    80 
       
    81 		@internalComponent
       
    82 		@released
       
    83 		*/
       
    84 		static CMetaData* NewL(const TDesC16& aField, const TDesC16& aData);
       
    85 
       
    86 		/** Construct a new CMetaData from a data stream
       
    87 
       
    88 		@param aStream The stream to read the CMetaData object from
       
    89 		@return A CMetaData object read from the stream
       
    90 		
       
    91 		@internalComponent
       
    92 		@released
       
    93 		*/
       
    94 		static CMetaData* NewL(RReadStream& aStream);
       
    95 
       
    96 		/** destructor 
       
    97 		*/
       
    98 		virtual ~CMetaData();
       
    99 
       
   100 		/** The field name 
       
   101 		@return The field name
       
   102 		*/
       
   103 		IMPORT_C const TDesC& Field() const;
       
   104 		
       
   105 		/** The data value 
       
   106 		@return The data value
       
   107 		*/
       
   108 		IMPORT_C const TDesC& Data() const;
       
   109 
       
   110 		/** The field name 
       
   111 		@return The field name
       
   112 		*/
       
   113 		IMPORT_C const TDesC8& Field8() const;
       
   114 		
       
   115 		/** The data value 
       
   116 		@return The data value
       
   117 		*/
       
   118 		IMPORT_C const TDesC8& Data8() const;
       
   119 
       
   120 		/** Write the CMetaData to a data stream
       
   121 		
       
   122 		@param aStream The stream to write the CMetaData object to
       
   123 		@internalComponent
       
   124 		@released
       
   125 		*/
       
   126 		void ExternalizeL(RWriteStream& aStream) const;
       
   127 
       
   128 	private:
       
   129 		CMetaData(TBool aUnicode);
       
   130 		void ConstructL(const TDesC8& aField, const TDesC8& aData);
       
   131 		void ConstructL(const TDesC16& aField, const TDesC16& aData);
       
   132 
       
   133 		/** Read the CMetaData from a data stream
       
   134 		*/
       
   135 		void InternalizeL(RReadStream& aStream);
       
   136 
       
   137 	private:
       
   138 		HBufC* iField;
       
   139 		HBufC* iData;
       
   140 		HBufC8* iField8;
       
   141 		HBufC8* iData8;
       
   142 		TBool iUnicode;
       
   143 		};
       
   144 	}
       
   145 
       
   146 #endif