blob: 0688e43940bf8c26a56577615ddac4f9e107e25f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
|