Browse Source

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

jianfeng1.wang 2 years ago
parent
commit
e39b789bfd
1 changed files with 29 additions and 1 deletions
  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();
 			}