|
1 /* |
|
2 * Copyright (c) 2002 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 * A string array class holding only one string |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef __TSingleDesCArray_H__ |
|
21 #define __TSingleDesCArray_H__ |
|
22 |
|
23 // INCLUDES |
|
24 #include <bamdesca.h> // MDesCArray |
|
25 |
|
26 // CLASS DECLARATION |
|
27 |
|
28 /** |
|
29 * A string array class holding only one string. |
|
30 */ |
|
31 class TSingleDesCArray : public MDesCArray |
|
32 { |
|
33 public: |
|
34 /** |
|
35 * Default constructor. |
|
36 * @postcond MdcaCount()==0 |
|
37 */ |
|
38 inline TSingleDesCArray(); |
|
39 |
|
40 /** |
|
41 * Constructor. |
|
42 * @param aString reference to the one and only string this array |
|
43 * contains |
|
44 * @postcond MdcaCount()==1 && MdcaPoint(0)==aString |
|
45 */ |
|
46 inline TSingleDesCArray(const TDesC& aString); |
|
47 |
|
48 /** |
|
49 * Sets the one and only string this array contains to aString. |
|
50 * @postcond MdcaCount()==1 && MdcaPoint(0)==aString |
|
51 */ |
|
52 inline void SetDesC(const TDesC& aString); |
|
53 |
|
54 /** |
|
55 * Makes this array empty. |
|
56 * @postcond MdcaCount()==0 |
|
57 */ |
|
58 inline void Reset(); |
|
59 |
|
60 public: // from MDesCArray |
|
61 TInt MdcaCount() const; |
|
62 TPtrC MdcaPoint(TInt aIndex) const; |
|
63 |
|
64 private: // Implementation |
|
65 enum TPanicCode |
|
66 { |
|
67 EPanicPostCond_Constructor, |
|
68 EPanicPostCond_Constructor_TDesC, |
|
69 EPanicPostCond_SetDesC, |
|
70 EPanicPostCond_Reset, |
|
71 EPanicPreCond_MdcaPoint |
|
72 }; |
|
73 static void Panic(TInt aReason); |
|
74 |
|
75 private: // Data |
|
76 /// Ref: the string which this array contains |
|
77 const TDesC* iString; |
|
78 }; |
|
79 |
|
80 |
|
81 inline TSingleDesCArray::TSingleDesCArray() |
|
82 : iString(NULL) |
|
83 { |
|
84 __ASSERT_DEBUG(MdcaCount()==0, Panic(EPanicPostCond_Constructor)); |
|
85 } |
|
86 |
|
87 inline TSingleDesCArray::TSingleDesCArray(const TDesC& aString) |
|
88 : iString(&aString) |
|
89 { |
|
90 __ASSERT_DEBUG(MdcaCount()==1 && MdcaPoint(0)==aString, |
|
91 Panic(EPanicPostCond_Constructor_TDesC)); |
|
92 } |
|
93 |
|
94 inline void TSingleDesCArray::SetDesC(const TDesC& aString) |
|
95 { |
|
96 iString = &aString; |
|
97 __ASSERT_DEBUG(MdcaCount()==1 && MdcaPoint(0)==aString, |
|
98 Panic(EPanicPostCond_SetDesC)); |
|
99 } |
|
100 |
|
101 inline void TSingleDesCArray::Reset() |
|
102 { |
|
103 iString = NULL; |
|
104 __ASSERT_DEBUG(MdcaCount()==0, Panic(EPanicPostCond_Reset)); |
|
105 } |
|
106 |
|
107 #endif // __TSingleDesCArray_H__ |
|
108 |
|
109 // End of File |