2#include "yaml-cpp/yaml.h"
5#include <boost/uuid/uuid.hpp>
6#include <boost/uuid/uuid_io.hpp>
10namespace RobotRaconteur
18static boost::array<uint8_t, 16> parse_uuid_bytes_override(
const YAML::Node& node,
const std::string& key)
22 auto string_uuid = node[key].as<std::string>();
23 auto boost_uuid = boost::lexical_cast<boost::uuids::uuid>(string_uuid);
24 boost::array<uint8_t, 16> ret{};
25 std::copy(boost_uuid.begin(), boost_uuid.end(), ret.begin());
30 throw RobotRaconteur::InvalidArgumentException(
"Key not found: " + key);
34static void device_info_extra_parse(
const YAML::Node& node, com::robotraconteur::device::DeviceInfoPtr& rhs)
36 RobotRaconteur::RRListPtr<RobotRaconteur::RRValue> tags_out =
37 RobotRaconteur::AllocateEmptyRRList<RobotRaconteur::RRValue>();
41 auto tags = node[
"tags"].as<std::vector<com::robotraconteur::identifier::IdentifierPtr> >();
44 tags_out->push_back(e);
50 auto extended = node[
"extended"];
53 auto tags = extended[
"tags"].as<std::vector<com::robotraconteur::identifier::IdentifierPtr> >();
56 tags_out->push_back(e);
61 if (tags_out->empty())
68 rhs->extended = RobotRaconteur::AllocateEmptyRRMap<std::string, RobotRaconteur::RRValue>();
71 rhs->extended->insert(std::make_pair(
"tags", tags_out));
82struct convert<com::robotraconteur::uuid::UUID>
84 static Node encode(
const com::robotraconteur::uuid::UUID& rhs)
91 static bool decode(
const Node& node, com::robotraconteur::uuid::UUID& rhs)
93 auto string_uuid = node.as<std::string>();
94 auto boost_uuid = boost::lexical_cast<boost::uuids::uuid>(string_uuid);
95 std::copy(boost_uuid.begin(), boost_uuid.end(), rhs.s.uuid_bytes.begin());
101struct convert<com::robotraconteur::identifier::IdentifierPtr>
103 static Node encode(
const com::robotraconteur::identifier::IdentifierPtr& rhs)
110 static bool decode(
const Node& node, com::robotraconteur::identifier::IdentifierPtr& rhs)
113 rhs.reset(
new com::robotraconteur::identifier::Identifier);
116 rhs->name = node.as<std::string>();
117 std::fill(rhs->uuid.a.begin(), rhs->uuid.a.end(), 0);
120 rhs->name = RobotRaconteur::Companion::InfoParser::yaml::parse_string(node,
"name",
true);
121 rhs->uuid = RobotRaconteur::Companion::InfoParser::yaml::parse_namedarray<com::robotraconteur::uuid::UUID>(