ALib C++ Library
Library Version: 2510 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 {
26 return key.Name .Hashcode()
27 ^ key.Category.Hashcode();
28 }
29 };
30
31 /// Equality functor for objects of type \b Key.
32 struct EqualTo
33 {
34 /// Compares two objects of type \b OperatorKey.
35 /// @param lhs The left-hand side object.
36 /// @param rhs The left-hand side object.
37 /// @return The result of the comparison.
38 bool operator()(const Key& lhs, const Key& rhs ) const
39 {
40 return lhs.Name .Equals<NC>( rhs.Name )
41 && lhs.Category.Equals<NC>( rhs.Category);
42 }
43 };
44};
45
46/// Hash map type used to store static resources. Key and value strings reference static
47/// string buffers.
49 Key,
50 #if !ALIB_DEBUG_RESOURCES
51 String,
52 #else
53 std::pair<String, integer>,
54 #endif
58 Recycling::None >;
59
60}} // namespace [alib::resources::detail]
std::size_t Hashcode() const
bool Equals(const TString< TChar > &rhs) const
Definition string.inl:541
@ 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:2390
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:2381
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.