1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2009, 2011, 2013-2014 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "TortoiseProc.h"
21 #include "AutoTextTestDlg.h"
22 #include "HighResClock.h"
27 // CAutoTextTestDlg dialog
29 IMPLEMENT_DYNAMIC(CAutoTextTestDlg
, CDialog
)
31 CAutoTextTestDlg::CAutoTextTestDlg(CWnd
* pParent
/*=nullptr*/)
32 : CDialog(CAutoTextTestDlg::IDD
, pParent
)
36 CAutoTextTestDlg::~CAutoTextTestDlg()
40 void CAutoTextTestDlg::DoDataExchange(CDataExchange
* pDX
)
42 CDialog::DoDataExchange(pDX
);
43 DDX_Text(pDX
, IDC_AUTOTEXTREGEX
, m_sRegex
);
44 DDX_Text(pDX
, IDC_TESTRESULT
, m_sResult
);
45 DDX_Text(pDX
, IDC_TIMINGLABEL
, m_sTimingLabel
);
46 DDX_Control(pDX
, IDC_AUTOTEXTCONTENT
, m_cContent
);
49 BEGIN_MESSAGE_MAP(CAutoTextTestDlg
, CDialog
)
50 ON_BN_CLICKED(IDC_AUTOTEXTSCAN
, &CAutoTextTestDlg::OnBnClickedAutotextscan
)
54 BOOL
CAutoTextTestDlg::OnInitDialog()
56 CDialog::OnInitDialog();
57 CAppUtils::MarkWindowAsUnpinnable(m_hWnd
);
59 m_cContent
.LimitText(200*1024);
64 void CAutoTextTestDlg::OnBnClickedAutotextscan()
69 m_sTimingLabel
.Empty();
70 m_cContent
.GetTextRange(0, m_cContent
.GetTextLength(), m_sContent
);
71 if ((!m_sContent
.IsEmpty())&&(!m_sRegex
.IsEmpty()))
75 std::set
<CString
> autolist
;
76 std::wstring s
= m_sContent
;
79 std::tr1::wregex regCheck
;
80 regCheck
= std::tr1::wregex(m_sRegex
, std::tr1::regex_constants::icase
| std::tr1::regex_constants::ECMAScript
);
81 const std::tr1::wsregex_iterator end
;
82 for (std::tr1::wsregex_iterator
it(s
.cbegin(), s
.cend(), regCheck
); it
!= end
; ++it
)
84 const std::tr1::wsmatch match
= *it
;
85 for (size_t i
=1; i
<match
.size(); ++i
)
87 if (match
[i
].second
-match
[i
].first
)
89 ATLTRACE(L
"matched keyword : %s\n", std::wstring(match
[i
]).c_str());
90 std::wstring result
= std::wstring(match
[i
]);
93 autolist
.insert(result
.c_str());
99 for (const auto& append
: autolist
)
102 m_sResult
+= L
"\r\n";
104 m_sTimingLabel
.Format(L
"Parse time: %ld uSecs", timer
.GetMusecsTaken());
106 catch (std::exception
&ex
)
108 m_sResult
= L
"Regex is invalid!\r\n" + CString(ex
.what());