1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
24 * This file contains the implementation of classes and its members related
25 * to OCRepresentation.
29 #include <OCRepresentation.h>
31 #include <boost/lexical_cast.hpp>
33 #include "ocpayload.h"
35 #include "oic_malloc.h"
36 #include "oic_string.h"
40 static const char COAP[] = "coap://";
41 static const char COAPS[] = "coaps://";
42 static const char COAP_TCP[] = "coap+tcp://";
44 void MessageContainer::setPayload(const OCPayload* rep)
53 case PAYLOAD_TYPE_REPRESENTATION:
54 setPayload(reinterpret_cast<const OCRepPayload*>(rep));
56 case PAYLOAD_TYPE_DEVICE:
57 setPayload(reinterpret_cast<const OCDevicePayload*>(rep));
59 case PAYLOAD_TYPE_PLATFORM:
60 setPayload(reinterpret_cast<const OCPlatformPayload*>(rep));
63 throw OC::OCException("Invalid Payload type in setPayload");
68 void MessageContainer::setPayload(const OCDevicePayload* payload)
70 if (payload == nullptr)
76 rep[OC_RSRVD_DEVICE_ID] = (payload->sid) ?
77 std::string(payload->sid) :
79 rep[OC_RSRVD_DEVICE_NAME] = payload->deviceName ?
80 std::string(payload->deviceName) :
82 rep[OC_RSRVD_SPEC_VERSION] = payload->specVersion ?
83 std::string(payload->specVersion) :
85 rep[OC_RSRVD_DATA_MODEL_VERSION] = payload->dataModelVersion ?
86 std::string(payload->dataModelVersion) :
88 m_reps.push_back(std::move(rep));
91 void MessageContainer::setPayload(const OCPlatformPayload* payload)
93 if (payload == nullptr)
99 rep[OC_RSRVD_PLATFORM_ID] = payload->info.platformID ?
100 std::string(payload->info.platformID) :
102 rep[OC_RSRVD_MFG_NAME] = payload->info.manufacturerName ?
103 std::string(payload->info.manufacturerName) :
105 rep[OC_RSRVD_MFG_URL] = payload->info.manufacturerUrl ?
106 std::string(payload->info.manufacturerUrl) :
108 rep[OC_RSRVD_MODEL_NUM] = payload->info.modelNumber ?
109 std::string(payload->info.modelNumber) :
111 rep[OC_RSRVD_MFG_DATE] = payload->info.dateOfManufacture ?
112 std::string(payload->info.dateOfManufacture) :
114 rep[OC_RSRVD_PLATFORM_VERSION] = payload->info.platformVersion ?
115 std::string(payload->info.platformVersion) :
117 rep[OC_RSRVD_OS_VERSION] = payload->info.operatingSystemVersion ?
118 std::string(payload->info.operatingSystemVersion) :
120 rep[OC_RSRVD_HARDWARE_VERSION] = payload->info.hardwareVersion ?
121 std::string(payload->info.hardwareVersion) :
123 rep[OC_RSRVD_FIRMWARE_VERSION] = payload->info.firmwareVersion ?
124 std::string(payload->info.firmwareVersion) :
126 rep[OC_RSRVD_SUPPORT_URL] = payload->info.supportUrl ?
127 std::string(payload->info.supportUrl) :
129 rep[OC_RSRVD_SYSTEM_TIME] = payload->info.systemTime ?
130 std::string(payload->info.systemTime) :
133 m_reps.push_back(std::move(rep));
136 void MessageContainer::setPayload(const OCRepPayload* payload)
138 const OCRepPayload* pl = payload;
141 OCRepresentation cur;
145 this->addRepresentation(cur);
149 OCRepPayload* MessageContainer::getPayload() const
151 OCRepPayload* root = nullptr;
152 for(const auto& r : representations())
156 root = r.getPayload();
160 OCRepPayloadAppend(root, r.getPayload());
167 const std::vector<OCRepresentation>& MessageContainer::representations() const
172 void MessageContainer::addRepresentation(const OCRepresentation& rep)
174 m_reps.push_back(rep);
180 struct get_payload_array: boost::static_visitor<>
183 void operator()(T& /*arr*/)
185 throw std::logic_error("Invalid calc_dimensions_visitor type");
189 void operator()(std::vector<T>& arr)
192 dimensions[0] = arr.size();
195 dimTotal = calcDimTotal(dimensions);
197 array = (void*)OICMalloc(dimTotal * root_size);
199 for(size_t i = 0; i < dimensions[0]; ++i)
201 copy_to_array(arr[i], array, i);
206 void operator()(std::vector<std::vector<T>>& arr)
209 dimensions[0] = arr.size();
212 for(size_t i = 0; i < arr.size(); ++i)
214 dimensions[1] = std::max(dimensions[1], arr[i].size());
216 dimTotal = calcDimTotal(dimensions);
217 array = (void*)OICCalloc(1, dimTotal * root_size);
219 for(size_t i = 0; i < dimensions[0]; ++i)
221 for(size_t j = 0; j < dimensions[1] && j < arr[i].size(); ++j)
223 copy_to_array(arr[i][j], array, i*dimensions[1] + j);
228 void operator()(std::vector<std::vector<std::vector<T>>>& arr)
231 dimensions[0] = arr.size();
234 for(size_t i = 0; i < arr.size(); ++i)
236 dimensions[1] = std::max(dimensions[1], arr[i].size());
238 for(size_t j = 0; j < arr[i].size(); ++j)
240 dimensions[2] = std::max(dimensions[2], arr[i][j].size());
244 dimTotal = calcDimTotal(dimensions);
245 array = (void*)OICCalloc(1, dimTotal * root_size);
247 for(size_t i = 0; i < dimensions[0]; ++i)
249 for(size_t j = 0; j < dimensions[1] && j < arr[i].size(); ++j)
251 for(size_t k = 0; k < dimensions[2] && k < arr[i][j].size(); ++k)
253 copy_to_array(arr[i][j][k], array,
255 dimensions[2] * dimensions[1] * i +
263 void root_size_calc()
265 root_size = sizeof(T);
269 void copy_to_array(T item, void* array, size_t pos)
271 ((T*)array)[pos] = item;
274 size_t dimensions[MAX_REP_ARRAY_DEPTH];
281 void get_payload_array::root_size_calc<int>()
283 root_size = sizeof(int64_t);
287 void get_payload_array::root_size_calc<std::string>()
289 root_size = sizeof(char*);
293 void get_payload_array::root_size_calc<OC::OCRepresentation>()
295 root_size = sizeof(OCRepPayload*);
299 void get_payload_array::copy_to_array(int item, void* array, size_t pos)
301 ((int64_t*)array)[pos] = item;
305 void get_payload_array::copy_to_array(std::_Bit_reference br, void* array, size_t pos)
307 ((bool*)array)[pos] = static_cast<bool>(br);
311 void get_payload_array::copy_to_array(std::string item, void* array, size_t pos)
313 ((char**)array)[pos] = OICStrdup(item.c_str());
317 void get_payload_array::copy_to_array(std::string& item, void* array, size_t pos)
319 ((char**)array)[pos] = OICStrdup(item.c_str());
323 void get_payload_array::copy_to_array(const std::string& item, void* array, size_t pos)
325 ((char**)array)[pos] = OICStrdup(item.c_str());
329 void get_payload_array::copy_to_array(OC::OCRepresentation item, void* array, size_t pos)
331 ((OCRepPayload**)array)[pos] = item.getPayload();
334 void OCRepresentation::getPayloadArray(OCRepPayload* payload,
335 const OCRepresentation::AttributeItem& item) const
337 get_payload_array vis{};
338 boost::apply_visitor(vis, m_values[item.attrname()]);
341 switch(item.base_type())
343 case AttributeType::Integer:
344 OCRepPayloadSetIntArrayAsOwner(payload, item.attrname().c_str(),
348 case AttributeType::Double:
349 OCRepPayloadSetDoubleArrayAsOwner(payload, item.attrname().c_str(),
353 case AttributeType::Boolean:
354 OCRepPayloadSetBoolArrayAsOwner(payload, item.attrname().c_str(),
358 case AttributeType::String:
359 OCRepPayloadSetStringArrayAsOwner(payload, item.attrname().c_str(),
363 case AttributeType::OCRepresentation:
364 OCRepPayloadSetPropObjectArrayAsOwner(payload, item.attrname().c_str(),
365 (OCRepPayload**)vis.array, vis.dimensions);
368 throw std::logic_error(std::string("GetPayloadArray: Not Implemented") +
369 std::to_string((int)item.base_type()));
373 OCRepPayload* OCRepresentation::getPayload() const
375 OCRepPayload* root = OCRepPayloadCreate();
378 throw std::bad_alloc();
381 OCRepPayloadSetUri(root, getUri().c_str());
383 for(const std::string& type : getResourceTypes())
385 OCRepPayloadAddResourceType(root, type.c_str());
388 for(const std::string& iface : getResourceInterfaces())
390 OCRepPayloadAddInterface(root, iface.c_str());
393 for(auto& val : *this)
397 case AttributeType::Null:
398 OCRepPayloadSetNull(root, val.attrname().c_str());
400 case AttributeType::Integer:
401 OCRepPayloadSetPropInt(root, val.attrname().c_str(), static_cast<int>(val));
403 case AttributeType::Double:
404 OCRepPayloadSetPropDouble(root, val.attrname().c_str(),
405 val.getValue<double>());
407 case AttributeType::Boolean:
408 OCRepPayloadSetPropBool(root, val.attrname().c_str(), val.getValue<bool>());
410 case AttributeType::String:
411 OCRepPayloadSetPropString(root, val.attrname().c_str(),
412 static_cast<std::string>(val).c_str());
414 case AttributeType::OCRepresentation:
415 OCRepPayloadSetPropObjectAsOwner(root, val.attrname().c_str(),
416 static_cast<OCRepresentation>(val).getPayload());
418 case AttributeType::Vector:
419 getPayloadArray(root, val);
422 throw std::logic_error(std::string("Getpayload: Not Implemented") +
423 std::to_string((int)val.type()));
431 size_t calcArrayDepth(const size_t dimensions[MAX_REP_ARRAY_DEPTH])
433 if (dimensions[0] == 0)
435 throw std::logic_error("invalid calcArrayDepth");
437 else if (dimensions[1] == 0)
441 else if (dimensions[2] == 0)
452 T OCRepresentation::payload_array_helper_copy(size_t index, const OCRepPayloadValue* pl)
454 throw std::logic_error("payload_array_helper_copy: unsupported type");
457 int OCRepresentation::payload_array_helper_copy<int>(size_t index, const OCRepPayloadValue* pl)
459 return pl->arr.iArray[index];
462 double OCRepresentation::payload_array_helper_copy<double>(size_t index, const OCRepPayloadValue* pl)
464 return pl->arr.dArray[index];
467 bool OCRepresentation::payload_array_helper_copy<bool>(size_t index, const OCRepPayloadValue* pl)
469 return pl->arr.bArray[index];
472 std::string OCRepresentation::payload_array_helper_copy<std::string>(
473 size_t index, const OCRepPayloadValue* pl)
475 if (pl->arr.strArray[index])
477 return std::string(pl->arr.strArray[index]);
481 return std::string{};
485 OCRepresentation OCRepresentation::payload_array_helper_copy<OCRepresentation>(
486 size_t index, const OCRepPayloadValue* pl)
489 if (pl->arr.objArray[index])
491 r.setPayload(pl->arr.objArray[index]);
497 void OCRepresentation::payload_array_helper(const OCRepPayloadValue* pl, size_t depth)
501 std::vector<T> val(pl->arr.dimensions[0]);
503 for(size_t i = 0; i < pl->arr.dimensions[0]; ++i)
505 val[i] = payload_array_helper_copy<T>(i, pl);
507 this->setValue(std::string(pl->name), val);
511 std::vector<std::vector<T>> val(pl->arr.dimensions[0]);
512 for(size_t i = 0; i < pl->arr.dimensions[0]; ++i)
514 val[i].resize(pl->arr.dimensions[1]);
515 for(size_t j = 0; j < pl->arr.dimensions[1]; ++j)
517 val[i][j] = payload_array_helper_copy<T>(
518 i * pl->arr.dimensions[1] + j, pl);
521 this->setValue(std::string(pl->name), val);
525 std::vector<std::vector<std::vector<T>>> val(pl->arr.dimensions[0]);
526 for(size_t i = 0; i < pl->arr.dimensions[0]; ++i)
528 val[i].resize(pl->arr.dimensions[1]);
529 for(size_t j = 0; j < pl->arr.dimensions[1]; ++j)
531 val[i][j].resize(pl->arr.dimensions[2]);
532 for(size_t k = 0; k < pl->arr.dimensions[2]; ++k)
534 val[i][j][k] = payload_array_helper_copy<T>(
535 pl->arr.dimensions[2] * j +
536 pl->arr.dimensions[2] * pl->arr.dimensions[1] * i +
542 this->setValue(std::string(pl->name), val);
546 throw std::logic_error("Invalid depth in payload_array_helper");
550 void OCRepresentation::setPayloadArray(const OCRepPayloadValue* pl)
556 payload_array_helper<int>(pl, calcArrayDepth(pl->arr.dimensions));
558 case OCREP_PROP_DOUBLE:
559 payload_array_helper<double>(pl, calcArrayDepth(pl->arr.dimensions));
561 case OCREP_PROP_BOOL:
562 payload_array_helper<bool>(pl, calcArrayDepth(pl->arr.dimensions));
564 case OCREP_PROP_STRING:
565 payload_array_helper<std::string>(pl, calcArrayDepth(pl->arr.dimensions));
567 case OCREP_PROP_OBJECT:
568 payload_array_helper<OCRepresentation>(pl, calcArrayDepth(pl->arr.dimensions));
571 throw std::logic_error("setPayload array invalid type");
576 void OCRepresentation::setPayload(const OCRepPayload* pl)
580 OCStringLL* ll = pl->types;
583 addResourceType(ll->value);
590 addResourceInterface(ll->value);
594 OCRepPayloadValue* val = pl->values;
600 case OCREP_PROP_NULL:
604 setValue<int>(val->name, val->i);
606 case OCREP_PROP_DOUBLE:
607 setValue<double>(val->name, val->d);
609 case OCREP_PROP_BOOL:
610 setValue<bool>(val->name, val->b);
612 case OCREP_PROP_STRING:
613 setValue<std::string>(val->name, val->str);
615 case OCREP_PROP_OBJECT:
617 OCRepresentation cur;
618 cur.setPayload(val->obj);
619 setValue<OCRepresentation>(val->name, cur);
622 case OCREP_PROP_ARRAY:
623 setPayloadArray(val);
626 throw std::logic_error(std::string("Not Implemented!") +
627 std::to_string((int)val->type));
634 void OCRepresentation::addChild(const OCRepresentation& rep)
636 m_children.push_back(rep);
639 void OCRepresentation::clearChildren()
644 const std::vector<OCRepresentation>& OCRepresentation::getChildren() const
649 void OCRepresentation::setChildren(const std::vector<OCRepresentation>& children)
651 m_children = children;
654 void OCRepresentation::setDevAddr(const OCDevAddr m_devAddr)
656 std::ostringstream ss;
657 if (m_devAddr.flags & OC_SECURE)
661 else if (m_devAddr.adapter & OC_ADAPTER_TCP)
669 if (m_devAddr.flags & OC_IP_USE_V6)
671 ss << '[' << m_devAddr.addr << ']';
675 ss << m_devAddr.addr;
679 ss << ':' << m_devAddr.port;
684 const std::string OCRepresentation::getHost() const
689 void OCRepresentation::setUri(const char* uri)
691 m_uri = uri ? uri : "";
694 void OCRepresentation::setUri(const std::string& uri)
699 std::string OCRepresentation::getUri() const
704 const std::vector<std::string>& OCRepresentation::getResourceTypes() const
706 return m_resourceTypes;
709 void OCRepresentation::setResourceTypes(const std::vector<std::string>& resourceTypes)
711 m_resourceTypes = resourceTypes;
714 void OCRepresentation::addResourceType(const std::string& str)
716 m_resourceTypes.push_back(str);
719 const std::vector<std::string>& OCRepresentation::getResourceInterfaces() const
724 void OCRepresentation::addResourceInterface(const std::string& str)
726 m_interfaces.push_back(str);
729 void OCRepresentation::setResourceInterfaces(const std::vector<std::string>& resourceInterfaces)
731 m_interfaces = resourceInterfaces;
734 bool OCRepresentation::hasAttribute(const std::string& str) const
736 return m_values.find(str) != m_values.end();
739 bool OCRepresentation::emptyData() const
741 // This logic is meant to determine whether based on the JSON serialization rules
742 // if this object will result in empty JSON. URI is only serialized if there is valid
743 // data, ResourceType and Interfaces are only serialized if we are a nothing, a
744 // child of a default or link item.
745 // Our values array is only printed in the if we are the child of a Batch resource,
746 // the parent in a 'default' situation, or not in a child/parent relationship.
751 else if ((m_interfaceType == InterfaceType::None
752 || m_interfaceType==InterfaceType::DefaultChild
753 || m_interfaceType==InterfaceType::LinkChild)
754 && (m_resourceTypes.size()>0 || m_interfaces.size()>0))
758 else if ((m_interfaceType == InterfaceType::None
759 || m_interfaceType == InterfaceType::BatchChild
760 || m_interfaceType == InterfaceType::DefaultParent)
761 && m_values.size()>0)
766 if (m_children.size() > 0)
774 int OCRepresentation::numberOfAttributes() const
776 return m_values.size();
779 bool OCRepresentation::erase(const std::string& str)
781 return m_values.erase(str);
784 void OCRepresentation::setNULL(const std::string& str)
786 m_values[str] = OC::NullType();
789 bool OCRepresentation::isNULL(const std::string& str) const
791 auto x = m_values.find(str);
793 if (m_values.end() != x)
795 return x->second.which() == AttributeValueNullIndex;
799 throw OCException(OC::Exception::INVALID_ATTRIBUTE+ str);
806 std::ostream& operator <<(std::ostream& os, const AttributeType at)
810 case AttributeType::Null:
813 case AttributeType::Integer:
816 case AttributeType::Double:
819 case AttributeType::Boolean:
822 case AttributeType::String:
825 case AttributeType::OCRepresentation:
826 os << "OCRepresentation";
828 case AttributeType::Vector:
836 // STL Container For OCRepresentation
839 OCRepresentation::AttributeItem::AttributeItem(const std::string& name,
840 std::map<std::string, AttributeValue>& vals):
841 m_attrName(name), m_values(vals){}
843 OCRepresentation::AttributeItem OCRepresentation::operator[](const std::string& key)
845 OCRepresentation::AttributeItem attr{key, m_values};
846 return std::move(attr);
849 const OCRepresentation::AttributeItem OCRepresentation::operator[](const std::string& key) const
851 OCRepresentation::AttributeItem attr{key, m_values};
852 return std::move(attr);
855 const std::string& OCRepresentation::AttributeItem::attrname() const
860 template<typename T, typename = void>
863 // contains the actual type
865 // contains the inner most vector-type
867 // contains the AttributeType for this item
868 constexpr static AttributeType enum_type =
869 AttributeTypeConvert<T>::type;
870 // contains the AttributeType for this base-type
871 constexpr static AttributeType enum_base_type =
872 AttributeTypeConvert<T>::type;
873 // depth of the vector
874 constexpr static size_t depth = 0;
878 struct type_info<T, typename std::enable_if<is_vector<T>::value>::type>
881 typedef typename type_info<typename T::value_type>::base_type base_type;
882 constexpr static AttributeType enum_type = AttributeType::Vector;
883 constexpr static AttributeType enum_base_type =
884 type_info<typename T::value_type>::enum_base_type;
885 constexpr static size_t depth = 1 +
886 type_info<typename T::value_type>::depth;
889 struct type_introspection_visitor : boost::static_visitor<>
892 AttributeType base_type;
895 type_introspection_visitor() : boost::static_visitor<>(),
896 type(AttributeType::Null), base_type(AttributeType::Null), depth(0){}
898 template <typename T>
899 void operator()(T const& /*item*/)
901 type = type_info<T>::enum_type;
902 base_type = type_info<T>::enum_base_type;
903 depth = type_info<T>::depth;
907 AttributeType OCRepresentation::AttributeItem::type() const
909 type_introspection_visitor vis;
910 boost::apply_visitor(vis, m_values[m_attrName]);
914 AttributeType OCRepresentation::AttributeItem::base_type() const
916 type_introspection_visitor vis;
917 boost::apply_visitor(vis, m_values[m_attrName]);
918 return vis.base_type;
921 size_t OCRepresentation::AttributeItem::depth() const
923 type_introspection_visitor vis;
924 boost::apply_visitor(vis, m_values[m_attrName]);
928 OCRepresentation::iterator OCRepresentation::begin()
930 return OCRepresentation::iterator(m_values.begin(), m_values);
933 OCRepresentation::const_iterator OCRepresentation::begin() const
935 return OCRepresentation::const_iterator(m_values.begin(), m_values);
938 OCRepresentation::const_iterator OCRepresentation::cbegin() const
940 return OCRepresentation::const_iterator(m_values.cbegin(), m_values);
943 OCRepresentation::iterator OCRepresentation::end()
945 return OCRepresentation::iterator(m_values.end(), m_values);
948 OCRepresentation::const_iterator OCRepresentation::end() const
950 return OCRepresentation::const_iterator(m_values.end(), m_values);
953 OCRepresentation::const_iterator OCRepresentation::cend() const
955 return OCRepresentation::const_iterator(m_values.cend(), m_values);
958 size_t OCRepresentation::size() const
960 return m_values.size();
963 bool OCRepresentation::empty() const
965 return m_values.empty();
968 bool OCRepresentation::iterator::operator==(const OCRepresentation::iterator& rhs) const
970 return m_iterator == rhs.m_iterator;
973 bool OCRepresentation::iterator::operator!=(const OCRepresentation::iterator& rhs) const
975 return m_iterator != rhs.m_iterator;
978 bool OCRepresentation::const_iterator::operator==(
979 const OCRepresentation::const_iterator& rhs) const
981 return m_iterator == rhs.m_iterator;
984 bool OCRepresentation::const_iterator::operator!=(
985 const OCRepresentation::const_iterator& rhs) const
987 return m_iterator != rhs.m_iterator;
990 OCRepresentation::iterator::reference OCRepresentation::iterator::operator*()
995 OCRepresentation::const_iterator::const_reference
996 OCRepresentation::const_iterator::operator*() const
1001 OCRepresentation::iterator::pointer OCRepresentation::iterator::operator->()
1006 OCRepresentation::const_iterator::const_pointer
1007 OCRepresentation::const_iterator::operator->() const
1012 OCRepresentation::iterator& OCRepresentation::iterator::operator++()
1015 if (m_iterator != m_item.m_values.end())
1017 m_item.m_attrName = m_iterator->first;
1021 m_item.m_attrName = "";
1026 OCRepresentation::const_iterator& OCRepresentation::const_iterator::operator++()
1029 if (m_iterator != m_item.m_values.end())
1031 m_item.m_attrName = m_iterator->first;
1035 m_item.m_attrName = "";
1040 OCRepresentation::iterator OCRepresentation::iterator::operator++(int)
1042 OCRepresentation::iterator itr(*this);
1047 OCRepresentation::const_iterator OCRepresentation::const_iterator::operator++(int)
1049 OCRepresentation::const_iterator itr(*this);
1054 struct to_string_visitor : boost::static_visitor<>
1057 template <typename T>
1058 void operator()(T const& item)
1060 str = boost::lexical_cast<std::string>(item);
1063 template <typename T>
1064 void operator()(std::vector<T> const& item)
1066 to_string_visitor vis;
1067 std::ostringstream stream;
1070 for(const auto& i : item)
1073 stream << vis.str << " ";
1081 void to_string_visitor::operator()(bool const& item)
1083 str = item ? "true" : "false";
1087 void to_string_visitor::operator()(std::string const& item)
1093 void to_string_visitor::operator()(NullType const& /*item*/)
1099 void to_string_visitor::operator()(OCRepresentation const& /*item*/)
1101 str = "OC::OCRepresentation";
1104 std::string OCRepresentation::getValueToString(const std::string& key) const
1106 auto x = m_values.find(key);
1107 if (x != m_values.end())
1109 to_string_visitor vis;
1110 boost::apply_visitor(vis, x->second);
1111 return std::move(vis.str);
1117 std::string OCRepresentation::AttributeItem::getValueToString() const
1119 to_string_visitor vis;
1120 boost::apply_visitor(vis, m_values[m_attrName]);
1121 return std::move(vis.str);
1124 std::ostream& operator<<(std::ostream& os, const OCRepresentation::AttributeItem& ai)
1126 os << ai.getValueToString();