{"id":592,"date":"2008-08-23T09:52:12","date_gmt":"2008-08-23T07:52:12","guid":{"rendered":"https:\/\/alax.info\/blog\/?p=592"},"modified":"2008-08-23T20:43:02","modified_gmt":"2008-08-23T18:43:02","slug":"how-to-dump-catlregexp-regular-expression-variable-on-parse-error","status":"publish","type":"post","link":"https:\/\/alax.info\/blog\/592","title":{"rendered":"How To: Dump CAtlRegExp regular expression variable on parse error"},"content":{"rendered":"<p><a href=\"http:\/\/www.codeplex.com\/AtlServe\">ATL regular expression code<\/a> adds dump\/debug capabilities with <strong>ATL_REGEXP_DUMP<\/strong> preprocessor definition defined (undocumented). Dump output is directed to <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/40bbyw78.aspx\">stdout<\/a>, so if the application is not console, it has to be redirected in advance, e.g. into a <em>$(BinaryPath)$(BinaryName)-atlrx.h<\/em> file.<\/p>\n<pre>\tCAtlRegExp&lt;&gt; Expression; LPCTSTR pszPattern; BOOL bCaseSensitive;\r\n#if defined(ATL_REGEXP_DUMP)\r\n\tREParseError Error = Expression.Parse(pszPattern, bCaseSensitive);\r\n\tif(Error != REPARSE_ERROR_OK)\r\n\t{\r\n\t\tFILE* pStream = NULL;\r\n\t\tif(!GetStdHandle(STD_OUTPUT_HANDLE))\r\n\t\t{\r\n\t\t\tTCHAR pszPath[MAX_PATH] = { 0 };\r\n\t\t\tATLVERIFY(GetModuleFileName(_AtlBaseModule.GetModuleInstance(), pszPath, _countof(pszPath)));\r\n\t\t\tRemoveExtension(pszPath); \/\/ ATLPath::\r\n\t\t\t_tcscat_s(pszPath, _countof(pszPath), _T(\"-atlrx.txt\"));\r\n\t\t\tATLVERIFY(freopen_s(&amp;pStream, CStringA(pszPath), \"w\", stdout) == 0);\r\n\t\t}\r\n\t\t_tprintf(_T(\"Error %d\\n\"), Error);\r\n\t\tExpression.Dump();\r\n\t\tif(pStream)\r\n\t\t\tATLVERIFY(fclose(pStream) == 0);\r\n\t\tATLASSERT(FALSE); \/\/ Break into debugger\r\n\t}\r\n#else\r\n\tATLVERIFY(Expression.Parse(pszPattern, bCaseSensitive) == REPARSE_ERROR_OK);\r\n#endif \/\/ defined(ATL_REGEXP_DUMP)<\/pre>\n<p>There is also <strong>ATLRX_DEBUG<\/strong> definition, which enables other debug capabilities. <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/k3zs4axe(VS.80).aspx\">CAtlRegExp<\/a> object is given a virtual function OnDebugEvent through which it prints comments on <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/s1d10w8z(VS.80).aspx\">CAtlRegExp::Match<\/a> process, which can be also redirected to file similar way.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ATL regular expression code adds dump\/debug capabilities with ATL_REGEXP_DUMP preprocessor definition defined (undocumented). Dump output is directed to stdout, so if the application is not console, it has to be redirected in advance, e.g. into a $(BinaryPath)$(BinaryName)-atlrx.h file. CAtlRegExp&lt;&gt; Expression; LPCTSTR pszPattern; BOOL bCaseSensitive; #if defined(ATL_REGEXP_DUMP) REParseError Error = Expression.Parse(pszPattern, bCaseSensitive); if(Error != REPARSE_ERROR_OK) {&hellip; <\/p>\n<p><a class=\"moretag\" href=\"https:\/\/alax.info\/blog\/592\">Read the full article<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[487,47,109,110],"class_list":["post-592","post","type-post","status-publish","format-standard","hentry","category-atl","tag-atl","tag-howto","tag-regexp","tag-regular-expressions"],"_links":{"self":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/592","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/comments?post=592"}],"version-history":[{"count":0,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/592\/revisions"}],"wp:attachment":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/media?parent=592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/categories?post=592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/tags?post=592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}