We have a SOAP-based client-server written in C++/Qt and Axis2C. It contains a lot of old-fashioned C-style structs (usually they describe raw arrays of custom data), because of the C nature of Axis2C. How can C usage be minimized in the code, which uses Axis2C? It's a pain to support these custom C structs, because it requires accuracy of assignment operators, c-tors,d-tors. Qt-based structs are less verbose.
I guess you are especially looking which datatypes to use instead of old fashioned C (not C++) datatypes. These datatypes are the C++ standard containers (http://www.cplusplus.com/reference/stl/) which are shipped with your compiler and are alway available. A Qt implementation of these containers is available, too (http://doc.qt.io/qt-5/containers.html).
Which one to choose depends of a lot of factors. Below I showed a simplified sample how to do this with the stl. So I think you will have to write a kind of wrapper which converts the c datatypes to C++/Qt datatypes. "std::vector" is one type of containers which is often a good replacement for c style arrays.
int32_t main ()
{
int arraySize = 10;
int* pCArray = new int [arraySize];
for ( int idx = 0; idx < arraySize; ++idx )
{
pCArray [idx] = idx + 100;
}
for ( int idx = 0; idx < arraySize; ++idx )
{
std::cout << pCArray [idx] << std::endl;
}
std::cout << "-------------------------" << std::endl;
std::vector<int> array;
array.assign ( pCArray, pCArray + arraySize );
delete pCArray;
for ( int idx = 0; idx < arraySize; ++idx )
{
std::cout << array [idx] << std::endl;
}
return 0;
}
There is not need to call delete array
at the end of this sample since "array" is deleted automatically (BTW delete array
would not even compile).