matlab::data::MATLABFieldIdentifier - C++ class used to identify field names in MATLAB struct array - MATLAB (original) (raw)
Main Content
C++ class used to identify field names in MATLAB struct array
Description
Class Details
Namespace: | matlab::data |
---|---|
Include: | MATLABFieldIdentifier.hpp |
Constructors
- Default Constructor
- Constructor
- Destructor
- Copy Constructors
- Copy Assignment Operators
- Move Constructors
- Move Assignment Operators
Default Constructor
Description
Construct an empty MATLABFieldIdentifier
.
Constructor
MATLABFieldIdentifier(std::string str)
Description
Construct a MATLABFieldIdentifier
from std::string
.
Parameters
std::string str | String that contains the field name. |
---|
Destructor
Description
Destroy a MATLABFieldIdentifier
.
Copy Constructors
MATLABFieldIdentifier(const MATLABFieldIdentifier& rhs)
Description
Creates a shared data copy of a MATLABFieldIdentifier
object.
Parameters
const MATLABFieldIdentifier& rhs | Value to copy. |
---|
Copy Assignment Operators
MATLABFieldIdentifier& operator=(MATLABFieldIdentifier const& rhs)
Description
Assigns a shared data copy to a MATLABFieldIdentifier
object.
Parameters
MATLABFieldIdentifier const& rhs | Value to move. |
---|
Returns
MATLABFieldIdentifier& | Updated instance. |
---|
Move Constructors
MATLABFieldIdentifier(MATLABFieldIdentifier&& rhs)
Description
Moves contents a MATLABFieldIdentifier
object to a new instance.
Parameters
MATLABFieldIdentifier&& rhs | Value to move. |
---|
Move Assignment Operators
MATLABFieldIdentifier& operator=(MATLABFieldIdentifier&& rhs)
Parameters
MATLABFieldIdentifier&& rhs | Value to move. |
---|
Returns
MATLABFieldIdentifier& | Updated instance. |
---|
Destructor
Description
Destroy a MATLABFieldIdentifier
.
Other Operators
operator std::string
operator std::string() const
Returns
std::string | Representation of the MATLABFieldIdentifier object. |
---|
Free Functions
operator==
bool operator==(const MATLABFieldIdentifier& rhs) const
Description
Check if two MATLABFieldIdentifier
objects are identical.
Parameters
const MATLABFieldIdentifier& rhs | Value to be compared. |
---|
Returns
bool | Returns true if the objects are identical. Otherwise, returns false. |
---|
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. TheDate
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 data = inStruct[0][fields.begin()[1]]; double cppData = data[0];
Version History
Introduced in R2017b