#include "pch.h" #include "CDataParser1.h" CDataParser1::CDataParser1() { } int CDataParser1::PutIn(unsigned char * str, int len1) { if (len1 <= 0) return 0; memcpy(InBuf + nBufDataLen, str, len1); nBufDataLen += len1; int handx, handy; int j; for (j = 0; j < nBufDataLen; j++) { if (nBufDataLen - j < 20) { break; } //µÈ´ýÊý¾Ý if (InBuf[j] == 'v'&&nBufDataLen - j < 12) { break;} if (InBuf[j] == 'v'&&InBuf[j - 1] == ' '&&InBuf[j + 1] == ' ') { char hex1, hex2; hex1 = InBuf[j + 8]; hex2 = InBuf[j + 9]; if (hex1 <= '9'&&hex1 >= '0') { handx = (hex1 - '0') * 16; } else { handx = (hex1 - 'A' + 10) * 16; } if (hex2 <= '9'&&hex2 >= '0') { handx += hex2 - '0'; } else { handx += hex2 - 'A' + 10; } hex1 = InBuf[j + 11]; hex2 = InBuf[j + 12]; if (hex1 <= '9'&&hex1 >= '0') { handy = (hex1 - '0') * 16; } else { handy = (hex1 - 'A' + 10) * 16; } if (hex2 <= '9'&&hex2 >= '0') { handy += hex2 - '0'; } else { handy += hex2 - 'A' + 10; } m_bHasData = 1; m_Value1 = handx; m_Value2 = handy; } } //½«recv2ÒÆλµ½×î×ó¶Ë if (j == nBufDataLen) { nBufDataLen = 0; } else { nBufDataLen = nBufDataLen - j; memmove(InBuf, InBuf + j, nBufDataLen); } return m_bHasData; } int CDataParser1::GetOutput(int * value1, int * value2) { if (m_bHasData) { *value1 = m_Value1; *value2 = m_Value2; m_bHasData = 0; return 1; } return 0; } int GetOutputStr(char * buf, int & len1) { len1 = 0; return 0; }