New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend ofToString to convert Windows data types #4098
Comments
could you also give some examples of where/when this might be useful? at first glance it looks like a very platform-dependent kind of thing, which OF tries to hide by making things work on different platforms rather than by providing helper functions. |
Right it is platform specific and ideally it would be a feature of ofString so that those data types could just be passed in like any other data type and thus the code only works in the background. It would be useful for anything that deals with HRESULTs as the error messages are returned as LPTSTR and can't be decoded by ofToString. Here is an example of having to decode things for the Media Foundation lib
|
ofToString on a HRESULT would be fantastic! @kylemcdonald - HRESULT's are the default return for any function on the Windows platform (e.g. COM functions). They give either S_OK or something which denotes in what way the function failed. |
thanks for the example @DomAmato and explanation @elliotwoods the only precedent i can think of for this sort of thing is the pascal strings used by ofQuickTimeGrabber. in that case, there's a macro defined in ofQtUtils.h, and i'm even not sure it's generally accessible (because people aren't usually writing addons that interface with quicktime directly). with that in mind, maybe there is somewhere else in OF that could make use of a function like this? and that would be an argument for including it... i'm sure @arturoc or @ofTheo have more thoughts on the matter, just wanted to see if i could get more info :) |
it doesn't happen often, but often enough that the feature would be nice to have, where I need to convert w_chars, LPTSTR, LPTWSTR etc... the functions are already a part of ofSystemUtils
The problem when you do ofToString(LPTSTR...) is you get the pointer not the string itself e.g.
LPTSTR errorText = 0x0336ffa0 L"The media session cannot pause from a stopped state." wchar_t *
string error = "0336FFA0" std::basic_string<char,std::char_traits,std::allocator >
The text was updated successfully, but these errors were encountered: