提交 80f6a6ae 编写于 作者: A Aaron Xiao 提交者: Xiangquan Xiao

Localization: Quick fix on std::for_each which doesn't support early return.

上级 8ea26125
......@@ -16,7 +16,6 @@
#include "modules/localization/msf/local_pyramid_map/base_map/base_map_config.h"
#include <algorithm>
#include <exception>
#include <iostream>
......@@ -46,12 +45,10 @@ bool BaseMapConfig::Save(const std::string &file_path) {
bool success = CreateXml(&config);
if (success) {
boost::property_tree::write_xml(file_path, config);
std::cerr << "Saved the map configuration to: " << file_path << "."
<< std::endl;
AINFO << "Saved the map configuration to: " << file_path;
return true;
} else {
return false;
}
return false;
}
bool BaseMapConfig::Load(const std::string &file_path) {
......@@ -60,12 +57,10 @@ bool BaseMapConfig::Load(const std::string &file_path) {
bool success = LoadXml(config);
if (success) {
std::cerr << "Loaded the map configuration from: " << file_path << "."
<< std::endl;
AINFO << "Loaded the map configuration from: " << file_path;
return true;
} else {
return false;
}
return false;
}
bool BaseMapConfig::CreateXml(boost::property_tree::ptree *config) const {
......@@ -171,27 +166,25 @@ bool BaseMapConfig::LoadXml(const boost::property_tree::ptree &config) {
auto datasets = config.get_child_optional("map.map_record.datasets");
if (datasets) {
std::for_each(datasets->begin(), datasets->end(),
[this](const boost::property_tree::ptree::value_type &v) {
map_datasets_.push_back(v.second.data());
AINFO << "Dataset: " << v.second.data();
});
for (const boost::property_tree::ptree::value_type &v : *datasets) {
map_datasets_.push_back(v.second.data());
AINFO << "Dataset: " << v.second.data();
}
}
// load md5 check info
auto nodes = config.get_child_optional("map.check_info.nodes");
if (nodes) {
std::for_each(nodes->begin(), nodes->end(),
[this](const boost::property_tree::ptree::value_type &v) {
const boost::property_tree::ptree &child = v.second;
auto path = child.get_optional<std::string>("path");
auto md5 = child.get_optional<std::string>("md5");
if (!path || !md5) {
std::cerr << "Lack path or md5." << std::endl;
return;
}
node_md5_map_[*path] = *md5;
});
for (const boost::property_tree::ptree::value_type &v : *nodes) {
const boost::property_tree::ptree &child = v.second;
auto path = child.get_optional<std::string>("path");
auto md5 = child.get_optional<std::string>("md5");
if (!path || !md5) {
AERROR << "Lack path or md5.";
return false;
}
node_md5_map_[*path] = *md5;
}
}
return true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册