C++ Utilities 5.24.7
Useful C++ classes and routines such as argument parser, IO and conversion utilities
|
The AdvancedIniFile class allows parsing and writing INI files. More...
#include <inifile.h>
Classes | |
class | Field |
The AdvancedIniFile::Field class represents a field within an INI file. More... | |
class | Section |
The AdvancedIniFile::Section class represents a section within an INI file. More... | |
Public Types | |
using | FieldList = std::vector<Field> |
using | SectionList = std::vector<Section> |
Public Member Functions | |
SectionList::iterator | findSection (std::string_view sectionName) |
Returns an iterator to the first section with the name sectionName. | |
SectionList::const_iterator | findSection (std::string_view sectionName) const |
Returns an iterator to the first section with the name sectionName. | |
SectionList::iterator | findSection (SectionList::iterator after, std::string_view sectionName) |
Returns an iterator to the first section with the name sectionName which comes after after. | |
SectionList::const_iterator | findSection (SectionList::iterator after, std::string_view sectionName) const |
Returns an iterator to the first section with the name sectionName which comes after after. | |
SectionList::iterator | sectionEnd () |
Returns an iterator that points one past the last section. | |
SectionList::const_iterator | sectionEnd () const |
Returns an iterator that points one past the last section. | |
std::optional< FieldList::iterator > | findField (std::string_view sectionName, std::string_view key) |
Returns an iterator to the first field within the first section with matching sectionName and key. | |
std::optional< FieldList::const_iterator > | findField (std::string_view sectionName, std::string_view key) const |
Returns an iterator to the first field within the first section with matching sectionName and key. | |
void | parse (std::istream &inputStream, IniFileParseOptions options=IniFileParseOptions::None) |
Parses all data from the specified inputStream. | |
void | make (std::ostream &outputStream, IniFileMakeOptions options=IniFileMakeOptions::None) |
Write the current data to the specified outputStream. | |
Public Attributes | |
SectionList | sections |
The AdvancedIniFile class allows parsing and writing INI files.
In contrast to IniFile this class preserves
In the following description the word "element" is used to refer to a section or a field.
The parsed data or data to be written is directly exposed via the "sections" member variable of this class. There are also convenience functions to find a particular element.
Since the preceding comment of an element usually belongs to it each element has a "precedingCommentBlock" member variable. If a file ends with a comment an implicit section is added at the end which contains that comment as "precedingCommentBlock". Comments are not stripped from newline and '#' characters. When altering/adding comments be sure to use newline and '#' characters as needed.
Comments appearing in the same line as an element are stored using the "followingInlineComment" member variable.
using CppUtilities::AdvancedIniFile::FieldList = std::vector<Field> |
using CppUtilities::AdvancedIniFile::SectionList = std::vector<Section> |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void CppUtilities::AdvancedIniFile::make | ( | std::ostream & | outputStream, |
IniFileMakeOptions | options = IniFileMakeOptions::None ) |
Write the current data to the specified outputStream.
Throws | an std::ios_base::failure when an IO error occurs. |
Definition at line 412 of file inifile.cpp.
void CppUtilities::AdvancedIniFile::parse | ( | std::istream & | inputStream, |
IniFileParseOptions | options = IniFileParseOptions::None ) |
Parses all data from the specified inputStream.
Throws | an std::ios_base::failure when an IO error (other than end-of-file) occurs. |
Definition at line 217 of file inifile.cpp.
|
inline |
|
inline |
SectionList CppUtilities::AdvancedIniFile::sections |