59, replacementDeclarations( allocator )
60, listeners ( allocator )
61, BooleanTokens ( allocator )
79 for (
int i = 0; i < 10; i+= 2 )
96 "Remaining registered listeners when destruction configuration.")
104 const String& variableName,
105 const String& pathPrefixGiven,
106 const String& pathSubstring )
110 ALIB_ASSERT_ERROR( variable==
nullptr || &variable->
AsCursor().
Tree() ==
this ,
"CONFIG",
"Given variable does not belong to this configuration.")
112 ALIB_ASSERT_ERROR( subTree ==
nullptr || &subTree ->Tree() ==
this ,
"CONFIG",
"Given cursor does not belong to this configuration.")
129 listeners.Back().variableName << variableName;
130 listeners.Back().pathPrefix << pathPrefix;
131 listeners.Back().pathSubstring<< pathSubstring;
138 if( it->listener == listener
139 && it->event == event
142 && it->variableName .Equals( variableName )
143 && it->pathPrefix .Equals( pathPrefix )
144 && it->pathSubstring.Equals( pathSubstring ) )
150 ALIB_WARNING(
"CONFIG",
"Listener with matching set of parameters not found with deregistration." )
163 if( it->listener == listener )
176 const String& variablePathGiven,
180 const String* variablePath= &variablePathGiven;
182 if( event == it->event )
186 && ( it->variableName .IsNotEmpty()
187 || it->pathPrefix .IsNotEmpty()
188 || it->pathSubstring.IsNotEmpty() ) )
190 variablePathBuffer << variable;
191 variablePath= &variablePathBuffer;
194 if( ( it->variable .IsValid() && ( it->variable == variable.
AsCursor().
Export() ) )
196 || ( it->variableName .IsNotEmpty() && it->variableName.Equals(variable.
AsCursor().
Name()) )
197 || ( it->pathPrefix .IsNotEmpty() && variablePath->
StartsWith(it->pathPrefix) )
198 || ( it->pathSubstring.IsNotEmpty() && variablePath->
IndexOf(it->pathSubstring) >= 0 )
201 it->listener->Notify( variable,
213 cursor.GoToCreateChildIfNotExistent(
A_CHAR(
"$PRESETS"));
218 if( cursor.GoTo(name).IsNotEmpty() )
221 auto& entry= *cursor;
222 if( entry.priority > priority )
227 entry.meta->destruct( entry.data,
Pool );
228 Pool().Free( entry.data, entry.meta->size() );
231 entry.priority= Priority::NONE;
235 if( !cursor.HasChildren() )
243 cursor.GoToCreatedPathIfNotExistent(name);
247 auto& entry= *cursor;
248 if( entry.data ==
nullptr )
252 "Variable type 'S' not registered. This usually cannot happen." )
253 auto* meta= entry.meta= *it;
257 meta->construct( cursor->data,
Pool );
258 entry.priority= priority;
261 if( entry.priority <= priority )
263 entry.priority = priority;
264 entry.declaration=
reinterpret_cast<const Declaration*
>( escaper );
278 const Box* replacementPtr;
288 replacementPtr = boxes->data();
289 qtyReplacements= boxes->
Size();
294 replacementPtr = boxes->data();
295 qtyReplacements= boxes->
Size();
300 replacementPtr = boxes->data();
301 qtyReplacements= boxes->
Size();
305 replacementPtr = &replacements;
313 for (
integer replCnt= 0; replCnt< qtyReplacements ; ++replCnt )
314 if ( !replacementPtr->IsType<
void>() )
316 String64 search(
"%"); search.
_( replCnt + 1 );
317 replace.
Reset( *( replacementPtr + replCnt) );
329 String1K bufComments;
ALIB_DBG( bufComments .DbgDisableBufferReplacementWarning() );
335 for (
integer replCnt= 0; replCnt< qtyReplacements ; ++replCnt )
336 if ( !replacementPtr->IsType<
void>() )
338 String64 search(
"%"); search.
_( replCnt + 1 );
339 replace.
Reset( *( replacementPtr + replCnt) );
351 result->comments .Allocate(
GetAllocator(), bufComments);
365 return {
false, int8_t(-1)};
369 if ( it.first .Match(value) )
return {
false, index};
370 if ( it.second.Match(value) )
return {true , index};
373 return {
false, int8_t(-1)};
383 for( int8_t index=0 ; index < idxRequested && it !=
BooleanTokens.end() ; ++index )
390 (!value ? it->first : it->second).GetExportName( dest );
396DOX_MARKER( [DOX_CONFIG_DELETE_SAMPLE] )
401if( cs.
GoTo(path).IsNotEmpty() )
409DOX_MARKER( [DOX_CONFIG_DELETE_SAMPLE] )
424#if ALIB_CHARACTERS_WIDE
429 variable.Name(target);
436#if ALIB_CHARACTERS_WIDE
437 variable.Name(target);
TElementType * UnboxArray() const
integer UnboxLength() const
const TUnboxable Unbox() const
ALIB_API ~Configuration()
Destructor.
EnvironmentVariablesPlugin * environmentPlugin
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_API void notifyListeners(int event, const Variable &variable, const String &variablePath, Priority previousPriority)
ALIB_API std::pair< bool, int8_t > ParseBooleanToken(const String &src)
ALIB_API AString & WriteBooleanToken(bool value, int8_t index, AString &dest)
ALIB_API 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)
ALIB_API const Declaration * StoreDeclaration(const Declaration *orig, const Box &replacements)
ALIB_API Configuration(MonoAllocator &allocator, lang::CreateDefaults createDefaults=lang::CreateDefaults::Yes)
List< MonoAllocator, ListenerRecord > listeners
The list of registered listeners.
ALIB_API bool DeletePath(const String &path)
List< MonoAllocator, std::pair< Token, Token >, Recycling::None > BooleanTokens
friend class Variable
Type alias in namespace alib.
CLIVariablesPlugin * cliPlugin
A default plugin created and inserted with construction.
ALIB_API int MonitorStop(ConfigurationListener *listener)
RDHashTable replacementDeclarations
ALIB_API void presetImportString(const String &name, const String &value, const StringEscaper *escaper, Priority priority)
VMeta * meta
The virtual handler instance for this variable.
VDATA * data
The list hook of values.
Iterator EmplaceUnique(TArgs &&... args)
Iterator Find(const KeyType &key)
const NameType & Name() const
SubstringType GoTo(const NameType &path)
int Distance(const TCursor< true > &other) const
AllocatorType & GetAllocator() noexcept
void DbgSetDCSName(const char *name) const
constexpr CharacterType Separator() const noexcept
Cursor ImportCursor(CursorHandle handle)
void InsertPlugin(ConfigurationPlugin *plugin, lang::Responsibility responsibility=lang::Responsibility::KeepWithSender)
void free(void *mem, size_t size)
ALIB_API integer SearchAndReplace(TChar needle, TChar replacement, integer startIdx=0, integer endIdx=strings::MAX_LEN)
TAString & _(const TString< TChar > &src, integer regionStart, integer regionLength=MAX_LEN)
void DbgDisableBufferReplacementWarning()
constexpr bool IsNull() const
integer IndexOf(TChar needle, integer startIdx=0) const
constexpr bool IsEmpty() const
void Allocate(TAllocator &allocator, const TString< TChar > ©)
TChar CharAtStart() const
constexpr bool IsNotNull() const
TString< TChar > Substring(integer regionStart, integer regionLength=MAX_LEN) const
bool StartsWith(const TString &needle) const
TSubstring & Trim(const TCString< TChar > &whiteSpaces=TT_CStringConstants< TChar >::DefaultWhitespaces())
static ALIB_API void LoadResourcedTokens(lang::resources::ResourcePool &resourcePool, const NString &resourceCategory, const NString &resourceName, strings::util::Token *target, int dbgSizeVerifier, character outerSeparator=',', character innerSeparator=' ')
#define ALIB_WARNING(...)
#define ALIB_WARNINGS_RESTORE
#define ALIB_ASSERT_ERROR(cond,...)
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
#define ALIB_ASSERT_WARNING(cond,...)
CreateDefaults
Denotes whether default entities should be created or not.
@ Yes
Create default values.
ContainerOp
Denotes standard container operations.
@ Insert
Denotes insertions.
config::ConfigCamp CONFIG
The singleton instance of ALib Camp class ConfigCamp.
LocalString< 256 > String256
Type alias name for TLocalString<character,256>.
lang::integer integer
Type alias in namespace alib.
strings::TAString< character, PoolAllocator > AStringPA
Type alias in namespace alib.
Event
The type of change that imposes the notification of a listener.
Record used to manage registered listeners.
static ALIB_API void FreeNode(TTree &tree, TTree::Node &node)
A handle type used with methods TCursor::Export and ImportCursor.
T data
The templated custom data object stored with each node.
typename TNodeHandler::CharacterType CharacterType
String EnumElementName
The name of the enum element.
void operator()(TAString< TChar > &target, const TAppendable &src)
NameStorageType storage
The name when stored in the hashtable.