ALib C++ Library
by
Library Version:
2402 R1
Documentation generated by
Loading...
Searching...
No Matches
home
dev
A-Worx
ALib
src
alib
lang
resources
detail
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)
12
# include "
alib/lang/resources/resources.hpp
"
13
#endif
14
15
#if !defined (HPP_ALIB_MONOMEM_HASHMAP)
16
# include "
alib/monomem/hashmap.hpp
"
17
#endif
18
19
20
namespace
alib::lang::resources
{
21
22
/**
23
* Internal details of namespace #alib::lang::resources.
24
*/
25
namespace
detail {
26
27
/** Key type for hashing resource values. */
28
struct
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. */
65
using
StaticResourceMap
=
HashMap
<
Key
,
66
#if !ALIB_DEBUG_RESOURCES
67
String
,
68
#else
69
std::pair<String, integer>,
70
#endif
71
Key::Hash
,
72
Key::EqualTo
,
73
lang::Caching::Enabled
,
74
Recycling::None
>;
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. */
79
using
CachingResourceMap
=
HashMap
<
Key
,
80
#if !ALIB_DEBUG_RESOURCES
81
strings::TLocalStringNoWarning<character, 32>
,
82
#else
83
std::pair<strings::TLocalStringNoWarning<character, 32>,
integer
>,
84
#endif
85
Key::Hash
,
86
Key::EqualTo
,
87
lang::Caching::Enabled
,
88
Recycling::None
>;
89
90
91
}}
// namespace [alib::lang::resources::detail]
92
93
94
95
#endif
// HPP_ALIB_LANG_RESOURCES_DETAIL_RESOURCEMAP
alib::monomem::HashTable
Definition
hashtable.hpp:454
alib::strings::TString< nchar >
alib::strings::TString::Hashcode
std::size_t Hashcode() const
alib::strings::TString::Equals
bool Equals(const TString< TChar > &rhs) const
Definition
string.hpp:573
hashmap.hpp
alib::lang::resources
Definition
records.hpp:43
alib::lang::integer
platform_specific integer
Definition
integers.hpp:50
alib::lang::Caching::Enabled
@ Enabled
Caching is enabled.
alib::String
strings::TString< character > String
Type alias in namespace alib.
Definition
strings/fwds.hpp:74
resources.hpp
alib::lang::resources::detail::Key::EqualTo
Definition
resourcemap.hpp:50
alib::lang::resources::detail::Key::EqualTo::operator()
bool operator()(const Key &lhs, const Key &rhs) const
Definition
resourcemap.hpp:55
alib::lang::resources::detail::Key::Hash
Definition
resourcemap.hpp:35
alib::lang::resources::detail::Key::Hash::operator()
std::size_t operator()(const Key &key) const
Definition
resourcemap.hpp:41
alib::lang::resources::detail::Key
Definition
resourcemap.hpp:29
alib::lang::resources::detail::Key::Category
NString Category
The resource category.
Definition
resourcemap.hpp:30
alib::lang::resources::detail::Key::Name
NString Name
The resource name.
Definition
resourcemap.hpp:31
alib::monomem::Recycling::None
Definition
monomem/fwds.hpp:42
alib::strings::TLocalStringNoWarning
Definition
localstring.hpp:238