9#ifndef HPP_ALIB_LANG_RESOURCES_RESOURCES
10#define HPP_ALIB_LANG_RESOURCES_RESOURCES 1
15#if !defined(ALIB_RESOURCES_OMIT_DEFAULTS)
16# define ALIB_RESOURCES_OMIT_DEFAULTS 0
19#if ALIB_DEBUG_RESOURCES
25namespace alib {
namespace lang::resources {
96 NString256(
"Doubly defined resource \"" ) << name
97 <<
"\" in category: " << category )
180 #if ALIB_CHARACTERS_WIDE
184 return Get( category, nName
ALIB_DBG(, dbgAssert ) );
189 #if ALIB_DEBUG_RESOURCES
217 std::vector<std::tuple<NString, NString, String, integer>>
238 std::vector<std::pair<NString, integer>>
261 AString DbgDump( std::vector<std::tuple<NString, NString, String, integer>>& list,
262 const NString& catFilter =
nullptr,
263 const String& format =
A_CHAR(
"({3:}) {1}={2!TAB20!ESC<!Q}\n") );
320 template<
typename TEnableIf= T>
324 template<
typename TEnableIf= T>
346 template<
typename TEnableIf= T>
350 template<
typename TEnableIf= T>
360 #if ALIB_CHARACTERS_WIDE && DOXYGEN
373 template<
typename TEnableIf= T>
377 #if ALIB_CHARACTERS_WIDE && !DOXYGEN
378 template<
typename TEnableIf= T>
384 resourceName
ALIB_DBG(, dbgAssert) );
511 void Set(
const T& sample);
551 #if ALIB_CHARACTERS_WIDE && DOXYGEN
565 #if ALIB_CHARACTERS_WIDE && !DOXYGEN
595#define ALIB_RESOURCED( T, ResPool, ResCategory, ResName ) \
596namespace alib::lang::resources { \
597template<> struct T_Resourced<T> : public std::true_type \
599 static ResourcePool* Pool() { return ResPool; } \
600 static constexpr NString Category() { return ResCategory; } \
601 static constexpr NString Name() { return ResName; } \
605# define ALIB_RESOURCED_IN_MODULE( T, Camp, ResName ) \
606 ALIB_RESOURCED( T, &Camp.GetResourcePool(), Camp.ResourceCategory, ResName )
const String & Get(const NString &category, const String &name, bool dbgAssert)
void Bootstrap(const NString &category, const NString &name, const String &data)
virtual ALIB_API std::vector< std::tuple< NString, NString, String, integer > > DbgGetList()
virtual ~ResourcePool()=default
Virtual destructor.
virtual void BootstrapBulk(const nchar *category,...)=0
static ALIB_API AString DbgDump(std::vector< std::tuple< NString, NString, String, integer > > &list, const NString &catFilter=nullptr, const String &format=A_CHAR("({3:}) {1}={2!TAB20!ESC<!Q}\n"))
virtual const String & Get(const NString &category, const NString &name, bool dbgAssert)=0
virtual ALIB_API std::vector< std::pair< NString, integer > > DbgGetCategories()
virtual bool BootstrapAddOrReplace(const NString &category, const NString &name, const String &data)=0
#define ATMP_VOID_IF(Cond)
#define ALIB_WARNINGS_RESTORE
#define ALIB_WARNINGS_ALLOW_NULL_POINTER_PASSING
#define ALIB_ASSERT_ERROR(cond,...)
#define ATMP_T_IF(T, Cond)
@ Get
Denotes to search data.
constexpr NString NULL_NSTRING
A nulled string of the narrow character type.
constexpr const String EMPTY_STRING
An empty string of the default character type.
NLocalString< 256 > NString256
Type alias name for TLocalString<nchar,256>.
characters::nchar nchar
Type alias in namespace alib.
const String & Get(const NString &name, bool dbgAssert)
resources::ResourcePool * Pool
The resource pool.
ResourceInfo() noexcept=default
Defaulted constructor leaving the fields uninitialized.
void Set(resources::ResourcePool *pool, NString category, NString name)
ResourceInfo(const T &sample)
NString Category
The resource category within Pool.
NString Name
The resource category within Pool.
void Set(const T &sample)
static const String & Get(const NString &name, bool dbgAssert)
static const String & Get()
static const String & TypeNamePrefix()
static const String & TypeNamePostfix()
static constexpr ResourcePool * Pool()
static constexpr NString Category()
static constexpr NString Name()