26#include <yuni/core/string.h>
51 void saveToStream(std::ostream& file, uint64_t& written)
const;
80 Property*
add(
const AnyString& key,
const std::optional<U>& value);
84 void saveToStream(std::ostream& file, uint64_t& written)
const;
86 Property* find(
const AnyString& key);
87 const Property* find(
const AnyString& key)
const;
97 template<
class U,
class StringT>
98 U
read(
const StringT& key,
const U& defValue)
const;
119 template<
class CallbackT>
120 void each(
const CallbackT& callback);
141 template<
class CallbackT>
142 void each(
const CallbackT& callback)
const;
197 bool open(
const std::string&
filename,
bool warnings =
true);
199 bool open(
const std::filesystem::path&
filename,
bool warnings =
true);
201 bool readStream(std::istream& in_stream);
207 void saveToStream(std::ostream&, uint64_t&)
const;
209 std::string toString()
const;
212 const std::string&
filename()
const;
256 template<
class CallbackT>
257 void each(
const CallbackT& callback);
273 template<
class CallbackT>
274 void each(
const CallbackT& callback)
const;
290 template<
class CallbackT>
307 template<
class CallbackT>
308 void properties(
const CallbackT& callback)
const;
312 Section* firstSection =
nullptr;
313 Section* lastSection =
nullptr;
322 std::string filename_;
328#include "inifile.hxx"
A single entry in an INI file.
Definition inifile.h:43
YString value
Its associated value.
Definition inifile.h:57
YString key
The key.
Definition inifile.h:55
Property * next
The next value.
Definition inifile.h:59
A single section, with all its keys.
Definition inifile.h:67
Property * add(const AnyString &key, const U &value)
Add a new property.
IniFile::Property * lastProperty
The last property of the section.
Definition inifile.h:156
Yuni::ShortString256 name
The name of the section.
Definition inifile.h:152
IniFile::Property * firstProperty
The first property of the section.
Definition inifile.h:154
void each(const CallbackT &callback)
Iterate through all properties.
Definition inifile.hxx:117
Section * next
The next section.
Definition inifile.h:158
uint size() const
Get the number of properties.
Definition inifile.cpp:143
U read(const StringT &key, const U &defValue) const
Try to read a property.
Definition inifile.hxx:82
bool empty() const
Get if the section is empty.
Definition inifile.hxx:50
Data for an INI file.
Definition inifile.h:34
bool save(const AnyString &filename) const
Save the entire INI into a file.
Definition inifile.cpp:287
bool empty() const
Get if the inifile is empty.
Definition inifile.hxx:30
void each(const CallbackT &callback)
Iterate through all sections.
Definition inifile.hxx:99
bool open(const std::string &filename, bool warnings=true)
Load an INI file.
Definition inifile.cpp:238
Section * addSection(const AnyString &name)
Create a new section.
Definition inifile.hxx:88
Section * add(Section *s)
Add an existing section into the INI structure.
Definition inifile.cpp:109
const std::string & filename() const
Get the last filename saved or loaded.
Definition inifile.hxx:93
IniFile()=default
Default Constructor.
void clear()
Empty the INI File.
Definition inifile.cpp:126
~IniFile()
Destructor.
Definition inifile.cpp:94
Section * find(const AnyString &name)
Try to find a section by its name.
Definition inifile.cpp:327
IniFile(const std::filesystem::path &filename)
Load an INI file.
bool loaded() const
Get if the INI file has been loaded/written.
Definition inifile.hxx:25
void properties(const CallbackT &callback)
Iterate through all properties of all sections.
Definition inifile.hxx:135