|
|
@@ -1,4 +1,6 @@
|
|
|
+#if (defined _WIN32 || defined _WIN64)
|
|
|
#include "stdafx.h"
|
|
|
+#endif
|
|
|
#include "BufferOperation.h"
|
|
|
#include "modp_b64.h"
|
|
|
#include "SpHelper.h"
|
|
|
@@ -75,9 +77,9 @@ void CWSCodec::DeserializeBase(CMessage& msg, CTransStruct& ts, int& rpos, cJSON
|
|
|
std::string t_arr[] = { "messageType", "sessionID", "transID", "isEnd", "errorCode", "errorMsg" };
|
|
|
std::vector<std::string> c_repeatParamList(t_arr, t_arr + sizeof(t_arr) / sizeof(t_arr[0]));
|
|
|
|
|
|
- for each (auto paramInfo in ts.mParamList)
|
|
|
+ for (auto paramInfo : ts.mParamList)
|
|
|
{
|
|
|
- for each (auto repeatName in c_repeatParamList)
|
|
|
+ for (auto repeatName : c_repeatParamList)
|
|
|
{
|
|
|
if (paramInfo.mName == repeatName)
|
|
|
DbgEx("requestAck参数名字重复, error, %s", paramInfo.mName);
|
|
|
@@ -90,7 +92,7 @@ void CWSCodec::DeserializeBase(CMessage& msg, CTransStruct& ts, int& rpos, cJSON
|
|
|
while (i != ts.mParamList.end())
|
|
|
{
|
|
|
bool t_isRepeat = false;
|
|
|
- for each (auto repeatName in c_repeatParamList)
|
|
|
+ for (auto repeatName : c_repeatParamList)
|
|
|
{
|
|
|
if (i->mName == repeatName)
|
|
|
{
|
|
|
@@ -263,10 +265,10 @@ void CWSCodec::DeserializeRequestAck(CMessage& msg, std::map<int, entity_def_str
|
|
|
{
|
|
|
DbgEx("error DeserializeRequestAck: %s, %s, %s", p_struct->entity_name, p_struct->class_name, p_struct->methodID);
|
|
|
std::string errorMsg;
|
|
|
- for each(auto it in ts.mParamList)
|
|
|
+ for(auto it : ts.mParamList)
|
|
|
errorMsg += it.mName + "--" + it.mType + "_";
|
|
|
DbgEx(errorMsg.c_str());
|
|
|
- throw std::exception("error DeserializeRequestAck");
|
|
|
+ throw std::exception(std::logic_error("error DeserializeRequestAck"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -291,10 +293,10 @@ void CWSCodec::DeserializeEvent(CMessage& msg,
|
|
|
catch (...)
|
|
|
{
|
|
|
std::string errorMsg;
|
|
|
- for each(auto it in ts.mParamList)
|
|
|
+ for(auto it : ts.mParamList)
|
|
|
errorMsg += it.mName + "--" + it.mType + "_";
|
|
|
DbgEx(errorMsg.c_str());
|
|
|
- throw std::exception("error DeserializeRequestAck");
|
|
|
+ throw std::exception(std::logic_error("error DeserializeRequestAck"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -686,9 +688,9 @@ void CWSCodec::SerializeRequest(cJSON* js, char* data, int* wpos, int* capacity,
|
|
|
//detect the same name
|
|
|
std::string t_arr[] = { "transID", "sessionID", "methodID", "signature", "timeout" ,"messageType","class","entity","methodID" };
|
|
|
std::vector<std::string> c_repeatParamList(t_arr, t_arr + sizeof(t_arr) / sizeof(t_arr[0]));
|
|
|
- for each (auto paramInfo in pI->mRequestInterpreter.mParamList)
|
|
|
+ for (auto paramInfo : pI->mRequestInterpreter.mParamList)
|
|
|
{
|
|
|
- for each (auto repeatName in c_repeatParamList)
|
|
|
+ for (auto repeatName : c_repeatParamList)
|
|
|
{
|
|
|
if (paramInfo.mName == repeatName)
|
|
|
DbgEx("request参数名字重复, error, %s", paramInfo.mName);
|
|
|
@@ -994,12 +996,16 @@ bool CWSCodec::GetCJsonObjectValue(cJSON *root, const char* strKey, CSimpleStrin
|
|
|
bool ret = false;
|
|
|
pTmpNode = cJSON_GetObjectItem(root, strKey);
|
|
|
if(NULL != pTmpNode){
|
|
|
+#if (defined(_WIN32) || defined(_WIN64))
|
|
|
CSimpleStringW wStr = "";
|
|
|
UTF8ToUnicode(pTmpNode->valuestring, wStr);
|
|
|
//DbgEx("GetCJsonObjectValue string : %s", pTmpNode->valuestring);
|
|
|
//hexdump(pTmpNode->valuestring, strlen(pTmpNode->valuestring));
|
|
|
dstValue = CSimpleStringW2A(wStr);
|
|
|
// dstValue = pTmpNode->valuestring;
|
|
|
+#else
|
|
|
+ dstValue = pTmpNode->valuestring;
|
|
|
+#endif
|
|
|
ret = true;
|
|
|
}else{
|
|
|
strcat(errmsg, strKey);
|
|
|
@@ -1014,7 +1020,11 @@ bool CWSCodec::GetCJsonObjectValue(cJSON *root, const char* strKey, CSimpleStrin
|
|
|
bool ret = false;
|
|
|
pTmpNode = cJSON_GetObjectItem(root, strKey);
|
|
|
if(NULL != pTmpNode){
|
|
|
+#if (defined(_WIN32) || defined(_WIN64))
|
|
|
UTF8ToUnicode(pTmpNode->valuestring, dstValue);
|
|
|
+#else
|
|
|
+ dstValue = pTmpNode->valuestring;
|
|
|
+#endif
|
|
|
// dstValue = pTmpNode->valuestring;
|
|
|
ret = true;
|
|
|
}else{
|
|
|
@@ -1155,12 +1165,15 @@ bool CWSCodec::GetCJsonObjectValue(cJSON *obj, unsigned int& dstValue, char*
|
|
|
|
|
|
bool CWSCodec::GetCJsonObjectValue(cJSON *obj, CSimpleStringA& dstValue, char* errmsg){
|
|
|
if(cJSON_String == obj->type){
|
|
|
-// dstValue = obj->valuestring;
|
|
|
DbgEx("GetCJsonObjectValue CSimpleStringA = %s", obj->valuestring);
|
|
|
hexdump(obj->valuestring, strlen(obj->valuestring));
|
|
|
+#if (defined(_WIN32) || defined(_WIN64))
|
|
|
CSimpleStringW strw = "";
|
|
|
UTF8ToUnicode(obj->valuestring, strw);
|
|
|
dstValue = CSimpleStringW2A(strw);
|
|
|
+#else
|
|
|
+ dstValue = obj->valuestring;
|
|
|
+#endif
|
|
|
return true;
|
|
|
}
|
|
|
strcat(errmsg, "array member ");
|
|
|
@@ -1170,15 +1183,18 @@ bool CWSCodec::GetCJsonObjectValue(cJSON *obj, CSimpleStringA& dstValue, char* e
|
|
|
|
|
|
bool CWSCodec::GetCJsonObjectValue(cJSON *obj, CSimpleStringW& dstValue, char* errmsg){
|
|
|
if(cJSON_String == obj->type){
|
|
|
-// dstValue = obj->valuestring;
|
|
|
+#if (defined(_WIN32) || defined(_WIN64))
|
|
|
UTF8ToUnicode(obj->valuestring, dstValue);
|
|
|
+#else
|
|
|
+ dstValue = obj->valuestring;
|
|
|
+#endif
|
|
|
return true;
|
|
|
}
|
|
|
strcat(errmsg, "array member ");
|
|
|
dstValue = "";
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
+#if (defined(_WIN32) || defined(_WIN64))
|
|
|
int CWSCodec::UTF8ToUnicode(char* input, CSimpleStringW& output){
|
|
|
//UTF8 to Unicode
|
|
|
//预转换,得到所需空间的大小
|
|
|
@@ -1194,7 +1210,7 @@ int CWSCodec::UTF8ToUnicode(char* input, CSimpleStringW& output){
|
|
|
wszString = NULL;
|
|
|
return 0;
|
|
|
}
|
|
|
-
|
|
|
+#endif
|
|
|
void CWSCodec::hexdump(const char *buf, const int num){
|
|
|
char str[8192] = { 0 };
|
|
|
int i = 0;
|