/* Copyright 2015-2016 The MathWorks, Inc. */ #ifndef MATLAB_DATA_ENUM_ARRAY_HPP #define MATLAB_DATA_ENUM_ARRAY_HPP #include "Enumeration.hpp" #include "TypedArray.hpp" #include "TypedArrayRef.hpp" #include "detail/enum_interface.hpp" #include "detail/HelperFunctions.hpp" #include #include namespace matlab { namespace data { namespace detail { class Access; } /** * Enum Array is a subclass of TypedArray for Enumeration objects. */ class EnumArray : public TypedArray { public: static const ArrayType type = ArrayType::ENUM; /** * move constructor * * @param rhs - rvalue to be moved * @return EnumArray the new instance * @throw none */ EnumArray(EnumArray&& rhs) MW_NOEXCEPT : TypedArray(std::move(rhs)) {} /** * move assignment operator * * @param rhs - rvalue to be moved * @return EnumArray& the updated instance * @throw none */ EnumArray& operator=(EnumArray&& rhs) MW_NOEXCEPT { TypedArray::operator=(std::move(rhs)); return *this; } /** * copy constructor - creates a shared data copy * * @param rhs - EnumArray to be copied * @return EnumArray the new instance * @throw none */ EnumArray(const EnumArray& rhs) MW_NOEXCEPT : TypedArray(rhs) {} /** * assignment operator - creates a shared data copy * * @param rhs - rvalue to be copied * @return EnumArray& the updated instance * @throw none */ EnumArray& operator=(const EnumArray& rhs) MW_NOEXCEPT { TypedArray::operator=(rhs); return *this; } /** * copy constructor - creates a shared data copy from an Array * * @param rhs - EnumArray to be copied * @return EnumArray the new instance * @throw InvalidArrayTypeException if type of rhs type is not ENUM */ EnumArray(const Array& rhs) : TypedArray(rhs) {} /** * assignment operator - creates a shared data copy fron an Array * * @param rhs - rvalue to be copied * @return EnumArray& the updated instance * @throw InvalidArrayTypeException if type of rhs type is not ENUM */ EnumArray& operator=(const Array& rhs) { TypedArray::operator=(rhs); return *this; } /** * Construct a EnumArray from an Array * * @param rhs - rvalue to be moved * @return EnumArray the new instance * @throw InvalidArrayTypeException if type of rhs type is not ENUM */ EnumArray(Array&& rhs) : TypedArray(std::move(rhs)) {} /** * move assignment operator from an Array * * @param rhs - rvalue to be moved * @return EnumArray& the updated instance * @throw InvalidArrayTypeException if type of rhs type is not ENUM */ EnumArray& operator=(Array&& rhs) { TypedArray::operator=(std::move(rhs)); return *this; } /** * Return class name for this Enum Array * * @return class name * @throw none */ std::string getClassName() const MW_NOEXCEPT { char* str = nullptr; size_t strlen = 0; enum_get_class(detail::Access::getImpl(*this), &str, &strlen); return std::string(str, strlen); } private: friend class detail::Access; EnumArray(matlab::data::impl::ArrayImpl* impl) MW_NOEXCEPT : TypedArray(impl) {} EnumArray() = delete; }; using EnumArrayRef = TypedArrayRef; } } #endif