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)
48 case PAYLOAD_TYPE_REPRESENTATION:
49 setPayload(reinterpret_cast<const OCRepPayload*>(rep));
51 case PAYLOAD_TYPE_DEVICE:
52 setPayload(reinterpret_cast<const OCDevicePayload*>(rep));
54 case PAYLOAD_TYPE_PLATFORM:
55 setPayload(reinterpret_cast<const OCPlatformPayload*>(rep));
58 throw OC::OCException("Invalid Payload type in setPayload");
63 void MessageContainer::setPayload(const OCDevicePayload* payload)
66 char uuidString[UUID_STRING_SIZE];
67 if(payload->sid && RAND_UUID_OK == OCConvertUuidToString(payload->sid, uuidString))
69 rep[OC_RSRVD_DEVICE_ID] = std::string(uuidString);
73 rep[OC_RSRVD_DEVICE_ID] = std::string();
75 rep[OC_RSRVD_DEVICE_NAME] = payload->deviceName ?
76 std::string(payload->deviceName) :
78 rep[OC_RSRVD_SPEC_VERSION] = payload->specVersion ?
79 std::string(payload->specVersion) :
81 rep[OC_RSRVD_DATA_MODEL_VERSION] = payload->dataModelVersion ?
82 std::string(payload->dataModelVersion) :
84 m_reps.push_back(std::move(rep));
87 void MessageContainer::setPayload(const OCPlatformPayload* payload)
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;
645 void OCRepresentation::setDevAddr(const OCDevAddr m_devAddr)
647 std::ostringstream ss;
648 if (m_devAddr.flags & OC_SECURE)
652 else if (m_devAddr.adapter & OC_ADAPTER_TCP)
660 if (m_devAddr.flags & OC_IP_USE_V6)
662 ss << '[' << m_devAddr.addr << ']';
666 ss << m_devAddr.addr;
670 ss << ':' << m_devAddr.port;
675 const std::string OCRepresentation::getHost() const
680 void OCRepresentation::setUri(const char* uri)
682 m_uri = uri ? uri : "";
685 void OCRepresentation::setUri(const std::string& uri)
690 std::string OCRepresentation::getUri() const
695 const std::vector<std::string>& OCRepresentation::getResourceTypes() const
697 return m_resourceTypes;
700 void OCRepresentation::setResourceTypes(const std::vector<std::string>& resourceTypes)
702 m_resourceTypes = resourceTypes;
705 void OCRepresentation::addResourceType(const std::string& str)
707 m_resourceTypes.push_back(str);
710 const std::vector<std::string>& OCRepresentation::getResourceInterfaces() const
715 void OCRepresentation::addResourceInterface(const std::string& str)
717 m_interfaces.push_back(str);
720 void OCRepresentation::setResourceInterfaces(const std::vector<std::string>& resourceInterfaces)
722 m_interfaces = resourceInterfaces;
725 bool OCRepresentation::hasAttribute(const std::string& str) const
727 return m_values.find(str) != m_values.end();
730 bool OCRepresentation::emptyData() const
732 // This logic is meant to determine whether based on the JSON serialization rules
733 // if this object will result in empty JSON. URI is only serialized if there is valid
734 // data, ResourceType and Interfaces are only serialized if we are a nothing, a
735 // child of a default or link item.
736 // Our values array is only printed in the if we are the child of a Batch resource,
737 // the parent in a 'default' situation, or not in a child/parent relationship.
742 else if ((m_interfaceType == InterfaceType::None
743 || m_interfaceType==InterfaceType::DefaultChild
744 || m_interfaceType==InterfaceType::LinkChild)
745 && (m_resourceTypes.size()>0 || m_interfaces.size()>0))
749 else if((m_interfaceType == InterfaceType::None
750 || m_interfaceType == InterfaceType::BatchChild
751 || m_interfaceType == InterfaceType::DefaultParent)
752 && m_values.size()>0)
757 if(m_children.size() > 0)
765 int OCRepresentation::numberOfAttributes() const
767 return m_values.size();
770 bool OCRepresentation::erase(const std::string& str)
772 return m_values.erase(str);
775 void OCRepresentation::setNULL(const std::string& str)
777 m_values[str] = OC::NullType();
780 bool OCRepresentation::isNULL(const std::string& str) const
782 auto x = m_values.find(str);
784 if(m_values.end() != x)
786 return x->second.which() == AttributeValueNullIndex;
790 throw OCException(OC::Exception::INVALID_ATTRIBUTE+ str);
797 std::ostream& operator <<(std::ostream& os, const AttributeType at)
801 case AttributeType::Null:
804 case AttributeType::Integer:
807 case AttributeType::Double:
810 case AttributeType::Boolean:
813 case AttributeType::String:
816 case AttributeType::OCRepresentation:
817 os << "OCRepresentation";
819 case AttributeType::Vector:
827 // STL Container For OCRepresentation
830 OCRepresentation::AttributeItem::AttributeItem(const std::string& name,
831 std::map<std::string, AttributeValue>& vals):
832 m_attrName(name), m_values(vals){}
834 OCRepresentation::AttributeItem OCRepresentation::operator[](const std::string& key)
836 OCRepresentation::AttributeItem attr{key, m_values};
837 return std::move(attr);
840 const OCRepresentation::AttributeItem OCRepresentation::operator[](const std::string& key) const
842 OCRepresentation::AttributeItem attr{key, m_values};
843 return std::move(attr);
846 const std::string& OCRepresentation::AttributeItem::attrname() const
851 template<typename T, typename = void>
854 // contains the actual type
856 // contains the inner most vector-type
858 // contains the AttributeType for this item
859 constexpr static AttributeType enum_type =
860 AttributeTypeConvert<T>::type;
861 // contains the AttributeType for this base-type
862 constexpr static AttributeType enum_base_type =
863 AttributeTypeConvert<T>::type;
864 // depth of the vector
865 constexpr static size_t depth = 0;
869 struct type_info<T, typename std::enable_if<is_vector<T>::value>::type>
872 typedef typename type_info<typename T::value_type>::base_type base_type;
873 constexpr static AttributeType enum_type = AttributeType::Vector;
874 constexpr static AttributeType enum_base_type =
875 type_info<typename T::value_type>::enum_base_type;
876 constexpr static size_t depth = 1 +
877 type_info<typename T::value_type>::depth;
880 struct type_introspection_visitor : boost::static_visitor<>
883 AttributeType base_type;
886 type_introspection_visitor() : boost::static_visitor<>(),
887 type(AttributeType::Null), base_type(AttributeType::Null), depth(0){}
889 template <typename T>
890 void operator()(T const& /*item*/)
892 type = type_info<T>::enum_type;
893 base_type = type_info<T>::enum_base_type;
894 depth = type_info<T>::depth;
898 AttributeType OCRepresentation::AttributeItem::type() const
900 type_introspection_visitor vis;
901 boost::apply_visitor(vis, m_values[m_attrName]);
905 AttributeType OCRepresentation::AttributeItem::base_type() const
907 type_introspection_visitor vis;
908 boost::apply_visitor(vis, m_values[m_attrName]);
909 return vis.base_type;
912 size_t OCRepresentation::AttributeItem::depth() const
914 type_introspection_visitor vis;
915 boost::apply_visitor(vis, m_values[m_attrName]);
919 OCRepresentation::iterator OCRepresentation::begin()
921 return OCRepresentation::iterator(m_values.begin(), m_values);
924 OCRepresentation::const_iterator OCRepresentation::begin() const
926 return OCRepresentation::const_iterator(m_values.begin(), m_values);
929 OCRepresentation::const_iterator OCRepresentation::cbegin() const
931 return OCRepresentation::const_iterator(m_values.cbegin(), m_values);
934 OCRepresentation::iterator OCRepresentation::end()
936 return OCRepresentation::iterator(m_values.end(), m_values);
939 OCRepresentation::const_iterator OCRepresentation::end() const
941 return OCRepresentation::const_iterator(m_values.end(), m_values);
944 OCRepresentation::const_iterator OCRepresentation::cend() const
946 return OCRepresentation::const_iterator(m_values.cend(), m_values);
949 size_t OCRepresentation::size() const
951 return m_values.size();
954 bool OCRepresentation::empty() const
956 return m_values.empty();
959 bool OCRepresentation::iterator::operator==(const OCRepresentation::iterator& rhs) const
961 return m_iterator == rhs.m_iterator;
964 bool OCRepresentation::iterator::operator!=(const OCRepresentation::iterator& rhs) const
966 return m_iterator != rhs.m_iterator;
969 bool OCRepresentation::const_iterator::operator==(
970 const OCRepresentation::const_iterator& rhs) const
972 return m_iterator == rhs.m_iterator;
975 bool OCRepresentation::const_iterator::operator!=(
976 const OCRepresentation::const_iterator& rhs) const
978 return m_iterator != rhs.m_iterator;
981 OCRepresentation::iterator::reference OCRepresentation::iterator::operator*()
986 OCRepresentation::const_iterator::const_reference
987 OCRepresentation::const_iterator::operator*() const
992 OCRepresentation::iterator::pointer OCRepresentation::iterator::operator->()
997 OCRepresentation::const_iterator::const_pointer
998 OCRepresentation::const_iterator::operator->() const
1003 OCRepresentation::iterator& OCRepresentation::iterator::operator++()
1006 if(m_iterator != m_item.m_values.end())
1008 m_item.m_attrName = m_iterator->first;
1012 m_item.m_attrName = "";
1017 OCRepresentation::const_iterator& OCRepresentation::const_iterator::operator++()
1020 if(m_iterator != m_item.m_values.end())
1022 m_item.m_attrName = m_iterator->first;
1026 m_item.m_attrName = "";
1031 OCRepresentation::iterator OCRepresentation::iterator::operator++(int)
1033 OCRepresentation::iterator itr(*this);
1038 OCRepresentation::const_iterator OCRepresentation::const_iterator::operator++(int)
1040 OCRepresentation::const_iterator itr(*this);
1045 struct to_string_visitor : boost::static_visitor<>
1048 template <typename T>
1049 void operator()(T const& item)
1051 str = boost::lexical_cast<std::string>(item);
1054 template <typename T>
1055 void operator()(std::vector<T> const& item)
1057 to_string_visitor vis;
1058 std::ostringstream stream;
1061 for(const auto& i : item)
1064 stream << vis.str << " ";
1072 void to_string_visitor::operator()(bool const& item)
1074 str = item ? "true" : "false";
1078 void to_string_visitor::operator()(std::string const& item)
1084 void to_string_visitor::operator()(NullType const& /*item*/)
1090 void to_string_visitor::operator()(OCRepresentation const& /*item*/)
1092 str = "OC::OCRepresentation";
1095 std::string OCRepresentation::getValueToString(const std::string& key) const
1097 auto x = m_values.find(key);
1098 if(x != m_values.end())
1100 to_string_visitor vis;
1101 boost::apply_visitor(vis, x->second);
1102 return std::move(vis.str);
1108 std::string OCRepresentation::AttributeItem::getValueToString() const
1110 to_string_visitor vis;
1111 boost::apply_visitor(vis, m_values[m_attrName]);
1112 return std::move(vis.str);
1115 std::ostream& operator<<(std::ostream& os, const OCRepresentation::AttributeItem& ai)
1117 os << ai.getValueToString();