Skip to main content

The KeywordHash Class Reference

Declaration

class KeywordHash { ... }

Public Static Functions Index

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

Private Static Functions Index

static size_thash (const char *str, size_t len)

Definition at line 687 of file defargs.l.

Public Static Functions

find()

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

Definition at line 692 of file defargs.l.

742const char * KeywordHash::find (const char *str, size_t len)
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);
787
788 if (key <= MAX_HASH_VALUE)
789 {
790 const char *s = wordlist[key];
791
792 if (*str == *s && !qstrcmp (str + 1, s + 1))
793 return s;
794 }
795 }
796 return nullptr;
797}

References hash, MAX_HASH_VALUE, MIN_WORD_LENGTH and qstrcmp.

Referenced by nameIsActuallyPartOfType.

Private Static Functions

hash()

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

Definition at line 690 of file defargs.l.

695inline size_t KeywordHash::hash (const char *str, size_t len)
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:


Generated via doxygen2docusaurus by Doxygen 1.14.0.