diff options
Diffstat (limited to 'indra/llcommon/llstrider.h')
-rw-r--r-- | indra/llcommon/llstrider.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/indra/llcommon/llstrider.h b/indra/llcommon/llstrider.h new file mode 100644 index 0000000000..0688e43940 --- /dev/null +++ b/indra/llcommon/llstrider.h @@ -0,0 +1,38 @@ +/** + * @file llstrider.h + * + * Copyright (c) 2001-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +#ifndef LL_LLSTRIDER_H +#define LL_LLSTRIDER_H + +#include "stdtypes.h" + +template <class Object> class LLStrider +{ + union + { + Object* mObjectp; + U8* mBytep; + }; + U32 mSkip; +public: + + LLStrider() { mObjectp = NULL; mSkip = sizeof(Object); } + ~LLStrider() { } + + const LLStrider<Object>& operator = (Object *first) { mObjectp = first; return *this;} + void setStride (S32 skipBytes) { mSkip = (skipBytes ? skipBytes : sizeof(Object));} + + void skip(const U32 index) { mBytep += mSkip*index;} + + Object* get() { return mObjectp; } + Object* operator->() { return mObjectp; } + Object& operator *() { return *mObjectp; } + Object* operator ++(int) { Object* old = mObjectp; mBytep += mSkip; return old; } + Object& operator[](U32 index) { return *(Object*)(mBytep + (mSkip * index)); } +}; + +#endif // LL_LLSTRIDER_H |