8#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
9# error "Symbol ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
19 module ALib.ALox.Impl;
23 import ALib.EnumRecords;
24 import ALib.EnumRecords.Bootstrap;
25 import ALib.Variables;
27 import ALib.Camp.Base;
51:
Name (allocator, name)
56 Data .reserve(
size_t( 2 ) );
61 fullPath[name.
Length()]=
'/';
67:
Name( parent->
Data.get_allocator().GetAllocator(), name )
70,
Data ( parent->
Data.get_allocator().GetAllocator() )
73 if( parent !=
nullptr )
81 if ( dom != this || dom->Parent == nullptr )
82 fullPath.InsertAt(
"/" , 0 );
83 fullPath.InsertAt( dom->Name, 0 );
86 while( dom !=
nullptr );
87 FullPath.Allocate(
Data.get_allocator().GetAllocator(), fullPath );
96 if ( wasCreated ==
nullptr )
110 Domain* startDomain=
this;
111 if ( lenBeforeTrim > domainPath.
Length() ) {
112 while (startDomain->
Parent !=
nullptr )
113 startDomain= startDomain->
Parent;
117 return startDomain->
findRecursive( domainPath, maxCreate, wasCreated );
125 ALIB_ASSERT_ERROR( endSubName != 0,
"ALOX",
"Internal error. This must never happen." )
129 if ( endSubName > 0 )
130 domainPath.
Split<
NC>( endSubName, restOfDomainPath, 1 );
133 Domain* subDomain=
nullptr;
140 else if( domainPath.
Equals<
NC>(
".." ) )
146 bool fixedOnce=
false;
152 if( comparison >= 0 ) {
153 if ( comparison == 0 )
154 subDomain= &(*subDomainIt);
161 if ( subDomain !=
nullptr )
168 bool illegalCharacterFound=
false;
169 for(
int i= 0; i< domainPath.
Length() ; ++i ) {
170 nchar c= domainPath[i];
172 || ( c >=
'A' && c <=
'Z' )
177 illegalCharacterFound=
true;
179 *
const_cast<nchar*
>( domainPath.
Buffer() + i)=
'#';
182 if ( illegalCharacterFound )
187 if ( maxCreate == 0 )
191 subDomainIt=
SubDomains.emplace( subDomainIt,
this, domainPath );
193 if ( maxCreate == 0 )
194 return &(*subDomainIt);
200 ? subDomain->findRecursive( restOfDomainPath, maxCreate, wasCreated )
211 subDomain.SetVerbosity( loggerNo, verbosity, priority );
219 subDomain.addLoggerRecursive( logger );
223 Data.erase(
Data.begin() + loggerNo );
225 subDomain.removeLoggerRecursive( loggerNo );
234 for(
size_t i= 0; i <
Data.size() ; ++i ) {
236 tAString.
_(i!=0 ?
", " :
"" )
ALIB_DLL Domain * Find(NSubstring domainPath, int maxCreate, bool *wasCreated)
void ToString(NAString &target)
ALIB_DLL Domain(MonoAllocator &allocator, PoolAllocator &pool, const NString &name)
ALIB_DLL void addLoggerRecursive(detail::Logger *logger)
NString Name
The name of the domain. For root domains, this is nulled.
Domain * Parent
The parent domain. For root domains, this is nullptr.
ListMA< Domain, Recycling::None > SubDomains
A list of subdomains, sorted by name.
ALIB_DLL Verbosity SetVerbosity(int loggerNo, Verbosity verbosity, Priority priority)
NString FullPath
The full path of the domain (set in the constructor once) .
ALIB_DLL void removeLoggerRecursive(int loggerNo)
ListPA< std::pair< PrefixLogable *, lang::Inclusion >, Recycling::None > PrefixLogables
Prefix Logables associated with this domain.
static constexpr nchar Separator()
StdVectorMA< LoggerData > Data
Domain * findRecursive(NSubstring &domainPath, int maxCreate, bool *wasCreated)
TAString & _(const TAppendable &src)
integer CopyTo(TChar *dest) const
constexpr integer Length() const
constexpr bool IsEmpty() const
integer IndexOf(TChar needle, integer startIdx=0) const
constexpr bool IsNotEmpty() const
constexpr const TChar * Buffer() const
bool Equals(const TString< TChar > &rhs) const
TSubstring & Split(integer position, TSubstring &target, integer separatorWidth=0, bool trim=false)
#define ALIB_ASSERT_ERROR(cond, domain,...)
constexpr Pair< T1, T2 > MakePair(const T1 &t1, const T2 &t2)
strings::TDec< nchar > NDec
Type alias in namespace alib.
strings::TSubstring< nchar > NSubstring
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
monomem::TPoolAllocator< MonoAllocator > PoolAllocator
strings::TString< nchar > NString
Type alias in namespace alib.
NLocalString< 1024 > NString1K
Type alias name for TLocalString<nchar,1024>.
strings::TAString< nchar, lang::HeapAllocator > NAString
Type alias in namespace alib.
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
alib::variables::Priority Priority
Type alias in namespace alib.
characters::nchar nchar
Type alias in namespace alib.
Internal class that holds data stored per Logger.
Verbosity LoggerVerbosity
The verbosity of the Logger for this domain.
int LogCallsPerDomain
the number of log calls on this domain for this logger.
variables::Priority Priority
The priority value that was used to set the verbosity.