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 699 of file defargs.l.

Member Function Documentation

◆ find()

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

Definition at line 754 of file defargs.l.

755{
756 static const char * const wordlist[] =
757 {
758 "", "", "",
759 "int",
760 "bool",
761 "float",
762 "signed",
763 "",
764 "volatile",
765 "char",
766 "short",
767 "double",
768 "wchar_t",
769 "uint16_t",
770 "long",
771 "const",
772 "int8_t",
773 "uint8_t",
774 "char16_t",
775 "void",
776 "", "",
777 "char8_t",
778 "intptr_t",
779 "uintptr_t",
780 "", "", "",
781 "intmax_t",
782 "uintmax_t",
783 "", "",
784 "int64_t",
785 "uint64_t",
786 "", "", "",
787 "int16_t",
788 "uint32_t",
789 "", "", "",
790 "int32_t",
791 "char32_t",
792 "", "", "", "",
793 "unsigned"
794 };
795
796 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
797 {
798 size_t key = hash (str, len);
static size_t hash(const char *str, size_t len)
Definition defargs.l:707
#define MIN_WORD_LENGTH
Definition defargs.l:693
799
800 if (key <= MAX_HASH_VALUE)
801 {
802 const char *s = wordlist[key];
#define MAX_HASH_VALUE
Definition defargs.l:696
803
804 if (*str == *s && !qstrcmp (str + 1, s + 1))
805 return s;
806 }
807 }
808 return nullptr;
int qstrcmp(const char *str1, const char *str2)
Definition qcstring.h:69
809}

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 707 of file defargs.l.

708{
709 static const unsigned char asso_values[] =
710 {
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, 5,
716 5, 30, 0, 49, 25, 49, 10, 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, 0, 49, 0, 5, 49,
721 15, 0, 49, 10, 49, 30, 49, 49, 0, 20,
722 0, 49, 15, 49, 5, 10, 0, 49, 49, 49,
723 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
724 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
725 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
726 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
727 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
728 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
729 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
730 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
731 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
732 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
733 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
734 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
735 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
736 49, 49, 49, 49, 49, 49
737 };
738 size_t hval = len;
739
740 switch (hval)
741 {
742 default:
743 hval += asso_values[static_cast<unsigned char>(str[4])];
744 /*FALLTHROUGH*/
745 case 4:
746 hval += asso_values[static_cast<unsigned char>(str[3])];
747 /*FALLTHROUGH*/
748 case 3:
749 break;
750 }
751 return hval;
752}

Referenced by find().


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