35 ALIB_ERROR(
"CONFIG",
"No INI-file loaded when trying to search data." )
36 return std::pair<IniFile::Section*, IniFile::Entry*>(
nullptr,
nullptr);
42 String entryName = (sectionSeparator != -1) ? path.
Substring<
NC>(sectionSeparator + 1, path.
Length() - sectionSeparator - 1) : path;
52 "Variable belongs to different configuration: ",
String256(var))
63 ALIB_ERROR(
"CONFIG",
"No INI-file loaded when trying to import data." )
68 if(section ==
nullptr)
70 ALIB_WARNING(
"CONFIG",
"Section name not found in INI-file: ", sectionName )
77 varName.
Reset(sectionName);
82 for (
auto& entry : section->Entries )
85 varName << entry.Name;
107 for (
auto& entry : section.
Entries )
111 varName << entry.Name;
114 if( var.
Try(varName) )
132 ALIB_ERROR(
"CONFIG",
"No INI-file loaded when trying to import data." )
137 if(section ==
nullptr)
139 ALIB_WARNING(
"CONFIG",
"Section name not found in INI-file: ", sectionName )
150 ALIB_ERROR(
"CONFIG",
"No INI-file loaded when trying to import data." )
171 ALIB_ERROR(
"CONFIG",
"No INI-file loaded when trying to export data." )
181 String entryName = (sectionSeparator != -1) ? name.
Substring<
NC>(sectionSeparator + 1, name.
Length() - sectionSeparator - 1) : name;
185 auto* entry= pair.second;
189 if( !entry->WriteBack && !pair.first->WriteBack )
204 if(entry->Comments.IsNull())
207 if( decl && decl->Comments().IsNotEmpty() )
218 ALIB_ERROR(
"CONFIG",
"No INI-file loaded when trying to export data." )
233 rit.
Initialize( cursor, directChildrenOnly ? 0 : (std::numeric_limits<unsigned int>::max)() );
236 if( rit.
Node().Name().Equals(
A_CHAR(
"$PRESETS")) )
254 const NString& resourceCategory,
255 const NString& resourceNamePrefix )
259 ALIB_ERROR(
"CONFIG",
"No INI-file loaded when trying to import data." )
266 if( section.Comments.IsNull() )
268 auto& comment= resourcePool.
Get( resourceCategory,
269 NString128() << resourceNamePrefix << section.Name
271 if( comment.IsNull() )
289 ALIB_ASSERT_WARNING( entry.second ,
"CONFIG",
"Variable {!Q} to mark as 'writeback' not found.",
291 if( entry.second && entry.second->RawValue.IsEmpty() )
293 entry.second->WriteBack=
true;
303 "Variable belongs to different configuration: ",
String256(var))
void PresetImportString(const String &name, const String &value, StringEscaper *escaper, Priority priority=Priority::DefaultValues)
StringEscaperStandard Escaper
ALIB_API bool SetWriteBackFlag(const String &path)
ALIB_API int ExportSubTree(Configuration::Cursor cursor, bool directChildrenOnly=false)
ALIB_API std::pair< IniFile::Section *, IniFile::Entry * > SearchEntry(const Variable &variable)
Priority priority
The priority to use to define variables. Set with construction.
String DefaultCommentPrefix
IniFile * iniFile
The INI-file. Created with methods ImportStart and ExportStart.
ALIB_API int AddResourcedSectionComments(ResourcePool &resourcePool, const NString &resourceCategory, const NString &resourceNamePrefix)
ALIB_API int importSection(IniFile::Section §ion)
ALIB_API bool Export(const Variable &var)
ALIB_API int ImportSection(const String §ionName)
Configuration & configuration
The configuration to work with. Set with construction.
ALIB_API void AddComments(String &dest, const String &comments, const String &prefix=A_CHAR("# "))
List< MonoAllocator, Section > Sections
The list of sections.
ALIB_API std::pair< Section *, bool > SearchOrCreateSection(const String §ionName)
MonoAllocator Allocator
A monotonic allocator used for allocating sections and entries.
ALIB_API Entry * CreateEntry(Section *section, const String &name)
ALIB_API Section * SearchSection(const String §ionName)
ALIB_API std::pair< Section *, Entry * > SearchEntry(const String §ion, const String &name)
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)
Configuration & GetConfiguration() const
ALIB_API void Import(const String &src, Priority priority, const StringEscaper *escaper=nullptr)
void Initialize(cmTree &pTree, unsigned int depth=(std::numeric_limits< unsigned int >::max)())
void SetPathGeneration(lang::Switch pathGeneration)
constexpr CharacterType Separator() const noexcept
virtual const String & Get(const NString &category, const NString &name, bool dbgAssert)=0
TAString & _(const TString< TChar > &src, integer regionStart, integer regionLength=MAX_LEN)
void Allocate(TAllocator &allocator, const TString< TChar > ©)
constexpr bool IsNotEmpty() const
constexpr integer Length() const
TString< TChar > Substring(integer regionStart, integer regionLength=MAX_LEN) const
ALIB_WARNINGS_RESTORE integer LastIndexOf(TChar needle, integer startIndex=MAX_LEN) const
#define ALIB_WARNING(...)
#define ALIB_LOCK_RECURSIVE_WITH(lock)
#define ALIB_ASSERT_ERROR(cond,...)
#define ALIB_ASSERT_WARNING(cond,...)
@ On
Switch it on, switched on, etc.
NLocalString< 128 > NString128
Type alias name for TLocalString<nchar,128>.
constexpr const String EMPTY_STRING
An empty string of the default character type.
constexpr CString NEW_LINE
A zero-terminated string containing the new-line character sequence.
LocalString< 256 > String256
Type alias name for TLocalString<character,256>.
A section of the INI-file.
String Name
The name of the section.
List< MonoAllocator, Entry, Recycling::None > Entries
The list of variables of the section.