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"
41 void MessageContainer::setPayload(const OCPayload* rep)
45 case PAYLOAD_TYPE_REPRESENTATION:
46 setPayload(reinterpret_cast<const OCRepPayload*>(rep));
48 case PAYLOAD_TYPE_DEVICE:
49 setPayload(reinterpret_cast<const OCDevicePayload*>(rep));
51 case PAYLOAD_TYPE_PLATFORM:
52 setPayload(reinterpret_cast<const OCPlatformPayload*>(rep));
55 throw OC::OCException("Invalid Payload type in setPayload");
60 void MessageContainer::setPayload(const OCDevicePayload* payload)
63 rep.setUri(payload->uri);
64 char uuidString[UUID_STRING_SIZE];
65 if(payload->sid && RAND_UUID_OK == OCConvertUuidToString(payload->sid, uuidString))
67 rep[OC_RSRVD_DEVICE_ID] = std::string(uuidString);
71 rep[OC_RSRVD_DEVICE_ID] = std::string();
73 rep[OC_RSRVD_DEVICE_NAME] = payload->deviceName ?
74 std::string(payload->deviceName) :
76 rep[OC_RSRVD_SPEC_VERSION] = payload->specVersion ?
77 std::string(payload->specVersion) :
79 rep[OC_RSRVD_DATA_MODEL_VERSION] = payload->dataModelVersion ?
80 std::string(payload->dataModelVersion) :
82 m_reps.push_back(std::move(rep));
85 void MessageContainer::setPayload(const OCPlatformPayload* payload)
88 rep.setUri(payload->uri);
90 rep[OC_RSRVD_PLATFORM_ID] = payload->info.platformID ?
91 std::string(payload->info.platformID) :
93 rep[OC_RSRVD_MFG_NAME] = payload->info.manufacturerName ?
94 std::string(payload->info.manufacturerName) :
96 rep[OC_RSRVD_MFG_URL] = payload->info.manufacturerUrl ?
97 std::string(payload->info.manufacturerUrl) :
99 rep[OC_RSRVD_MODEL_NUM] = payload->info.modelNumber ?
100 std::string(payload->info.modelNumber) :
102 rep[OC_RSRVD_MFG_DATE] = payload->info.dateOfManufacture ?
103 std::string(payload->info.dateOfManufacture) :
105 rep[OC_RSRVD_PLATFORM_VERSION] = payload->info.platformVersion ?
106 std::string(payload->info.platformVersion) :
108 rep[OC_RSRVD_OS_VERSION] = payload->info.operatingSystemVersion ?
109 std::string(payload->info.operatingSystemVersion) :
111 rep[OC_RSRVD_HARDWARE_VERSION] = payload->info.hardwareVersion ?
112 std::string(payload->info.hardwareVersion) :
114 rep[OC_RSRVD_FIRMWARE_VERSION] = payload->info.firmwareVersion ?
115 std::string(payload->info.firmwareVersion) :
117 rep[OC_RSRVD_SUPPORT_URL] = payload->info.supportUrl ?
118 std::string(payload->info.supportUrl) :
120 rep[OC_RSRVD_SYSTEM_TIME] = payload->info.systemTime ?
121 std::string(payload->info.systemTime) :
124 m_reps.push_back(std::move(rep));
127 void MessageContainer::setPayload(const OCRepPayload* payload)
129 const OCRepPayload* pl = payload;
132 OCRepresentation cur;
136 this->addRepresentation(cur);
140 OCRepPayload* MessageContainer::getPayload() const
142 OCRepPayload* root = nullptr;
143 for(const auto& r : representations())
147 root = r.getPayload();
151 OCRepPayloadAppend(root, r.getPayload());
158 const std::vector<OCRepresentation>& MessageContainer::representations() const
163 void MessageContainer::addRepresentation(const OCRepresentation& rep)
165 m_reps.push_back(rep);
171 struct get_payload_array: boost::static_visitor<>
174 void operator()(T& /*arr*/)
176 throw std::logic_error("Invalid calc_dimensions_visitor type");
180 void operator()(std::vector<T>& arr)
183 dimensions[0] = arr.size();
186 dimTotal = calcDimTotal(dimensions);
188 array = (void*)OICMalloc(dimTotal * root_size);
190 for(size_t i = 0; i < dimensions[0]; ++i)
192 copy_to_array(arr[i], array, i);
197 void operator()(std::vector<std::vector<T>>& arr)
200 dimensions[0] = arr.size();
203 for(size_t i = 0; i < arr.size(); ++i)
205 dimensions[1] = std::max(dimensions[1], arr[i].size());
207 dimTotal = calcDimTotal(dimensions);
208 array = (void*)OICCalloc(1, dimTotal * root_size);
210 for(size_t i = 0; i < dimensions[0]; ++i)
212 for(size_t j = 0; j < dimensions[1] && j < arr[i].size(); ++j)
214 copy_to_array(arr[i][j], array, i*dimensions[1] + j);
219 void operator()(std::vector<std::vector<std::vector<T>>>& arr)
222 dimensions[0] = arr.size();
225 for(size_t i = 0; i < arr.size(); ++i)
227 dimensions[1] = std::max(dimensions[1], arr[i].size());
229 for(size_t j = 0; j < arr[i].size(); ++j)
231 dimensions[2] = std::max(dimensions[2], arr[i][j].size());
235 dimTotal = calcDimTotal(dimensions);
236 array = (void*)OICCalloc(1, dimTotal * root_size);
238 for(size_t i = 0; i < dimensions[0]; ++i)
240 for(size_t j = 0; j < dimensions[1] && j < arr[i].size(); ++j)
242 for(size_t k = 0; k < dimensions[2] && k < arr[i][j].size(); ++k)
244 copy_to_array(arr[i][j][k], array,
246 dimensions[2] * dimensions[1] * i +
254 void root_size_calc()
256 root_size = sizeof(T);
260 void copy_to_array(T item, void* array, size_t pos)
262 ((T*)array)[pos] = item;
265 size_t dimensions[MAX_REP_ARRAY_DEPTH];
272 void get_payload_array::root_size_calc<int>()
274 root_size = sizeof(int64_t);
278 void get_payload_array::root_size_calc<std::string>()
280 root_size = sizeof(char*);
284 void get_payload_array::root_size_calc<OC::OCRepresentation>()
286 root_size = sizeof(OCRepPayload*);
290 void get_payload_array::copy_to_array(int item, void* array, size_t pos)
292 ((int64_t*)array)[pos] = item;
296 void get_payload_array::copy_to_array(std::_Bit_reference br, void* array, size_t pos)
298 ((bool*)array)[pos] = static_cast<bool>(br);
302 void get_payload_array::copy_to_array(std::string item, void* array, size_t pos)
304 ((char**)array)[pos] = OICStrdup(item.c_str());
308 void get_payload_array::copy_to_array(std::string& item, void* array, size_t pos)
310 ((char**)array)[pos] = OICStrdup(item.c_str());
314 void get_payload_array::copy_to_array(const std::string& item, void* array, size_t pos)
316 ((char**)array)[pos] = OICStrdup(item.c_str());
320 void get_payload_array::copy_to_array(OC::OCRepresentation item, void* array, size_t pos)
322 ((OCRepPayload**)array)[pos] = item.getPayload();
325 void OCRepresentation::getPayloadArray(OCRepPayload* payload,
326 const OCRepresentation::AttributeItem& item) const
328 get_payload_array vis{};
329 boost::apply_visitor(vis, m_values[item.attrname()]);
332 switch(item.base_type())
334 case AttributeType::Integer:
335 OCRepPayloadSetIntArrayAsOwner(payload, item.attrname().c_str(),
339 case AttributeType::Double:
340 OCRepPayloadSetDoubleArrayAsOwner(payload, item.attrname().c_str(),
344 case AttributeType::Boolean:
345 OCRepPayloadSetBoolArrayAsOwner(payload, item.attrname().c_str(),
349 case AttributeType::String:
350 OCRepPayloadSetStringArrayAsOwner(payload, item.attrname().c_str(),
354 case AttributeType::OCRepresentation:
355 OCRepPayloadSetPropObjectArrayAsOwner(payload, item.attrname().c_str(),
356 (OCRepPayload**)vis.array, vis.dimensions);
359 throw std::logic_error(std::string("GetPayloadArray: Not Implemented") +
360 std::to_string((int)item.base_type()));
364 OCRepPayload* OCRepresentation::getPayload() const
366 OCRepPayload* root = OCRepPayloadCreate();
369 throw std::bad_alloc();
372 OCRepPayloadSetUri(root, getUri().c_str());
374 for(const std::string& type : getResourceTypes())
376 OCRepPayloadAddResourceType(root, type.c_str());
379 for(const std::string& iface : getResourceInterfaces())
381 OCRepPayloadAddInterface(root, iface.c_str());
384 for(auto& val : *this)
388 case AttributeType::Null:
389 OCRepPayloadSetNull(root, val.attrname().c_str());
391 case AttributeType::Integer:
392 OCRepPayloadSetPropInt(root, val.attrname().c_str(), static_cast<int>(val));
394 case AttributeType::Double:
395 OCRepPayloadSetPropDouble(root, val.attrname().c_str(),
396 val.getValue<double>());
398 case AttributeType::Boolean:
399 OCRepPayloadSetPropBool(root, val.attrname().c_str(), val.getValue<bool>());
401 case AttributeType::String:
402 OCRepPayloadSetPropString(root, val.attrname().c_str(),
403 static_cast<std::string>(val).c_str());
405 case AttributeType::OCRepresentation:
406 OCRepPayloadSetPropObjectAsOwner(root, val.attrname().c_str(),
407 static_cast<OCRepresentation>(val).getPayload());
409 case AttributeType::Vector:
410 getPayloadArray(root, val);
413 throw std::logic_error(std::string("Getpayload: Not Implemented") +
414 std::to_string((int)val.type()));
422 size_t calcArrayDepth(const size_t dimensions[MAX_REP_ARRAY_DEPTH])
424 if(dimensions[0] == 0)
426 throw std::logic_error("invalid calcArrayDepth");
428 else if(dimensions[1] == 0)
432 else if (dimensions[2] == 0)
443 T OCRepresentation::payload_array_helper_copy(size_t index, const OCRepPayloadValue* pl)
445 throw std::logic_error("payload_array_helper_copy: unsupported type");
448 int OCRepresentation::payload_array_helper_copy<int>(size_t index, const OCRepPayloadValue* pl)
450 return pl->arr.iArray[index];
453 double OCRepresentation::payload_array_helper_copy<double>(size_t index, const OCRepPayloadValue* pl)
455 return pl->arr.dArray[index];
458 bool OCRepresentation::payload_array_helper_copy<bool>(size_t index, const OCRepPayloadValue* pl)
460 return pl->arr.bArray[index];
463 std::string OCRepresentation::payload_array_helper_copy<std::string>(
464 size_t index, const OCRepPayloadValue* pl)
466 if (pl->arr.strArray[index])
468 return std::string(pl->arr.strArray[index]);
472 return std::string{};
476 OCRepresentation OCRepresentation::payload_array_helper_copy<OCRepresentation>(
477 size_t index, const OCRepPayloadValue* pl)
480 if (pl->arr.objArray[index])
482 r.setPayload(pl->arr.objArray[index]);
488 void OCRepresentation::payload_array_helper(const OCRepPayloadValue* pl, size_t depth)
492 std::vector<T> val(pl->arr.dimensions[0]);
494 for(size_t i = 0; i < pl->arr.dimensions[0]; ++i)
496 val[i] = payload_array_helper_copy<T>(i, pl);
498 this->setValue(std::string(pl->name), val);
502 std::vector<std::vector<T>> val(pl->arr.dimensions[0]);
503 for(size_t i = 0; i < pl->arr.dimensions[0]; ++i)
505 val[i].resize(pl->arr.dimensions[1]);
506 for(size_t j = 0; j < pl->arr.dimensions[1]; ++j)
508 val[i][j] = payload_array_helper_copy<T>(
509 i * pl->arr.dimensions[1] + j, pl);
512 this->setValue(std::string(pl->name), val);
516 std::vector<std::vector<std::vector<T>>> val(pl->arr.dimensions[0]);
517 for(size_t i = 0; i < pl->arr.dimensions[0]; ++i)
519 val[i].resize(pl->arr.dimensions[1]);
520 for(size_t j = 0; j < pl->arr.dimensions[1]; ++j)
522 val[i][j].resize(pl->arr.dimensions[2]);
523 for(size_t k = 0; k < pl->arr.dimensions[2]; ++k)
525 val[i][j][k] = payload_array_helper_copy<T>(
526 pl->arr.dimensions[2] * j +
527 pl->arr.dimensions[2] * pl->arr.dimensions[1] * i +
533 this->setValue(std::string(pl->name), val);
537 throw std::logic_error("Invalid depth in payload_array_helper");
541 void OCRepresentation::setPayloadArray(const OCRepPayloadValue* pl)
547 payload_array_helper<int>(pl, calcArrayDepth(pl->arr.dimensions));
549 case OCREP_PROP_DOUBLE:
550 payload_array_helper<double>(pl, calcArrayDepth(pl->arr.dimensions));
552 case OCREP_PROP_BOOL:
553 payload_array_helper<bool>(pl, calcArrayDepth(pl->arr.dimensions));
555 case OCREP_PROP_STRING:
556 payload_array_helper<std::string>(pl, calcArrayDepth(pl->arr.dimensions));
558 case OCREP_PROP_OBJECT:
559 payload_array_helper<OCRepresentation>(pl, calcArrayDepth(pl->arr.dimensions));
562 throw std::logic_error("setPayload array invalid type");
567 void OCRepresentation::setPayload(const OCRepPayload* pl)
571 OCStringLL* ll = pl->types;
574 addResourceType(ll->value);
581 addResourceInterface(ll->value);
585 OCRepPayloadValue* val = pl->values;
591 case OCREP_PROP_NULL:
595 setValue<int>(val->name, val->i);
597 case OCREP_PROP_DOUBLE:
598 setValue<double>(val->name, val->d);
600 case OCREP_PROP_BOOL:
601 setValue<bool>(val->name, val->b);
603 case OCREP_PROP_STRING:
604 setValue<std::string>(val->name, val->str);
606 case OCREP_PROP_OBJECT:
608 OCRepresentation cur;
609 cur.setPayload(val->obj);
610 setValue<OCRepresentation>(val->name, cur);
613 case OCREP_PROP_ARRAY:
614 setPayloadArray(val);
617 throw std::logic_error(std::string("Not Implemented!") +
618 std::to_string((int)val->type));
625 void OCRepresentation::addChild(const OCRepresentation& rep)
627 m_children.push_back(rep);
630 void OCRepresentation::clearChildren()
635 const std::vector<OCRepresentation>& OCRepresentation::getChildren() const
640 void OCRepresentation::setChildren(const std::vector<OCRepresentation>& children)
642 m_children = children;
644 void OCRepresentation::setUri(const char* uri)
646 m_uri = uri ? uri : "";
649 void OCRepresentation::setUri(const std::string& uri)
654 std::string OCRepresentation::getUri() const
659 const std::vector<std::string>& OCRepresentation::getResourceTypes() const
661 return m_resourceTypes;
664 void OCRepresentation::setResourceTypes(const std::vector<std::string>& resourceTypes)
666 m_resourceTypes = resourceTypes;
669 void OCRepresentation::addResourceType(const std::string& str)
671 m_resourceTypes.push_back(str);
674 const std::vector<std::string>& OCRepresentation::getResourceInterfaces() const
679 void OCRepresentation::addResourceInterface(const std::string& str)
681 m_interfaces.push_back(str);
684 void OCRepresentation::setResourceInterfaces(const std::vector<std::string>& resourceInterfaces)
686 m_interfaces = resourceInterfaces;
689 bool OCRepresentation::hasAttribute(const std::string& str) const
691 return m_values.find(str) != m_values.end();
694 bool OCRepresentation::emptyData() const
696 // This logic is meant to determine whether based on the JSON serialization rules
697 // if this object will result in empty JSON. URI is only serialized if there is valid
698 // data, ResourceType and Interfaces are only serialized if we are a nothing, a
699 // child of a default or link item.
700 // Our values array is only printed in the if we are the child of a Batch resource,
701 // the parent in a 'default' situation, or not in a child/parent relationship.
706 else if ((m_interfaceType == InterfaceType::None
707 || m_interfaceType==InterfaceType::DefaultChild
708 || m_interfaceType==InterfaceType::LinkChild)
709 && (m_resourceTypes.size()>0 || m_interfaces.size()>0))
713 else if((m_interfaceType == InterfaceType::None
714 || m_interfaceType == InterfaceType::BatchChild
715 || m_interfaceType == InterfaceType::DefaultParent)
716 && m_values.size()>0)
721 if(m_children.size() > 0)
729 int OCRepresentation::numberOfAttributes() const
731 return m_values.size();
734 bool OCRepresentation::erase(const std::string& str)
736 return m_values.erase(str);
739 void OCRepresentation::setNULL(const std::string& str)
741 m_values[str] = OC::NullType();
744 bool OCRepresentation::isNULL(const std::string& str) const
746 auto x = m_values.find(str);
748 if(m_values.end() != x)
750 return x->second.which() == AttributeValueNullIndex;
754 throw OCException(OC::Exception::INVALID_ATTRIBUTE+ str);
761 std::ostream& operator <<(std::ostream& os, const AttributeType at)
765 case AttributeType::Null:
768 case AttributeType::Integer:
771 case AttributeType::Double:
774 case AttributeType::Boolean:
777 case AttributeType::String:
780 case AttributeType::OCRepresentation:
781 os << "OCRepresentation";
783 case AttributeType::Vector:
791 // STL Container For OCRepresentation
794 OCRepresentation::AttributeItem::AttributeItem(const std::string& name,
795 std::map<std::string, AttributeValue>& vals):
796 m_attrName(name), m_values(vals){}
798 OCRepresentation::AttributeItem OCRepresentation::operator[](const std::string& key)
800 OCRepresentation::AttributeItem attr{key, m_values};
801 return std::move(attr);
804 const OCRepresentation::AttributeItem OCRepresentation::operator[](const std::string& key) const
806 OCRepresentation::AttributeItem attr{key, m_values};
807 return std::move(attr);
810 const std::string& OCRepresentation::AttributeItem::attrname() const
815 template<typename T, typename = void>
818 // contains the actual type
820 // contains the inner most vector-type
822 // contains the AttributeType for this item
823 constexpr static AttributeType enum_type =
824 AttributeTypeConvert<T>::type;
825 // contains the AttributeType for this base-type
826 constexpr static AttributeType enum_base_type =
827 AttributeTypeConvert<T>::type;
828 // depth of the vector
829 constexpr static size_t depth = 0;
833 struct type_info<T, typename std::enable_if<is_vector<T>::value>::type>
836 typedef typename type_info<typename T::value_type>::base_type base_type;
837 constexpr static AttributeType enum_type = AttributeType::Vector;
838 constexpr static AttributeType enum_base_type =
839 type_info<typename T::value_type>::enum_base_type;
840 constexpr static size_t depth = 1 +
841 type_info<typename T::value_type>::depth;
844 struct type_introspection_visitor : boost::static_visitor<>
847 AttributeType base_type;
850 type_introspection_visitor() : boost::static_visitor<>(),
851 type(AttributeType::Null), base_type(AttributeType::Null), depth(0){}
853 template <typename T>
854 void operator()(T const& /*item*/)
856 type = type_info<T>::enum_type;
857 base_type = type_info<T>::enum_base_type;
858 depth = type_info<T>::depth;
862 AttributeType OCRepresentation::AttributeItem::type() const
864 type_introspection_visitor vis;
865 boost::apply_visitor(vis, m_values[m_attrName]);
869 AttributeType OCRepresentation::AttributeItem::base_type() const
871 type_introspection_visitor vis;
872 boost::apply_visitor(vis, m_values[m_attrName]);
873 return vis.base_type;
876 size_t OCRepresentation::AttributeItem::depth() const
878 type_introspection_visitor vis;
879 boost::apply_visitor(vis, m_values[m_attrName]);
883 OCRepresentation::iterator OCRepresentation::begin()
885 return OCRepresentation::iterator(m_values.begin(), m_values);
888 OCRepresentation::const_iterator OCRepresentation::begin() const
890 return OCRepresentation::const_iterator(m_values.begin(), m_values);
893 OCRepresentation::const_iterator OCRepresentation::cbegin() const
895 return OCRepresentation::const_iterator(m_values.cbegin(), m_values);
898 OCRepresentation::iterator OCRepresentation::end()
900 return OCRepresentation::iterator(m_values.end(), m_values);
903 OCRepresentation::const_iterator OCRepresentation::end() const
905 return OCRepresentation::const_iterator(m_values.end(), m_values);
908 OCRepresentation::const_iterator OCRepresentation::cend() const
910 return OCRepresentation::const_iterator(m_values.cend(), m_values);
913 size_t OCRepresentation::size() const
915 return m_values.size();
918 bool OCRepresentation::empty() const
920 return m_values.empty();
923 bool OCRepresentation::iterator::operator==(const OCRepresentation::iterator& rhs) const
925 return m_iterator == rhs.m_iterator;
928 bool OCRepresentation::iterator::operator!=(const OCRepresentation::iterator& rhs) const
930 return m_iterator != rhs.m_iterator;
933 bool OCRepresentation::const_iterator::operator==(
934 const OCRepresentation::const_iterator& rhs) const
936 return m_iterator == rhs.m_iterator;
939 bool OCRepresentation::const_iterator::operator!=(
940 const OCRepresentation::const_iterator& rhs) const
942 return m_iterator != rhs.m_iterator;
945 OCRepresentation::iterator::reference OCRepresentation::iterator::operator*()
950 OCRepresentation::const_iterator::const_reference
951 OCRepresentation::const_iterator::operator*() const
956 OCRepresentation::iterator::pointer OCRepresentation::iterator::operator->()
961 OCRepresentation::const_iterator::const_pointer
962 OCRepresentation::const_iterator::operator->() const
967 OCRepresentation::iterator& OCRepresentation::iterator::operator++()
970 if(m_iterator != m_item.m_values.end())
972 m_item.m_attrName = m_iterator->first;
976 m_item.m_attrName = "";
981 OCRepresentation::const_iterator& OCRepresentation::const_iterator::operator++()
984 if(m_iterator != m_item.m_values.end())
986 m_item.m_attrName = m_iterator->first;
990 m_item.m_attrName = "";
995 OCRepresentation::iterator OCRepresentation::iterator::operator++(int)
997 OCRepresentation::iterator itr(*this);
1002 OCRepresentation::const_iterator OCRepresentation::const_iterator::operator++(int)
1004 OCRepresentation::const_iterator itr(*this);
1009 struct to_string_visitor : boost::static_visitor<>
1012 template <typename T>
1013 void operator()(T const& item)
1015 str = boost::lexical_cast<std::string>(item);
1018 template <typename T>
1019 void operator()(std::vector<T> const& item)
1021 to_string_visitor vis;
1022 std::ostringstream stream;
1025 for(const auto& i : item)
1028 stream << vis.str << " ";
1036 void to_string_visitor::operator()(bool const& item)
1038 str = item ? "true" : "false";
1042 void to_string_visitor::operator()(std::string const& item)
1048 void to_string_visitor::operator()(NullType const& /*item*/)
1054 void to_string_visitor::operator()(OCRepresentation const& /*item*/)
1056 str = "OC::OCRepresentation";
1059 std::string OCRepresentation::getValueToString(const std::string& key) const
1061 auto x = m_values.find(key);
1062 if(x != m_values.end())
1064 to_string_visitor vis;
1065 boost::apply_visitor(vis, x->second);
1066 return std::move(vis.str);
1072 std::string OCRepresentation::AttributeItem::getValueToString() const
1074 to_string_visitor vis;
1075 boost::apply_visitor(vis, m_values[m_attrName]);
1076 return std::move(vis.str);
1079 std::ostream& operator<<(std::ostream& os, const OCRepresentation::AttributeItem& ai)
1081 os << ai.getValueToString();