Open arthurvd opened 2 years ago
@lucacarniato answered this question:
does that C++ function now return an array of single chars? Or an array of strings (one for each variable name?)
The C api returns an error code, but the results are always the last parameters of the function, in this case a char *
, so i flatten the results in vector_of_strings_to_char_array()
.
There is no separator, but it is assumed the individual data variable names do not exceed the ugrid::name_long_length
.
To use this, you can count the variables using ug_topology_count_data_variables()
, then allocate the memory on the client side, and loop throught it in these same-sized blocks of substrings.
If we would consider a char**
to be the result instead, then we should test whether one can pass an array of char * (not only in python, but also to fortran).
Is your feature request related to a problem? Please describe. All UgridPy API functions to get data from a file currently require a string variable name passed as a argument. This now can only be hardcoded by the user. Rather, I'd like to inquire which variables are in the file on a particular mesh.
Describe the solution you'd like
ug_topology_get_data_variables_names()
p.s.: Question: does that C++ function now return an array of single chars? Or an array of strings (one for each variable name?)Describe alternatives you've considered Hardcoding is not an option, especially when data variable occur multiple times in the same file, for example: "mesh1d_waterdepth", "mesh2d_waterdepth"
Additional context This arose in a discussion with @d2hydro.