}
OCRepresentation rep;
- char uuidString[UUID_STRING_SIZE];
- if (payload->sid && RAND_UUID_OK == OCConvertUuidToString(payload->sid, uuidString))
- {
- rep[OC_RSRVD_DEVICE_ID] = std::string(uuidString);
- }
- else
- {
- rep[OC_RSRVD_DEVICE_ID] = std::string();
- }
+ rep[OC_RSRVD_DEVICE_ID] = (payload->sid) ?
+ std::string(payload->sid) :
+ std::string();
rep[OC_RSRVD_DEVICE_NAME] = payload->deviceName ?
std::string(payload->deviceName) :
std::string();
rep[OC_RSRVD_DATA_MODEL_VERSION] = payload->dataModelVersion ?
std::string(payload->dataModelVersion) :
std::string();
+ for (OCStringLL *strll = payload->types; strll; strll = strll->next)
+ {
+ rep.addResourceType(strll->value);
+ }
m_reps.push_back(std::move(rep));
}
std::string(payload->info.systemTime) :
std::string();
+ for (OCStringLL *strll = payload->rt; strll; strll = strll->next)
+ {
+ rep.addResourceType(strll->value);
+ }
+ for (OCStringLL *strll = payload->interfaces; strll; strll = strll->next)
+ {
+ rep.addResourceInterface(strll->value);
+ }
+
m_reps.push_back(std::move(rep));
}
case AttributeType::Vector:
getPayloadArray(root, val);
break;
+ case AttributeType::Binary:
+ OCRepPayloadSetPropByteString(root, val.attrname().c_str(),
+ OCByteString{const_cast<uint8_t*>(val.getValue<std::vector<uint8_t>>().data()),
+ val.getValue<std::vector<uint8_t>>().size()});
+ break;
default:
throw std::logic_error(std::string("Getpayload: Not Implemented") +
std::to_string((int)val.type()));
case OCREP_PROP_ARRAY:
setPayloadArray(val);
break;
+ case OCREP_PROP_BYTE_STRING:
+ setValue(val->name,
+ std::vector<uint8_t>
+ (val->ocByteStr.bytes, val->ocByteStr.bytes + val->ocByteStr.len)
+ );
+ break;
default:
throw std::logic_error(std::string("Not Implemented!") +
std::to_string((int)val->type));
case AttributeType::Vector:
os << "Vector";
break;
+ case AttributeType::Binary:
+ os<< "Binary";
}
return os;
}
};
template<typename T>
- struct type_info<T, typename std::enable_if<is_vector<T>::value>::type>
+ struct type_info<
+ T,
+ typename std::enable_if<
+ is_vector<T>::value &&
+ !std::is_same<uint8_t, typename T::value_type>::value
+ >::type
+ >
{
typedef T type;
typedef typename type_info<typename T::value_type>::base_type base_type;
type_info<typename T::value_type>::depth;
};
+ // special case for binary data, which is a std::vector<uint8_t>
+ template<>
+ struct type_info<std::vector<uint8_t>, void>
+ {
+ typedef std::vector<uint8_t> type;
+ typedef std::vector<uint8_t> base_type;
+ constexpr static AttributeType enum_type = AttributeType::Binary;
+ constexpr static AttributeType enum_base_type = AttributeType::Binary;
+ constexpr static size_t depth = 0;
+ };
+
+
struct type_introspection_visitor : boost::static_visitor<>
{
AttributeType type;