XMLConfiguration -- Poco
阅读原文时间:2023年08月14日阅读:1

Library : Util

Package: Configuration

Header : Poco/Util.XMLConfiguration.h

此配置类从 XML 文档中提取配置属性。 支持类似于 xpath 的属性名语法,以允许对 XML 文档的完全访问。 不支持 XML 名称空间。 Xml 文档的根元素的名称不重要并且被忽略。 不支持标记名中的句点。

以下面的 XML 文档为例:

value1 value2 value5 value6
下列属性名称将是有效的,并将产生所示值:

prop1 -> value1
prop2 -> value2
prop3.prop4 -> (empty string)
prop3.prop4[@attr] -> value3
prop3.prop4[1][@attr] -> value4
prop5[0] -> value5
prop5[1] -> value6
prop5[@id=first] -> value5
prop5[@id='second'] -> value6
不支持枚举属性。 调用键(“ prop3.prop4”)将返回一个空范围。
作为一种特殊功能,通过将所需的字符传递给构造函数,可以将用于分隔属性名称的分隔符字符更改为句点('.')以外的其他字符。 这允许使用带有句点的元素名称的 XML 文档。
Direct Base Clases : AbstractConfiguration
All Base Classes: Poco::RefCountedObject, AbstractConfiguration
Xmlconfiguration () ; 创建一个带有“ config”根元素的空 XMLConfiguration。
XMLConfiguration(
    char delim
);
使用给定的分隔符 char (而不是默认的“ . ”)创建带有“ config”根元素的空 XMLConfiguration .

XMLConfiguration(
    Poco::XML::InputSource * pInputSource
);

创建 XMLConfiguration 并从给定 InputSource 加载 XML 文档。
XMLConfiguration(
    std::istream & istr
);
创建 XMLConfiguration 并从给定流加载 XML 文档。
XMLConfiguration(
    const std::string & path
);
创建 XMLConfiguration 并从给定路径加载 XML 文档。
XMLConfiguration(
    const Poco::XML::Document * pDocument
);
使用给定的 XML 文档创建 XMLConfiguration。
XMLConfiguration(
    const Poco::XML::Node * pNode
);
使用给定的 XML 节点创建 XMLConfiguration
XMLConfiguration(
    Poco::XML::InputSource * pInputSource,
    char delim
);
创建 XMLConfiguration 并从给定 InputSource 加载 XML 文档。 使用给定的分隔符字符,而不是默认的“ . ” .
XMLConfiguration(
    std::istream & istr,
    char delim
);
创建 XMLConfiguration 并从给定流加载 XML 文档。 使用给定的分隔符字符,而不是默认的“ . ” .
XMLConfiguration(
    const std::string & path,
    char delim
);
创建 XMLConfiguration 并从给定路径加载 XML 文档。 使用给定的分隔符字符,而不是默认的“ . ” .
XMLConfiguration(
    const Poco::XML::Document * pDocument,
    char delim
);
使用给定的 XML 文档创建 XMLConfiguration。 使用给定的分隔符字符,而不是默认的“ . ” .
XMLConfiguration(
    const Poco::XML::Node * pNode,
    char delim
);
使用给定的 XML 节点创建 XMLConfiguration。 使用给定的分隔符字符,而不是默认的“ . ” .
void load(
    Poco::XML::InputSource * pInputSource
);
从给定的 InputSource 加载包含配置数据的 XML 文档。
void load(
    std::istream & istr
);
加载包含来自给定流的配置数据的 XML 文档。
void load(
    const std::string & path
);
从给定文件加载包含配置数据的 XML 文档。
void load(
    const Poco::XML::Document * pDocument
);
从给定的 XML 文档加载包含配置数据的 XML 文档。
void load(
    const Poco::XML::Node * pNode
);
从给定的 XML 节点加载包含配置数据的 XML 文档。
void loadEmpty(
    const std::string & rootElementName
);
加载一个只包含给定名称的根元素的空 XML 文档。
void save(
    const std::string & path
) const;
将包含配置数据的 XML 文档写入 path 给出的文件。
void save(
    std::ostream & str
) const;
将包含配置数据的 XML 文档写入给定的流。
void save(
    Poco::XML::DOMWriter & writer,
    const std::string & path
) const;
使用给定的 DOMWriter 将包含配置数据的 XML 文档写入 path 给出的文件。
void save(
    Poco::XML::DOMWriter & writer,
    std::ostream & str
) const;
将包含配置数据的 XML 文档写入给定的流。

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章