Recursively build cell array in MEX? c/c++
Mostrar comentarios más antiguos
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
Respuestas (1)
James Tursa
el 7 de Mzo. de 2013
1 voto
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 comentarios
George Coles
el 7 de Mzo. de 2013
Editada: George Coles
el 8 de Mzo. de 2013
George Coles
el 18 de Mzo. de 2013
Jan
el 18 de Mzo. de 2013
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.
Categorías
Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!