llstrider.h

Go to the documentation of this file.
00001 
00031 #ifndef LL_LLSTRIDER_H
00032 #define LL_LLSTRIDER_H
00033 
00034 #include "stdtypes.h"
00035 
00036 template <class Object> class LLStrider
00037 {
00038         union
00039         {
00040                 Object* mObjectp;
00041                 U8*             mBytep;
00042         };
00043         U32     mSkip;
00044 public:
00045 
00046         LLStrider()  { mObjectp = NULL; mSkip = sizeof(Object); } 
00047         ~LLStrider() { } 
00048 
00049         const LLStrider<Object>& operator =  (Object *first)    { mObjectp = first; return *this;}
00050         void setStride (S32 skipBytes)  { mSkip = (skipBytes ? skipBytes : sizeof(Object));}
00051 
00052         void skip(const U32 index)     { mBytep += mSkip*index;}
00053 
00054         Object* get()                  { return mObjectp; }
00055         Object* operator->()           { return mObjectp; }
00056         Object& operator *()           { return *mObjectp; }
00057         Object* operator ++(int)       { Object* old = mObjectp; mBytep += mSkip; return old; }
00058         Object* operator +=(int i)     { mBytep += mSkip*i; return mObjectp; }
00059         Object& operator[](U32 index)  { return *(Object*)(mBytep + (mSkip * index)); }
00060 };
00061 
00062 #endif // LL_LLSTRIDER_H

Generated on Thu Jul 1 06:09:13 2010 for Second Life Viewer by  doxygen 1.4.7