TwCopyStdStringToLibrary (function)Description
This function is related to variables of type TW_TYPE_STDSTRING (ie. of type
It copies the string
It is useful if you are adding variables of type This function is required because memory allocated by the application (your program) cannot be resized or deleted by a dynamic library (like AntTweakBar) and vice versa. Thus it should be called for copying a string in order to avoid bad memory handling between the two modules. ParametersdestReference to the destination string handled by the AntTweakBar library. srcThe source string handled by your application. Example
The following example adds a std::string s = "a STL string"; // ... void TW_CALL SetMyStdStringCB(const void *value, void * /*clientData*/) { // Set: copy the value of s from AntTweakBar const std::string *srcPtr = static_cast<const std::string *>(value); s = *srcPtr; } void TW_CALL GetMyStdStringCB(void *value, void * /*clientData*/) { // Get: copy the value of s to AntTweakBar std::string *destPtr = static_cast<std::string *>(value); TwCopyStdStringToLibrary(*destPtr, s); // the use of TwCopyStdStringToLibrary is required here } // ... TwAddVarCB(bar, "s", TW_TYPE_STDSTRING, SetMyStdStringCB, GetMyStdStringCB, NULL, "");
See TwCopyStdStringToClientFunc for a simpler example that uses See alsoTW_TYPE_STDSTRING, TwAddVarRW, TwAddVarRO, TwAddVarCB, TwCopyStdStringToClientFunc, string variable examples |