KDSoap icon indicating copy to clipboard operation
KDSoap copied to clipboard

Generate getter returning pointer to the messageobject for better accessibility

Open henrihaikonen opened this issue 11 years ago • 1 comments

DESCRIPTION: KDWSDL2CPP code generator could generate pointer to the nested message object types for better accessibility and possibility to modify existing object.

USE CASE It would be very nice to be able to do something like this: message.list.append(new ListItem()); or message.list.at(i).setProperty("value"); But currently the generated getter method returns a copy of the actual member so the above mentioned code does not modify the message object. Currently programmer needs to reconstruct the whole message if a modification is needed inside the message.

PROPOSED SOLUTION: The code generator could generate a getter method for complextypes for instance: propertyType* propertyname_ptr() { return &propertyname; }

or possibly using const reference

const propertyType& propertyname_ptr() { return propertyname; }

EXAMPLE CODE: KDSoap/kdwsdl2cpp/src/converter_complextype.cpp // pointer method, only when a complex type is used. if (typeName.contains("__")) { KODE::Function pointer( mNameMapper.escape( lowerName ) + QLatin1String("_ptr"), typeName + QLatin1String("*")); pointer.setBody( QLatin1String("return &") + variableName + QLatin1Char(';') ); pointer.setConst(false); newClass.addFunction(pointer); }

henrihaikonen avatar Mar 07 '13 03:03 henrihaikonen

In my application the internal datamodel is using the generated message objects. So I need to be able to access and modify any node in the structure.

henrihaikonen avatar Mar 07 '13 03:03 henrihaikonen