llvm::Type结构的字符串表示形式
string representation of llvm::Type structure
llvm::Type
2.9及更早版本曾经使用getDescription
方法来检索该类型的字符串表示。此方法在llvm 3.0中已不存在。
我不确定这是否被弃用以支持Type::print(raw_ostream&)
,但无论如何,我对这个API很好奇。关于如何使用它,有哪些例子?如何转储到string
或const char*
?
特别是,我想将字符串传递给Boost::Format
,它是一个现代的c++sprintf
。
我想,您需要创建一个llvm::raw_string_ostream
的实例,并将std::string传递到它的构造器中。现在您可以将其用作llvm::raw_ostream
,完成后只需调用.str()
即可获得字符串。
类似的东西:
std::string type_str;
llvm::raw_string_ostream rso(&type_str);
your_type->print(rso);
std::cout<<rso.str();
LLVM已经更改了它的接口,所以现在以下内容将起作用:
std::string type_str;
llvm::raw_string_ostream rso(type_str);
your_type->print(rso);
std::cout<<rso.str();
相关文章:
- 输入中的字符串数未知(以字母表示)
- 如何解析表示树状数据结构的字符串
- 将图形表示为unordered_map<字符串、向量>时拓扑排序错误<string>
- 基于类型作为参数的字符串表示形式具有不同返回类型的函数
- C++ 将十六进制字符串表示形式转换为十六进制字符串表示形式
- C++ 如何以二进制格式表示字符串?
- C++字符串表示中将无符号字符数组转换为长(或长长)
- 递归地将给定字符串转换为它所表示的数字
- C++:用于调试的类的字符串表示形式
- 在C++中将数据结构表示为字符串的首选方法是什么?
- 字符串表示日期并转换
- 从带有ifstream和get()的文件中获取一个用引号表示的字符串
- 生成包含分数和时区的完整 iso 日期时间表示字符串
- 如何使用 msgfmt 验证格式字符串中的位置表示法占位符
- 如何解析小数分离器为结肠的数字的字符串表示:
- 分割故障添加了两个表示字符串的大数字
- 如何在跨平台(Windows、iOS、Android)C++应用程序中表示字符串
- 如何在C++中使用hash_map来表示字符串键和整数值
- 有一个很好的表示字符串从一个双
- <<运算符与重载 + 运算符表示C++字符串