c++ - Identical objects but different types
问题描述
I use a C++ app to synchronyze data between two PHP servers.
My first server is local, my C++ app call a webservice on that server to get an object to synchronyze. Then, my C++ app use another webservice to send it on my Cloud PHP server.
So my Object is a soap object defined strictly identically on my two php server.
However, for my C++ apps, these two object are not the same (or at least with a different namespace), so Y can't compile the following line:
soapErrorCode = cloudWebService.action(myLocalObject);
//C++ is waiting for an object of type myCloudObject, even if these two object have the same attributes
My soap objects and Webservice definition are defined in my C++ with help of gSoap.
I see different solution, but not sure which is the best:
- Is there a way to tell to C++ that myLocalObject and myCloudObject are the same? Note: I don't want manually modify the code generated by gsoap (too much work!).
- Is there a way to tell to gsoap that myLocalObject and myCloudObject are the same?
- Am I obliged to create fonction to convert myLocalObject to myCloudObject?
Thanks!
解决方案
In my opinion two possible variants are:
- Write converter function from
myLocalObject
tomyCloudObject
and from frommyCloudObject
tomyLocalObject
- You can make a base class for
myLocalObject
andmyCloudObject
and work through its pointer.
推荐阅读
- node.js - API调用在ReactJS中得到CORS错误,但在节点和邮递员中得到响应
- r - 按列表名称应用函数
- ios - 重置分数按钮 iOS
- reactjs - 即使使用确切的路径,React Router v4 也无法正常工作
- keycloak - 如何在 keycloak 领域重定向 URL 中传递动态 IP 地址?
- linux - 守护进程如何在不使用内存的情况下保持活动状态?
- aop - 我们可以在使用 AspectJ 加载时间编织时定义编织顺序吗?
- mapbox - 在本地运行 mapbox-gl-js(无法提供调试页面)
- javascript - 在 javascript 中调用多个 ID 的可能性的更好方法?
- c# - WPF 设计时属性