#ifndef __rf_common_ih__ #define __rf_common_ih__ #include "rf_common.hh" #include "pxx_common.ih" #include "pxx_heap_allocator.ih" namespace rfrt { static inline bool is_refal_alnum (wint_t _wc) { return iswalnum(_wc) || _wc == L'!' || _wc == L'?' || _wc == '-'; } static inline bool is_refal_upper (wint_t _wc) { return iswupper(_wc) || _wc == L'!' || _wc == L'?'; } static inline uint32_t update_hash (uint32_t _hash, void* _ptr, size_t _len) { char* p = static_cast(_ptr); while (_len--) { _hash += *p++; _hash += (_hash << 10); _hash ^= (_hash >> 6); } return _hash; } static inline uint32_t finish_hash (uint32_t _hash) { _hash += (_hash << 3); _hash ^= (_hash >> 11); _hash += (_hash << 15); return (_hash & (hash_size - 1)); } static inline uint32_t compute_hash (void* _ptr, size_t _len) { return finish_hash(update_hash(0, _ptr, _len)); } static inline size_t strtowstr (wchar_t* _wstr, char* _str, size_t _len) { wchar_t* wp = _wstr; char* p = _str; for (; _len; _len--) { size_t l = mbrtowc (wp, p, MB_CUR_MAX, null); wp++; p += l; } return wp - _wstr; } } #endif // __rf_common_ih__