Generates a Crc32 value from a string representation. This macro is not guaranteed to be evaluated at compile time if the version with one parameter is used, so it should only be used if the parameter is not a constexpr value. If the parameter is a constexpr value, the AZ_CRC_CE macro should be used instead. The version with two parameters is deprecated, also use AZ_CRC_CE instead.
#pragma once
#include <AzCore/base.h>
#include <AzCore/std/hash.h>
#include <AzCore/std/string/string_view.h>
#include <AzCore/RTTI/TypeInfoSimple.h>
#define AZ_CRC_1(_1) AZ::Crc32(_1)
#define AZ_CRC_2(_1, _2) AZ::Crc32(AZ::u32(_2))
#define AZ_CRC(...) AZ_MACRO_SPECIALIZE(AZ_CRC_, AZ_VA_NUM_ARGS(__VA_ARGS__), (__VA_ARGS__))
#define AZ_CRC_CE(literal_) AZ::Internal::CompileTimeCrc32<static_cast<AZ::u32>(AZ::Crc32{ literal_ })>
{
class SerializeContext;
class AZCORE_API Crc32
{
public:
AZ_TYPE_INFO_WITH_NAME_DECL_API(AZCORE_API, Crc32);
constexpr Crc32()
: m_value(0) { }
explicit constexpr Crc32(AZ::u32 value) : m_value{ value } {}
Crc32(const void* data, size_t size, bool forceLowerCase = false);
template<class ByteType, class = AZStd::enable_if_t<sizeof(ByteType) == 1>>
constexpr Crc32(const ByteType* data, size_t size, bool forceLowerCase = false);
void Add(const void* data, size_t size, bool forceLowerCase = false);
template<class ByteType>
constexpr auto Add(const ByteType* data, size_t size, bool forceLowerCase = false)
-> AZStd::enable_if_t<sizeof(ByteType) == 1>;
constexpr operator u32() const { return m_value; }
constexpr u32 GetValue() const { return m_value; }
constexpr bool operator==(Crc32 rhs) const { return (m_value == rhs.m_value); }
constexpr bool operator!=(Crc32 rhs) const { return (m_value != rhs.m_value); }
constexpr bool operator!() const { return (m_value == 0); }
protected:
void Set(const void* data, size_t size, bool forceLowerCase = false);
template<class ByteType>
constexpr auto Set(const ByteType* data, size_t size, bool forceLowerCase = false)
-> AZStd::enable_if_t<sizeof(ByteType) == 1>;
constexpr void Combine(u32 crc, size_t len);
u32 m_value;
};
AZ_TYPE_INFO_WITH_NAME_DECL_EXT_API(AZCORE_API, Crc32);
}
{
template<>
{
{
return hasher(static_cast<AZ::u32>(id));
}
};
}
#include <AzCore/Math/Crc.inl>
Definition SerializeContext.h:127
Definition string_view.h:622
Reopen namespace to define DataPatch class.
Definition AssetCommon.h:26
AZ namespace needs to be closed in order to specialize the AZStd::hash struct for AddressTypeElement ...
Definition AssetCommon.h:1248
Default template (just try to cast the value to size_t)
Definition hash.h:34