Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::Settings::ConfigParserSettings Struct Reference

#include <ConfigParser.h>

Classes

struct  ConfigEntry
 
struct  ConfigKeyValuePair
 

Public Types

using ParseConfigEntryFunc = AZStd::function< bool(const ConfigEntry &)>
 
using CommentPrefixFunc = AZStd::function< AZStd::string_view(AZStd::string_view line)>
 
using SectionHeaderFunc = AZStd::function< AZStd::string_view(AZStd::string_view line)>
 
using DelimiterFunc = AZStd::function< ConfigKeyValuePair(AZStd::string_view line)>
 

Static Public Member Functions

static AZStd::string_view DefaultCommentPrefixFilter (AZStd::string_view line)
 
static AZStd::string_view DefaultSectionHeaderFilter (AZStd::string_view line)
 
static ConfigKeyValuePair DefaultDelimiterFunc (AZStd::string_view line)
 

Public Attributes

ParseConfigEntryFunc m_parseConfigEntryFunc
 
CommentPrefixFunc m_commentPrefixFunc = &DefaultCommentPrefixFilter
 
SectionHeaderFunc m_sectionHeaderFunc = &DefaultSectionHeaderFilter
 
DelimiterFunc m_delimiterFunc = &DefaultDelimiterFunc
 

Detailed Description

Settings structure which is used to determine how to parse Windows INI style config file(.cfg, .ini, etc...) It supports being able to supply a custom comment filter and section header filter The names of section headers are appended to the root Json pointer path member to form new root paths Ex. test.ini

Member Typedef Documentation

◆ CommentPrefixFunc

Callback function that is invoked when a line is read. returns a substr of the line which contains the non-commented portion of the line

◆ DelimiterFunc

Callback function which is invoked after a line has been filtered through the SectionHeaderFunc to split the key,value pair of a line NOTE: Leading and trailing whitespace will be removed from the line before invoking the callback

Returns
an instance of a ConfigKeyValuePair with the split key and value with surrounding whitespaced trimmed

◆ ParseConfigEntryFunc

Callback invoked with each parsed key, value (key=value) entry from a Windows Style INI file with the section header if available [section header] This is the the only member that is required to be set within this struct All other members are defaulted to work with INI style files IMPORTANT: Any lambda functions or class instances that are larger than 16 bytes in size requires a memory allocation to store. So it is recommmended that users binding a lambda bind at most 2 reference or pointer members to avoid dynamic heap allocations

NOTE: This function will not be called if the key is empty

Returns
True should be returned from this function to indicate that parsing of the config entry has succeeded

◆ SectionHeaderFunc

Callback function that is after a line has been filtered through the CommentPrefixFunc to determine if the text matches a section header NOTE: Leading and trailing whitespace will be removed from the line before invoking the callback

Returns
returns a view of the section name if the line contains a section Otherwise an empty view is returned

Member Function Documentation

◆ DefaultCommentPrefixFilter()

static AZStd::string_view AZ::Settings::ConfigParserSettings::DefaultCommentPrefixFilter ( AZStd::string_view  line)
static

Filters out line which start with a prefix of ';' or '#' If a line matches the comment filter and empty view is returned Otherwise the line is returned as is

Parameters
lineline to parse for comments
Returns
view of line without any comments

◆ DefaultDelimiterFunc()

static ConfigKeyValuePair AZ::Settings::ConfigParserSettings::DefaultDelimiterFunc ( AZStd::string_view  line)
static

Splits a line into two views of a key and a value pair Surrounding whitespace around the key and value are not part of the string views This function is invoked after the section header filter is invoked

Parameters
lineto search for delimiter and split int key value params
Returns
key, value pair structure representing the setting key and value

◆ DefaultSectionHeaderFilter()

static AZStd::string_view AZ::Settings::ConfigParserSettings::DefaultSectionHeaderFilter ( AZStd::string_view  line)
static

Matches a section header in the regular expression form of [(?P<header>[^]]+)] # '[' followed by 1 or more non-']' characters followed by a ']' If the line matches section header format, the section name portion of that line is returned in the output parameter otherwise an empty view is returned

Parameters
lineto parse for section header
Returns
section name header if the line starts contains an INI style section header

Member Data Documentation

◆ m_commentPrefixFunc

CommentPrefixFunc AZ::Settings::ConfigParserSettings::m_commentPrefixFunc = &DefaultCommentPrefixFilter

Function which is invoked to retrieve the non-commented section of a line The input line will never start with leading whitespace

◆ m_delimiterFunc

DelimiterFunc AZ::Settings::ConfigParserSettings::m_delimiterFunc = &DefaultDelimiterFunc

Function which is invoked on the config line after filtering through the SectionHeaderFunc to determine the delimiter of the line The structure contains a functor which returns a ConfigKeyValuePair to split the key value pair

◆ m_sectionHeaderFunc

SectionHeaderFunc AZ::Settings::ConfigParserSettings::m_sectionHeaderFunc = &DefaultSectionHeaderFilter

Invoked on the non-commented section of a line that has been read from the config file This function should examine the supplied line to determine if it matches a section header If so the section name should be returned Any sections names returned will be supplied as a section header to the Parse callback


The documentation for this struct was generated from the following file: