summaryrefslogtreecommitdiff
path: root/indra/llcommon/llstrider.h
diff options
context:
space:
mode:
authorJames Cook <james@lindenlab.com>2007-01-02 08:33:20 +0000
committerJames Cook <james@lindenlab.com>2007-01-02 08:33:20 +0000
commit420b91db29485df39fd6e724e782c449158811cb (patch)
treeb471a94563af914d3ed3edd3e856d21cb1b69945 /indra/llcommon/llstrider.h
Print done when done.
Diffstat (limited to 'indra/llcommon/llstrider.h')
-rw-r--r--indra/llcommon/llstrider.h38
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