Bläddra i källkod

Keyname全转小写。

scbc.sat2 5 år sedan
förälder
incheckning
40b639e9f0
1 ändrade filer med 40 tillägg och 1 borttagningar
  1. 40 1
      TestWizard/TestWizard/TestWizard.cpp

+ 40 - 1
TestWizard/TestWizard/TestWizard.cpp

@@ -21,6 +21,10 @@ std::vector<KeyItem> g_vtKeyItem;
 CSynSerial g_synSerial;
 CSerialPort g_serialPort;
 
+
+std::string tolower(const char *p);
+std::string toupper(const char *p);
+
 // 唯一的应用程序对象
 #ifdef __CONSOLE__ 
 
@@ -41,6 +45,7 @@ int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
 	}
 	else
 	{
+		std::string a = tolower("FFDFDFfdfdfdDDA");
 		// TODO: 在此处为应用程序的行为编写代码。
 		if ( OpenDevice(7, 115200, 8, 0, 0) )
 		{
@@ -154,6 +159,40 @@ PyMODINIT_FUNC initTestWizard()
 }
 #else
 
+std::string tolower(const char *p)
+{
+	if ( p == NULL )
+		return std::string();
+
+	std::string str;
+	while ( *p != '\0') {
+		if ( *p >= 'A' && *p <= 'Z' )
+			str.append(1,*p + 32);
+		else
+			str.append(1,*p);
+		p++;
+	}
+
+	return str;
+}
+
+std::string toupper(const char *p)
+{
+	if ( p == NULL )
+		return std::string();
+
+	std::string str;
+	while ( *p != '\0') {
+		if ( *p >= 'a' && *p <= 'z' )
+			str.append(1,*p - 32);
+		else
+			str.append(1,*p);
+		p++;
+	}
+
+	return str;
+}
+
 int __LoadXML(LPCTSTR lpXMLPath)
 {
 	if ( !lpXMLPath || !PathFileExists(lpXMLPath) )
@@ -191,7 +230,7 @@ int __LoadXML(LPCTSTR lpXMLPath)
 					while (pItem) {
 						if (_tcsicmp(pItem->Value(), _T("KeyName")) == 0)
 						{
-							keyItem.keyName = pItem->GetText();
+							keyItem.keyName = tolower(pItem->GetText());
 						}
 						else if (_tcsicmp(pItem->Value(), _T("KeyDesc")) == 0)
 						{