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

Member Function Documentation

◆ find()

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

Definition at line 750 of file defargs.l.

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

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

704{
705 static const unsigned char asso_values[] =
706 {
707 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
708 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
709 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
710 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
711 49, 49, 49, 49, 49, 49, 49, 49, 49, 5,
712 5, 30, 0, 49, 25, 49, 10, 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, 0, 49, 0, 5, 49,
717 15, 0, 49, 10, 49, 30, 49, 49, 0, 20,
718 0, 49, 15, 49, 5, 10, 0, 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, 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
733 };
734 size_t hval = len;
735
736 switch (hval)
737 {
738 default:
739 hval += asso_values[static_cast<unsigned char>(str[4])];
740 /*FALLTHROUGH*/
741 case 4:
742 hval += asso_values[static_cast<unsigned char>(str[3])];
743 /*FALLTHROUGH*/
744 case 3:
745 break;
746 }
747 return hval;
748}

Referenced by find().


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