32 Entry& entry= node.data;
62 std::array<Token, 10> tokenBuf;
65 for (
size_t i = 0; i < tokenBuf.size(); i+= 2 )
87 "{} remaining registered listeners when destruction configuration.",
listeners.size() )
95 const String& variableName,
96 const String& pathPrefixGiven,
97 const String& pathSubstring ) {
100 ALIB_ASSERT_ERROR( variable==
nullptr || &variable->
AsCursor().Tree() ==
this ,
"VARIABLES",
"Given variable does not belong to this configuration.")
101 ALIB_ASSERT_ERROR( subTree ==
nullptr || subTree->IsValid() ,
"VARIABLES",
"Invalid cursor given." )
102 ALIB_ASSERT_ERROR( subTree ==
nullptr || &subTree ->Tree() ==
this ,
"VARIABLES",
"Given cursor does not belong to this configuration.")
113 variable ? variable->
AsCursor().Export() : ConstCursorHandle(),
114 subTree ? subTree-> Export() : ConstCursorHandle(),
118 listeners.back().variableName << variableName;
119 listeners.back().pathPrefix << pathPrefix;
120 listeners.back().pathSubstring<< pathSubstring;
127 if( it->listener == listener
128 && it->event == event
129 && it->variable == ( variable ? variable->
AsCursor().Export() : ConstCursorHandle() )
130 && it->subTree == ( subTree ? subTree ->Export() : ConstCursorHandle() )
131 && it->variableName .Equals( variableName )
132 && it->pathPrefix .Equals( pathPrefix )
133 && it->pathSubstring.Equals( pathSubstring ) )
139 ALIB_WARNING(
"VARIABLES",
"Listener with matching set of parameters not found with "
152 if( it->listener == listener ) {
164 const String& variablePathGiven,
167 const String* variablePath= &variablePathGiven;
169 if( event == it->event ) {
172 && ( it->variableName .IsNotEmpty()
173 || it->pathPrefix .IsNotEmpty()
174 || it->pathSubstring.IsNotEmpty() ) )
176 variablePathBuffer << variable;
177 variablePath= &variablePathBuffer;
180 if( ( it->variable .IsValid() && ( it->variable == variable.
AsCursor().Export() ) )
181 || ( it->subTree .IsValid() && ( variable.
AsCursor().Distance(
ImportCursor(it->subTree) ) >= 0 ) )
182 || ( it->variableName .IsNotEmpty() && it->variableName.Equals(variable.
AsCursor().Name()) )
183 || ( it->pathPrefix .IsNotEmpty() && variablePath->
StartsWith(it->pathPrefix) )
184 || ( it->pathSubstring.IsNotEmpty() && variablePath->
IndexOf(it->pathSubstring) >= 0 )
187 it->listener->Notify( variable,
197 cursor.GoToCreateChildIfNotExistent(
A_CHAR(
"$PRESETS"));
201 if( cursor.GoTo(name).IsNotEmpty() )
204 auto& entry= *cursor;
205 if( entry.priority > priority )
209 entry.meta->destruct( entry.data,
Pool );
210 Pool().Free( entry.data, entry.meta->size() );
213 entry.priority= Priority::NONE;
217 if( !cursor.HasChildren() )
225 cursor.GoToCreatedPathIfNotExistent(name);
229 auto& entry= *cursor;
230 if( entry.data ==
nullptr ) {
233 "Variable type 'S' not registered. This usually cannot happen." )
234 auto* meta= entry.meta= *it;
238 meta->construct( cursor->data,
Pool );
239 entry.priority= priority;
242 if( entry.priority <= priority ) {
243 entry.priority = priority;
244 entry.declaration=
reinterpret_cast<const Declaration*
>( escaper );
252 const Box& replacements ) {
256 const Box* replacementPtr;
263 const auto* boxes= replacements.
Unbox<
Boxes*>();
264 replacementPtr = boxes->
data();
265 qtyReplacements= boxes->Size();
269 replacementPtr = boxes->
data();
270 qtyReplacements= boxes->Size();
274 replacementPtr = boxes->
data();
275 qtyReplacements= boxes->Size();
277 replacementPtr = &replacements;
285 for (
integer replCnt= 0; replCnt< qtyReplacements ; ++replCnt )
286 if ( !replacementPtr->
IsType<
void>() ) {
287 String64 search(
"%"); search.
_( replCnt + 1 );
288 replace.
Reset( *( replacementPtr + replCnt) );
300 String1K bufComments;
ALIB_DBG( bufComments .DbgDisableBufferReplacementWarning() );
306 for (
integer replCnt= 0; replCnt< qtyReplacements ; ++replCnt )
307 if ( !replacementPtr->
IsType<
void>() ) {
308 String64 search(
"%"); search.
_( replCnt + 1 );
309 replace.
Reset( *( replacementPtr + replCnt) );
332 return {
false, int8_t(-1)};
335 if ( it.first .Match(value) )
return {
false, index};
336 if ( it.second.Match(value) )
return {true , index};
339 return {
false, int8_t(-1)};
348 for( int8_t index=0 ; index < idxRequested && it !=
BooleanTokens.end() ; ++index )
355 (!value ? it->first : it->second).GetExportName( dest );
360DOX_MARKER( [DOX_VARIABLES_DELETE_SAMPLE] )
365if( cs.GoTo(path).IsNotEmpty() )
373DOX_MARKER( [DOX_VARIABLES_DELETE_SAMPLE] )
396 TAString<nchar, lang::HeapAllocator>& target,
const variables::Variable& variable ) {
397#if ALIB_CHARACTERS_WIDE
402 variable.Name(target);
409#if ALIB_CHARACTERS_WIDE
410 variable.Name(target);
#define ALIB_WARNING(domain,...)
#define ALIB_ASSERT_WARNING(cond, domain,...)
#define ALIB_ASSERT_ERROR(cond, domain,...)
#define ALIB_BOXING_VTABLE_DEFINE(TMapped, Identifier)
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)
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())
bool DeletePath(const String &path)
void notifyListeners(int event, const Variable &variable, const String &variablePath, Priority previousPriority)
AString & WriteBooleanToken(bool value, int8_t index, AString &dest)
ConfigurationPlugin * cliPlugin
A default plugin created and inserted with construction.
ListMA< std::pair< Token, Token >, Recycling::None > BooleanTokens
TypesHashTable types
A hashtable for the registered types. Key is the type name, value is the VMeta singleton.
const Declaration * StoreDeclaration(const Declaration *orig, const Box &replacements)
RDHashTable replacementDeclarations
int MonitorStop(ConfigurationListener *listener)
ConfigurationPlugin * environmentPlugin
A default plugin created and inserted with construction.
ListMA< ListenerRecord > listeners
The list of registered listeners.
~Configuration()
Destructor.
void presetImportString(const String &name, const String &value, const StringEscaper *escaper, Priority priority)
Configuration(MonoAllocator &allocator, lang::CreateDefaults createDefaults=lang::CreateDefaults::Yes)
std::pair< bool, int8_t > ParseBooleanToken(const String &src)
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.
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".
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
variables::Variable Variable
Type alias in namespace #"%alib".
strings::TAString< character, PoolAllocator > AStringPA
Type alias in namespace #"%alib".
LocalString< 64 > String64
Type alias name for #"TLocalString;TLocalString<character,64>".
boxing::TBoxes< lang::HeapAllocator > Boxes
Type alias in namespace #"%alib".
lang::integer integer
Type alias in namespace #"%alib".
boxing::Box Box
Type alias in namespace #"%alib".
boxing::TBoxes< PoolAllocator > BoxesPA
Type alias in namespace #"%alib".
strings::util::StringEscaper StringEscaper
Type alias in namespace #"%alib".
strings::TString< character > String
Type alias in namespace #"%alib".
strings::TSubstring< character > Substring
Type alias in namespace #"%alib".
camp::Basecamp BASECAMP
The singleton instance of ALib Camp class #"Basecamp".
LocalString< 1024 > String1K
Type alias name for #"TLocalString;TLocalString<character,1024>".
LocalString< 128 > String128
Type alias name for #"TLocalString;TLocalString<character,128>".
boxing::TBoxes< MonoAllocator > BoxesMA
Type alias in namespace #"%alib".
LocalString< 256 > String256
Type alias name for #"TLocalString;TLocalString<character,256>".
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace #"%alib".
strings::util::Token Token
Type alias in namespace #"%alib".
typename ConfigNodeHandler::CharacterType CharacterType
String EnumElementName
The name of the enum element.
static 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.
void Parse()
Implementation of #"EnumRecordPrototype::Parse;*".
int Priority
The precedence of an operator in respect to other binary operators.
static void FreeNode(TTree::Node &node, TTree &tree)