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" 
   30    if( substitutionVariableStart.
IsEmpty() )
 
   37    int     maxReplacements = 50;
 
   41        integer repStart= orig.
IndexOf( substitutionVariableStart, searchStartIdx );
 
   44        buf << orig.
Substring( searchStartIdx, repStart - searchStartIdx );
 
   45        searchStartIdx  = repStart;
 
   46        integer varStart= repStart + substitutionVariableStart.
Length();
 
   51        if ( substitutionVariableEnd.
IsEmpty() )
 
   57            varLen= idx - varStart;
 
   66                ALIB_WARNING( 
"VARIABLES", 
"End of substitution variable not found " 
   67                                         "(while start was found). Variable name: ", 
Name(namebuf) )
 
   71            varLen= idx - varStart;
 
   72            searchStartIdx= idx + substitutionVariableEnd.
Length();
 
   79            buf << substitutionVariableStart;
 
   90        if( replVar.
Try(replVarName) )
 
   91            replVar.
Export( buf, escaper );
 
  100            replVar.
Export( buf, escaper );
 
  106    while( --maxReplacements );
 
  108    if( maxReplacements < 50)
 
 
  120    auto it= Tree<Configuration>().types.Find(typeName);
 
  122          "No Meta-Handler found for given variable type \"{}\".\n" 
  123          "Probably the type was not registered during bootstrap.\n" 
  124          "Use macro ALIB_VARIABLES_REGISTER_TYPE in bootstrap phase " 
  125                    "'PrepareConfig' to register your custom types.", typeName)
 
  126    auto*  meta= Cursor::Value().meta= *it;
 
  129    Cursor::Value().data    =  
reinterpret_cast<detail::VDATA*
>(Tree<Configuration>().Pool().Alloc( meta->size(), 
alignof(
detail::VDATA)));
 
  130    meta->construct(Cursor::Value().data, Tree<Configuration>().Pool );
 
  131    Cursor::Value().priority= Priority::NONE;
 
  146        for (
int i = 0; i < Tree<Configuration>().CountPlugins(); ++i)
 
  148            auto& plugin= *Tree<Configuration>().GetPlugin(i);
 
  149            auto  plPrio= plugin.GetPriority();
 
  150            if( Cursor::Value().priority <= plPrio  && plugin.Get(varName, buf) )
 
  153                Cursor::Value().priority= plPrio;
 
  154                Cursor::Value().meta->imPort( Cursor::Value().data, 
GetConfiguration(), plugin.GetEscaper(),
 
  155                                              substitute(buf, substBuf, &plugin.GetEscaper())  );
 
  161    auto cursor= Tree<Configuration>().Root();
 
  162    if(     cursor.GoToChild(
A_CHAR(
"$PRESETS"))
 
  163        &&  cursor.GoTo(varName).IsEmpty()
 
  164        &&  cursor->meta != 
nullptr              )
 
  167                   "Internal error. This must never happen. ")
 
  169                   "Internal error. This must never happen. ")
 
  171        auto* escaper= cursor->declaration ? 
reinterpret_cast<const StringEscaper*
>( cursor->declaration )
 
  173        Cursor::Value().priority= cursor->priority;
 
  175        Cursor::Value().meta->imPort( Cursor::Value().data,
 
  183    if( Cursor::Value().priority <= Priority::DefaultValues  &&  defaultValue.
IsNotEmpty() )
 
  187        Cursor::Value().priority= Priority::DefaultValues;
 
  188        Cursor::Value().meta->imPort( Cursor::Value().data,
GetConfiguration(), escaper,
 
  189                                      substitute( defaultValue, substBuf, &escaper)  );
 
 
  204      "Invalid Variable. Not associated with a Configuration. Probably a default constructed " 
  205      "instance.\nCopy or move a valid Variable object before usage.")
 
  208                                                 "Variable name with placeholder(s) given: ", name )
 
  212    if(    GoToCreatedPathIfNotExistent(name) == 0
 
  213        && Cursor::Value().meta != 
nullptr              )
 
  216            auto it=  Tree<Configuration>().types.Find(typeName);
 
  217            if( it == Tree<Configuration>().types.end() )
 
  220                "No Meta-Handler found for given variable type \"{}\".\n" 
  221                "Probably the type was not registered during bootstrap.\n" 
  222                "Use macro ALIB_VARIABLES_REGISTER_TYPE in bootstrap phase " 
  223                "'PrepareConfig' to register your custom types.", typeName )
 
  225            if( *it != Cursor::Value().meta )
 
  228                 "Variable \"{}\" redeclared with a different typename.\n" 
  229                 "Previous typename: ", Cursor::Value().meta->typeName(), typeName )
 
  236    Cursor::Value().declaration= 
