os/security/contentmgmt/contentaccessfwfordrm/inc/stringattributeset.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 __STRINGATTRIBUTESET_H__
    27 #define __STRINGATTRIBUTESET_H__
    28 
    29 #include <e32base.h>
    30 #include <caf/caftypes.h>
    31 
    32 class RReadStream;
    33 class RWriteStream;
    34 
    35 namespace ContentAccess
    36 	{
    37 	class CStringAttribute;
    38 
    39 	/** Holds the values of a predefined set of attributes based upon 
    40 	ContentAccess::TStringAttribute
    41 	
    42 	It is also possible for an agent to provide an extended set of these 
    43 	attributes beyond EAgentSpecificAttributeBase but only applications written 
    44 	to support that particular agent will support this.
    45 
    46 	No duplicate attributes are allowed in the set
    47 
    48 	*/
    49 	class RStringAttributeSet
    50 		{
    51 	public:
    52 		IMPORT_C RStringAttributeSet();
    53 		
    54 		/** Release all resources used by the RStringAttributeSet
    55 		
    56 		This must be called before the RStringAttribute set goes out of scope
    57 		*/
    58 		IMPORT_C void Close();
    59 
    60 		/** Add a new attribute to the set
    61 		The attribute value is initalised with an empty string
    62 		
    63 		@param aAttribute The attribute to add to the set
    64 		*/
    65 		IMPORT_C void AddL(TInt aAttribute);
    66 
    67 		/** Get the value of a specified attribute
    68 		@param aAttribute The attribute to query
    69 		@param aValue The value of the attribute is copied to this descriptor
    70 		@return The value of the attribute
    71 		@return KErrOverflow If the descriptor is not large enough to store the attribute
    72 		@return KErrNotFound if the attribute is not part of the set
    73 		*/
    74 		IMPORT_C TInt GetValue(TInt aAttribute, TDes& aValue) const;
    75 		
    76 
    77 		/** Get the length of a buffer required to store the value of a specified attribute
    78 		@param aAttribute The attribute to query
    79 		@return The length of the value of the attribute
    80 		*/
    81 		IMPORT_C TInt GetValueLength(TInt aAttribute) const;
    82 		
    83 
    84 		/** Set the value of an attribute within the set
    85 		@param aAttribute The attribute to set
    86 		@param aValue The value of the attribute
    87 		@param aErrorCode The error to return when GetValue() is called for this attribute
    88 		@leave KErrNotFound if the attribute is not part of the set
    89 		*/
    90 		IMPORT_C TInt SetValue(TInt aAttribute, const TDesC& aValue, TInt aErrorCode);
    91 		
    92 
    93 		/** Find the attribute stored at a particular index in the set
    94 		@param aIndex The index of the attribute
    95 		@return The attribute, NOT the value of the attribute
    96 		*/
    97 		IMPORT_C TInt operator [] (TInt aIndex) const;
    98 
    99 		/** The number of attributes in the set
   100 		@return The number of attributes in the set
   101 		*/
   102 		IMPORT_C TInt Count() const;
   103 		
   104 		/** Write the RAttributeSet to a stream
   105 		@param aStream The stream to write the attribute set to
   106 		*/
   107 		IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
   108 
   109 		/** Read the RAttributeSet from a stream
   110 		This does not clear the contents of the attribute set before reading. The 
   111 		values of any attributes already in the set are updated with new values 
   112 		from the stream. New attributes from the stream and their values are added
   113 		to the set.
   114 		@param aStream The stream to read the attribute set from
   115 		*/
   116 		IMPORT_C void InternalizeL(RReadStream& aStream);
   117 
   118 	private:
   119 		void AddL(TInt aAttribute, const TDesC& aValue, TInt aErrorCode);
   120 
   121 		RPointerArray <CStringAttribute> iAttributes;
   122 		};
   123 	}
   124 #endif