I have a legacy C/C++ struct like this (with many other members as well):
struct S {
char one_name[MAX_LEN];
char names[N_NAMES][MAX_LEN];
}
and a C function that creates these:
S *get_S(...)
I'd like to export S and names via swig so I can do this in python:
s = MyModule.get_S()
print s.one_name # I have this working
print s.names[1] # should print the 2nd string, this is harder
I assume I need some kind of typemap but I'm new to swig. I can do one_name
with the wrapped_array template as in SWIG/python array inside structure, but I'm not sure how to extend that to an array of strings. I only need to read these strings from python (as above), not write them. I can do it with an accessor so the python would look like:
print s.get_name(i) # prints the ith name
but I'd prefer the array interface just because it's similar to the C one.