+ std::string m_host;
+
+ // STL Container stuff
+ public:
+ class iterator;
+ class const_iterator;
+ // Shim class to allow iterating and indexing of the OCRepresentation
+ // object.
+ class AttributeItem
+ {
+ friend class OCRepresentation;
+ friend class iterator;
+ friend class const_iterator;
+ public:
+ const std::string& attrname() const;
+ AttributeType type() const;
+ AttributeType base_type() const;
+ size_t depth() const;
+ template<typename T>
+ T getValue() const
+ {
+ T val = T();
+ try
+ {
+ if (m_values[m_attrName].type() == typeid(T))
+ {
+ val = boost::get<T>(m_values[m_attrName]);
+ }
+ else
+ {
+ return val;
+ }
+ }
+ catch (boost::bad_get& e)
+ {
+ return val;
+ }
+ return val;
+ }
+
+ std::string getValueToString() const;
+
+ template<typename T>
+ AttributeItem& operator=(T&& rhs)
+ {
+ m_values[m_attrName] = std::forward<T>(rhs);
+ return *this;
+ }
+
+ AttributeItem& operator=(std::nullptr_t /*rhs*/)
+ {
+ NullType t;
+ m_values[m_attrName] = t;
+ return *this;
+ }
+
+ // Enable-if required to prevent conversions to alternate types. This prevents
+ // ambigious conversions in the case where conversions can include a number of
+ // types, such as the string constructor.
+#if (defined(_MSC_VER) ) || (defined(__GNUC__) && (__GNUC__ <= 5))
+ template<typename T, typename std::enable_if<
+ std::is_same<T, int>::value ||
+ std::is_same<T, double>::value ||
+ std::is_same<T, bool>::value ||
+ std::is_same<T, std::string>::value ||
+ std::is_same<T, OCRepresentation>::value ||
+ std::is_same<T, OCByteString>::value ||
+ std::is_same<T, std::vector<int>>::value ||
+ std::is_same<T, std::vector<std::vector<int>>>::value ||
+ std::is_same<T, std::vector<std::vector<std::vector<int>>>>::value ||
+ std::is_same<T, std::vector<double>>::value ||
+ std::is_same<T, std::vector<std::vector<double>>>::value ||
+ std::is_same<T, std::vector<std::vector<std::vector<double>>>>::value ||
+ std::is_same<T, std::vector<bool>>::value ||
+ std::is_same<T, std::vector<std::vector<bool>>>::value ||
+ std::is_same<T, std::vector<std::vector<std::vector<bool>>>>::value ||
+ std::is_same<T, std::vector<std::string>>::value ||
+ std::is_same<T, std::vector<std::vector<std::string>>>::value ||
+ std::is_same<T, std::vector<std::vector<std::vector<std::string>>>>::value ||
+ std::is_same<T, std::vector<OCRepresentation>>::value ||
+ std::is_same<T, std::vector<std::vector<OCRepresentation>>>::value ||
+ std::is_same<T, std::vector<std::vector<std::vector<OCRepresentation>>>>::value ||
+ std::is_same<T, std::vector<OCByteString>>::value ||
+ std::is_same<T, std::vector<std::vector<OCByteString>>>::value ||
+ std::is_same<T, std::vector<std::vector<std::vector<OCByteString>>>>::value
+ , int>::type = 0// enable_if
+ >
+#else
+ template<typename T, typename std::enable_if<
+ is_component<T,
+ remove_first<AttributeValue>::type
+ >::value
+ , int>::type = 0
+ >
+#endif
+ operator T() const
+ {
+ return this->getValue<T>();
+ }
+
+ template<typename T, typename std::enable_if<
+ std::is_same<T, std::nullptr_t>::value
+ , int>::type = 0
+ >
+ operator T() const
+ {
+ this->getValue<NullType>();
+ return nullptr;
+ }
+
+ private:
+ AttributeItem(const std::string& name,
+ std::map<std::string, AttributeValue>& vals);
+ AttributeItem(const AttributeItem&) = default;
+ std::string m_attrName;
+ std::map<std::string, AttributeValue>& m_values;
+ };
+
+ // Iterator to allow iteration via STL containers/methods
+ class iterator
+ {
+ friend class OCRepresentation;
+ public:
+ typedef iterator self_type;
+ typedef AttributeItem value_type;
+ typedef value_type& reference;
+ typedef value_type* pointer;
+ typedef std::forward_iterator_tag iterator_category;
+ typedef int difference_type;
+
+ iterator(const iterator&) = default;
+ ~iterator() = default;
+
+ bool operator ==(const iterator&) const;
+ bool operator !=(const iterator&) const;
+
+ iterator& operator++();
+ iterator operator++(int);