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