码迷,mamicode.com
首页 > 编程语言 > 详细

Code-C++-Cut CString to get keyValue by ","||"}"

时间:2020-07-10 09:43:09      阅读:52      评论:0      收藏:0      [点我收藏+]

标签:++   lse   etl   source   flag   temp   length   ||   code   

Code-C++-Cut CString to get keyValue by ","||"}"

July 10, 2020 2:19 AM

// cut CString to get keyValue
void GetKeyValue(CString strSource, CString strKey, CString& strValue)
{
	CString strTemp = strSource;
	int n = strTemp.Find(strKey.GetString(), 0);

	if (n == -1)
	{
		strValue = _T("0");
		return;
	}

	strTemp = strTemp.Mid(n + strKey.GetLength() + 2); //"AA":BB
	int n1 = strTemp.ReverseFind(‘,‘);//End Flag
	int n2 = strTemp.ReverseFind(‘}‘);//End Flag

	if (n1 >= 0 && n2 >= 0)
	{
		n = n1 > n2 ? n2 : n1;
	}
	else if (n1 == -1)
	{
		n = n2;
	}
	else if (n2 == -1)
	{
		n = n1;
	}

	strValue = strTemp.Left(n);

}

Code-C++-Cut CString to get keyValue by ","||"}"

标签:++   lse   etl   source   flag   temp   length   ||   code   

原文地址:https://www.cnblogs.com/yongchao/p/13277267.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!