|
1 /** |
|
2 * Copyright (c) 2003-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 "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 @file |
|
22 */ |
|
23 |
|
24 |
|
25 #ifndef __CMTF_ENUMERATOR_CONVERTER_H__ |
|
26 #define __CMTF_ENUMERATOR_CONVERTER_H__ |
|
27 |
|
28 |
|
29 #include <e32base.h> |
|
30 |
|
31 /** CMtfEnumeratorConverter provides the functionality to convert a descriptor containing |
|
32 an enumerator value to the correct numerical value. This class contains the description of |
|
33 an enumeration. */ |
|
34 class CMtfEnumeratorConverter: public CBase |
|
35 { |
|
36 public: |
|
37 |
|
38 /** TMtfEnumeratorPart defines the different component parts of an enumerator value |
|
39 that is contained in a descriptor. */ |
|
40 enum TMtfEnumeratorPart |
|
41 { |
|
42 EMtfEnumeratorClassName, |
|
43 EMtfEnumeratorEnumerationName, |
|
44 EMtfEnumeratorValueName |
|
45 }; |
|
46 |
|
47 /** Creates a new empty object. aEnumeratorValue must be full enumerator value, e.g., |
|
48 CMtfClass::TMtfEnumeratorXYZ::EMtfValueXYZ. */ |
|
49 static CMtfEnumeratorConverter* NewL(const TDesC& aEnumeratorValue); |
|
50 |
|
51 /** Creates a new empty object from the class name and enumeration name. Class name is |
|
52 optional and may be empty. */ |
|
53 static CMtfEnumeratorConverter* NewL(const TDesC& aClassName, const TDesC& aEnumerationName); |
|
54 |
|
55 /** Returns true if the given parameter is a constant enumerator value of any enumeration. */ |
|
56 static TBool IsConstantEnumerator(const TDesC& aParameter); |
|
57 |
|
58 /** Extracts the required part from the given enumerator value. */ |
|
59 static TPtrC ParseEnumeratorValueL(const TDesC& aEnumeratorValue, TMtfEnumeratorPart aPart); |
|
60 |
|
61 virtual ~CMtfEnumeratorConverter(); |
|
62 |
|
63 /* Compares two enumerator converters. Only the names are compared. */ |
|
64 TBool operator==(const CMtfEnumeratorConverter& aConverter) const; |
|
65 |
|
66 /* Compares two enumerator converters. Only the names are compared. */ |
|
67 TBool operator!=(const CMtfEnumeratorConverter& aConverter) const; |
|
68 |
|
69 |
|
70 /** Adds a new enumerator constant and its associated value. */ |
|
71 void AddEnumeratorValueL(const TDesC& aEnumeratorValue, TInt aValue); |
|
72 |
|
73 /** Convert a constant enumerator value to the associated numerical value. The |
|
74 enumerator value can be full name (i.e., including class name, enumeration name and constant, |
|
75 or just the constant name. */ |
|
76 TInt ConvertL(const TDesC& aEnumeratorValue) const; |
|
77 |
|
78 private: |
|
79 CMtfEnumeratorConverter(); |
|
80 void ConstructL(const TDesC& aClassName, const TDesC& aEnumerationName); |
|
81 |
|
82 private: |
|
83 HBufC* iClassName; |
|
84 HBufC* iEnumerationName; |
|
85 RPointerArray<HBufC> iEnumeratorValues; |
|
86 RArray<TInt> iValues; |
|
87 }; |
|
88 |
|
89 #endif |