Skip to content

Commit 7ac0bfc

Browse files
committed
draft multiple write value options
1 parent 981521a commit 7ac0bfc

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/nixsection.cc

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,33 @@ void create_property(const extractor &input, infusor &output)
6868
void create_property_with_value(const extractor &input, infusor &output)
6969
{
7070
nix::Section currObj = input.entity<nix::Section>(1);
71-
std::vector<nix::Value> currVec = input.vec(3);
71+
72+
std::vector<nix::Value> currVec;
73+
74+
mxClassID currID = input.class_id(3);
75+
if (currID == mxCELL_CLASS){
76+
mexPrintf("Cell\n");
77+
const mxArray *cell_element_ptr = input.cellElemPtr(3, 0);
78+
79+
if (mxGetClassID(cell_element_ptr) == mxSTRUCT_CLASS){
80+
mexPrintf("Struct\n");
81+
currVec = input.extractFromStruct(3);
82+
}
83+
else
84+
{
85+
mexPrintf("Cell with normal values\n");
86+
currVec = input.vec(3);
87+
}
88+
}
89+
else if (currID == mxCHAR_CLASS){
90+
mexPrintf("Just char\n");
91+
}
92+
else if (currID == mxDOUBLE_CLASS){
93+
mexPrintf("Just double\n");
94+
}
95+
else if (currID == mxLOGICAL_CLASS){
96+
mexPrintf("Just logical\n");
97+
}
7298

7399
nix::Property p = currObj.createProperty(input.str(2), currVec);
74100
output.set(0, handle(p));

src/utils/arguments.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ class extractor : public argument_helper<const mxArray> {
6565
return mx_array_to_str(array[pos]);
6666
}
6767

68+
const mxArray * cellElemPtr(size_t pos, int index) const {
69+
const mxArray *cell_element_ptr = mxGetCell(array[pos], index);
70+
return cell_element_ptr;
71+
}
72+
6873
template<typename T>
6974
T num(size_t pos) const {
7075
check_arg_type(pos, nix::to_data_type<T>::value);

0 commit comments

Comments
 (0)