1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: ut_ResMetaData.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_RES_META_DATA_H_ 19 #define NW_UT_RES_META_DATA_H_ 20 21 #include <nw/ut/ut_Inlines.h> 22 #include <nw/ut/ut_ResTypes.h> 23 #include <nw/ut/ut_ResUtil.h> 24 #include <nw/math/math_ResTypes.h> 25 #include <nw/ut/ut_ResTypeInfo.h> 26 27 namespace nw { 28 namespace ut { 29 30 //! @details :private 31 struct ResMetaDataData 32 { 33 nw::ut::ResTypeInfo typeInfo; 34 nw::ut::BinString toKey; 35 nw::ut::ResS32 m_DataType; 36 }; 37 38 //! @details :private 39 struct ResIntArrayMetaDataData : public ResMetaDataData 40 { 41 nw::ut::ResS32 m_ValuesCount; 42 nw::ut::ResS32 m_Values[1]; // ValueCount分の値が格納されている 43 }; 44 45 //! @details :private 46 struct ResFloatArrayMetaDataData : public ResMetaDataData 47 { 48 nw::ut::ResS32 m_ValuesCount; 49 nw::ut::ResF32 m_Values[1]; // ValueCount分の値が格納されている 50 }; 51 52 //! @details :private 53 struct ResStringArrayMetaDataData : public ResMetaDataData 54 { 55 nw::ut::ResU32 m_Encoding; 56 nw::ut::ResS32 m_ValuesCount; 57 nw::ut::BinString m_Values[1]; // ValueCount分の値が格納されている 58 }; 59 60 //! @details :private 61 class ResMetaData : public nw::ut::ResCommon< ResMetaDataData > 62 { 63 public: 64 enum { TYPE_INFO = NW_UT_RES_TYPE_INFO(ResMetaData) }; 65 66 enum DataType 67 { 68 DATATYPE_FLOAT_ARRAY = 0, 69 DATATYPE_INT_ARRAY, 70 DATATYPE_STRING_ARRAY, 71 DATATYPE_UNKOWN = -1 72 }; 73 74 NW_RES_CTOR( ResMetaData ) 75 NW_RES_FIELD_STRING_DECL(Key)76 NW_RES_FIELD_STRING_DECL( Key ) // GetKey() 77 NW_RES_FIELD_PRIMITIVE_DECL( s32, DataType ) // GetDataType(), SetDataType() 78 79 nw::ut::ResTypeInfo GetTypeInfo() const { return ref().typeInfo; } 80 }; 81 82 //! @details :private 83 class ResIntArrayMetaData : public ResMetaData 84 { 85 public: 86 enum { TYPE_INFO = NW_UT_RES_TYPE_INFO(ResIntArrayMetaData) }; 87 NW_RES_CTOR_INHERIT(ResIntArrayMetaData,ResMetaData)88 NW_RES_CTOR_INHERIT( ResIntArrayMetaData, ResMetaData ) 89 90 s32 GetValuesCount() const { return ref().m_ValuesCount; } GetValues()91 const s32* GetValues() const { return &(ref().m_Values[0]); } GetValues()92 s32* GetValues() { return &(ref().m_Values[0]); } 93 GetValues(int idx)94 s32 GetValues(int idx) const { return ref().m_Values[idx]; } SetValues(int idx,s32 value)95 void SetValues(int idx, s32 value) { ref().m_Values[idx] = value; } 96 GetTypeInfo()97 nw::ut::ResTypeInfo GetTypeInfo() const { return ref().typeInfo; } 98 }; 99 100 //! @details :private 101 class ResFloatArrayMetaData : public ResMetaData 102 { 103 public: 104 enum { TYPE_INFO = NW_UT_RES_TYPE_INFO(ResFloatArrayMetaData) }; 105 NW_RES_CTOR_INHERIT(ResFloatArrayMetaData,ResMetaData)106 NW_RES_CTOR_INHERIT( ResFloatArrayMetaData, ResMetaData ) 107 108 s32 GetValuesCount() const { return ref().m_ValuesCount; } 109 GetValues()110 const f32* GetValues() const { return &(ref().m_Values[0]); } GetValues()111 f32* GetValues() { return &(ref().m_Values[0]); } 112 GetValues(int idx)113 f32 GetValues(int idx) const { return ref().m_Values[idx]; } SetValues(int idx,f32 value)114 void SetValues(int idx, f32 value) { ref().m_Values[idx] = value; } 115 GetTypeInfo()116 nw::ut::ResTypeInfo GetTypeInfo() const { return ref().typeInfo; } 117 }; 118 119 //! @details :private 120 class ResStringArrayMetaData : public ResMetaData 121 { 122 public: 123 enum { TYPE_INFO = NW_UT_RES_TYPE_INFO(ResStringArrayMetaData) }; 124 125 enum Encoding 126 { 127 ENCODING_ASCII = 0, 128 ENCODING_UTF8 = 1, 129 ENCODING_UTF16LE = 2, 130 ENCODING_UTF16BE = 3 131 }; 132 NW_RES_CTOR_INHERIT(ResStringArrayMetaData,ResMetaData)133 NW_RES_CTOR_INHERIT( ResStringArrayMetaData, ResMetaData ) 134 135 NW_RES_FIELD_PRIMITIVE_DECL( s32, Encoding ) // GetEncoding() 136 137 s32 GetValuesCount() const { return ref().m_ValuesCount; } 138 GetValues(int idx)139 const char* GetValues(int idx) const { return ref().m_Values[idx].to_ptr(); } GetWValues(int idx)140 const wchar_t* GetWValues(int idx) const { return reinterpret_cast<const wchar_t*>(ref().m_Values[idx].to_ptr()); } 141 GetTypeInfo()142 nw::ut::ResTypeInfo GetTypeInfo() const { return ref().typeInfo; } 143 }; 144 145 146 } /* namespace ut */ 147 } /* namespace nw */ 148 149 #endif // NW_UT_RES_META_DATA_H_ 150