257 std::equal_to<String> ,
279 std::equal_to<String> ,
294 template<
typename TVMeta>
298 types.EmplaceUnique( meta );
326 const String& variableName,
328 const String& pathSubstring );
337 const String& variablePath,
434 template<
typename TVMeta>
494 template<
typename TEnum>
520 Priority priority= Priority::DefaultValues)
532 Priority priority= Priority::DefaultValues )
591 "Event::Creation will never be invoked with this listener-registration-type.")
610 const String& variableName ) {
653 const String& pathPrefix ) {
675 const String& pathSubstring ) {
694{ node.name.storage.Allocate(
static_cast<Configuration&
>(tree).Pool, node.name.key ); }
788 :
Cursor(cursor) { Cursor::Value().declaration=
nullptr;
create( typeName, defaultValue); }
827 template<
typename TEnum>
842 template<
typename TEnum>
843 requires std::is_enum_v<TEnum>
896 template<
typename TEnum>
911 template<
typename TEnum>
933 bool IsDeclared()
const {
return Cursor::Value().data !=
nullptr; }
951 {
return Cursor::GoToRoot().GoTo( name ).IsEmpty() &&
IsDeclared(); }
1027 bool Define(
Priority requestedPriority= Priority::Standard );
1075 return Cursor::Value().priority != Priority::NONE;
1124 escaper= &nonEscaper;
1155 template<
typename T> T&
Get() {
1157 "Requesting value from undeclared variable \"{}\"",
this )
1159 "Requesting value from undefined variable \"{}\".\n"
1160 "Use 'var.Define();' to mitigate this error.",
this )
1162 "Wrong variable type requested for variable: \"{}\".\n"
1165 this, &
getMeta()->dbgTypeID(), &
typeid(T) )
1167 return Cursor::Value().data->As<T>();
1174 template<
typename T>
const T&
Get()
const {
1176 "Requested value from unset variable: ", *
this )
1178 "Requesting value from undefined variable. Use 'var.Define();' to mitigate\n"
1179 "this error. Variable: ", *
this )
1181 "Wrong variable type requested for variable: \"{}\".\n"
1184 *
this,
getMeta()->dbgTypeID(),
typeid(T) )
1186 return Cursor::Value().data->As<T>();
1208 float operator= (
float val) {
Get<double>()= double(val);
return val; }
1266template<
typename TEnum>
1300template<
typename TLock>
1333 unsigned bufferGrowthInPercent = 200,
1335 :
Base(initialBufferSizeInKB, bufferGrowthInPercent) {
1362 template<
typename TRequires=
typename Base::LockType>
1363 requires (!std::same_as<TRequires, void>)
1365 #if ALIB_DEBUG_CRITICAL_SECTIONS
1368 else Base::Self().NodeTable().dcs.DCSLock=
nullptr;
1375 template<
typename TRequires=
typename Base::LockType>
1376 requires std::same_as<TRequires, void>
1402#if !ALIB_SINGLE_THREADED || DOXYGEN
1422namespace APPENDABLES {
TCursor< true > ConstCursor
AllocatorType & GetAllocator() noexcept
StringTree(AllocatorType &allocator, CharacterType pathSeparator)
Plugin(PrioritiesType pPriority)
bool IsNulled() const noexcept
void ConstructT(TArgs &&... args)
TLock & GetLock() const noexcept
void Reset(TArgs &&... args)
AllocatorType & GetAllocator() noexcept
integer IndexOf(TChar needle, integer startIdx=0) const
constexpr bool IsNotEmpty() const
virtual String Name() const =0
StringEscaperStandard stringEscaper
virtual const StringEscaper & GetEscaper() const
virtual ~ConfigurationPlugin()
Virtual Destructor.
ConfigurationPlugin(Priority pPriority)
virtual ALIB_DLL bool Get(const String &name, AString &target)=0
HashTable< MonoAllocator, ValueDescriptorTypes, std::hash< String >, std::equal_to< String >, lang::Caching::Enabled, Recycling::None > TypesHashTable
A hashtable for the registered types. Key is the type name, value is the VMeta singleton.
ALIB_DLL bool DeletePath(const String &path)
String SubstitutionVariableStart
StringTree< MonoAllocator, detail::Entry, detail::ConfigNodeHandler > base
Alias to the StringTree-parent.
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.
ListMA< std::pair< Token, Token >, Recycling::None > BooleanTokens
void PresetImportString(const String &name, const String &value, StringEscaper *escaper, Priority priority=Priority::DefaultValues)
CString SubstitutionVariableDelimiters
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)
void MonitorPath(lang::ContainerOp insertOrRemove, ConfigurationListener *listener, ConfigurationListener::Event event, const Configuration::Cursor &cursor)
alib::NumberFormat NumberFormat
void MonitorPathPrefix(lang::ContainerOp insertOrRemove, ConfigurationListener *listener, ConfigurationListener::Event event, const String &pathPrefix)
RDHashTable replacementDeclarations
ALIB_DLL int MonitorStop(ConfigurationListener *listener)
void PresetImportString(const String &name, const String &value, Priority priority=Priority::DefaultValues)
void MonitorVariablesByName(lang::ContainerOp insertOrRemove, ConfigurationListener *listener, ConfigurationListener::Event event, const String &variableName)
String SubstitutionVariableEnd
ConfigurationPlugin * environmentPlugin
A default plugin created and inserted with construction.
friend class Variable
Type alias in namespace alib.
void MonitorDistinctVariable(lang::ContainerOp insertOrRemove, ConfigurationListener *listener, ConfigurationListener::Event event, const Variable &variable)
ListMA< ListenerRecord > listeners
The list of registered listeners.
ALIB_DLL ~Configuration()
Destructor.
ALIB_DLL void presetImportString(const String &name, const String &value, const StringEscaper *escaper, Priority priority)
void MonitorPathSubstring(lang::ContainerOp insertOrRemove, ConfigurationListener *listener, ConfigurationListener::Event event, const String &pathSubstring)
ALIB_DLL Configuration(MonoAllocator &allocator, lang::CreateDefaults createDefaults=lang::CreateDefaults::Yes)
ALIB_DLL std::pair< bool, int8_t > ParseBooleanToken(const String &src)
StringEscaperStandard Escaper
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)
HashTable< MonoAllocator, ValueDescriptorRD, std::hash< String >, std::equal_to< String >, lang::Caching::Disabled, Recycling::None > RDHashTable
static const Declaration * Get(TEnum element)
const String & Name() const
monomem::TSharedMonoVal< Configuration, HeapAllocator, TLock > Base
Exposed shortcut to the base type.
TSharedConfiguration(std::nullptr_t) noexcept
TSharedConfiguration & operator=(const TSharedConfiguration &)=default
TSharedConfiguration(const TSharedConfiguration &)=default
Defaulted copy-constructor.
void Reset(lang::CreateDefaults createDefaults=lang::CreateDefaults::Yes)
TSharedConfiguration()=default
Constructs an empty instance, hence a cleared automatic pointer.
TSharedConfiguration(size_t initialBufferSizeInKB, unsigned bufferGrowthInPercent=200, lang::CreateDefaults createDefaults=lang::CreateDefaults::Yes)
void DbgCriticalSections(lang::Switch onOff)
ALIB_DLL bool Define(Priority requestedPriority=Priority::Standard)
bool GetOrSetDefault(bool value, Priority priority=Priority::DefaultValues)
Variable(Configuration &cfg, const Declaration *decl)
AString & Export(AString &dest, const StringEscaper *escaper=nullptr) const
bool IsNotDefined() const
AString & Name(AString &target) const
Variable & Declare(TEnum Enum, const Box &replacements)
void create(const String &typeName, const String &defaultValue)
const Cursor & AsCursor() const
Variable(Configuration &cfg, TEnum Enum, const Box replacements)
String & GetString(int idx)
Priority GetPriority() const
String & GetOrSetDefault(const String &value, Priority priority=Priority::DefaultValues)
bool Try(const String &name)
Variable(Configuration &cfg, const String &name, const String &typeName, const String &defaultValue=NULL_STRING)
ALIB_DLL Variable & Declare(const String &name, const String &typeName, const String &defaultValue=NULL_STRING)
Variable(const Cursor &cursor)
const Declaration * GetDeclaration() const
Configuration::Cursor Cursor
Variable(Configuration &cfg, TEnum Enum)
Variable(Configuration &cfg)
Variable(const Cursor &cursor, const String &typeName, const String &defaultValue=NULL_STRING)
StringVectorPA & GetStrings()
Configuration & GetConfiguration() const
bool GetOrSetDefault(integer value, Priority priority=Priority::DefaultValues)
const String & substitute(const String &importString, AString &buf, const StringEscaper *escaper)
Variable & Declare(TEnum Enum)
bool IsDefinedExternally() const
Entry(Entry &&)=delete
Deleted move-constructor.
VMeta * meta
The virtual handler instance for this variable.
const Declaration * declaration
Entry()
Defaulted default constructor.
VDATA * data
The list hook of values.
Priority priority
The priority level of this data element.
Entry(const Entry &)=delete
Deleted copy-constructor.
#define ALIB_ASSERT_WARNING(cond, domain,...)
#define ALIB_BOXING_VTABLE_DECLARE(TMapped, Identifier)
#define ALIB_ASSERT_ERROR(cond, domain,...)
ContainerOp
Denotes standard container operations.
Switch
Denotes if sth. is switched on or off.
@ On
Switch it on, switched on, etc.
@ Off
Switch it off, switched off, etc.
@ Keep
Chooses not no clear existing data.
CreateDefaults
Denotes whether default entities should be created or not.
@ Yes
Create default values.
@ Enabled
Caching is enabled.
@ Disabled
Caching is disabled.
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.
variables::Declaration Declaration
Type alias in namespace alib.
constexpr String NULL_STRING
A nulled string of the default character type.
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
variables::Variable Variable
Type alias in namespace alib.
containers::HashTable< TAllocator, TValueDescriptor, THash, TEqual, THashCaching, TRecycling > HashTable
Type alias in namespace alib. See type definition alib::containers::HashSet.
containers::List< T, MonoAllocator, TRecycling > ListMA
Type alias in namespace alib.
variables::ConfigurationListener ConfigurationListener
Type alias in namespace alib.
variables::Configuration Configuration
Type alias in namespace alib.
strings::TCString< character > CString
Type alias in namespace alib.
characters::wchar wchar
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
monomem::TPoolAllocator< MonoAllocator > PoolAllocator
strings::TNumberFormat< character > NumberFormat
Type alias in namespace alib.
strings::util::TStringVector< character, PoolAllocator > StringVectorPA
Type alias in namespace alib.
variables::TSharedConfiguration< SharedLock > SharedConfiguration
Type alias in namespace alib.
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
enumrecords::EnumRecords< TEnum > EnumRecords
Type alias in namespace alib.
characters::nchar nchar
Type alias in namespace alib.
boxing::Enum Enum
Type alias in namespace alib.
boxing::Box Box
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
strings::util::StringEscaperStandard StringEscaperStandard
Type alias in namespace alib.
strings::TAString< character, PoolAllocator > AStringPA
Type alias in namespace alib.
characters::character character
Type alias in namespace alib.
strings::TSubstring< character > Substring
Type alias in namespace alib.
String EnumElementName
The name of the enum element.
static ForwardIterator begin()
static constexpr ForwardIterator end()
ALIB_DLL void operator()(TAString< nchar, lang::HeapAllocator > &target, const variables::Variable &variable)
ALIB_DLL void operator()(TAString< wchar, lang::HeapAllocator > &target, const variables::Variable &variable)
virtual ~ConfigurationListener()
Virtual destructor.
virtual void Notify(const Variable &variable, Event event, Priority previousPriority)=0
Event
The type of change that imposes the notification of a listener.
@ Definition
A variable was defined or re-defined with the same or a higher priority.
@ Creation
A variable was declared for the first time.
Record used to manage registered listeners.
ConstCursorHandle subTree
If given, the subtree of variables to listen to.
ConfigurationListener * listener
The listener to register or dispose.
AStringPA variableName
If given, the variable's name to listen to.
int event
The event to listen to.
AStringPA pathPrefix
If given, the start string of the file path to monitor.
ConstCursorHandle variable
If given, the variable to listen to.
Helper-struct used for implementing field replacementDeclarations.
const String & Key(const Declaration *src) const
Helper-struct used for implementing field types.
const String Key(const VMeta *src) const
static ALIB_DLL void FreeNode(TTree::Node &node, TTree &tree)
static void InitializeNode(TTree::Node &node, TTree &tree)
character CharacterType
The character type that the StringTree uses for child name and path strings.
strings::TString< character > NameStringType