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

Member Function Documentation

◆ find()

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

Definition at line 749 of file defargs.l.

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

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

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

Referenced by find().


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