3 #ifndef vtkStringToken_h
4 #define vtkStringToken_h
29 #include <token/Token.h>
35 #include <vtk_nlohmannjson.h>
36 #include VTK_NLOHMANN_JSON(json.hpp)
40 #include <unordered_set>
42 VTK_ABI_NAMESPACE_BEGIN
47 using Hash = std::uint32_t;
63 unsigned int GetHash()
const {
return static_cast<unsigned int>(this->Id); }
89 return token_NAMESPACE::Token::stringHash(
data,
size);
93 static Hash InvalidHash();
116 std::unordered_set<vtkStringToken> Children(
bool recursive =
true);
118 static std::unordered_set<vtkStringToken> AllGroups();
132 if (jj.is_number_integer())
136 else if (jj.is_string())
142 throw std::runtime_error(
"String tokens must be JSON integers or strings.");
162 VTK_ABI_NAMESPACE_END
168 VTK_ABI_NAMESPACE_BEGIN
210 VTK_ABI_NAMESPACE_END
214 VTK_ABI_NAMESPACE_BEGIN
242 VTK_ABI_NAMESPACE_END
255 #endif // vtkStringToken_h
std::size_t operator()(const vtkStringToken &t) const
void to_json(nlohmann::json &jj, const vtkStringToken &tt)
Convert a string token into a JSON value.
bool VTKCOMMONCORE_EXPORT operator>(const std::string &a, const vtkStringToken &b)
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
bool VTKCOMMONCORE_EXPORT operator==(const std::string &a, const vtkStringToken &b)
Hash GetId() const
Return the token's ID (usually its hash but possibly not in the case of collisions).
constexpr vtkStringToken(Hash tokenId) noexcept
Construct a token given its hash value.
bool VTKCOMMONCORE_EXPORT operator!=(const std::string &a, const vtkStringToken &b)
unsigned int GetHash() const
A Python-wrappable (but less strongly typed) alternative to GetId()
bool VTKCOMMONCORE_EXPORT operator<(const std::string &a, const vtkStringToken &b)
void from_json(const nlohmann::json &jj, vtkStringToken &tt)
Convert a JSON value into a string token.
Represent a string by its integer hash.
bool HasData() const
Return whether a string is available for the token's hash ID.
static constexpr Hash StringHash(const char *data, std::size_t size) noexcept
Return the hash of a string This is used internally but also by the ""_token() literal operator...
const std::string & Data() const
Return the string corresponding to the token.
bool VTKCOMMONCORE_EXPORT operator>=(const std::string &a, const vtkStringToken &b)
bool VTKCOMMONCORE_EXPORT operator<=(const std::string &a, const vtkStringToken &b)