1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     ut_ResArrayTypes.h
4 
5   Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Revision: 13145 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NW_UT_RESARRAYTYPES_H_
17 #define NW_UT_RESARRAYTYPES_H_
18 
19 #include <nw/types.h>
20 #include <nw/ut/ut_ResArray.h>
21 #include <nw/ut/ut_ResDictionary.h>
22 #include <iterator>
23 
24 namespace nw {
25 namespace ut {
26 
27 namespace internal {
28 
29     template <typename TDic>
30     class ResArrayDicTraits
31     {
32     public:
33 
34     template <typename T>
35     class Traits
36     {
37     public:
38         typedef typename TDic::ResDicNodeData*         pointer;
39         typedef const typename TDic::ResDicNodeData*   const_pointer;
40         typedef T                                      reference;
41         typedef const T                                const_reference;
42         typedef int                                    difference_type;
43         typedef std::input_iterator_tag iterator_category;
44 
45     #if defined(NW_UT_RESARRAY_ENABLE_ARROW_OP_)
46         typedef ResPtr<T>           iter_pointer;
47         typedef ResPtr<const T>     const_iter_pointer;
48 
GetPointer(pointer ptr)49         static iter_pointer        GetPointer(pointer ptr) { return ResPtr<T>( ptr->to_ptr() ); }
GetPointer(const_pointer ptr)50         static const_iter_pointer  GetPointer(const_pointer ptr) { return ResPtr<T>( ptr->to_ptr() ); }
51     #endif
52 
GetValue(void * ptr)53         static reference    GetValue(void* ptr)   { return GetValue( reinterpret_cast<pointer>(ptr) ); }
GetValue(pointer ptr)54         static reference    GetValue(pointer ptr) { return T( ptr->ofsData.to_ptr() ); }
GetValue(const void * ptr)55         static const_reference GetValue(const void* ptr) { return GetValue( reinterpret_cast<const_pointer>(ptr) ); }
GetValue(const_pointer ptr)56         static const_reference GetValue(const_pointer ptr) { return T( ptr->ofsData.to_ptr() ); }
57 
GetNext(pointer ptr)58         static pointer       GetNext(pointer ptr) { return ptr + 1; }
GetNext(const_pointer ptr)59         static const_pointer GetNext(const_pointer ptr) { return ptr + 1; }
ValueSize()60         static size_t       ValueSize()          { return sizeof(TDic::ResDicNodeData); }
61     };
62     };
63 
64 } /* namespace internal */
65 
66 
67 //! @details :private
68 template <typename T>
69 class ResArrayPrimitive
70 {
71 public:
72     typedef internal::ResArray< T, internal::ResArrayPrimitiveTraits >   type;
73 };
74 
75 //! @details :private
76 template <typename T>
77 class ResArrayClass
78 {
79 public:
80     typedef internal::ResArray< T, internal::ResArrayClassTraits >   type;
81 };
82 
83 //! @details :private
84 template <typename T>
85 class ResArrayLinear
86 {
87 public:
88     typedef internal::ResArray< T, internal::ResArrayDicTraits<ResDicLinearData>::Traits > type;
89 };
90 
91 //! @details :private
92 template <typename T>
93 class ResArrayPatricia
94 {
95 public:
96     typedef internal::ResArray< T, internal::ResArrayDicTraits<ResDicPatriciaData>::Traits > type;
97 };
98 
99 
100 } // namespace ut
101 } // namespace nw
102 
103 #endif // NW_UT_RESARRAYTYPES_H_
104 
105