Use gperf - not faster yet
This commit is contained in:
33
src/json_token_enum.hpp
Normal file
33
src/json_token_enum.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
enum class JsonTokenType {
|
||||
Unknown = 0,
|
||||
Preconditions = 1,
|
||||
Operations = 2,
|
||||
RequestId = 3,
|
||||
LeaderId = 4,
|
||||
ReadVersion = 5,
|
||||
Type = 6,
|
||||
Key = 7,
|
||||
Begin = 8,
|
||||
End = 9,
|
||||
Value = 10,
|
||||
Version = 11,
|
||||
PointRead = 12,
|
||||
RangeRead = 13,
|
||||
Write = 14,
|
||||
Delete = 15,
|
||||
RangeDelete = 16
|
||||
};
|
||||
|
||||
#include "json_tokens.hpp"
|
||||
#include <string_view>
|
||||
|
||||
inline JsonTokenType get_json_token_type(std::string_view str) {
|
||||
const JsonToken *token =
|
||||
Perfect_Hash::lookup_json_token(str.data(), str.size());
|
||||
if (token && token->name[0] != '\0') { // Check that we got a valid token
|
||||
return static_cast<JsonTokenType>(token->token_id);
|
||||
}
|
||||
return JsonTokenType::Unknown;
|
||||
}
|
||||
Reference in New Issue
Block a user