SetString
Description
Frees an existing string and assigns a new string value to it by
performing a deep copy.
Syntax
|
1 |
SetString (pbstring string, LPCTSTR src) |
|
Argument |
Description |
|---|---|
|
string |
A valid pbstring variable whose value is to be |
|
src |
The string to be assigned to string |
Return value
PBXRESULT. Returns PBX_OK for success or PBX_E_INVALID_ARGUMENT if
the new string value is invalid; otherwise, returns
PBX_E_OUTOF_MEMORY.
Examples
This example uses the IPB_Session SetString method to set the
ret_val string to the return value in the PBCallInfo structure. It also
uses the IPB_Value SetPBString method to set values in
PBCallInfo:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
pbclass cls; pbmethodID mid; PBCallInfo* ci = new PBCallInfo; pbstring ret_val; LPCTSTR pStr; cls= Session -> GetClass(myobj); if (isAny) mid=Session-> GetMethodID(cls, "uf_any_byvalue", PBRT_FUNCTION, "AAAAA"); else mid=Session-> GetMethodID(cls, "uf_string_byvalue", PBRT_FUNCTION, "SSSSS"); Session-> InitCallInfo(cls, mid, ci); ci-> pArgs -> GetAt(0) -> SetPBString(s_low); ci-> pArgs -> GetAt(1) -> SetPBString(s_mid); ci-> pArgs -> GetAt(2) -> SetPBString(s_high); pStr = Session -> GetString(s_null); if (pStr != 0) { if (strcmp(pStr, "null") == 0 ) ci-> pArgs -> GetAt(3) -> SetToNull(); else ci-> pArgs -> GetAt(3) -> SetPBString(s_null); } Session -> InvokeObjectFunction(myobj, mid, ci); ret_val = Session -> NewString(""); Session -> SetPBString(ret_val, Session->GetString (ci->returnValue->GetString())); Session -> FreeCallInfo(ci); delete ci; return ret_val; |
Usage
A deep copy is performed. The existing value is destroyed first,
and then the contents of the src argument are copied into a new
value.
See also