matlab::data::MATLABFieldIdentifier
C++ class used to identify field names in MATLAB struct array
Description
Class Details
Namespace: | matlab::data |
Include: | MATLABFieldIdentifier.hpp |
Constructors
Default Constructor
MATLABFieldIdentifier()
Construct an empty MATLABFieldIdentifier
.
None
Constructor
MATLABFieldIdentifier(std::string str)
Construct a MATLABFieldIdentifier
from std::string
.
| String that contains the field name. |
Destructor
~MATLABFieldIdentifier()
Destroy a MATLABFieldIdentifier
.
None
Copy Constructors
MATLABFieldIdentifier(const MATLABFieldIdentifier&
rhs)
Creates a shared data copy of a MATLABFieldIdentifier
object.
| Value to copy. |
None
Copy Assignment Operators
MATLABFieldIdentifier& operator=(MATLABFieldIdentifier
const& rhs)
Assigns a shared data copy to a MATLABFieldIdentifier
object.
| Value to move. |
| Updated instance. |
None
Move Constructors
MATLABFieldIdentifier(MATLABFieldIdentifier&&
rhs)
Moves contents a MATLABFieldIdentifier
object to a new instance.
| Value to move. |
None
Move Assignment Operators
MATLABFieldIdentifier& operator=(MATLABFieldIdentifier&&
rhs)
| Value to move. |
| Updated instance. |
None
Destructor
~MATLABFieldIdentifier()
Description
Destroy a MATLABFieldIdentifier
.
Other Operators
operator std::string
operator std::string() const
| Representation of the |
None
Free Functions
operator==
bool operator==(const MATLABFieldIdentifier& rhs)
const
Check if two MATLABFieldIdentifier
objects are identical.
| Value to be compared. |
| Returns true if the objects are identical. Otherwise, returns false. |
None
Examples
Get Contents of Structure
Access the data in MATLAB® structures that are passed to C++ MEX functions or C++ Engine programs using the structure field name.
Here is a structure passed to a MEX function. The
Date
field contains the date when the
structure is created, as returned by the datetime
function. The Data
field contains a numeric
value.
s = struct("Date",string(datetime("today")),"Data",100);
In a MEX function, store the input as a StructArray
. Use the getFieldNames
member function to get a range of MATLABFieldIdentifier
elements representing the structure field names. Use the second element to get the numeric data from the Data
field. Store numeric data in a TypedArray
with elements of type double
.
matlab::data::StructArray inStruct(inputs[0]); matlab::data::Range<matlab::data::ForwardIterator, matlab::data::MATLABFieldIdentifier const> fields = inStruct.getFieldNames(); const matlab::data::TypedArray<double> data = inStruct[0][fields.begin()[1]]; double cppData = data[0];
Version History
Introduced in R2017b