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"
73 Entry& entry= node.data;
107 std::array<Token, 10> tokenBuf;
110 for (
size_t i = 0; i < tokenBuf.size(); i+= 2 )
134 "{} remaining registered listeners when destruction configuration.",
listeners.size() )
142 const String& variableName,
143 const String& pathPrefixGiven,
144 const String& pathSubstring )
148 ALIB_ASSERT_ERROR( variable==
nullptr || &variable->
AsCursor().Tree() ==
this ,
"VARIABLES",
"Given variable does not belong to this configuration.")
149 ALIB_ASSERT_ERROR( subTree ==
nullptr || subTree->IsValid() ,
"VARIABLES",
"Invalid cursor given." )
150 ALIB_ASSERT_ERROR( subTree ==
nullptr || &subTree ->Tree() ==
this ,
"VARIABLES",
"Given cursor does not belong to this configuration.")
162 variable ? variable->
AsCursor().Export() : ConstCursorHandle(),
163 subTree ? subTree-> Export() : ConstCursorHandle(),
167 listeners.back().variableName << variableName;
168 listeners.back().pathPrefix << pathPrefix;
169 listeners.back().pathSubstring<< pathSubstring;
176 if( it->listener == listener
177 && it->event == event
178 && it->variable == ( variable ? variable->
AsCursor().Export() : ConstCursorHandle() )
179 && it->subTree == ( subTree ? subTree ->Export() : ConstCursorHandle() )
180 && it->variableName .Equals( variableName )
181 && it->pathPrefix .Equals( pathPrefix )
182 && it->pathSubstring.Equals( pathSubstring ) )
188 ALIB_WARNING(
"VARIABLES",
"Listener with matching set of parameters not found with "
202 if( it->listener == listener )
215 const String& variablePathGiven,
219 const String* variablePath= &variablePathGiven;
221 if( event == it->event )
225 && ( it->variableName .IsNotEmpty()
226 || it->pathPrefix .IsNotEmpty()
227 || it->pathSubstring.IsNotEmpty() ) )
229 variablePathBuffer << variable;
230 variablePath= &variablePathBuffer;
233 if( ( it->variable .IsValid() && ( it->variable == variable.
AsCursor().Export() ) )
234 || ( it->subTree .IsValid() && ( variable.
AsCursor().Distance(
ImportCursor(it->subTree) ) >= 0 ) )
235 || ( it->variableName .IsNotEmpty() && it->variableName.Equals(variable.
AsCursor().Name()) )
236 || ( it->pathPrefix .IsNotEmpty() && variablePath->
StartsWith(it->pathPrefix) )
237 || ( it->pathSubstring.IsNotEmpty() && variablePath->
IndexOf(it->pathSubstring) >= 0 )
240 it->listener->Notify( variable,
252 cursor.GoToCreateChildIfNotExistent(
A_CHAR(
"$PRESETS"));
257 if( cursor.GoTo(name).IsNotEmpty() )
260 auto& entry= *cursor;
261 if( entry.priority > priority )
266 entry.meta->destruct( entry.data,
Pool );
267 Pool().Free( entry.data, entry.meta->size() );
270 entry.priority= Priority::NONE;
274 if( !cursor.HasChildren() )
282 cursor.GoToCreatedPathIfNotExistent(name);
286 auto& entry= *cursor;
287 if( entry.data ==
nullptr )
291 "Variable type 'S' not registered. This usually cannot happen." )
292 auto* meta= entry.meta= *it;
296 meta->construct( cursor->data,
Pool );
297 entry.priority= priority;
300 if( entry.priority <= priority )
302 entry.priority = priority;
303 entry.declaration=
reinterpret_cast<const Declaration*
>( escaper );
316 const Box* replacementPtr;
326 replacementPtr = boxes->
data();
327 qtyReplacements= boxes->Size();
332 replacementPtr = boxes->
data();
333 qtyReplacements= boxes->Size();
338 replacementPtr = boxes->
data();
339 qtyReplacements= boxes->Size();
343 replacementPtr = &replacements;
351 for (
integer replCnt= 0; replCnt< qtyReplacements ; ++replCnt )
352 if ( !replacementPtr->
IsType<
void>() )
354 String64 search(
"%"); search.
_( replCnt + 1 );
355 replace.
Reset( *( replacementPtr + replCnt) );
367 String1K bufComments;
ALIB_DBG( bufComments .DbgDisableBufferReplacementWarning() );
373 for (
integer replCnt= 0; replCnt< qtyReplacements ; ++replCnt )
374 if ( !replacementPtr->
IsType<
void>() )
376 String64 search(
"%"); search.
_( replCnt + 1 );
377 replace.
Reset( *( replacementPtr + replCnt) );
401 return {
false, int8_t(-1)};
405 if ( it.first .Match(value) )
return {
false, index};
406 if ( it.second.Match(value) )
return {true , index};
409 return {
false, int8_t(-1)};
419 for( int8_t index=0 ; index < idxRequested && it !=
BooleanTokens.end() ; ++index )
426 (!value ? it->first : it->second).GetExportName( dest );
432DOX_MARKER( [DOX_VARIABLES_DELETE_SAMPLE] )
437if( cs.GoTo(path).IsNotEmpty() )
445DOX_MARKER( [DOX_VARIABLES_DELETE_SAMPLE] )
469#if ALIB_CHARACTERS_WIDE
474 variable.Name(target);
481#if ALIB_CHARACTERS_WIDE
482 variable.Name(target);
Placeholder data
The data that we encapsulate.
TElementType * UnboxArray() const
integer UnboxLength() const
constexpr CharacterType Separator() const noexcept
TCursor< true > ConstCursor
Cursor ImportCursor(CursorHandle handle)
void DbgSetDCSName(const char *name) const
AllocatorType & GetAllocator() noexcept
StringTree(AllocatorType &allocator, CharacterType pathSeparator)
void InsertPlugin(ConfigurationPlugin *plugin, lang::Responsibility responsibility=lang::Responsibility::KeepWithSender)
void free(void *mem, size_t size)
ALIB_DLL integer SearchAndReplace(TChar needle, TChar replacement, integer startIdx=0, integer endIdx=strings::MAX_LEN)
TAString & _(const TAppendable &src)
void DbgDisableBufferReplacementWarning()
constexpr bool IsEmpty() const
TChar CharAtStart() const
integer IndexOf(TChar needle, integer startIdx=0) const
constexpr bool IsNotNull() const
void Allocate(TAllocator &allocator, const TString< TChar > ©)
TString< TChar > Substring(integer regionStart, integer regionLength=MAX_LEN) const
constexpr bool IsNull() const
bool StartsWith(const TString &needle) const
TSubstring & Trim(const TCString< TChar > &whiteSpaces=CStringConstantsTraits< TChar >::DefaultWhitespaces())
ALIB_DLL bool DeletePath(const String &path)
ALIB_DLL void notifyListeners(int event, const Variable &variable, const String &variablePath, Priority previousPriority)
ALIB_DLL AString & WriteBooleanToken(bool value, int8_t index, AString &dest)
ConfigurationPlugin * cliPlugin
A default plugin created and inserted with construction.
TypesHashTable types
A hashtable for the registered types. Key is the type name, value is the VMeta singleton.
ALIB_DLL const Declaration * StoreDeclaration(const Declaration *orig, const Box &replacements)
RDHashTable replacementDeclarations
ALIB_DLL int MonitorStop(ConfigurationListener *listener)
ConfigurationPlugin * environmentPlugin
A default plugin created and inserted with construction.
friend class Variable
Type alias in namespace alib.
ALIB_DLL ~Configuration()
Destructor.
ALIB_DLL void presetImportString(const String &name, const String &value, const StringEscaper *escaper, Priority priority)
List< MonoAllocator, ListenerRecord > listeners
The list of registered listeners.
ALIB_DLL Configuration(MonoAllocator &allocator, lang::CreateDefaults createDefaults=lang::CreateDefaults::Yes)
List< MonoAllocator, std::pair< Token, Token >, Recycling::None > BooleanTokens
ALIB_DLL std::pair< bool, int8_t > ParseBooleanToken(const String &src)
ALIB_DLL void registerListener(ConfigurationListener *listener, lang::ContainerOp insertOrRemove, int event, const Variable *variable, const StringTree::Cursor *subTree, const String &variableName, const String &pathPrefix, const String &pathSubstring)
VMeta * meta
The virtual handler instance for this variable.
VDATA * data
The list hook of values.
#define ALIB_BOXING_VTABLE_DEFINE(TMapped, Identifier)
#define ALIB_WARNING(domain,...)
#define ALIB_ASSERT_WARNING(cond, domain,...)
#define ALIB_ASSERT_ERROR(cond, domain,...)
ContainerOp
Denotes standard container operations.
@ Insert
Denotes insertions.
CreateDefaults
Denotes whether default entities should be created or not.
@ Yes
Create default values.
void LoadResourcedTokens(camp::Camp &module, const NString &resourceName, strings::util::Token *target, int dbgSizeVerifier, character outerSeparator=',', character innerSeparator=' ')
containers::detail::StringTreeBase< MonoAllocator, Entry, ConfigNodeHandler, Recycling::Private > TTree
A shortcut to the base class of the base class of class Configuration.
strings::util::StringEscaper StringEscaper
Type alias in namespace alib.
strings::util::Token Token
Type alias in namespace alib.
LocalString< 256 > String256
Type alias name for TLocalString<character,256>.
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
camp::Basecamp BASECAMP
The singleton instance of ALib Camp class Basecamp.
LocalString< 128 > String128
Type alias name for TLocalString<character,128>.
LocalString< 64 > String64
Type alias name for TLocalString<character,64>.
lang::integer integer
Type alias in namespace alib.
boxing::TBoxes< PoolAllocator > BoxesPA
Type alias in namespace alib.
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
boxing::Box Box
Type alias in namespace alib.
LocalString< 1024 > String1K
Type alias name for TLocalString<character,1024>.
boxing::TBoxes< MonoAllocator > BoxesMA
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
strings::TAString< character, PoolAllocator > AStringPA
Type alias in namespace alib.
boxing::TBoxes< lang::HeapAllocator > BoxesHA
Type alias in namespace alib.
strings::TSubstring< character > Substring
Type alias in namespace alib.
typename ConfigNodeHandler::CharacterType CharacterType
String EnumElementName
The name of the enum element.
static ALIB_DLL void Get(String &result, bool isLastField=false)
void operator()(TAString< TChar > &target, const TAppendable &src)
Event
The type of change that imposes the notification of a listener.
Record used to manage registered listeners.
ALIB_DLL void Parse()
Implementation of EnumRecordPrototype::Parse.
int Priority
The precedence of an operator in respect to other binary operators.
static ALIB_DLL void FreeNode(TTree &tree, TTree::Node &node)