Web Services Client for C++ supports deep copying. Deep copying is where, when setting a value on a complex type, the set method makes a private copy of the original data. Subsequent modification or deletion of the original data does not affect the complex type, and the application must delete the original data to prevent memory leaks.
//This is an example of deep copying. ComplexType * complexType = new ComplexType(); xsd__string aStringType = new char[9]; strcpy(aStringType, "Welcome!"); complexType->setaStringType(aStringType); // Note: By default deep copying will take place. delete [] aStringType; // This object is no longer required by the generated objects so can be deleted // at the earliest opportunity. Result result = ws.useComplexType(complexType); delete complexType; // This is an example of explicitly deep copying. ComplexType * complexType = new ComplexType(); xsd__string aStringType = new char[9]; strcpy(aStringType, "Welcome!"); complexType->setaStringType(aStringType, true); // Note: Use of additional parameter set to 'true' indicates deep copying is to // take place. delete [] aStringType; // This object is no longer required by the generated objects so can be deleted // at the earliest opportunity. Result result = ws.useComplexType(complexType); delete complexType;
// This is an example of shallow copying ComplexType * complexType = new ComplexType(); xsd__string aStringType = new char[9]; strcpy(aStringType, "Welcome!"); complexType->setaStringType(aStringType, false); // Note: Use of additional parameter set to 'false' indicates shallow // copying is to take place. Result result = ws.useComplexType(complexType); delete complexType; delete [] aStringType; // This object MUST NOT be deleted until generated object has been deleted.