{
namespace Service
{
+ /**
+ * This RCSByteString the one of RCSResourceAttributes value for Byte String (Binary).
+ *
+ * It provides similar usage to c++ standard vector.<br/>
+ * An RCSByteString can be one of various attribute value type.
+ *
+ * @see Value
+ * @see Type
+ * @see RCSRemoteResourceObject
+ * @see RCSResourceObject
+ * @see RCSResourceAttributes
+ */
+ class RCSByteString
+ {
+ public:
+ typedef std::vector<uint8_t> DataType;
+
+ /**
+ * Returns a vector<uint8_t> type of byte string.
+ *
+ * @return A stored byte string with std::vector<uint8_t>
+ */
+ DataType getByteString() const
+ {
+ return {m_data};
+ }
+
+ /**
+ * Returns a size of stored vector<uint8_t>.
+ *
+ * @return A size of stored byte string.
+ */
+ size_t size() const
+ {
+ return m_data.size();
+ }
+
+ /**
+ * @relates RCSByteString
+ *
+ * Checks if the byte string is same contents, or not.
+ *
+ * @return true if the byte string are equal, false otherwise.
+ */
+ inline bool operator==(const RCSByteString& rhs) const
+ {
+ return this->m_data == rhs.getByteString();
+ }
+
+ /**
+ * @relates RCSByteString
+ *
+ * Checks if the byte string is not same contents, or is same.
+ *
+ * @return true if the byte string are not equal, false otherwise.
+ */
+ inline bool operator!=(const RCSByteString& rhs) const
+ {
+ return this->m_data != rhs.getByteString();
+ }
+
+ /**
+ * Return a value of indexed byte string.
+ *
+ * @param it location of the element.
+ *
+ * @return A copied value of indexed byte string.
+ */
+ inline uint8_t operator[](size_t it) const
+ {
+ return this->m_data[it];
+ }
+
+ RCSByteString()
+ {
+ }
+ RCSByteString(DataType && rhs)
+ : m_data {std::move(rhs)}
+ {
+ }
+ RCSByteString(const DataType & rhs)
+ : m_data {rhs}
+ {
+ }
+ RCSByteString(RCSByteString && rhs)
+ : m_data {DataType{rhs.getByteString()}}
+ {
+ }
+ RCSByteString(const RCSByteString & rhs)
+ : m_data {DataType{rhs.getByteString()}}
+ {
+ }
+
+ RCSByteString(::OCByteString && rhs)
+ : m_data {DataType{rhs.bytes, rhs.bytes + rhs.len}}
+ {
+ }
+ RCSByteString(const ::OCByteString & rhs)
+ : m_data {DataType{rhs.bytes, rhs.bytes + rhs.len}}
+ {
+ }
+
+ RCSByteString(uint8_t* bytes, size_t size)
+ : m_data {DataType{bytes, bytes + size}}
+ {
+ }
+ inline RCSByteString& operator=(RCSByteString&& rhs)
+ {
+ return operator =(rhs);
+ }
+ inline RCSByteString& operator=(const RCSByteString& rhs)
+ {
+ if (!m_data.empty())
+ {
+ m_data.clear();
+ }
+ m_data = DataType{rhs.getByteString()};
+ return *this;
+ }
+ private:
+ DataType m_data;
+ };
+
+#ifdef __APPLE__
+ class RCSResourceAttributes;
+ typedef boost::variant<
+ std::nullptr_t,
+ int,
+ double,
+ bool,
+ std::string,
+ RCSByteString,
+ RCSResourceAttributes,
+
+ std::vector< int >,
+ std::vector< double >,
+ std::vector< bool >,
+ std::vector< std::string >,
+ std::vector< RCSByteString >,
+ std::vector< RCSResourceAttributes >,
+
+ std::vector< std::vector< int > >,
+ std::vector< std::vector< std::vector< int > > >,
+
+ std::vector< std::vector< double > >,
+ std::vector< std::vector< std::vector< double > > >,
+
+ std::vector< std::vector< bool > >,
+ std::vector< std::vector< std::vector< bool > > >,
+
+ std::vector< std::vector< std::string > >,
+ std::vector< std::vector< std::vector< std::string > > >,
+
+ std::vector< std::vector< RCSByteString > >,
+ std::vector< std::vector< std::vector< RCSByteString > > >,
+
+ std::vector< std::vector< RCSResourceAttributes > >,
+ std::vector< std::vector< std::vector< RCSResourceAttributes > > >
+ > ValueVariant;
+#endif
/**
* This represents the attributes for a resource.
* @see RCSDiscoveryManager
* @see RCSRemoteResourceObject
* @see RCSResourceObject
+ * @see RCSByteString
*/
class RCSResourceAttributes
{
private:
template< typename T > struct IsSupportedTypeHelper;
-
+#ifndef __APPLE__
typedef boost::variant<
std::nullptr_t,
int,
double,
bool,
std::string,
+ RCSByteString,
RCSResourceAttributes,
std::vector< int >,
std::vector< double >,
std::vector< bool >,
std::vector< std::string >,
+ std::vector< RCSByteString >,
std::vector< RCSResourceAttributes >,
std::vector< std::vector< int > >,
std::vector< std::vector< std::string > >,
std::vector< std::vector< std::vector< std::string > > >,
+ std::vector< std::vector< RCSByteString > >,
+ std::vector< std::vector< std::vector< RCSByteString > > >,
+
std::vector< std::vector< RCSResourceAttributes > >,
std::vector< std::vector< std::vector< RCSResourceAttributes > > >
> ValueVariant;
-
+#endif
template< typename T, typename V = void,
typename = typename std::enable_if<
IsSupportedTypeHelper< T >::type::value, V >::type >
DOUBLE, /**< double */
BOOL, /**< bool */
STRING, /**< std::string */
+ BYTESTRING, /**< RCSByteString */
ATTRIBUTES, /**< RCSResourceAttributes */
VECTOR /**< std::vector */
};
double
bool
std::string
+ RCSByteString
RCSResourceAttributes
std::vector< int >
std::vector< double >
std::vector< bool >
std::vector< std::string >
+ std::vector< RCSByteString >
std::vector< RCSResourceAttributes >
std::vector< std::vector< int > >
std::vector< std::vector< std::string > >
std::vector< std::vector< std::vector< std::string > > >
+ std::vector< std::vector< RCSByteString > >
+ std::vector< std::vector< std::vector< RCSByteString > > >
+
std::vector< std::vector< RCSResourceAttributes > >
std::vector< std::vector< std::vector< RCSResourceAttributes > > >
* @endcode
{
try
{
- return boost::get< T >(*m_data);
+ if ((*m_data).type() == typeid(T))
+ {
+ return boost::get< T >(*m_data);
+ }
+ else
+ {
+ throw RCSBadGetException{ "Wrong type" };
+ }
}
catch (const boost::bad_get&)
{
}
}
+#ifdef __APPLE__
+ public:
+#else
private:
+#endif
boost::scoped_ptr< ValueVariant > m_data;
};
boost::apply_visitor(helper, key, *i.second.m_data);
}
}
-
+#ifdef __APPLE__
+ public:
+#else
private:
+#endif
std::unordered_map< std::string, Value > m_values;
//! @cond