问题描述
std::string calculator_graph_config_contents; // name of string
MP_RETURN_IF_ERROR(mediapipe::file::GetContents(
FLAGS_calculator_graph_config_file,&calculator_graph_config_contents));
LOG(INFO) << "Get calculator graph config contents: "
<< calculator_graph_config_contents;
mediapipe::CalculatorgraphConfig config =
mediapipe::ParseTextProtoOrDie<mediapipe::CalculatorgraphConfig>(
calculator_graph_config_contents);
我从Google的mediapipe的demo_run_graph_main.cc文件中获得了这段代码。我无法理解MP_RETURN_IF_ERROR函数的功能。我没有找到说明这一点的文档。有人可以给我解释一下吗?
宏定义
#define MP_RETURN_IF_ERROR(expr) \
STATUS_MACROS_IMPL_ELSE_BLOCKER_ \
if (::mediapipe::status_macro_internal::StatusAdaptorForMacros \
status_macro_internal_adaptor = {(expr),__FILE__,__LINE__}) { \
} else /* NOLINT */ \
return status_macro_internal_adaptor.Consume()
// Executes an expression `rexpr` that returns a `::mediapipe::StatusOr<T>`. On
// OK,extracts its value into the variable defined by `lhs`,otherwise returns
// from the current function. By default the error status is returned
// unchanged,but it may be modified by an `error_expression`. If there is an
// error,`lhs` is not evaluated; thus any side effects that `lhs` may have
// only occur in the success case.
#define STATUS_MACROS_IMPL_ELSE_BLOCKER_ \
switch (0) \
case 0: \
default: // NOLINT
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)