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