| 1763 | } |
| 1764 | |
| 1765 | CheckedError Parser::ParseHash(Value &e, FieldDef *field) { |
| 1766 | FLATBUFFERS_ASSERT(field); |
| 1767 | Value *hash_name = field->attributes.Lookup("hash"); |
| 1768 | switch (e.type.base_type) { |
| 1769 | case BASE_TYPE_SHORT: { |
| 1770 | auto hash = FindHashFunction16(hash_name->constant.c_str()); |
| 1771 | int16_t hashed_value = static_cast<int16_t>(hash(attribute_.c_str())); |
| 1772 | e.constant = NumToString(hashed_value); |
| 1773 | break; |
| 1774 | } |
| 1775 | case BASE_TYPE_USHORT: { |
| 1776 | auto hash = FindHashFunction16(hash_name->constant.c_str()); |
| 1777 | uint16_t hashed_value = hash(attribute_.c_str()); |
| 1778 | e.constant = NumToString(hashed_value); |
| 1779 | break; |
| 1780 | } |
| 1781 | case BASE_TYPE_INT: { |
| 1782 | auto hash = FindHashFunction32(hash_name->constant.c_str()); |
| 1783 | int32_t hashed_value = static_cast<int32_t>(hash(attribute_.c_str())); |
| 1784 | e.constant = NumToString(hashed_value); |
| 1785 | break; |
| 1786 | } |
| 1787 | case BASE_TYPE_UINT: { |
| 1788 | auto hash = FindHashFunction32(hash_name->constant.c_str()); |
| 1789 | uint32_t hashed_value = hash(attribute_.c_str()); |
| 1790 | e.constant = NumToString(hashed_value); |
| 1791 | break; |
| 1792 | } |
| 1793 | case BASE_TYPE_LONG: { |
| 1794 | auto hash = FindHashFunction64(hash_name->constant.c_str()); |
| 1795 | int64_t hashed_value = static_cast<int64_t>(hash(attribute_.c_str())); |
| 1796 | e.constant = NumToString(hashed_value); |
| 1797 | break; |
| 1798 | } |
| 1799 | case BASE_TYPE_ULONG: { |
| 1800 | auto hash = FindHashFunction64(hash_name->constant.c_str()); |
| 1801 | uint64_t hashed_value = hash(attribute_.c_str()); |
| 1802 | e.constant = NumToString(hashed_value); |
| 1803 | break; |
| 1804 | } |
| 1805 | default: FLATBUFFERS_ASSERT(0); |
| 1806 | } |
| 1807 | NEXT(); |
| 1808 | return NoError(); |
| 1809 | } |
| 1810 | |
| 1811 | CheckedError Parser::TokenError() { |
| 1812 | return Error("cannot parse value starting with: " + TokenToStringId(token_)); |
nothing calls this directly
no test coverage detected