22 if( substitutionVariableStart.
IsEmpty() )
29 int maxReplacements = 50;
33 integer repStart= orig.
IndexOf( substitutionVariableStart, searchStartIdx );
36 buf << orig.
Substring( searchStartIdx, repStart - searchStartIdx );
37 searchStartIdx = repStart;
38 integer varStart= repStart + substitutionVariableStart.
Length();
43 if ( substitutionVariableEnd.
IsEmpty() )
49 varLen= idx - varStart;
58 ALIB_WARNING(
"CONFIG",
"End of substitution variable not found (while start was found). "
59 "Variable name: ",
Name(namebuf) )
63 varLen= idx - varStart;
64 searchStartIdx= idx + substitutionVariableEnd.
Length();
71 buf << substitutionVariableStart;
82 if( replVar.
Try(replVarName) )
83 replVar.
Export( buf, escaper );
92 replVar.
Export( buf, escaper );
98 while( --maxReplacements );
100 if( maxReplacements < 50)
114 "No Meta-Handler found for given variable type . Probably the type was not registered\n"
115 "during bootstrap. Use macro ALIB_CONFIG_VARIABLE_REGISTER_TYPE in bootstrap phase \n"
116 "'PrepareConfig' to register your custom types.\n"
117 "Type name in question: ", typeName)
138 for (
int i = 0; i < Tree<Configuration>().CountPlugins(); ++i)
141 auto plPrio= plugin.GetPriority();
142 if(
Cursor::Value().priority <= plPrio && plugin.Get(varName, buf) )
147 substitute(buf, substBuf, &plugin.GetEscaper()) );
154 if( cursor.GoToChild(
A_CHAR(
"$PRESETS"))
155 && cursor.GoTo(varName).IsEmpty()
156 && cursor->meta !=
nullptr )
159 "Internal error. This must never happen. ")
161 "Internal error. This must never happen. ")
163 auto* escaper= cursor->declaration ?
reinterpret_cast<const StringEscaper*
>( cursor->declaration )
181 substitute( defaultValue, substBuf, &escaper) );
196 "Invalid Variable. Not associated with a Configuration. Probably a default constructed instance.\n"
197 "Copy or move a valid Variable object before usage.")
200 "Variable name with placeholder(s) given: ", name )
212 "\n No Meta-Handler found for given variable type . Probably the type was not registered\n"
213 " during bootstrap. Use macro ALIB_CONFIG_VARIABLE_REGISTER_TYPE in bootstrap phase \n"
214 " 'PrepareConfig' to register your custom types.\n"
215 " Type name in question: ", typeName)
220 "\n Variable {} redeclared with a different typename.\n"
229 create( typeName, defaultValue );
236 "Invalid Variable. Not associated with a Configuration. Probably a default constructed instance.\n"
237 "Copy or move a valid Variable object before usage.")
240 "Variable descriptor with unset placeholders given: ", decl->
Name() )
248 "\n Variable redeclared with different declaration record pointer.\n"
249 " Declaration records should be singletons and their life-time needs to survive\n"
250 " that of the variable. New record will be ignored. Variable: ", decl->
Name() )
257 "\n No Meta-Handler found for given variable type . Probably the type was not registered\n"
258 " during bootstrap. Use macro ALIB_CONFIG_VARIABLE_REGISTER_TYPE in bootstrap phase \n"
259 " 'PrepareConfig' to register your custom types.\n"
292 Cursor::node=
nullptr;
298 "Invalid Variable. Not associated with a Configuration. Probably a default constructed instance.\n"
299 "Copy or move a valid Variable object before usage.")
308 if( cursor.GoToChild(
A_CHAR(
"$PRESETS")) && cursor.GoTo(name).IsEmpty() )
311 "Internal error. This must never happen.")
316 auto* escaper= cursor->declaration ?
reinterpret_cast<const StringEscaper*
>( cursor->declaration )
337 "\n Variable redeclared with different declaration record pointer.\n"
338 " Declaration records should be singletons and their life-time needs to survive\n"
339 " that of the variable. New record will be ignored. Variable: ", decl->
Name() )
352 "Tried to import nulled string for variable {!Q}", *
this )
CString SubstitutionVariableDelimiters
String SubstitutionVariableEnd
String SubstitutionVariableStart
const String & DefaultValue() const
const String & Name() const
const String & TypeName() const
const String & substitute(const String &importString, AString &buf, const StringEscaper *escaper)
ALIB_API Variable & Declare(const String &name, const String &typeName, const String &defaultValue=NULL_STRING)
bool Try(const String &name)
AString & Export(AString &dest, const StringEscaper *escaper=nullptr) const
const Declaration * GetDeclaration() const
ALIB_API bool Define(Priority requestedPriority=Priority::Standard)
void create(const String &typeName, const String &defaultValue)
Configuration & GetConfiguration() const
Priority GetPriority() const
ALIB_API void Import(const String &src, Priority priority, const StringEscaper *escaper=nullptr)
const NameType & Name() const
SubstringType GoTo(const NameType &path)
integer GoToCreatedPathIfNotExistent(const NameType &path, TArgs &&... args)
integer IndexOf(TChar needle, integer startIdx=0) const
constexpr bool IsEmpty() const
constexpr bool IsNotEmpty() const
constexpr integer Length() const
constexpr bool IsNotNull() const
integer IndexOfAny(const TString &needles, integer startIdx=0) const
TString< TChar > Substring(integer regionStart, integer regionLength=MAX_LEN) const
#define ALIB_WARNING(...)
#define ALIB_ASSERT_ERROR(cond,...)
#define ALIB_ASSERT_WARNING(cond,...)
@ Include
Chooses inclusion.
lang::integer integer
Type alias in namespace alib.
@ Definition
A variable was defined or re-defined with the same or a higher priority.
@ Creation
A variable was declared for the first time.