属性&C++ 的反射库?

2021-12-26 00:00:00 attributes reflection c++

大多数成熟的 C++ 项目似乎都有自己的反射和属性系统,即用于定义可以通过字符串访问并自动序列化的属性.至少我参与的许多 C++ 项目似乎重新发明轮子.

Most mature C++ projects seem to have an own reflection and attribute system, i.e for defining attributes which can be accessed by string and are automatically serializable. At least many C++ projects I participated in seemed to reinvent the wheel.

你知道有哪些支持反射和属性容器的 C++好的开源库,特别是:

Do you know any good open source libraries for C++ which support reflection and attribute containers, specifically:

  • 通过宏定义 RTTI 和属性
  • 通过代码访问 RTTI 和属性
  • 属性的自动序列化
  • 监听属性修改(例如 OnValueChanged)

推荐答案

你可以看看下面的两个工具.我从来没有用过它们,所以我不能告诉你它们有多(不)实用.

You could have a look at the two tools below. I've never used either of them, so I can't tell you how (im)practical they are.

XRTTI:

Xrtti 是一个工具和附带的 C++ 库,它扩展了 C++ 的标准运行时类型系统,以提供关于类和方法的更丰富的反射信息集,以操作这些类及其成员.

Xrtti is a tool and accompanying C++ library which extends the standard runtime type system of C++ to provide a much richer set of reflection information about classes and methods to manipulate these classes and their members.

OpenC++:

OpenC++ 是 C++ 前端库(词法分析器+解析器+DOM/MOP)和源代码到源代码的翻译器.OpenC++ 支持开发 C++ 语言工具、扩展、特定领域的编译器优化和运行时元对象协议.

OpenC++ is C++ frontend library (lexer+parser+DOM/MOP) and source-to-source translator. OpenC++ enables development of C++ language tools, extensions, domain specific compiler optimizations and runtime metaobject protocols.

相关文章