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.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
/**
sl@0
    20
 @file
sl@0
    21
 @publishedAll
sl@0
    22
 @released
sl@0
    23
*/
sl@0
    24
sl@0
    25
sl@0
    26
#ifndef __STRINGATTRIBUTESET_H__
sl@0
    27
#define __STRINGATTRIBUTESET_H__
sl@0
    28
sl@0
    29
#include <e32base.h>
sl@0
    30
#include <caf/caftypes.h>
sl@0
    31
sl@0
    32
class RReadStream;
sl@0
    33
class RWriteStream;
sl@0
    34
sl@0
    35
namespace ContentAccess
sl@0
    36
	{
sl@0
    37
	class CStringAttribute;
sl@0
    38
sl@0
    39
	/** Holds the values of a predefined set of attributes based upon 
sl@0
    40
	ContentAccess::TStringAttribute
sl@0
    41
	
sl@0
    42
	It is also possible for an agent to provide an extended set of these 
sl@0
    43
	attributes beyond EAgentSpecificAttributeBase but only applications written 
sl@0
    44
	to support that particular agent will support this.
sl@0
    45
sl@0
    46
	No duplicate attributes are allowed in the set
sl@0
    47
sl@0
    48
	*/
sl@0
    49
	class RStringAttributeSet
sl@0
    50
		{
sl@0
    51
	public:
sl@0
    52
		IMPORT_C RStringAttributeSet();
sl@0
    53
		
sl@0
    54
		/** Release all resources used by the RStringAttributeSet
sl@0
    55
		
sl@0
    56
		This must be called before the RStringAttribute set goes out of scope
sl@0
    57
		*/
sl@0
    58
		IMPORT_C void Close();
sl@0
    59
sl@0
    60
		/** Add a new attribute to the set
sl@0
    61
		The attribute value is initalised with an empty string
sl@0
    62
		
sl@0
    63
		@param aAttribute The attribute to add to the set
sl@0
    64
		*/
sl@0
    65
		IMPORT_C void AddL(TInt aAttribute);
sl@0
    66
sl@0
    67
		/** Get the value of a specified attribute
sl@0
    68
		@param aAttribute The attribute to query
sl@0
    69
		@param aValue The value of the attribute is copied to this descriptor
sl@0
    70
		@return The value of the attribute
sl@0
    71
		@return KErrOverflow If the descriptor is not large enough to store the attribute
sl@0
    72
		@return KErrNotFound if the attribute is not part of the set
sl@0
    73
		*/
sl@0
    74
		IMPORT_C TInt GetValue(TInt aAttribute, TDes& aValue) const;
sl@0
    75
		
sl@0
    76
sl@0
    77
		/** Get the length of a buffer required to store the value of a specified attribute
sl@0
    78
		@param aAttribute The attribute to query
sl@0
    79
		@return The length of the value of the attribute
sl@0
    80
		*/
sl@0
    81
		IMPORT_C TInt GetValueLength(TInt aAttribute) const;
sl@0
    82
		
sl@0
    83
sl@0
    84
		/** Set the value of an attribute within the set
sl@0
    85
		@param aAttribute The attribute to set
sl@0
    86
		@param aValue The value of the attribute
sl@0
    87
		@param aErrorCode The error to return when GetValue() is called for this attribute
sl@0
    88
		@leave KErrNotFound if the attribute is not part of the set
sl@0
    89
		*/
sl@0
    90
		IMPORT_C TInt SetValue(TInt aAttribute, const TDesC& aValue, TInt aErrorCode);
sl@0
    91
		
sl@0
    92
sl@0
    93
		/** Find the attribute stored at a particular index in the set
sl@0
    94
		@param aIndex The index of the attribute
sl@0
    95
		@return The attribute, NOT the value of the attribute
sl@0
    96
		*/
sl@0
    97
		IMPORT_C TInt operator [] (TInt aIndex) const;
sl@0
    98
sl@0
    99
		/** The number of attributes in the set
sl@0
   100
		@return The number of attributes in the set
sl@0
   101
		*/
sl@0
   102
		IMPORT_C TInt Count() const;
sl@0
   103
		
sl@0
   104
		/** Write the RAttributeSet to a stream
sl@0
   105
		@param aStream The stream to write the attribute set to
sl@0
   106
		*/
sl@0
   107
		IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
sl@0
   108
sl@0
   109
		/** Read the RAttributeSet from a stream
sl@0
   110
		This does not clear the contents of the attribute set before reading. The 
sl@0
   111
		values of any attributes already in the set are updated with new values 
sl@0
   112
		from the stream. New attributes from the stream and their values are added
sl@0
   113
		to the set.
sl@0
   114
		@param aStream The stream to read the attribute set from
sl@0
   115
		*/
sl@0
   116
		IMPORT_C void InternalizeL(RReadStream& aStream);
sl@0
   117
sl@0
   118
	private:
sl@0
   119
		void AddL(TInt aAttribute, const TDesC& aValue, TInt aErrorCode);
sl@0
   120
sl@0
   121
		RPointerArray <CStringAttribute> iAttributes;
sl@0
   122
		};
sl@0
   123
	}
sl@0
   124
#endif