00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef FXELEMENT_H
00025 #define FXELEMENT_H
00026
00027 namespace FX {
00028
00029
00030
00031
00032
00033
00035 template<class TYPE>
00036 inline void constructElms(TYPE* ptr,unsigned long n){
00037 while(n--){ ::new ((void*)ptr) TYPE; ptr++; }
00038 }
00039
00040
00042 template<class TYPE>
00043 inline void destructElms(TYPE* ptr,unsigned long n){
00044 while(n--){ ptr->~TYPE(); ptr++; }
00045 }
00046
00047
00049 template<class TYPE>
00050 inline void copyElms(TYPE* dst,const TYPE* src,unsigned long n){
00051 while(n--){ *dst++ = *src++; }
00052 }
00053
00054
00056 template<class TYPE>
00057 inline void moveElms(TYPE* dst,const TYPE* src,unsigned long n){
00058 if(src>dst){
00059 while(n--){ *dst++ = *src++; }
00060 }
00061 else if(dst>src){
00062 dst+=n;
00063 src+=n;
00064 while(n--){ *--dst = *--src; }
00065 }
00066 }
00067
00068
00070 template<class TYPE>
00071 inline void fillElms(TYPE* dst,const TYPE& src,unsigned long n){
00072 while(n--){ *dst++ = src; }
00073 }
00074
00075
00077 template<class TYPE>
00078 inline void clearElms(TYPE* dst,unsigned long n){
00079 memset(dst,0,sizeof(TYPE)*n);
00080 }
00081
00082
00084 template<class TYPE>
00085 inline void saveElms(FXStream& store,const TYPE* ptr,unsigned long n){
00086 while(n--){ store << *ptr; ptr++; }
00087 }
00088
00089
00091 template<class TYPE>
00092 inline void loadElms(FXStream& store,TYPE* ptr,unsigned long n){
00093 while(n--){ store >> *ptr; ptr++; }
00094 }
00095
00096
00098 template<class TYPE>
00099 inline FXint allocElms(TYPE*& ptr,unsigned long n){
00100 return fxmalloc((void**)&ptr,sizeof(TYPE)*n);
00101 }
00102
00103
00105 template<class TYPE>
00106 inline FXint callocElms(TYPE*& ptr,unsigned long n){
00107 return fxcalloc((void**)&ptr,sizeof(TYPE)*n);
00108 }
00109
00110
00112 template<class TYPE>
00113 inline FXint dupElms(TYPE*& ptr,const TYPE* src,unsigned long n){
00114 return fxmemdup((void**)&ptr,src,sizeof(TYPE)*n);
00115 }
00116
00117
00119 template<class TYPE>
00120 inline FXint resizeElms(TYPE*& ptr,unsigned long n){
00121 return fxresize((void**)&ptr,sizeof(TYPE)*n);
00122 }
00123
00124
00126 template<class TYPE>
00127 inline void freeElms(TYPE*& ptr){
00128 fxfree((void**)&ptr);
00129 }
00130
00131
00132
00133
00134
00135
00136
00137
00138 inline void constructElms(FXuchar*,unsigned long){ }
00139 inline void constructElms(FXchar*,unsigned long){ }
00140 inline void constructElms(FXushort*,unsigned long){ }
00141 inline void constructElms(FXshort*,unsigned long){ }
00142 inline void constructElms(FXuint*,unsigned long){ }
00143 inline void constructElms(FXint*,unsigned long){ }
00144 inline void constructElms(FXfloat*,unsigned long){ }
00145 inline void constructElms(FXdouble*,unsigned long){ }
00146
00147
00148 inline void destructElms(FXuchar*,unsigned long){ }
00149 inline void destructElms(FXchar*,unsigned long){ }
00150 inline void destructElms(FXushort*,unsigned long){ }
00151 inline void destructElms(FXshort*,unsigned long){ }
00152 inline void destructElms(FXuint*,unsigned long){ }
00153 inline void destructElms(FXint*,unsigned long){ }
00154 inline void destructElms(FXfloat*,unsigned long){ }
00155 inline void destructElms(FXdouble*,unsigned long){ }
00156
00157
00158 inline void copyElms(FXuchar* dst,const FXuchar* src,unsigned long n){ memcpy(dst,src,n); }
00159 inline void copyElms(FXchar* dst,const FXchar* src,unsigned long n){ memcpy(dst,src,n); }
00160 inline void copyElms(FXushort* dst,const FXushort* src,unsigned long n){ memcpy(dst,src,n<<1); }
00161 inline void copyElms(FXshort* dst,const FXshort* src,unsigned long n){ memcpy(dst,src,n<<1); }
00162 inline void copyElms(FXuint* dst,const FXuint* src,unsigned long n){ memcpy(dst,src,n<<2); }
00163 inline void copyElms(FXint* dst,const FXint* src,unsigned long n){ memcpy(dst,src,n<<2); }
00164 inline void copyElms(FXfloat* dst,const FXfloat* src,unsigned long n){ memcpy(dst,src,n<<2); }
00165 inline void copyElms(FXdouble* dst,const FXdouble* src,unsigned long n){ memcpy(dst,src,n<<3); }
00166
00167
00168 template<class TYPE> inline void copyElms(TYPE** dst,const TYPE** src,unsigned long n){ memcpy(dst,src,n*sizeof(void*)); }
00169
00170
00171 inline void moveElms(FXuchar* dst,const FXuchar* src,unsigned long n){ memmove(dst,src,n); }
00172 inline void moveElms(FXchar* dst,const FXchar* src,unsigned long n){ memmove(dst,src,n); }
00173 inline void moveElms(FXushort* dst,const FXushort* src,unsigned long n){ memmove(dst,src,n<<1); }
00174 inline void moveElms(FXshort* dst,const FXshort* src,unsigned long n){ memmove(dst,src,n<<1); }
00175 inline void moveElms(FXuint* dst,const FXuint* src,unsigned long n){ memmove(dst,src,n<<2); }
00176 inline void moveElms(FXint* dst,const FXint* src,unsigned long n){ memmove(dst,src,n<<2); }
00177 inline void moveElms(FXfloat* dst,const FXfloat* src,unsigned long n){ memmove(dst,src,n<<2); }
00178 inline void moveElms(FXdouble* dst,const FXdouble* src,unsigned long n){ memmove(dst,src,n<<3); }
00179
00180
00181 template<class TYPE> inline void moveElms(TYPE** dst,const TYPE** src,unsigned long n){ memmove(dst,src,n*sizeof(void*)); }
00182
00183
00184 inline void fillElms(FXuchar* dst,const FXuchar& src,unsigned long n){ memset(dst,src,n); }
00185 inline void fillElms(FXchar* dst,const FXchar& src,unsigned long n){ memset(dst,src,n); }
00186
00187
00188 inline void saveElms(FXStream& store,const FXuchar* ptr,unsigned long n){ store.save(ptr,n); }
00189 inline void saveElms(FXStream& store,const FXchar* ptr,unsigned long n){ store.save(ptr,n); }
00190 inline void saveElms(FXStream& store,const FXushort* ptr,unsigned long n){ store.save(ptr,n); }
00191 inline void saveElms(FXStream& store,const FXshort* ptr,unsigned long n){ store.save(ptr,n); }
00192 inline void saveElms(FXStream& store,const FXuint* ptr,unsigned long n){ store.save(ptr,n); }
00193 inline void saveElms(FXStream& store,const FXint* ptr,unsigned long n){ store.save(ptr,n); }
00194 inline void saveElms(FXStream& store,const FXfloat* ptr,unsigned long n){ store.save(ptr,n); }
00195 inline void saveElms(FXStream& store,const FXdouble* ptr,unsigned long n){ store.save(ptr,n); }
00196
00197
00198 inline void loadElms(FXStream& store,FXuchar* ptr,unsigned long n){ store.load(ptr,n); }
00199 inline void loadElms(FXStream& store,FXchar* ptr,unsigned long n){ store.load(ptr,n); }
00200 inline void loadElms(FXStream& store,FXushort* ptr,unsigned long n){ store.load(ptr,n); }
00201 inline void loadElms(FXStream& store,FXshort* ptr,unsigned long n){ store.load(ptr,n); }
00202 inline void loadElms(FXStream& store,FXuint* ptr,unsigned long n){ store.load(ptr,n); }
00203 inline void loadElms(FXStream& store,FXint* ptr,unsigned long n){ store.load(ptr,n); }
00204 inline void loadElms(FXStream& store,FXfloat* ptr,unsigned long n){ store.load(ptr,n); }
00205 inline void loadElms(FXStream& store,FXdouble* ptr,unsigned long n){ store.load(ptr,n); }
00206
00207 }
00208
00209 #endif