【发布时间】:2017-03-22 13:14:59
【问题描述】:
如何使用mongocxx c++驱动递归生成Mongodb文档? 1.我使用mongocxx c++驱动v.3和c++11。 2. 这是我的 main.cpp 方法,它解析十六进制字符串并生成这样的 mongocxx 代码: 控制台:$ ./main dissect 0x160301012c01000128030340c70e243001b96d8c 和输出:
<< "MainType" << bsoncxx::builder::stream::open_document
<< "TLSRecord" << bsoncxx::builder::stream::open_document
<< "type"<< "16"
<< "version"<< "0301"
<< "length"<< "012C"
<< "hsMsg" << bsoncxx::builder::stream::open_document
<< "type"<< "01"
<< "length"<< "000128"
<< "clientHello" << bsoncxx::builder::stream::open_document
<< "version"<< "0303"
<< "random"<< "40C70E243001B96D8C"
<< "session_id_length"<< ""
<< bsoncxx::builder::stream::close_document
<< bsoncxx::builder::stream::close_document
<< bsoncxx::builder::stream::close_document
-
之后我需要将它推送到 mongodb 中。
从 dissect 方法窗体 main.cpp 调用连接方法 Call mongodb connection after hex string parsing
创建 mongodbConnection:
调用 MongodbMapper 将生成的代码映射到 db
调用 GenerateDocument 自动生成 Connect -> Mapp -> Generate -> Insert
-
我在这里堆积,尝试编译时出错。
src/MongodbMapper.cpp:76:6: note: candidate function not viable: no known conversion from'bsoncxx::v_noabi::builder::stream::key_context<bsoncxx::v_noabi::builder::stream::key_context<bsoncxx::v_noabi::builder::stream::closed_context> >' to'bsoncxx::builder::stream::document &' for 3rd argument void generateDocument(DataUnit& node, int level, bsoncxx::builder::stream::document& doc) {
【问题讨论】:
标签: c++ mongodb c++11 mongo-cxx-driver mongo-collection