| 2130 | } |
| 2131 | |
| 2132 | EnumVal *EnumDef::FindByValue(const std::string &constant) const { |
| 2133 | int64_t i64; |
| 2134 | auto done = false; |
| 2135 | if (IsUInt64()) { |
| 2136 | uint64_t u64; // avoid reinterpret_cast of pointers |
| 2137 | done = StringToNumber(constant.c_str(), &u64); |
| 2138 | i64 = static_cast<int64_t>(u64); |
| 2139 | } else { |
| 2140 | done = StringToNumber(constant.c_str(), &i64); |
| 2141 | } |
| 2142 | FLATBUFFERS_ASSERT(done); |
| 2143 | if (!done) return nullptr; |
| 2144 | return ReverseLookup(i64, false); |
| 2145 | } |
| 2146 | |
| 2147 | void EnumDef::SortByValue() { |
| 2148 | auto &v = vals.vec; |
no test coverage detected