Recursively build cell array in MEX? c/c++
이전 댓글 표시
Hi, before I even attempt to do this, I wanted to ask if anyone else (including Mathworks staff) has tried to recursively build a cell array? I have to deal with a library (hiredis) that may return nested results in a reply struct. I have to examine the reply type, and if it is a certain type, then I have to traverse all the child replies and examine each of them, etc.
Hiredis sets an arbitrary max nesting level, which I am also going to enforce. I set it to 7, which matches hiredis.
My mind is boggling a bit at what might be involved with recursively adding to the cell array which holds all the results. This is the last major task in writing my redis wrapper and I wish I could just ignore this but there are many redis commands which return replies of a type called "Multi Bulk" which can be arbitrarily nested.
I thought it would be better to ask for help in advance instead of posting a bunch of garbage asking "why I get error".
thx George
답변 (1개)
James Tursa
2013년 3월 7일
1 개 추천
Generally, you can pretty much build and/or examine "nested" cell or struct mxArray variables in the mex environment using the mxSetCell, mxGetCell, mxSetField, mxGetField etc API functions recursively. If you could provide a short descriptive sample (i.e., pseudo-code) of what you are trying to do we can probably advise how to go about it in C/C++.
댓글 수: 3
George Coles
2013년 3월 7일
편집: George Coles
2013년 3월 8일
George Coles
2013년 3월 18일
Jan
2013년 3월 18일
In general the code looks ok. There are two strong testers on your computer: 1. let the compiler parse the input, 2. let the code run and test the results with your expectations.
Btw., this is not C-code, but C++, because the later allows to declare variables inside the code. But as long as the compiler accept this, this is a cosmethical aspect only.
카테고리
도움말 센터 및 File Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!