sqstring.h

00001 /*  see copyright notice in squirrel.h */
00002 #ifndef _SQSTRING_H_
00003 #define _SQSTRING_H_
00004 
00005 inline SQHash _hashstr (const SQChar *s, size_t l)
00006 {
00007     SQHash h = (SQHash)l;  /* seed */
00008     size_t step = (l>>5)|1;  /* if string is too long, don't hash all its chars */
00009     for (; l>=step; l-=step)
00010       h = h ^ ((h<<5)+(h>>2)+(unsigned short)*(s++));
00011     return h;
00012 }
00013 
00014 struct SQString : public SQRefCounted
00015 {
00016   SQString(){}
00017   ~SQString(){}
00018 public:
00019   static SQString *Create(SQSharedState *ss, const SQChar *, SQInteger len = -1 );
00020   SQInteger Next(const SQObjectPtr &refpos, SQObjectPtr &outkey, SQObjectPtr &outval);
00021   void Release();
00022   SQSharedState *_sharedstate;
00023   SQString *_next; //chain for the string table
00024   SQInteger _len;
00025   SQHash _hash;
00026   SQChar _val[1];
00027 };
00028 
00029 
00030 
00031 #endif //_SQSTRING_H_

Generated on Mon Dec 14 20:59:56 2009 for OpenTTD by  doxygen 1.5.6