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"
50 ALIB_ERROR(
"VARIABLES",
"No INI-file loaded when trying to search data." )
51 return std::pair<IniFile::Section*, IniFile::Entry*>(
nullptr,
nullptr);
57 String entryName = (sectionSeparator != -1) ? path.
Substring<
NC>(sectionSeparator + 1, path.
Length() - sectionSeparator - 1) : path;
60 return iniFile->SearchEntry(sectionName, entryName);
67 "Variable belongs to different configuration: ", var )
78 ALIB_ERROR(
"VARIABLES",
"No INI-file loaded when trying to import data." )
82 auto* section=
iniFile->SearchSection( sectionName );
83 if(section ==
nullptr)
85 ALIB_WARNING(
"VARIABLES",
"Section named \"{}\" not found in INI-file.", sectionName )
92 varName.
Reset(sectionName);
97 for (
auto& entry : section->Entries )
100 varName << entry.Name;
122 for (
auto& entry : section.
Entries )
126 varName << entry.Name;
129 if( var.
Try(varName) )
147 ALIB_ERROR(
"VARIABLES",
"No INI-file loaded when trying to import data." )
151 auto* section=
iniFile->SearchSection( sectionName );
152 if(section ==
nullptr)
154 ALIB_WARNING(
"VARIABLES",
"Section name \"{}\" not found in INI-file.", sectionName )
165 ALIB_ERROR(
"VARIABLES",
"No INI-file loaded when trying to import data." )
186 ALIB_ERROR(
"VARIABLES",
"No INI-file loaded when trying to export data." )
196 String entryName = (sectionSeparator != -1) ? name.
Substring<
NC>(sectionSeparator + 1, name.
Length() - sectionSeparator - 1) : name;
199 auto pair=
iniFile->SearchEntry(sectionName, entryName);
200 auto* entry= pair.second;
204 if( !entry->WriteBack && !pair.first->WriteBack )
210 auto sectionIt=
iniFile->SearchOrCreateSection( sectionName );
211 entry =
iniFile->CreateEntry( sectionIt.first, entryName );
219 if(entry->Comments.IsNull())
222 if( decl && decl->Comments().IsNotEmpty() )
233 ALIB_ERROR(
"VARIABLES",
"No INI-file loaded when trying to export data." )
238 if( !cursor.IsRoot() )
248 rit.Initialize( cursor, directChildrenOnly ? 0 : (std::numeric_limits<unsigned int>::max)() );
249 while ( rit.IsValid() )
251 if( rit.Node().Name().Equals(
A_CHAR(
"$PRESETS")) )
270 const NString& resourceCategory,
271 const NString& resourceNamePrefix )
275 ALIB_ERROR(
"VARIABLES",
"No INI-file loaded when trying to import data." )
281 for(
auto& section :
iniFile->Sections )
282 if( section.Comments.IsNull() )
284 auto& comment= resourcePool.
Get( resourceCategory,
285 NString128() << resourceNamePrefix << section.Name
287 if( comment.IsNull() )
307 "Variable \"{}\" to be marked as 'writeback' not found.", path )
309 if( entry.second && entry.second->RawValue.IsEmpty() )
311 entry.second->WriteBack=
true;
321 "Variable belongs to different configuration: ", var)
constexpr CharacterType Separator() const noexcept
TRecursiveIterator< false > RecursiveIterator
virtual const String & Get(const NString &category, const NString &name, bool dbgAssert)=0
TAString & _(const TAppendable &src)
constexpr integer Length() const
constexpr bool IsNotEmpty() const
integer LastIndexOf(TChar needle, integer startIndex=MAX_LEN) const
void Allocate(TAllocator &allocator, const TString< TChar > ©)
TString< TChar > Substring(integer regionStart, integer regionLength=MAX_LEN) const
String DefaultCommentPrefix
ALIB_DLL std::pair< IniFile::Section *, IniFile::Entry * > SearchEntry(const Variable &variable)
ALIB_DLL int AddResourcedSectionComments(ResourcePool &resourcePool, const NString &resourceCategory, const NString &resourceNamePrefix)
ALIB_DLL int ExportSubTree(Configuration::Cursor cursor, bool directChildrenOnly=false)
IniFile * iniFile
The INI-file. Created with methods ImportStart and ExportStart.
ALIB_DLL bool SetWriteBackFlag(const String &path)
Configuration & configuration
The configuration to work with. Set with construction.
ALIB_DLL int ImportSection(const String §ionName)
ALIB_DLL int importSection(IniFile::Section §ion)
Priority priority
The priority to use to define variables. Set with construction.
ALIB_DLL bool Export(const Variable &var)
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
bool Try(const String &name)
const Declaration * GetDeclaration() const
Configuration & GetConfiguration() const
#define ALIB_WARNING(domain,...)
#define ALIB_ASSERT_WARNING(cond, domain,...)
#define ALIB_ERROR(domain,...)
#define ALIB_LOCK_RECURSIVE_WITH(lock)
#define ALIB_ASSERT_ERROR(cond, domain,...)
@ On
Switch it on, switched on, etc.
strings::TStringLengthResetter< character,lang::HeapAllocator > StringLengthResetter
Type alias in namespace alib.
NLocalString< 128 > NString128
Type alias name for TLocalString<nchar,128>.
LocalString< 256 > String256
Type alias name for TLocalString<character,256>.
constexpr CString NEW_LINE
A zero-terminated string containing the new-line character sequence.
constexpr const String EMPTY_STRING
An empty string of the default character type.
strings::TString< nchar > NString
Type alias in namespace alib.
format::Paragraphs Paragraphs
Type alias in namespace alib.
resources::ResourcePool ResourcePool
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
LocalString< 2048 > String2K
Type alias name for TLocalString<character,2048>.
strings::TSubstring< character > Substring
Type alias in namespace alib.
A section of the INI-file.
List< MonoAllocator, Entry, Recycling::None > Entries
The list of variables of the section.
String Name
The name of the section.