我有两个问题在教程中找不到答案。
我得到一个文档,然后是文档中的一个元素,如下所示:
bsoncxx::document::element e = doc["id"];
if (!e || e.type() != bsoncxx::type::k_int32) return ERROR;
int id = e.get_int32();
有没有办法获取类型的字符串值,用于调试目的?喜欢:
std::cout << e.type() << std::endl;
(这不起作用)
第二个问题是如何将utf8类型的值转换成std::string。这不起作用:
e = doc["name"];
if (!e || e.type() != bsoncxx::type::k_utf8) return ERROR;
string name = e.get_utf8().value;
有小费吗?