Kaynağa Gözat

修复转xml后,未去空格导致的抄写问题。

jianfeng1.wang 2 yıl önce
ebeveyn
işleme
4049f88d84
1 değiştirilmiş dosya ile 12 ekleme ve 10 silme
  1. 12 10
      TCLCommand/TCLCommand/Command.cpp

+ 12 - 10
TCLCommand/TCLCommand/Command.cpp

@@ -285,16 +285,18 @@ bool TCLCommand::ParseCommandsFromXml(std::string strFileOrString, std::vector<C
 					cmdparam.nOption = CMDOPT_Write;
 			}
 
-			if (_tcsicmp(pAttr->Name(), "head") == 0) {
-				cmdparam.head = pAttr->Value();
-			}
-
-			if (_tcsicmp(pAttr->Name(), "cmd") == 0) {
-				cmdparam.cmd = pAttr->Value();
-			}
-
-			if (_tcsicmp(pAttr->Name(), "param") == 0) {
-				cmdparam.param = pAttr->Value();
+			if (_tcsicmp(pAttr->Name(), "head") == 0 || _tcsicmp(pAttr->Name(), "cmd") == 0 || _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.head = strValue;
 			}
 
 			if (_tcsicmp(pAttr->Name(), "returnParam") == 0) {