matlab::data::CharArray
C++ class to access MATLAB character arrays
Description
Use CharArray
objects to work with MATLAB® character arrays. To create a CharArray
, call createCharArray
in the
ArrayFactory
class.
Class Details
Namespace: | matlab::data |
Base class: | TypedArray<char16_t> |
Include: | CharArray.hpp |
Constructors
Copy Constructors
CharArray(const CharArray& rhs)
CharArray(const Array& rhs)
Creates a shared data copy of a CharArray
object.
|
Value to copy. |
|
Value specified as |
|
Type of input |
#include "MatlabDataArray.hpp" int main() { using namespace matlab::data; ArrayFactory factory; CharArray A = factory.createCharArray("This is a char array"); CharArray B(A); return 0; }
Copy Assignment Operators
CharArray& operator=(const CharArray& rhs)
CharArray& operator=(const Array& rhs)
Assigns a shared data copy to a CharArray
object.
|
Value to copy. |
|
Value specified as |
|
Updated instance. |
|
Type of input |
#include "MatlabDataArray.hpp" int main() { using namespace matlab::data; ArrayFactory factory; CharArray A = factory.createCharArray("This is a char array"); CharArray C = factory.createCharArray(""); // Arrays A and C refer to the same data. C = A; return 0; }
Move Constructors
CharArray(CharArray&& rhs)
CharArray(Array&& rhs)
Moves contents of a CharArray
object to a new instance.
|
Value to move. |
|
Value specified as |
|
Type of input |
#include "MatlabDataArray.hpp" int main() { using namespace matlab::data; ArrayFactory factory; CharArray A = factory.createCharArray("This is a char array"); // Move constructor - Creates B, copies data from A. A not valid. CharArray B(std::move(A)); return 0; }
Move Assignment Operators
CharArray& operator=(CharArray&& rhs)
CharArray& operator=(Array&& rhs)
Assigns the input to this CharArray
object.
|
Value to move. |
|
Value specified as |
|
Updated instance. |
|
Type of input |
#include "MatlabDataArray.hpp" int main() { using namespace matlab::data; ArrayFactory factory; CharArray A = factory.createCharArray("This is a char array"); // Move assignment - Data from A moved to C. A no longer valid. CharArray C = factory.createCharArray(""); C = std::move(A); return 0; }
Member Functions
toUTF16
String toUTF16() const
|
Contents of |
None
toAscii
std::string toAscii() const
|
Contents of |
|
Data contains non-ASCII characters. |
#include "MatlabDataArray.hpp" int main() { using namespace matlab::data; ArrayFactory f; auto arr = f.createCharArray("helloworld"); std::string s = arr.toAscii(); return 0; }
Version History
Introduced in R2017b