ScummVM API documentation
sqstring.h
1 /* see copyright notice in squirrel.h */
2 #ifndef _SQSTRING_H_
3 #define _SQSTRING_H_
4 
5 inline SQHash _hashstr (const SQChar *s, size_t l)
6 {
7  SQHash h = (SQHash)l; /* seed */
8  size_t step = (l>>5)|1; /* if string is too long, don't hash all its chars */
9  for (; l>=step; l-=step)
10  h = h ^ ((h<<5)+(h>>2)+(unsigned short)*(s++));
11  return h;
12 }
13 
14 struct SQString : public SQRefCounted
15 {
16  SQString() : _sharedstate(nullptr), _next(nullptr), _len(0), _hash(0)
17  {
18  _val[0] = 0;
19  }
20  ~SQString(){}
21 public:
22  static SQString *Create(SQSharedState *ss, const SQChar *, SQInteger len = -1 );
23  SQInteger Next(const SQObjectPtr &refpos, SQObjectPtr &outkey, SQObjectPtr &outval);
24  void Release();
25  SQSharedState *_sharedstate;
26  SQString *_next; //chain for the string table
27  SQInteger _len;
28  SQHash _hash;
29  SQChar _val[1];
30 };
31 
32 
33 
34 #endif //_SQSTRING_H_
Definition: sqstate.h:59
Definition: sqobject.h:87
Definition: sqobject.h:205
Definition: sqstring.h:14