Back to home page

Enduro/X

 
 

    


0001 /*  see copyright notice in pscript.h */
0002 #ifndef _PSSTRING_H_
0003 #define _PSSTRING_H_
0004 
0005 inline PSHash _hashstr (const PSChar *s, size_t l)
0006 {
0007         PSHash h = (PSHash)l;  /* seed */
0008         size_t step = (l>>5)|1;  /* if string is too long, don't hash all its chars */
0009         for (; l>=step; l-=step)
0010             h = h ^ ((h<<5)+(h>>2)+(unsigned short)*(s++));
0011         return h;
0012 }
0013 
0014 struct PSString : public PSRefCounted
0015 {
0016     PSString(){}
0017     ~PSString(){}
0018 public:
0019     static PSString *Create(PSSharedState *ss, const PSChar *, PSInteger len = -1 );
0020     PSInteger Next(const PSObjectPtr &refpos, PSObjectPtr &outkey, PSObjectPtr &outval);
0021     void Release();
0022     PSSharedState *_sharedstate;
0023     PSString *_next; //chain for the string table

0024     PSInteger _len;
0025     PSHash _hash;
0026     PSChar _val[1];
0027 };
0028 
0029 
0030 
0031 #endif //_PSSTRING_H_