ALib C++ Library
Library Version: 2402 R1
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
11#if !defined (HPP_ALIB_LANG_RESOURCES_RESOURCES)
13#endif
14
15#if !defined (HPP_ALIB_MONOMEM_HASHMAP)
17#endif
18
19
20namespace alib::lang::resources {
21
22/**
23 * Internal details of namespace #alib::lang::resources.
24 */
25namespace detail {
26
27/** Key type for hashing resource values. */
28struct Key
29{
30 NString Category; ///< The resource category.
31 NString Name; ///< The resource name.
32
33 /** Hash functor for objects of type \b Key. */
34 struct Hash
35 {
36 /**
37 * Calculates a hash code.
38 * @param key The object to hash.
39 * @return The hash code.
40 */
41 std::size_t operator()(const Key& key) const
42 {
43 return key.Name .Hashcode()
44 ^ key.Category.Hashcode();
45 }
46 };
47
48 /** Equality functor for objects of type \b Key. */
49 struct EqualTo
50 {
51 /** Compares two objects of type \b OperatorKey.
52 * @param lhs The left-hand side object.
53 * @param rhs The left-hand side object.
54 * @return The result of the comparison. */
55 bool operator()(const Key& lhs, const Key& rhs ) const
56 {
57 return lhs.Name .Equals<false>( rhs.Name )
58 && lhs.Category.Equals<false>( rhs.Category);
59 }
60 };
61};
62
63/** Hash map type used to store static resources. Key and value strings reference static
64 * string buffers. */
66 #if !ALIB_DEBUG_RESOURCES
67 String,
68 #else
69 std::pair<String, integer>,
70 #endif
75
76/** Hash map type used to store cached/persistent resources. The value strings is a
77 * local string of length \c 32. The key strings have to probably made persistent as well, but
78 * this is an obligation of the user of this type. */
80 #if !ALIB_DEBUG_RESOURCES
82 #else
83 std::pair<strings::TLocalStringNoWarning<character, 32>, integer>,
84 #endif
89
90
91}} // namespace [alib::lang::resources::detail]
92
93
94
95#endif // HPP_ALIB_LANG_RESOURCES_DETAIL_RESOURCEMAP
std::size_t Hashcode() const
bool Equals(const TString< TChar > &rhs) const
Definition string.hpp:573
platform_specific integer
Definition integers.hpp:50
@ Enabled
Caching is enabled.
strings::TString< character > String
Type alias in namespace alib.
bool operator()(const Key &lhs, const Key &rhs) const
std::size_t operator()(const Key &key) const
NString Category
The resource category.
NString Name
The resource name.