Main Content

matlab::data::EnumArray

C++ class to access MATLAB enumeration arrays

Description

Use EnumArray objects to access enumeration arrays. To create an EnumArray, call createEnumArray in the ArrayFactory class.

Class Details

Namespace:

matlab::data

Base class:

TypedArray<Enumeration>

Include:

EnumArray.hpp

Constructors

Copy Constructors

EnumArray(const EnumArray& rhs)

EnumArray(const Array& rhs)

Description

Creates a shared data copy of an EnumArray object.

Parameters

const EnumArray& rhs

Value to copy.

const Array& rhs

Value specified as EnumArray object.

Throws

matlab::data::InvalidArrayTypeException

Type of input Array is not ArrayType::ENUM.

Copy Assignment Operators

EnumArray& operator=(const EnumArray& rhs)

EnumArray& operator=(const Array& rhs)

Description

Assigns a shared data copy to an EnumArray object.

Parameters

const EnumArray& rhs

Value to copy.

const Array& rhs

Value specified as ArrayType::ENUM object.

Returns

EnumArray&

Updated instance.

Throws

matlab::data::InvalidArrayTypeException

Type of input Array is not ArrayType::ENUM.

Move Constructors

EnumArray(EnumArray&& rhs)

EnumArray(Array&& rhs)

Description

Moves contents of an EnumArray object to a new instance.

Parameters

EnumArray&& rhs

Value to move.

Array&& rhs

Value specified as ArrayType::ENUM object.

Throws

matlab::data::InvalidArrayTypeException

Type of input Array is not ArrayType::ENUM.

Move Assignment Operators

EnumArray& operator=(EnumArray&& rhs)

EnumArray& operator=(Array&& rhs)

Description

Assigns the input to this EnumArray object.

Parameters

EnumArray&& rhs

Value to move.

Array&& rhs

Value specified as ArrayType::ENUM object.

Returns

EnumArray&

Updated instance.

Throws

matlab::data::InvalidArrayTypeException

Type of input Array is not ArrayType::ENUM.

Member Functions

getClassName

std::string getClassName() const
Description

Return class name for this EnumArray.

Returns

std::string

Class name.

Throws

None

Examples

Display enum Value

Define an enumeration class:

classdef MyClass
   enumeration
       A
       B
       C
   end
end

Define a matlab::data::EnumArray object for the MyClass.C enumeration argument and display the value.

#include "MatlabDataArray.hpp"
#include "MatlabEngine.hpp"
#include <iostream>

int main()
{
	using namespace matlab::data;
	ArrayFactory f;
	auto e = f.createEnumArray({ 1,1 }, "MyClass", { "C" });
	// Display enum value
	std::cout << "Property value: " << std::string(e[0]) << std::endl;
	return 0;
}

Version History

Introduced in R2017b