00001
00024 #ifndef INC_MI32_RECORDARRAY_H
00025 #define INC_MI32_RECORDARRAY_H
00026
00027 #ifndef INC_MI32_SIMPLEAR_H
00028 #include <mi32/simplear.h>
00029 #endif
00030
00031 #ifdef MISYSTEMDLL
00032 #define CLASSLIBEXPORT MI_DLLCLASSEXPORT
00033 #else
00034 #define CLASSLIBEXPORT MI_DLLCLASSIMPORT
00035 #endif
00036
00037
00038
00039
00041 class CLASSLIBEXPORT RECORDARRAY {
00042 public:
00043
00045 class CLASSLIBEXPORT RECORD {
00046 public:
00047
00049 RECORD ();
00050
00052 RECORD (const RECORD& rhs);
00053
00055 RECORD (RECORDARRAY& Array);
00056
00058 RECORD (RECORDARRAY& Array, UINT32 ArrayIdx);
00059
00061 ~RECORD ()
00062 { }
00063
00064
00065 RECORD& operator= (
00066 const RECORD& rhs
00067 );
00068
00070 RECORD& operator++ (
00071 ) {
00072 ++m_ArrayIdx;
00073 m_Data += m_RecordSize;
00074 return (*this);
00075 }
00076
00078 RECORD& operator-- (
00079 ) {
00080 if (m_ArrayIdx == 0) {
00081 m_ArrayIdx = m_ArraySize;
00082 m_Data = m_pArray->GetPtrBuffer() + m_ArrayIdx * m_RecordSize;
00083 }
00084 else {
00085 --m_ArrayIdx;
00086 m_Data -= m_RecordSize;
00087 }
00088 return (*this);
00089 }
00090
00092 bool AtEnd () const
00093 { return (m_ArrayIdx >= m_ArraySize); }
00094
00096 void Clear ();
00097
00099 const RECORDARRAY& GetArray () const
00100 { return (*m_pArray); }
00101
00103 RECORDARRAY& GetArray ()
00104 { return (*m_pArray); }
00105
00107 UINT32 GetArrayIdx () const
00108 { return (m_ArrayIdx); }
00109
00111 const UINT8* GetData () const
00112 { return (m_Data); }
00113
00115 UINT8* GetData ()
00116 { return (m_Data); }
00117
00119 UINT32 GetRecordSize () const
00120 { return (m_RecordSize); }
00121
00123 void SetArrayIdx (
00124 UINT32 ArrayIdx
00125 ) {
00126 m_ArrayIdx = ArrayIdx;
00127 m_Data = m_pArray->GetPtrBuffer() + m_ArrayIdx * m_RecordSize;
00128 }
00129
00130 private:
00131 #ifndef GENERATING_DOXYGEN_OUTPUT
00132 RECORDARRAY *m_pArray;
00133 UINT8 *m_Data;
00134 UINT32 m_ArrayIdx;
00135 UINT32 m_ArraySize;
00136 UINT32 m_RecordSize;
00137 #endif
00138 };
00139
00141 explicit RECORDARRAY (
00142 UINT32 RecordSize = 1
00143 );
00144
00146 ~RECORDARRAY ();
00147
00149 UINT32 GetNumRecords () const
00150 { return (m_Buffer.GetNumItems() / m_RecordSize); }
00151
00153 const UINT8* GetPtrBuffer () const
00154 { return (m_Buffer); }
00155
00157 UINT8* GetPtrBuffer ()
00158 { return (m_Buffer); }
00159
00161 const UINT8* GetPtrRecord (
00162 UINT32 idx
00163 ) const { return (static_cast<const UINT8*>(m_Buffer) + idx*m_RecordSize); }
00164
00166 UINT8* GetPtrRecord (
00167 UINT32 idx
00168 ) { return (static_cast<UINT8*>(m_Buffer) + idx*m_RecordSize); }
00169
00171 UINT32 GetRecordSize () const
00172 { return (m_RecordSize); }
00173
00177 ERRVALUE Resize (
00178 UINT32 NumRecords
00179 );
00180
00183 void SetRecordSize (
00184 UINT32 RecordSize
00185 );
00186
00187 private:
00188 #ifndef GENERATING_DOXYGEN_OUTPUT
00189 SIMPLE_ARRAY<UINT8> m_Buffer;
00190 UINT32 m_RecordSize;
00191
00192
00193 RECORDARRAY (const RECORDARRAY&);
00194 RECORDARRAY& operator= (const RECORDARRAY&);
00195 #endif
00196 };
00197
00198
00199
00200 #undef CLASSLIBEXPORT
00201
00202 #endif // INC_MI32_RECORDARRAY_H