nullptr;
 
  237    create( typeName, defaultValue );
 
 
  244      "Invalid Variable. Not associated with a Configuration.\n" 
  245      "Probably a default constructed instance.\n" 
  246      "Copy or move a valid Variable object before usage.")
 
  249                      "Variable descriptor \"{}\" with unset placeholders given.", decl->
Name() )
 
  253    if( 0 == GoToCreatedPathIfNotExistent( decl->
Name() ))
 
  257             "Variable \"{}\" redeclared with different declaration record pointer.\n" 
  258             "Declaration records should be singletons and their life-time needs to survive\n" 
  259             "that of the variable. New record will be ignored.", decl->
Name() )
 
  261            auto it= Tree<Configuration>().types.Find(decl->
typeName);
 
  262            if( it == Tree<Configuration>().types.end() )
 
  265              "No Meta-Handler found for given variable type \"{}\".\n" 
  266              "Probably the type was not registered during bootstrap.\n" 
  267              "Use macro ALIB_VARIABLES_REGISTER_TYPE in bootstrap phase " 
  268                    "'PrepareConfig' to register your custom types.",  
GetDeclaration()->typeName)
 
  275    Cursor::Value().declaration= decl;
 
 
  282    if( Cursor::Value().priority > requestedPriority )
 
  284    auto prevPriority= Cursor::Value().priority;
 
  285    Cursor::Value().priority= requestedPriority ;
 
 
  300    Cursor::node= 
nullptr;
 
 
  306      "Invalid Variable. Not associated with a Configuration. Probably a default constructed " 
  307      "instance.\nCopy or move a valid Variable object before usage.")
 
  310    if(    Cursor::GoToRoot().GoTo( name ).IsEmpty()
 
  315    auto cursor= Tree<Configuration>().Root();
 
  316    if( cursor.GoToChild(
A_CHAR(
"$PRESETS")) && cursor.GoTo(name).IsEmpty() )
 
  319                           "Internal error. This must never happen.")
 
  321        if( Cursor::Value().priority < cursor->priority)
 
  324            auto* escaper=  cursor->declaration ? 
reinterpret_cast<const StringEscaper*
>( cursor->declaration )
 
  327            Cursor::Value().priority= cursor->priority;
 
  328            Cursor::Value().meta->imPort( Cursor::Value().data,
 
 
  344                            || Cursor::Value().declaration == decl,          
"CONFIG/VARDECL",
 
  345             "Variable \"{}\" redeclared with different declaration record pointer.\n" 
  346             "Declaration records should be singletons and their life-time needs to survive\n" 
  347             "that of the variable. New record will be ignored.", decl->
Name() )
 
  349        if( Cursor::Value().declaration== 
nullptr)
 
  350            Cursor::Value().declaration= decl;
 
 
  360       "Tried to import nulled string for variable \"{}\"", 
this )
 
 
constexpr integer Length() const
constexpr bool IsEmpty() const
integer IndexOf(TChar needle, integer startIdx=0) const
constexpr bool IsNotNull() const
constexpr bool IsNotEmpty() const
integer IndexOfAny(const TString &needles, integer startIdx=0) const
TString< TChar > Substring(integer regionStart, integer regionLength=MAX_LEN) const
String SubstitutionVariableStart
CString SubstitutionVariableDelimiters
String SubstitutionVariableEnd
const String & DefaultValue() const
const String & TypeName() const
const String & Name() const
ALIB_DLL bool Define(Priority requestedPriority=Priority::Standard)
ALIB_DLL void Import(const String &src, Priority priority, const StringEscaper *escaper=nullptr)
AString & Export(AString &dest, const StringEscaper *escaper=nullptr) const
AString & Name(AString &target) const
void create(const String &typeName, const String &defaultValue)
Priority GetPriority() const
bool Try(const String &name)
ALIB_DLL Variable & Declare(const String &name, const String &typeName, const String &defaultValue=NULL_STRING)
const Declaration * GetDeclaration() const
Configuration & GetConfiguration() const
const String & substitute(const String &importString, AString &buf, const StringEscaper *escaper)
#define ALIB_WARNING(domain,...)
#define ALIB_ASSERT_WARNING(cond, domain,...)
#define ALIB_ERROR(domain,...)
#define ALIB_ASSERT_ERROR(cond, domain,...)
@ Include
Chooses inclusion.
strings::util::StringEscaper StringEscaper
Type alias in namespace alib.
LocalString< 512 > String512
Type alias name for TLocalString<character,512>.
LocalString< 256 > String256
Type alias name for TLocalString<character,256>.
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
strings::TSubstring< character > Substring
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.