1 /* |
|
2 * Copyright (c) 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: Templated class for using static arrays. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __STATIC_ARRAY_C_H__ |
|
20 #define __STATIC_ARRAY_C_H__ |
|
21 |
|
22 |
|
23 // CLASS DECLARATIONS |
|
24 |
|
25 /** |
|
26 * TStaticArrayC |
|
27 * This templated class provides a type, and size, safe method of |
|
28 * using static arrays. |
|
29 */ |
|
30 template <class T> |
|
31 class TStaticArrayC |
|
32 { |
|
33 public: // enumerations |
|
34 |
|
35 /** |
|
36 * operator[] |
|
37 * Return an element from the array. |
|
38 * @param aIndex the index of the element to return |
|
39 * @return a reference to the object |
|
40 */ |
|
41 inline const T& operator[]( TInt aIndex ) const; |
|
42 |
|
43 /** |
|
44 * TPanicCode |
|
45 * Panic code |
|
46 * EIndexOutOfBounds index is out of bounds |
|
47 */ |
|
48 enum TPanicCode |
|
49 { |
|
50 EIndexOutOfBounds = 1 |
|
51 }; |
|
52 |
|
53 /** |
|
54 * Panic |
|
55 * Generate a panic. |
|
56 * @param aPanicCode the reason code for the panic |
|
57 */ |
|
58 inline void Panic( TPanicCode aPanicCode ) const; |
|
59 |
|
60 public: // data |
|
61 |
|
62 /** iArray the arrat of elements */ |
|
63 const T* iArray; |
|
64 |
|
65 /** iCount the number of elements */ |
|
66 TInt iCount; |
|
67 |
|
68 }; |
|
69 |
|
70 // INCLUDES |
|
71 #include "staticarrayc.inl" |
|
72 |
|
73 /** |
|
74 * CONSTRUCT_STATIC_ARRAY_C |
|
75 * Initalise a global constant of type TStaticArrayC<>. |
|
76 * @param aValue the underlying const array of T |
|
77 */ |
|
78 #define CONSTRUCT_STATIC_ARRAY_C( aValue ) \ |
|
79 { \ |
|
80 aValue, \ |
|
81 sizeof( aValue ) / sizeof( *aValue ) \ |
|
82 } \ |
|
83 |
|
84 #endif // __STATIC_ARRAY_C_H__ |
|
85 |
|
86 // End of File |
|