- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
编译器能够找到所有驱动程序,但在我尝试使用 << 运算符创建 bsoncxx 文档时给出类型特征错误(不完整类型)。它引用了 c++ 库,所以我没有理由认为 mongo cxx 驱动程序安装不正确。就在我尝试创建 bsoncxx 文档时,编译器也不会提示前面的 mongo 操作。这是我所拥有的:
标题:
#include <bsoncxx/builder/stream/document.hpp>
#include <bsoncxx/types.hpp>
#include <bsoncxx/json.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>
#include <mongocxx/options/find.hpp>
using bsoncxx::builder::stream::document;
using bsoncxx::builder::stream::open_document;
using bsoncxx::builder::stream::close_document;
using bsoncxx::builder::stream::open_array;
using bsoncxx::builder::stream::close_array;
using bsoncxx::builder::stream::finalize;
代码:
string start;
string end;
mongocxx::instance inst{};
mongocxx::client conn{};
auto db = conn["test"];
db["shortestpaths"].drop();
document index_spec{};
index_spec << "cost" << "-1"; // THE LINE THAT CAUSES THE ERROR
db["shortestpaths"].create_index(index_spec, {});
auto source = db["topology.src_ip"].find({});
for (auto&& doc : source){
start = bsoncxx::to_json(doc);
startVertex = std::stoi(start);
auto dest = db["topology.dest_ip"].find({});
for (auto&& field : dest){
end = bsoncxx::to_json(field);
destinationVertex = std::stoi(end);
document filter;
filter << "source" << start << "dest" << end; // if the line giving the error is commented out, this one gives the same error
auto dest = db["shortestpaths"].find(filter);
for (auto&& doc : dest){
exists = true;
continue;
}
if (startVertex != destinationVertex && !exists){
YenTopKShortestPathsAlg yenAlg(my_graph, my_graph.get_vertex(startVertex),
my_graph.get_vertex(destinationVertex));
while(yenAlg.has_next())
{
// TODO: Add mongoDB query here to add the entry
yenAlg.next()->PrintOut(outFile);
outFile << '\n';
}
}
exists = false;
}
生成文件:
CXX=c++
CFLAGS=-c --std=c++11 -Wall -I/usr/local/mongo-cxx-driver/include/mongocxx/v0.3 -I/usr/local/mongo-cxx-driver/include/libmongoc-1.0 -I/usr/local/mongo-cxx-driver/include/bsoncxx/v0.3 -I/usr/local/mongo-cxx-driver/include/libbson-1.0
LDFLAGS=-L/usr/local/mongo-cxx-driver/lib -lmongocxx -lbsoncxx pkg-config
SOURCES=DijkstraShortestPathAlg.cpp Graph.cpp MainP.cpp YenTopKShortestPathsAlg.cpp
OBJECTS=DijkstraShortestPathAlg.o Graph.o MainP.o YenTopKShortestPathsAlg.o
EXECUTABLE=algorithm
all: $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CXX) $(OBJECTS) -o $(EXECUTABLE) $(LDFLAGS)
$(OBJECTS): $(SOURCES)
$(CXX) $(CFLAGS) -c $(SOURCES)
clean:
@rm -f $(PROGRAMS) *.o core
当我运行 make 时,我得到:
In file included from MainP.cpp:5:
In file included from
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/limits:110:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/type_traits:7 94:59: error:
incomplete type
'bsoncxx::v0::builder::stream::value_context<bsoncxx::v0::builder::stream::key_context<bsoncxx::v0::builder::stream::closed_context>
>' used in type trait expression
: public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ostream:1052: 5: note:
in instantiation of template class
'std::__1::is_base_of<std::__1::ios_base,
bsoncxx::v0::builder::stream::value_context<bsoncxx::v0::builder::stream::key_context<bsoncxx::v0::builder::stream::closed_context>
> >' requested here
is_base_of<ios_base, _Stream>::value,
^
/usr/local/mongo-cxx-driver/include/bsoncxx/v0.3/bsoncxx/builder/stream/value_context.hpp:63:86: note:
while substituting deduced template arguments into function template
'operator<<' [with _Stream =
bsoncxx::v0::builder::stream::value_context<bsoncxx::v0::builder::stream::key_context<bsoncxx::v0::builder::stream::closed_context>
>, _Tp = int]
...decltype(std::declval<value_context>() << 1 << "str")>::value,
^
MainP.cpp:67:16: note: in instantiation of template class
'bsoncxx::v0::builder::stream::value_context<bsoncxx::v0::builder::stream::key_context<bsoncxx::v0::builder::stream::closed_context>
>' requested here
index_spec << "cost" << "-1";
^
/usr/local/mongo-cxx-driver/include/bsoncxx/v0.3/bsoncxx/builder/stream/value_context.hpp:31:7: note:
definition of
'bsoncxx::v0::builder::stream::value_context<bsoncxx::v0::builder::stream::key_context<bsoncxx::v0::builder::stream::closed_context>
>' is not complete until the closing '}'
class value_context {
^
有什么建议吗?
最佳答案
您将 bsoncxx::builder::stream::document
与 bsoncxx::document
混淆了。
请阅读:Handling BSON in the new driver
这是一个如何使用它的例子:
using bsoncxx::builder::stream::document;
using bsoncxx::builder::stream::finalize;
auto index_spec = document{} << "cost" << "-1" << finalize;
db["shortestpaths"].create_index(index_spec.view(), {});
关于c++ - 在 OSX 10.10.5 上使用 mongo-cxx-driver 编译 C++ 文件时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33902778/
我想知道是否有办法只在编译时而不是在链接时将一些标志传递给编译器 (g++)。让我用一个例子来解释:我想这样构建我的程序: g++ -c source1.cpp -o source1.o g++ -c
我们在使用 Visual Studio 2012 在 Windows 7 64Bit 下使用 CMake (v2.8.12) 编译项目时遇到问题。CMake 给我们以下错误。我们已经尝试使用管理员权限
我是 Linux 的新用户,正在尝试下载 Avogadro 1.2.0。 我在使用命令 cmake ../ 时遇到问题,当我这样做时 -- The C compiler identification
我使用的是 Julia 1.1.1 和 Cxx 的 0.3.2 版。我发现当我从我定义的模块中调用 icxx""时出现错误,但在 REPL 中调用它时却没有。在我的 REPL 中: using Cxx
./cmake-3.4.1/bin/cmake .. -- The CXX compiler identification is unknown CMake Error at CMakeLists.t
我的代码库中有大量文件。我正在尝试使用具有一个文件 a.h. 的其他库来编译我的代码库。如果我在我的代码库中包含 say a.h 文件,我会遇到编译问题,该文件已经定义了一些具有与 a.h 中定义的枚
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: Where does the value of CXX in a makefile come from? 我
我正在尝试使用 Cmake 将外部库安装到我的 C++ 项目中。我希望使用该库生成 Xcode 项目。在我的终端中,我从构建目录运行以下命令: cmake -G Xcode .. 这给了我以下错误:
我正在尝试在ubuntu 16.10上交叉编译ndn-cxx以在arduino yun上使用它。我正在关注steps。 当我尝试执行./waf命令时,出现以下错误: [ 30/141] Com
来自CXX Driver Quickstart guide我完全无法在 Ubuntu 或 CentOS VM 上完成新驱动程序的编译。 我已经按照这封信中的步骤执行了好几次,但我不确定哪里出了问题。
我有一个类,它有一个 bsoncxx::document::view view 作为 private 属性,还有一个从 Mongo 数据库获取文档并保存的方法结果在本地 bsoncxx::docume
这个问题在这里已经有了答案: gitignore does not ignore folder (7 个答案) 关闭 10 个月前。 我的 android 项目中有这个 .gitignore 文件,
我正在尝试在 Ubuntu14.4 上编译 mongo-cxx-driver-r3.1.1 。我已经按照说明从源代码安装了 mongo-c-driver-1.6.3。 pkg-config --cfl
我尝试让我的库目标依赖于 c++14。我怎样才能实现链接到我的库目标的目标也依赖于 c++14? 我尝试使用: add_library(lib SHARED ${FILES}) target_comp
帮助!我在提交我的项目使用 dbus-cxx 时可能犯了一个巨大的错误。该库似乎已被其作者遗弃,并且邮件列表对新成员不开放。这是我的问题: 没有关于使用 dbux-cxx 发送或接收包含非 POD 数
我使用 dbus-cxx通过 dbus 进行方法调用。现在有返回多个参数的方法,我不知道如何接收第一个参数以外的任何参数。 我初始化代理方法: DBus::MethodProxy& info_prox
CXX 测试框架的有效性如何,假设您正在围绕您编写的代码编写单元测试用例。代码中的任何错误也可能会转化为单元测试代码中的错误吗?这不是两个负数组成一个正数吗? 此外,花在 CXX 上的时间和精力至少等
在 cmake 已经预编译失败后,在 99% 编译时链接 CXX 可执行世界服务器。 [ 99%] Linking CXX executable worldserver /usr/bin/ld: ..
代码片段: target_test : test.cc $(CXX) $(CPPFLAGS) $(CFLAGS) test.cc 我知道 CXX 是一个变量(包含要调用的编译器命令),但我想知
我正在使用以下代码查询一个集合: bsoncxx::stdx::optional query_result = collection.find_one(bsoncxx::builder::stream
我是一名优秀的程序员,十分优秀!