Struct StringToken ​
Namespace: ValveResourceFormat.Utils
Assembly: ValveResourceFormat.dll
String token, also known as global symbol, is a 32-bit hash of a string. The string can be interned into a global table, for later retrieval.
public readonly struct StringToken : IEquatable<StringToken>Implements ​
Constructors ​
StringToken(string) ​
Hashes and records a name. An empty name is unset.
public StringToken(string name)Parameters ​
name string
StringToken(uint, bool) ​
Wraps a token, which must be known unless allowed otherwise.
public StringToken(uint token, bool allowUnknown = false)Parameters ​
token uint
allowUnknown bool
Fields ​
VRF_GENERATOR ​
Generator identification string with version.
public static readonly string VRF_GENERATORField Value ​
string
Properties ​
InvertedTable ​
Gets the inverted table for hash to string lookups.
public static ConcurrentDictionary<uint, string> InvertedTable { get; }Property Value ​
ConcurrentDictionary<uint, string>
IsValid ​
Whether this symbol holds a stored token, as opposed to being unset.
public bool IsValid { get; }Property Value ​
bool
Name ​
The name the token was hashed from, empty when unset.
public string Name { get; }Property Value ​
string
Token ​
The hashed token.
public uint Token { get; }Property Value ​
uint
Methods ​
Equals(StringToken) ​
Indicates whether the current object is equal to another object of the same type.
public bool Equals(StringToken other)Parameters ​
other StringToken
An object to compare with this object.
Returns ​
bool
true if the current object is equal to the other parameter; otherwise, false.
Equals(object?) ​
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)Parameters ​
obj object?
The object to compare with the current instance.
Returns ​
bool
true if obj and this instance are the same type and represent the same value; otherwise, false.
FromString(string) ​
Hashes and records a name.
public static StringToken FromString(string name)Parameters ​
name string
Returns ​
FromUInt32(uint) ​
Wraps a token, known or not.
public static StringToken FromUInt32(uint token)Parameters ​
token uint
Returns ​
Get(ReadOnlySpan<char>) ​
Computes the hash token for the given string, case insensitive. Only ASCII letters are case folded, the string is hashed as UTF-8.
public static uint Get(ReadOnlySpan<char> key)Parameters ​
key ReadOnlySpan<char>
The string to hash.
Returns ​
uint
The hash token.
GetHashCode() ​
Returns the hash code for this instance.
public override int GetHashCode()Returns ​
int
A 32-bit signed integer that is the hash code for this instance.
GetKnownString(uint) ​
Gets a known string for the given hash, or returns an unknown key placeholder.
public static string GetKnownString(uint hash)Parameters ​
hash uint
The hash to look up.
Returns ​
string
The known string or a placeholder.
Lookup(ReadOnlySpan<char>) ​
Hashes a name without recording it, so it neither allocates nor touches the shared table. An empty name is unset.
public static StringToken Lookup(ReadOnlySpan<char> name)Parameters ​
name ReadOnlySpan<char>
Returns ​
Store(ReadOnlySpan<char>) ​
Store a string to the table of known string hashes, so it can later be retrieved using StringToken.GetKnownString(uint).
public static uint Store(ReadOnlySpan<char> key)Parameters ​
key ReadOnlySpan<char>
Returns ​
uint
ToString() ​
Returns the fully qualified type name of this instance.
public override string ToString()Returns ​
string
The fully qualified type name.
ToUInt32() ​
Gets the token.
public uint ToUInt32()Returns ​
uint
Operators ​
operator ==(StringToken, StringToken) ​
Whether two symbols have the same token.
public static bool operator ==(StringToken left, StringToken right)Parameters ​
left StringToken
right StringToken
Returns ​
bool
implicit operator uint(StringToken) ​
Gets the token.
public static implicit operator uint(StringToken symbol)Parameters ​
symbol StringToken
Returns ​
uint
implicit operator StringToken(uint) ​
Wraps a token, known or not.
public static implicit operator StringToken(uint token)Parameters ​
token uint
Returns ​
implicit operator StringToken(string) ​
Hashes and records a name.
public static implicit operator StringToken(string name)Parameters ​
name string
Returns ​
operator !=(StringToken, StringToken) ​
Whether two symbols have different tokens.
public static bool operator !=(StringToken left, StringToken right)Parameters ​
left StringToken
right StringToken
Returns ​
bool

