How to wrap std::string and std::vector<std::string>?
AllenDang opened this issue · comments
Hi, @dertseha
This is not an issue but a question.
I'm trying to wrap ImGuiColorTextEdit but I'm not very familiar with C++, so I met a problem about wrap std::string and std::vectorstd::string to Go string and string slice and verse versa.
Can you give me a hint about this? Many thanks!
Hello - thank you for your patience.
"Wrapping" the standard types managed by C++ will get you into opening a can of worms.
Like with the wrapper of imgui-go, first have a raw C-conversion-layer that then interfaces from/to Go.
What will be necessary is a back-and-forth copying of a string from Go to this C-wrapper, which then copies the the data into the C++ std::string. And the other way back again.
Sadly, this will be quite a hit on performance, so perhaps it's possible to use a more direct approach in ImGuiColorTextEdit - perhaps you can access its internal buffer somewhat directly from/into which you can copy.