NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
yaml_value类 参考abstract

YAML值的抽象基类 更多...

#include <yaml_value.hpp>

类 yaml_value 继承关系图:
[图例]

Public 类型

enum  types {
  Null , Boolean , Integer , Float ,
  String , Timestamp , Sequence , Mapping
}
 YAML值类型枚举 更多...

Public 成员函数

virtual types type () const noexcept=0
 获取值的具体类型
void set_anchor (const string &a)
 设置锚点名
void set_tag (const string &t)
 设置类型标签
string to_string () const
 紧凑单行序列化
string to_document () const
 格式化文档序列化
类型转换方法

安全地向下转型到具体类型,失败时返回 nullptr。

类型检查方法

便捷的类型判断方法,等价于 type() == types::Xxx。

Public 成员函数 继承自 istringify< yaml_value >
constexpr string to_string () const
 转换为字符串

Public 属性

string anchor
 锚点名(YAML &anchor 语法),空字符串表示无锚点
string tag
 类型标签(YAML !tag 语法),空字符串表示无标签

详细描述

YAML值的抽象基类

所有YAML值类型的基类,定义了YAML值树的公共接口和类型系统。

每个 yaml_value 节点可携带可选的锚点和标签元数据:

  • anchor:锚点名(对应YAML中的 &anchor 语法)
  • tag:类型标签(对应YAML中的 !tag 语法)
注解
此类为抽象基类,不可直接实例化。
使用 type() 配合 as_*() 方法进行类型安全的向下转型。

在文件 yaml_value.hpp216 行定义.

成员枚举类型说明

◆ types

YAML值类型枚举

枚举值
Null 

空值类型

Boolean 

布尔值类型

Integer 

64位有符号整数类型

Float 

双精度浮点数类型

String 

Unicode字符串类型

Timestamp 

ISO 8601 / RFC 3339 时间戳类型

Sequence 

有序值列表类型

Mapping 

键值对集合类型

在文件 yaml_value.hpp225 行定义.

成员函数说明

◆ set_anchor()

void yaml_value::set_anchor ( const string & a)
inline

设置锚点名

参数
a锚点名字符串(对应 &anchor 语法)

在文件 yaml_value.hpp281 行定义.

◆ set_tag()

void yaml_value::set_tag ( const string & t)
inline

设置类型标签

参数
t标签字符串(对应 !tag 语法)

在文件 yaml_value.hpp287 行定义.

◆ to_document()

string yaml_value::to_document ( ) const
nodiscard

格式化文档序列化

返回
块样式的YAML文档表示(以换行结尾)

◆ to_string()

string yaml_value::to_string ( ) const
nodiscard

紧凑单行序列化

返回
流样式的YAML字符串表示

◆ type()

virtual types yaml_value::type ( ) const
nodiscardpure virtualnoexcept

获取值的具体类型

返回
类型枚举值

yaml_boolean, yaml_float, yaml_integer, yaml_mapping, yaml_null, yaml_sequence, yaml_string , 以及 yaml_timestamp 内被实现.

引用了 type().

被这些函数引用 type().


该类的文档由以下文件生成: