|
Console Library 8.0.0
A header-only library that makes C++ simple
|
INI 配置文件操作类。 More...
#include <config.h>
Classes | |
| class | Item |
| 配置项代理类,支持隐式类型转换。 More... | |
Public Member Functions | |
| BasicINIConfig ()=default | |
| 默认构造函数,创建空的配置对象。 | |
| BasicINIConfig (const std::string &filename) | |
| 从指定文件加载配置的构造函数。 | |
| BasicINIConfig (const Path &filename) | |
| 从指定文件加载配置的构造函数。 | |
| void | load (const Path &filename) |
| 从文件加载 INI 配置。 | |
| void | save (const std::string &filename) |
| 将配置保存到文件。 | |
| void | save (const Path &filename) const |
| 将配置保存到文件。 | |
| Item | get (const string_type §ion_and_key) const |
| 获取配置项的值。 | |
| template<class T> | |
| T | get (const string_type §ion_and_key) const |
| template<class T> | |
| T | get (const string_type §ion_and_key, const T &default_value) const |
| 获取配置项的值,若不存在则返回默认值。 | |
| void | set (const string_type §ion_and_key, const string_type &value) |
| 设置配置项的值。 | |
| bool | has (const string_type §ion_and_key) const |
| 检查配置项或节是否存在。 | |
| bool | remove (const string_type §ion_and_key) |
| 删除配置项或节。 | |
| const std::map< string_type, std::map< string_type, string_type > > & | data () const |
| 获取原始数据结构的只读引用。 | |
Private Types | |
| using | string_type = std::basic_string<CharT> |
Private Member Functions | |
| void | write_to_stream (std::ostream &os) const |
| void | read_from_stream (std::istream &is) |
Static Private Member Functions | |
| static std::string | to_narrow (const string_type &s) |
Private Attributes | |
| std::map< string_type, std::map< string_type, string_type > > | data_ |
Friends | |
| std::basic_ostream< CharT > & | operator<< (std::basic_ostream< CharT > &os, const BasicINIConfig &config) |
| 配置对象的输出流运算符,按 INI 格式输出配置内容。 | |
| std::basic_istream< CharT > & | operator>> (std::basic_istream< CharT > &is, BasicINIConfig &config) |
| 配置对象的输入流运算符,按 INI 格式输入配置内容。 | |
INI 配置文件操作类。
| CharT | 字符类型,支持 char 和 wchar_t。 |
支持加载、保存、读取、修改 INI 格式的配置文件,本类的 INI 变种支持空节头和空键。
|
private |
|
default |
默认构造函数,创建空的配置对象。
|
inline |
从指定文件加载配置的构造函数。
| filename | 配置文件路径。 |
|
inline |
从指定文件加载配置的构造函数。
| filename | 配置文件路径。 |
|
inline |
获取原始数据结构的只读引用。
|
inline |
|
inline |
获取配置项的值。
| section_and_key | 节和键,格式为 "节名.键名"。 |
| IndexError | 格式错误、节不存在或键不存在时抛出。 |
|
inline |
获取配置项的值,若不存在则返回默认值。
| T | 目标类型。 |
| section_and_key | 节和键,格式为 "节名.键名"。 |
| default_value | 默认值,当配置项不存在时返回。 |
|
inline |
检查配置项或节是否存在。
| section_and_key | 节和键,格式为 "节名.键名" 或仅 "节名"。 |
|
inline |
从文件加载 INI 配置。
| filename | 配置文件路径。 |
支持行首注释(; 或 #),支持节头 [section]。
|
inlineprivate |
|
inline |
删除配置项或节。
| section_and_key | 节和键,格式为 "节名.键名" 或仅 "节名"。 |
|
inline |
|
inline |
|
inline |
设置配置项的值。
| section_and_key | 节和键,格式为 "节名.键名"。 |
| value | 要设置的值。 |
| IndexError | 格式错误时抛出。 |
|
inlinestaticprivate |
|
inlineprivate |
|
friend |
配置对象的输出流运算符,按 INI 格式输出配置内容。
|
friend |
配置对象的输入流运算符,按 INI 格式输入配置内容。
|
private |