【发布时间】:2016-07-16 02:10:48
【问题描述】:
我想使用 Boost/Property Tree 作为与我的应用程序的一种同步。 为此,我计划使用 Zeroc/ICE 进行状态同步(使用观察模式和双向连接)。
但是,要以一种有效的方式执行此操作,我需要以某种方式指定应用程序的 I/O(显然)。
这很适合将值导入树 (因为我可以使用 InputStream 转换为任何原始类型并捕获发生的错误)但是当我想导出值时它会受到阻碍。
使用文档中公开的函数,我看不到任何检索元素实际类型的方法
boost::property_tree::ptree Tree;
// Import
Ice::CommunicatorPtr communicator = current.adapter->getCommunicator();
Ice::InputStreamPtr in = Ice::createInputStream(communicator, item.data);
switch (item.type) {
case BOOLVAL:
double boolval;
in->read(boolval);
Tree.put(item.path, boolval);
break;
}
// Export
// This is not possible since I cannot retrieve or compare the type
Ice::CommunicatorPtr communicator = current.adapter->getCommunicator();
Ice::OutputStreamPtr out = Ice::createOutputStream(communicator);
auto data = Tree.get<TYPE>(path);
out->write(data);
【问题讨论】:
标签: c++ boost rpc boost-propertytree ice