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

Member Function Documentation

◆ find()

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

Definition at line 756 of file defargs.l.

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

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

Referenced by nameIsActuallyPartOfType().

◆ hash()

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

Definition at line 709 of file defargs.l.

710{
711 static const unsigned char asso_values[] =
712 {
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, 5,
718 5, 30, 0, 49, 25, 49, 10, 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, 0, 49, 0, 5, 49,
723 15, 0, 49, 10, 49, 30, 49, 49, 0, 20,
724 0, 49, 15, 49, 5, 10, 0, 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, 49, 49, 49, 49,
737 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
738 49, 49, 49, 49, 49, 49
739 };
740 size_t hval = len;
741
742 switch (hval)
743 {
744 default:
745 hval += asso_values[static_cast<unsigned char>(str[4])];
746 /*FALLTHROUGH*/
747 case 4:
748 hval += asso_values[static_cast<unsigned char>(str[3])];
749 /*FALLTHROUGH*/
750 case 3:
751 break;
752 }
753 return hval;
754}

Referenced by find().


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