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