如何使用mongocxx C++驅動程序遞歸生成Mongodb文檔? 1.我使用mongocxx C++驅動程序v.3和C++ 11。 2.這是我的main.cpp方法,它解析十六進制字符串,並生成這樣mongocxx代碼: 控制檯:$ ./main解剖0x160301012c01000128030340c70e243001b96d8c 和輸出:如何使用mongocxx C++驅動程序遞歸生成Mongodb文檔?
<< "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中推它。從解剖法形式的main.cpp
創建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) {