Skip to content

Commit 4377fbc

Browse files
committed
adding SubTree model
1 parent 676a7cb commit 4377fbc

File tree

6 files changed

+450
-285
lines changed

6 files changed

+450
-285
lines changed

include/behaviortree_cpp/basic_types.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,16 @@ inline StringConverter GetAnyFromStringFunctor<void>()
158158
template<typename T> [[nodiscard]]
159159
std::string toStr(const T& value)
160160
{
161-
if constexpr(!std::is_arithmetic_v<T>)
161+
if constexpr (std::is_convertible_v<T, std::string> or
162+
std::is_convertible_v<T, std::string_view>)
163+
{
164+
return value;
165+
}
166+
else if constexpr(!std::is_arithmetic_v<T>)
162167
{
163168
throw LogicError(
164169
StrCat("Function BT::toStr<T>() not specialized for type [",
165-
BT::demangle(typeid(T)), "],",
166-
"Implement it consistently with BT::convertFromString<T>(), "
167-
"or provide at dummy version that returns an empty string.")
170+
BT::demangle(typeid(T)), "]")
168171
);
169172
} else {
170173
return std::to_string(value);

include/behaviortree_cpp/scripting/operators.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,16 @@ struct ExprComparison : ExprBase
380380
return False;
381381
}
382382
}
383+
else if ((lhs_v.isString() && rhs_v.isNumber()) ||
384+
(lhs_v.isNumber() && rhs_v.isString()))
385+
{
386+
auto lv = lhs_v.cast<double>();
387+
auto rv = lhs_v.cast<double>();
388+
if (!SwitchImpl(lv, rv, ops[i]))
389+
{
390+
return False;
391+
}
392+
}
383393
else
384394
{
385395
throw RuntimeError(StrCat("Can't mix different types in Comparison. "

0 commit comments

Comments
 (0)