os/security/contentmgmt/contentaccessfwfordrm/inc/metadataarray.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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  @file
    21  @publishedAll
    22  @released
    23 */
    24 
    25 
    26 #ifndef __CAF_METADATAARRAY_H__
    27 #define __CAF_METADATAARRAY_H__
    28 
    29 #include <e32base.h>
    30 #include <f32file.h>
    31 
    32 class RWriteStream;
    33 class RReadStream;
    34 
    35 namespace ContentAccess
    36 	{
    37 	class CMetaData;
    38 
    39 	/**
    40 	Stores an array of CMetaData objects for use in a supplier import operation
    41 	
    42 	It provides search and routines (for both 8 bit and Unicode) to find the
    43 	value corresponding to a particular field in the array.
    44 
    45   	Applications should use the unicode search function whenever possible because 
    46 	it removes the risk of losing information during the unicode to 8 bit 
    47 	conversion.
    48 
    49 	*/
    50 	class CMetaDataArray : public CBase
    51 		{
    52 	public:
    53 	
    54 		IMPORT_C static CMetaDataArray* NewL();
    55 		IMPORT_C static CMetaDataArray* NewLC();
    56 
    57 		/** Construct a CMetaDataArray from a stream
    58 		@param aStream the stream containing the metadata array
    59 		@return a new CMetaDataArray
    60 		*/
    61 		IMPORT_C static CMetaDataArray* NewL(RReadStream& aStream);
    62 
    63 		/** Destructor */
    64 		virtual ~CMetaDataArray();
    65 
    66 		/** Adds a new meta data,
    67 		@param aField The name used to index the value of interest
    68 		@param aData		The data
    69 		*/		
    70 		IMPORT_C void AddL(const TDesC8& aField, const TDesC8& aData);
    71 
    72 		/** Adds a new meta data,
    73 		@param aField The name used to index the value of interest
    74 		@param aData		The data
    75 		*/		
    76 		IMPORT_C void AddL(const TDesC& aField, const TDesC& aData);
    77 
    78 		/** Retrieves the MetaData at the given index
    79 		*
    80 		* @param aIndex	The index of the meta-data
    81 		* @return		
    82 		*/
    83 		IMPORT_C const CMetaData& operator [] (TInt aIndex) const;
    84 
    85 		/** The number of metadata objects in the list
    86 		*/
    87 		IMPORT_C TInt Count() const;
    88 
    89 		/** Find the unicode data for a given unicode field. 
    90 
    91 		@param aField	The field to retrieve
    92 		@param aMatchCase ETrue To perform case sensitive search, EFalse - To perform non case sensitive search
    93 		@return The corresponding data or else a zero length string if the field was not found	
    94 		*/
    95 		IMPORT_C const TDesC& SearchL(const TDesC& aField, TBool aMatchCase = EFalse) const;
    96 		
    97 		/** Find the 8 bit data for a given 8 bit field. 
    98 
    99 		@param aField8	The field to retrieve
   100 		@param aMatchCase ETrue To perform case sensitive search, EFalse - To perform non case sensitive search
   101 		@return The corresponding data or else a zero length string if the field was not found
   102 		*/
   103 		IMPORT_C const TDesC8& SearchL(const TDesC8& aField8, TBool aMatchCase = EFalse) const;
   104 		
   105 		/** Externalizes the CMetaDataArray object to a stream.
   106 		* 
   107 		* @param aStream	The stream to write the header information to.
   108 		*/
   109 		IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
   110 
   111 	private:
   112 		CMetaDataArray();
   113 		void InternalizeL(RReadStream& aStream);
   114 	private:
   115 
   116 		RPointerArray <CMetaData> iArray;  
   117 
   118 		// Length of the longest data item in the array
   119 		TInt iMaxFieldLength;
   120 		};
   121 	}
   122 
   123 #endif