src/ext/amaretto/socket/inc/staticarrayc.h
changeset 0 ca70ae20a155
equal deleted inserted replaced
-1:000000000000 0:ca70ae20a155
       
     1 /* Copyright (c) 2005 - 2008 Nokia Corporation
       
     2  *
       
     3  * Licensed under the Apache License, Version 2.0 (the "License");
       
     4  * you may not use this file except in compliance with the License.
       
     5  * You may obtain a copy of the License at
       
     6  *
       
     7  *     http://www.apache.org/licenses/LICENSE-2.0
       
     8  *
       
     9  * Unless required by applicable law or agreed to in writing, software
       
    10  * distributed under the License is distributed on an "AS IS" BASIS,
       
    11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    12  * See the License for the specific language governing permissions and
       
    13  * limitations under the License.
       
    14  */
       
    15 
       
    16 #ifndef __STATIC_ARRAY_C_H__
       
    17 #define __STATIC_ARRAY_C_H__
       
    18 
       
    19 
       
    20 
       
    21 /*! 
       
    22   @class TStaticArrayC
       
    23   
       
    24   @discussion This templated class provides a type, and size, safe method of
       
    25   using static arrays.
       
    26   */
       
    27 template <class T>
       
    28 class TStaticArrayC
       
    29     {
       
    30 public:
       
    31 
       
    32 /*!
       
    33   @function operator[]
       
    34   
       
    35   @discussion Return an element from the array.
       
    36   @param aIndex the index of the element to return
       
    37   @result a reference to the object
       
    38   */
       
    39     inline const T& operator[](TInt aIndex) const;
       
    40 
       
    41     /*!
       
    42       @enum TPanicCode
       
    43   
       
    44       @discussion Panic code
       
    45       @value EIndexOutOfBounds index is out of bounds
       
    46       */
       
    47     enum TPanicCode
       
    48         { 
       
    49         EIndexOutOfBounds = 1 
       
    50         };
       
    51 
       
    52 /*!
       
    53   @function Panic
       
    54   
       
    55   @discussion Generate a panic.
       
    56   @param aPanicCode the reason code for the panic
       
    57   */
       
    58     inline void Panic(TPanicCode aPanicCode) const;
       
    59 
       
    60 public:
       
    61     /*! @var iArray the arrat of elements */
       
    62     const T* iArray;
       
    63 
       
    64     /*! @var iCount the number of elements */
       
    65     TInt iCount;
       
    66 
       
    67     };
       
    68 
       
    69 /*!
       
    70   @function CONSTRUCT_STATIC_ARRAY_C
       
    71   
       
    72   @discussion Initalise a global constant of type TStaticArrayC<>.
       
    73   @param aValue the underlying const array of T
       
    74   */
       
    75 #define CONSTRUCT_STATIC_ARRAY_C(aValue) \
       
    76         {   \
       
    77         aValue,    \
       
    78         sizeof(aValue) / sizeof(*aValue)  \
       
    79         }  \
       
    80 
       
    81 
       
    82 #include "StaticArrayC.inl"
       
    83 
       
    84 #endif //   __STATIC_ARRAY_C_H__