2017-06-14 9 views
1

mongo-c-driver-1.6.2に基づくmongo-cxx-driver-r3.1.1を使用しています。 latest examples provided on githubを使用して、データベースの接続方法とドキュメントの保存方法を調べました。mongodbのC++ドライバで宣言「見つからない」を使用

私は、mongocxx/query.cpp exampleで提供されている情報に従ったフィルタを使用して結果を取得するのに苦労しています。

make_documentメソッドの呼び出しがたくさんありますが、その名前のbsoncxx名前空間にクラス/メソッド/テンプレートがありません(make_arrayと同じ問題)。

#include <bsoncxx/builder/basic/document.hpp> 
#include <bsoncxx/builder/basic/array.hpp> 
#include <bsoncxx/builder/basic/kvp.hpp> 
#include <bsoncxx/types.hpp> 
#include <bsoncxx/json.hpp> 
#include <bsoncxx/stdx/make_unique.hpp> 
#include <bsoncxx/stdx/optional.hpp> 
#include <bsoncxx/stdx/string_view.hpp> 

#include <mongocxx/instance.hpp> 
#include <mongocxx/pool.hpp> 
#include <mongocxx/stdx.hpp> 
#include <mongocxx/client.hpp> 
#include <mongocxx/logger.hpp> 
#include <mongocxx/uri.hpp> 
#include <mongocxx/exception/exception.hpp> 
#include <mongocxx/options/find.hpp> 

using namespace mongocxx; 
using namespace bsoncxx; 

using bsoncxx::builder::basic::document; 
using bsoncxx::builder::basic::kvp; 
using bsoncxx::builder::basic::sub_document; 
using bsoncxx::builder::basic::sub_array; 
using bsoncxx::builder::basic::array; 
using bsoncxx::types::value; 
using mongocxx::result::insert_one; 

使用して宣言 "が見つかりません":

using bsoncxx::builder::basic::make_array; 
using bsoncxx::builder::basic::make_document; 

は、私が何かを明らかに足りない

は相続人、usingディレクティブと使用して宣言を含んでいるのか? 最近の例がありますか?

+0

奇妙なことに、 'make_document'は[document.hpp](https://github.com/mongodb/mongo-cxx-driver/blob/master/src/bsoncxx/builder/basic/document.hpp)にあります。 'make_array'は両方とも含まれている[array.hpp](https://github.com/mongodb/mongo-cxx-driver/blob/master/src/bsoncxx/builder/basic/array.hpp)にあります。コンパイラの実際のエラーメッセージを提供してください。 –

+0

ありがとう!私のdocument.hppにmake_documentテンプレート(およびmake_arrayテンプレートのarray.hpp)が含まれていないことに気がつきました。 私はそれらを追加して、今日の午後にテストします。新しい情報が入り次第お知らせします。 – Francois

答えて

0

make_documentmake_arrayに必要なすべての必要なヘッダーファイルが含まれているため、コードは正しく表示されます。 あなたのコメントで、document.hppにはmake_documentが含まれず、array.hppにはmake_arrayテンプレートが含まれていないと述べました。 これは、リリースmongo-cxx-driver-r3.1.1のために適切です。

現在のマスターブランチでは、ソースファイルの後に表示されるように、ヘッダーファイルが存在します(document.hppおよびarray.hpp)。使用している例はおそらく、新しいマスターブランチのためのもので、gitの現在のブランチからのものでもあります。

+0

ソースコードは、[mongocxx github release page] [1]の最新リリース(r3.1.1)に由来しています。 [1]:https://github.com/mongodb/mongo-cxx-driver/releases – Francois

+0

あなたが提供したhppファイルへのリンクがmasterブランチにつながっていることがわかりました。 私が使用している安定版リリースはstable/releaseブランチ上にあります。 テンプレートが追加された場所にコミットが見つかりませんでしたが、見つからなかった理由が説明されています。 多くのご協力ありがとうございます。 – Francois

+0

@Francois:そうです、彼らはリリースブランチにはいません。彼らは例では、奇妙なことを言及する必要があります... –

関連する問題