ALib C++ Library
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
resourcemap.inl
1//==================================================================================================
2/// This header-file is part of module \alib_resources of the \aliblong.
3///
4/// \emoji :copyright: 2013-2025 A-Worx GmbH, Germany.
5/// Published under \ref mainpage_license "Boost Software License".
6//==================================================================================================
7namespace alib::resources {
8
9/// Internal details of namespace #alib::resources.
10namespace detail {
11
12/// Key type for hashing resource values.
13struct Key
14{
15 NString Category; ///< The resource category.
16 NString Name; ///< The resource name.
17
18 /// Hash functor for objects of type \b Key.
19 struct Hash
20 {
21 /// Calculates a hash code.
22 /// @param key The object to hash.
23 /// @return The hash code.
24 std::size_t operator()(const Key& key) const {
25 return key.Name .Hashcode()
26 ^ key.Category.Hashcode();
27 }
28 };
29
30 /// Equality functor for objects of type \b Key.
31 struct EqualTo
32 {
33 /// Compares two objects of type \b OperatorKey.
34 /// @param lhs The left-hand side object.
35 /// @param rhs The left-hand side object.
36 /// @return The result of the comparison.
37 bool operator()(const Key& lhs, const Key& rhs ) const {
38 return lhs.Name .Equals<NC>( rhs.Name )
39 && lhs.Category.Equals<NC>( rhs.Category);
40 }
41 };
42};
43
44/// Hash map type used to store static resources. Key and value strings reference static
45/// string buffers.
47 Key,
48 #if !ALIB_DEBUG_RESOURCES
49 String,
50 #else
51 std::pair<String, integer>,
52 #endif
56 Recycling::None >;
57
58}} // namespace [alib::resources::detail]
std::size_t Hashcode() const
bool Equals(const TString< TChar > &rhs) const
Definition string.inl:531
@ Enabled
Caching is enabled.
Internal details of namespace alib::resources.
HashMap< MonoAllocator, Key, std::pair< String, integer >, Key::Hash, Key::EqualTo, lang::Caching::Enabled, Recycling::None > StaticResourceMap
strings::TString< nchar > NString
Type alias in namespace alib.
Definition string.inl:2198
containers::HashMap< TAllocator, TKey, TMapped, THash, TEqual, THashCaching, TRecycling > HashMap
Type alias in namespace alib.
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
strings::TString< character > String
Type alias in namespace alib.
Definition string.inl:2189
Equality functor for objects of type Key.
bool operator()(const Key &lhs, const Key &rhs) const
Hash functor for objects of type Key.
std::size_t operator()(const Key &key) const
Key type for hashing resource values.
NString Category
The resource category.
NString Name
The resource name.