MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / convert

Method convert

include/behaviortree_cpp/utils/safe_any.hpp:396–418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

394
395template <typename DST>
396inline nonstd::expected<DST, std::string> Any::convert(EnableString<DST>) const
397{
398 const auto& type = _any.type();
399
400 if(type == typeid(SafeAny::SimpleString))
401 {
402 return linb::any_cast<SafeAny::SimpleString>(_any).toStdString();
403 }
404 else if(type == typeid(int64_t))
405 {
406 return std::to_string(linb::any_cast<int64_t>(_any));
407 }
408 else if(type == typeid(uint64_t))
409 {
410 return std::to_string(linb::any_cast<uint64_t>(_any));
411 }
412 else if(type == typeid(double))
413 {
414 return std::to_string(linb::any_cast<double>(_any));
415 }
416
417 return nonstd::make_unexpected(errorMsg<DST>());
418}
419
420template <typename T>
421inline nonstd::expected<T, std::string> Any::stringToNumber() const

Callers 1

valueFunction · 0.45

Calls 4

make_unexpectedFunction · 0.85
toStdStringMethod · 0.80
to_stringFunction · 0.50
typeMethod · 0.45

Tested by

no test coverage detected