※OLE2T が実行されるたびに、スタック領域が消費されるのでループ内での使用や、非常に大きな文字列の使用は避けてね!
#include <regex>
#include <string>
#include <iostream>
.....
// パーサー
LPTSTR p_json = OLE2T(json);
// strtok "}"で区切り
LPTSTR p_tp;
LPTSTR p_next;
p_tp = _tcstok_s(p_json,_T("}"),&p_next); // 最初の1回
while( p_tp != NULL ){
std::wcmatch match;
std::wregex regex(_T("\"ABC\":[0123456789]*"));
if (std::regex_search(p_tp, match, regex))
{
const wchar_t* p = match.str().data();
double dhp = _tstof(match.str().data()+_tcslen(_T("\"ABC\":")));
std::wstring aa = match.str();
}
p_tp = _tcstok_s(NULL,_T("}"),&p_next);
}
どうも内部でstringの生成&コピーしてるようなのでループで数こなす処理だと速度が遅いかも。
ネタ元