Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

IDL string and wstring in C++

The IDL string type is mapped as char*, and wstring as _wchar_t* (where _wchar_t is typedef-ed to unsigned short). When used anywhere other than an in parameter, the pointer is accompanied by a size that allows the caller to specify the number of characters (char for string, _wchar_t for wstring) allocated for the string or wstring. This is the length of the buffer in characters, not the length of the string -- since strings are null-terminated in C++, the length of the string is computable. Specifying the length of the buffer separately allows for a string longer than the original to be returned in the inrout case. In addition to the size parameter, inrout and rout string types also expand to a third int* argument, which upon completion of the call is populated with the size required to store the full content of the resultant string, including the null-terminator. All length and length required parameters associated with a string or wstring include the null-terminator.

Note: In this section, characters should be interpreted as meaning one-byte chars for string types, and a two-byte _wchar_ts for wstring types. The term character is not used here in the lexical sense -- when storing text, character set and encoding considerations are left to the application. It is, therefore, possible for a lexical character to require more than one IDL character (non-zero byte) to represent it.