Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE )
# Define here the needed parameters
set (OPENRAVE_VERSION_MAJOR 0)
set (OPENRAVE_VERSION_MINOR 167)
set (OPENRAVE_VERSION_PATCH 6)
set (OPENRAVE_VERSION_PATCH 7)
set (OPENRAVE_VERSION ${OPENRAVE_VERSION_MAJOR}.${OPENRAVE_VERSION_MINOR}.${OPENRAVE_VERSION_PATCH})
set (OPENRAVE_SOVERSION ${OPENRAVE_VERSION_MAJOR}.${OPENRAVE_VERSION_MINOR})
message(STATUS "Compiling OpenRAVE Version ${OPENRAVE_VERSION}, soversion=${OPENRAVE_SOVERSION}")
Expand Down
5 changes: 5 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
ChangeLog
#########

Version 0.167.7
===============

- Add support for serialization and deserialization of std::vector<bool> for openravejson.

Version 0.167.6
===============

Expand Down
19 changes: 19 additions & 0 deletions include/openrave/openravejson.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,20 @@ inline void LoadJsonValue(const rapidjson::Value& v, bool& t) {
}
}

inline void LoadJsonValue(const rapidjson::Value& v, std::vector<bool>::reference t)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is std::vector<bool>::reference? is that std::vector<bool>&?

@cielavenir cielavenir Aug 26, 2025

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://en.cppreference.com/w/cpp/container/vector_bool.html , vector<bool>& is not applicable

{
if (v.IsInt())
t = v.GetInt();
else if (v.IsBool())
t = v.GetBool();
else if (v.IsString()) {
t = boost::lexical_cast<bool>(v.GetString());
}
else {
throw OPENRAVE_EXCEPTION_FORMAT("Cannot convert JSON type %s to Bool", GetJsonString(v), OpenRAVE::ORE_InvalidArguments);
}
}

template<class T>
inline void LoadJsonValue(const rapidjson::Value& v, OpenRAVE::RaveVector<T>& t) {
if(!v.IsArray() || (v.Size() != 3 && v.Size() != 4)) {
Expand Down Expand Up @@ -683,6 +697,11 @@ inline void SaveJsonValue(rapidjson::Value& v, bool t, rapidjson::Document::Allo
v.SetBool(t);
}

inline void SaveJsonValue(rapidjson::Value& v, const std::vector<bool>::reference t, rapidjson::Document::AllocatorType& alloc)
{
v.SetBool(t);
}

inline void SaveJsonValue(rapidjson::Value& v, double t, rapidjson::Document::AllocatorType& alloc) {
v.SetDouble(t);
}
Expand Down