3#ifndef vtkStringToken_h
4#define vtkStringToken_h
30VTK_ABI_NAMESPACE_BEGIN
36 using Hash = std::uint32_t;
39 vtkStringToken(
const char* data =
nullptr, std::size_t size = std::string::npos);
52 const std::string&
Data()
const;
67 inline static constexpr Hash StringHash(
const char* data, std::size_t size)
noexcept
84 static constexpr uint32_t hash32a_const = 0x811c9dc5;
85 static constexpr uint32_t hash32b_const = 0x1000193;
86 static constexpr uint64_t hash64a_const = 0xcbf29ce484222325;
87 static constexpr uint64_t hash64b_const = 0x100000001b3;
93 const char*
const str, std::size_t size,
const uint32_t value = hash32a_const)
noexcept
95 return (!str || size <= 0)
97 : hash_32_fnv1a_const(&str[1], size - 1, (value ^ uint32_t(str[0])) * hash32b_const);
102 inline static constexpr uint64_t hash_64_fnv1a_const(
103 const char*
const str, std::size_t size,
const uint64_t value = hash64a_const)
noexcept
105 return (!str || size <= 0) ? value :
106 hash_64_fnv1a_const(&str[1], size - 1, (value ^ uint64_t(str[0])) * hash64b_const);
117VTK_ABI_NAMESPACE_BEGIN
140 const char* data, std::size_t size)
155 const char* data, std::size_t size)
165VTK_ABI_NAMESPACE_BEGIN
Hold a reference to a vtkObjectBase instance.
Manage string-token mappings.
Represent a string by its integer hash.
bool operator<=(const vtkStringToken &other) const
bool operator<(const vtkStringToken &other) const
Slow, but unsurprising string comparison (preserves lexical string ordering).
static vtkSmartPointer< vtkStringManager > Manager
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.
constexpr vtkStringToken(Hash tokenId) noexcept
Construct a token given its hash value.
static const vtkStringManager * GetManager()
Return the database of strings and their tokens (hashes).
vtkStringToken(const char *data=nullptr, std::size_t size=std::string::npos)
Construct a token from a string literal.
bool operator!=(const vtkStringToken &other) const
Fast inequality comparison (compares hashes, not strings).
const std::string & Data() const
Return the string corresponding to the token.
bool operator>=(const vtkStringToken &other) const
static constexpr uint32_t hash_32_fnv1a_const(const char *const str, std::size_t size, const uint32_t value=hash32a_const) noexcept
vtkStringToken(const std::string &data)
Construct a token from a std::string.
Hash GetId() const
Return the token's ID (usually its hash but possibly not in the case of collisions).
bool operator>(const vtkStringToken &other) const
bool operator==(const vtkStringToken &other) const
Fast equality comparison (compares hashes, not strings).
static vtkStringManager * GetManagerInternal()
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
std::size_t operator()(const vtkStringToken &t) const
bool VTKCOMMONCORE_EXPORT operator>=(const std::string &a, const vtkStringToken &b)
bool VTKCOMMONCORE_EXPORT operator==(const std::string &a, const vtkStringToken &b)
bool VTKCOMMONCORE_EXPORT operator>(const std::string &a, const vtkStringToken &b)
bool VTKCOMMONCORE_EXPORT operator<=(const std::string &a, const vtkStringToken &b)
bool VTKCOMMONCORE_EXPORT operator<(const std::string &a, const vtkStringToken &b)
bool VTKCOMMONCORE_EXPORT operator!=(const std::string &a, const vtkStringToken &b)