瀏覽代碼

修复多个xml值赋值给head的问题。

jianfeng1.wang 2 年之前
父節點
當前提交
e39b789bfd
共有 1 個文件被更改,包括 29 次插入1 次删除
  1. 29 1
      TCLCommand/TCLCommand/Command.cpp

+ 29 - 1
TCLCommand/TCLCommand/Command.cpp

@@ -285,7 +285,7 @@ bool TCLCommand::ParseCommandsFromXml(std::string strFileOrString, std::vector<C
 					cmdparam.nOption = CMDOPT_Write;
 			}
 
-			if (_tcsicmp(pAttr->Name(), "head") == 0 || _tcsicmp(pAttr->Name(), "cmd") == 0 || _tcsicmp(pAttr->Name(), "param") == 0) 
+			if (_tcsicmp(pAttr->Name(), "head") == 0) 
 			{
 				std::string strValue = pAttr->Value();
 				// È¥³ý¿Õ¸ñ;
@@ -299,6 +299,34 @@ bool TCLCommand::ParseCommandsFromXml(std::string strFileOrString, std::vector<C
 				cmdparam.head = strValue;
 			}
 
+			if ( _tcsicmp(pAttr->Name(), "cmd") == 0 ) 
+			{
+				std::string strValue = pAttr->Value();
+				// È¥³ý¿Õ¸ñ;
+#if _MSC_VER > 1900
+				strValue.erase(std::remove_if(strValue.begin(), strValue.end(), [](unsigned char x) {return std::isspace(x); }), strValue.end()); //C++17
+#else
+				for (std::string::iterator it = strValue.begin(); it != strValue.end();) {
+					!isspace(*it) ? it++ : it = it = strValue.erase(it);
+				}
+#endif
+				cmdparam.cmd = strValue;
+			}
+
+			if (_tcsicmp(pAttr->Name(), "param") == 0) 
+			{
+				std::string strValue = pAttr->Value();
+				// È¥³ý¿Õ¸ñ;
+#if _MSC_VER > 1900
+				strValue.erase(std::remove_if(strValue.begin(), strValue.end(), [](unsigned char x) {return std::isspace(x); }), strValue.end()); //C++17
+#else
+				for (std::string::iterator it = strValue.begin(); it != strValue.end();) {
+					!isspace(*it) ? it++ : it = it = strValue.erase(it);
+				}
+#endif
+				cmdparam.param = strValue;
+			}
+
 			if (_tcsicmp(pAttr->Name(), "returnParam") == 0) {
 				cmdparam.returnParam = pAttr->BoolValue();
 			}