Doxygen
Loading...
Searching...
No Matches
KeywordHash Class Reference

Static Public Member Functions

static const char * find (const char *str, size_t len)
 

Static Private Member Functions

static size_t hash (const char *str, size_t len)
 

Detailed Description

Definition at line 687 of file defargs.l.

Member Function Documentation

◆ find()

const char * KeywordHash::find ( const char * str,
size_t len )
static

Definition at line 742 of file defargs.l.

743{
744 static const char * const wordlist[] =
745 {
746 "", "", "",
747 "int",
748 "bool",
749 "float",
750 "signed",
751 "",
752 "volatile",
753 "char",
754 "short",
755 "double",
756 "wchar_t",
757 "uint16_t",
758 "long",
759 "const",
760 "int8_t",
761 "uint8_t",
762 "char16_t",
763 "void",
764 "", "",
765 "char8_t",
766 "intptr_t",
767 "uintptr_t",
768 "", "", "",
769 "intmax_t",
770 "uintmax_t",
771 "", "",
772 "int64_t",
773 "uint64_t",
774 "", "", "",
775 "int16_t",
776 "uint32_t",
777 "", "", "",
778 "int32_t",
779 "char32_t",
780 "", "", "", "",
781 "unsigned"
782 };
783
784 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
785 {
786 size_t key = hash (str, len);
static size_t hash(const char *str, size_t len)
Definition defargs.l:695
#define MIN_WORD_LENGTH
Definition defargs.l:681
787
788 if (key <= MAX_HASH_VALUE)
789 {
790 const char *s = wordlist[key];
#define MAX_HASH_VALUE
Definition defargs.l:684
791
792 if (*str == *s && !qstrcmp (str + 1, s + 1))
793 return s;
794 }
795 }
796 return nullptr;
int qstrcmp(const char *str1, const char *str2)
Definition qcstring.h:69
797}

References hash(), MAX_HASH_VALUE, MIN_WORD_LENGTH, and qstrcmp().

Referenced by nameIsActuallyPartOfType().

◆ hash()

size_t KeywordHash::hash ( const char * str,
size_t len )
inlinestaticprivate

Definition at line 695 of file defargs.l.

696{
697 static const unsigned char asso_values[] =
698 {
699 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
700 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
701 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
702 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
703 49, 49, 49, 49, 49, 49, 49, 49, 49, 5,
704 5, 30, 0, 49, 25, 49, 10, 49, 49, 49,
705 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
706 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
707 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
708 49, 49, 49, 49, 49, 0, 49, 0, 5, 49,
709 15, 0, 49, 10, 49, 30, 49, 49, 0, 20,
710 0, 49, 15, 49, 5, 10, 0, 49, 49, 49,
711 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
712 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
713 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
714 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
715 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
716 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
717 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
718 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
719 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
720 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
721 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
722 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
723 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
724 49, 49, 49, 49, 49, 49
725 };
726 size_t hval = len;
727
728 switch (hval)
729 {
730 default:
731 hval += asso_values[static_cast<unsigned char>(str[4])];
732 /*FALLTHROUGH*/
733 case 4:
734 hval += asso_values[static_cast<unsigned char>(str[3])];
735 /*FALLTHROUGH*/
736 case 3:
737 break;
738 }
739 return hval;
740}

Referenced by find().


The documentation for this class was generated from the following file: