本文整理汇总了C++中wxRegEx::GetMatch方法的典型用法代码示例。如果您正苦于以下问题:C++ wxRegEx::GetMatch方法的具体用法?C++ wxRegEx::GetMatch怎么用?C++ wxRegEx::GetMatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxRegEx
的用法示例。
在下文中一共展示了wxRegEx::GetMatch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDebugeePID
void DbgGdb::GetDebugeePID(const wxString& line)
{
if(m_debuggeePid == wxNOT_FOUND) {
if(GetIsRemoteDebugging()) {
m_debuggeePid = m_gdbProcess->GetPid();
} else {
static wxRegEx reDebuggerPidWin(wxT("New Thread ([0-9]+)\\.(0[xX][0-9a-fA-F]+)"));
static wxRegEx reGroupStarted(wxT("id=\"([0-9]+)\""));
static wxRegEx reSwitchToThread(wxT("Switching to process ([0-9]+)"));
// test for the debuggee PID
// in the line with the following pattern:
// =thread-group-started,id="i1",pid="15599"
if(m_debuggeePid < 0 && !line.IsEmpty()) {
wxString debuggeePidStr;
if(line.Contains(wxT("=thread-group-started")) && reGroupStarted.Matches(line)) {
debuggeePidStr = reGroupStarted.GetMatch(line, 1);
} else if(line.Contains(wxT("=thread-group-created")) && reGroupStarted.Matches(line)) {
debuggeePidStr = reGroupStarted.GetMatch(line, 1);
} else if(reDebuggerPidWin.Matches(line)) {
debuggeePidStr = reDebuggerPidWin.GetMatch(line, 1);
} else if(reSwitchToThread.Matches(line)) {
debuggeePidStr = reSwitchToThread.GetMatch(line, 1);
}
if(!debuggeePidStr.IsEmpty()) {
long iPid(0);
if(debuggeePidStr.ToLong(&iPid)) {
m_debuggeePid = iPid;
wxString msg;
msg << wxT(">> Debuggee process ID: ") << m_debuggeePid;
m_observer->UpdateAddLine(msg);
// Now there's a known pid, the debugger can be interrupted to let any to-be-disabled bps be
// disabled. So...
m_observer->DebuggerPidValid();
}
}
}
}
}
}
示例2: GetVersion
double clClangFormatLocator::GetVersion(const wxString& clangFormat) const
{
double double_version = 3.3;
#ifdef __WXGTK__
// Ubuntu clang-format version 3.5.0-4ubuntu2~trusty2 (tags/RELEASE_350/final) (based on LLVM 3.5.0) // Linux
// LLVM version 3.3 // Linux, old format
// clang-format version 3.6.0 (217570) // Windows
double_version = 3.3;
static wxRegEx reClangFormatVersion("version ([0-9]+\\.[0-9]+)");
wxString command;
command << clangFormat;
::WrapWithQuotes(command);
command << " --version";
wxString output = ProcUtils::SafeExecuteCommand(command);
wxArrayString lines = ::wxStringTokenize(output, "\n", wxTOKEN_STRTOK);
for(size_t i = 0; i < lines.GetCount(); ++i) {
if(reClangFormatVersion.Matches(lines.Item(i))) {
wxString version = reClangFormatVersion.GetMatch(lines.Item(i), 1);
//wxLogMessage("clang-format version is %s", version);
version.ToCDouble(&double_version);
return double_version;
}
}
#elif defined(__WXMSW__)
double_version = 3.6;
#else
double_version = 3.5;
#endif
return double_version; // Default
}
示例3: AdjustPathForCygwinIfNeeded
void CodeLiteApp::AdjustPathForCygwinIfNeeded()
{
#ifdef __WXMSW__
CL_DEBUG("AdjustPathForCygwinIfNeeded called");
if(!::clIsCygwinEnvironment()) {
CL_DEBUG("Not running under Cygwin - nothing be done");
return;
}
CL_SYSTEM("Cygwin environment detected");
wxString cygwinRootDir;
CompilerLocatorCygwin cygwin;
if(cygwin.Locate()) {
// this will return the base folder for cygwin (e.g. D:\cygwin)
cygwinRootDir = (*cygwin.GetCompilers().begin())->GetInstallationPath();
}
// Running under Cygwin
// Adjust the PATH environment variable
wxString pathEnv;
::wxGetEnv("PATH", &pathEnv);
// Always add the default paths
wxArrayString paths;
if(!cygwinRootDir.IsEmpty()) {
CL_SYSTEM("Cygwin root folder is: %s", cygwinRootDir);
wxFileName cygwinBinFolder(cygwinRootDir, "");
cygwinBinFolder.AppendDir("bin");
paths.Add(cygwinBinFolder.GetPath());
}
paths.Add("/usr/local/bin");
paths.Add("/usr/bin");
paths.Add("/usr/sbin");
paths.Add("/bin");
paths.Add("/sbin");
// Append the paths from the environment variables
wxArrayString userPaths = ::wxStringTokenize(pathEnv, ";", wxTOKEN_STRTOK);
paths.insert(paths.end(), userPaths.begin(), userPaths.end());
wxString fixedPath;
for(size_t i = 0; i < paths.GetCount(); ++i) {
wxString& curpath = paths.Item(i);
static wxRegEx reCygdrive("/cygdrive/([A-Za-z])");
if(reCygdrive.Matches(curpath)) {
// Get the drive letter
wxString volume = reCygdrive.GetMatch(curpath, 1);
volume << ":";
reCygdrive.Replace(&curpath, volume);
}
fixedPath << curpath << ";";
}
CL_DEBUG("Setting PATH environment variable to:\n%s", fixedPath);
::wxSetEnv("PATH", fixedPath);
#endif
}
示例4: SortReferences
/**
* Compare two references (e.g. "R100", "R19") and perform a 'natural' sort
* This sorting must preserve numerical order rather than alphabetical
* e.g. "R100" is lower (alphabetically) than "R19"
* BUT should be placed after R19
*/
int BOM_TABLE_GROUP::SortReferences( const wxString& aFirst, const wxString& aSecond )
{
// Default sorting
int defaultSort = aFirst.Cmp( aSecond );
static const wxString REGEX_STRING = "^([a-zA-Z]+)(\\d+)$";
// Compile regex statically
static wxRegEx regexFirst( REGEX_STRING, wxRE_ICASE | wxRE_ADVANCED );
static wxRegEx regexSecond( REGEX_STRING, wxRE_ICASE | wxRE_ADVANCED );
if( !regexFirst.Matches( aFirst ) || !regexSecond.Matches( aSecond ) )
{
return defaultSort;
}
// First priority is to order by prefix
wxString prefixFirst = regexFirst.GetMatch( aFirst, 1 );
wxString prefixSecond = regexSecond.GetMatch( aSecond, 1 );
if( prefixFirst.CmpNoCase( prefixSecond ) != 0 ) // Different prefixes!
{
return defaultSort;
}
wxString numStrFirst = regexFirst.GetMatch( aFirst, 2 );
wxString numStrSecond = regexSecond.GetMatch( aSecond, 2 );
// If either match failed, just return normal string comparison
if( numStrFirst.IsEmpty() || numStrSecond.IsEmpty() )
{
return defaultSort;
}
// Convert each number string to an integer
long numFirst = 0;
long numSecond = 0;
// If either conversion fails, return normal string comparison
if( !numStrFirst.ToLong( &numFirst ) || !numStrSecond.ToLong( &numSecond ) )
{
return defaultSort;
}
return (int) (numFirst - numSecond);
}
示例5: OnTernOutput
void clTernServer::OnTernOutput(clProcessEvent& event)
{
static wxRegEx rePort("Listening on port ([0-9]+)");
if(rePort.IsValid() && rePort.Matches(event.GetOutput())) {
wxString strPort = rePort.GetMatch(event.GetOutput(), 1);
strPort.ToCLong(&m_port);
}
PrintMessage(event.GetOutput());
}
示例6: GetGCCVersion
wxString CompilerLocatorCygwin::GetGCCVersion(const wxString& gccBinary)
{
static wxRegEx reVersion("([0-9]+\\.[0-9]+\\.[0-9]+)");
wxString command;
command << gccBinary << " --version";
wxString versionString = ProcUtils::SafeExecuteCommand(command);
if ( !versionString.IsEmpty() && reVersion.Matches( versionString ) ) {
return reVersion.GetMatch( versionString );
}
return wxEmptyString;
}
示例7: AppendLine
void CppCheckReportPage::AppendLine(const wxString& line)
{
wxString tmpLine(line);
// Locate status messages:
// 6/7 files checked 85% done
static wxRegEx reProgress(wxT("([0-9]+)/([0-9]+)( files checked )([0-9]+%)( done)"));
static wxRegEx reFileName(wxT("(Checking )([a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)"));
// Locate the progress messages and update our progress bar
wxArrayString arrLines = wxStringTokenize(tmpLine, wxT("\n\r"), wxTOKEN_STRTOK);
for(size_t i = 0; i < arrLines.GetCount(); i++) {
if(reProgress.Matches(arrLines.Item(i))) {
// Get the current progress
wxString currentLine = reProgress.GetMatch(arrLines.Item(i), 1);
long fileNo(0);
currentLine.ToLong(&fileNo);
}
if(reFileName.Matches(arrLines.Item(i))) {
// Get the file name
wxString filename = reFileName.GetMatch(arrLines.Item(i), 2);
m_mgr->SetStatusMessage("CppCheck: checking file " + filename);
}
}
// Remove progress messages from the printed output
reProgress.ReplaceAll(&tmpLine, wxEmptyString);
tmpLine.Replace(wxT("\r"), wxT(""));
tmpLine.Replace(wxT("\n\n"), wxT("\n"));
m_stc->SetReadOnly(false);
m_stc->AppendText(tmpLine);
m_stc->SetReadOnly(true);
m_stc->ScrollToLine(m_stc->GetLineCount() - 1);
}
示例8: GetLineNumberFromFilter
void OpenResourceDialog::GetLineNumberFromFilter(const wxString& filter, wxString& modFilter, long& lineNumber)
{
modFilter = filter;
lineNumber = -1;
static wxRegEx reNumber(":([0-9]+)", wxRE_ADVANCED);
if(reNumber.IsValid() && reNumber.Matches(modFilter)) {
wxString strLineNumber;
strLineNumber = reNumber.GetMatch(modFilter, 1);
strLineNumber.ToCLong(&lineNumber);
reNumber.Replace(&modFilter, "");
}
}
示例9: DoOpenLine
void CppCheckReportPage::DoOpenLine(int outputLine)
{
static wxRegEx gccPattern(wxT("^([^ ][a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([0-9]*)(:)([a-zA-Z ]*)"));
static int fileIndex = 1;
static int lineIndex = 3;
wxString txt = m_stc->GetLine(outputLine);
if(gccPattern.Matches(txt)) {
wxString file = gccPattern.GetMatch(txt, fileIndex);
wxString lineNumber = gccPattern.GetMatch(txt, lineIndex);
if(file.IsEmpty() == false) {
long n(0);
lineNumber.ToCLong(&n);
// Zero based line number
if(n) n--;
m_mgr->OpenFile(file, wxEmptyString, n);
}
}
}
示例10: IsIncludeOrRequireStatement
bool PHPEditorContextMenu::IsIncludeOrRequireStatement(wxString& includeWhat)
{
// Do a basic check to see whether this line is include statement or not.
// Don't bother in full parsing the file since it can be a quite an expensive operation
// (include|require_once|require|include_once)[ \t\\(]*(.*?)[\\) \t)]*;
static wxRegEx reInclude(wxT("(include|require_once|require|include_once)[ \t\\(]*(.*?)[\\) \t]*;"), wxRE_ADVANCED);
IEditor* editor = m_manager->GetActiveEditor();
if(!editor) return false;
wxString line = editor->GetCtrl()->GetLine(editor->GetCurrentLine());
if(reInclude.IsValid() && reInclude.Matches(line)) {
includeWhat = reInclude.GetMatch(line, 2);
return true;
}
return false;
}
示例11: GetGCCVersion
wxString Compiler::GetGCCVersion() const
{
// Get the compiler version
static wxRegEx reVersion("([0-9]+\\.[0-9]+\\.[0-9]+)");
wxString command;
command << GetTool("CXX") << " --version";
wxArrayString out;
ProcUtils::SafeExecuteCommand(command, out);
if(out.IsEmpty()) {
return "";
}
if(reVersion.Matches(out.Item(0))) {
return reVersion.GetMatch(out.Item(0));
}
return "";
}
示例12: BreakpointHit
// When a a breakpoint is hit, see if it's got a command-list that needs faking
void BreakptMgr::BreakpointHit(int id)
{
int index = FindBreakpointById(id, m_bps);
if ((index == wxNOT_FOUND) || (index >= FIRST_INTERNAL_ID)) {
return;
}
BreakpointInfo bp = m_bps.at(index);
if (! bp.commandlist.IsEmpty()) {
IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger();
if (dbgr && dbgr->IsRunning()) {
// A likely command, presumably at the end of the command-list, is 'continue' or 'cont'
// Filter this out and do it separately, otherwise Manager::UpdateLostControl isn't called to blank the indicator
static wxRegEx reContinue(wxT("(([[:space:]]|(^))((cont$)|(continue)))"));
bool needsCont = false;
wxString commands = bp.commandlist;
if (reContinue.IsValid() && reContinue.Matches(commands)) {
size_t start, len;
if (reContinue.GetMatch(&start,&len)) {
commands = commands.Left(start);
needsCont = true;
}
}
if (! commands.IsEmpty()) { // Just in case someone's _only_ command is 'continue' !
dbgr->ExecuteCmd(commands);
}
if (needsCont) {
dbgr->Continue();
}
}
}
if (bp.bp_type == BP_type_tempbreak) {
// If this is a temporary bp, remove it from m_bps now it's been hit
// Otherwise it will be treated as a 'Pending' bp, the button will be displayed
// and, if clicked, the bp will be resurrected.
int index = FindBreakpointById(id, m_bps);
if (index != wxNOT_FOUND) {
m_bps.erase(m_bps.begin()+index);
}
}
}
示例13: DetectRepeatingSymbols
inline int DetectRepeatingSymbols(wxString const &str, int pos)
{
int newPos = -1, currPos = pos;
while (1)
{
if (currPos + 4 >= static_cast<int>(str.length()))
break;
if (str[currPos + 1] != wxT(','))
break;
if (str[currPos + 3] == wxT('\''))
{
const wxString &s = str.substr(currPos + 3, str.length() - (currPos + 3));
if (regexRepeatedChars.Matches(s))
{
size_t start, length;
regexRepeatedChars.GetMatch(&start, &length, 0);
newPos = currPos + 3 + length;
if ((newPos + 4 < static_cast<int>(str.length()))
&& str[newPos] == wxT(',') && str[newPos + 2] == wxT('"'))
{
newPos += 3;
while (newPos < static_cast<int>(str.length()) && str[newPos] != wxT('"'))
++newPos;
if (newPos + 1 < static_cast<int>(str.length()) && str[newPos] == wxT('"'))
++newPos;
}
currPos = newPos;
}
else
break;
}
else
break;
// move the current position to point at the '"' character
currPos--;
}
return newPos;
}
示例14: parseTypeString
IDbType* MySqlDbAdapter::parseTypeString(const wxString& typeString)
{
static wxRegEx reType(wxT("([a-zA-Z]+)(\\([0-9]+\\))?"));
IDbType* type(NULL);
if(reType.Matches(typeString)) {
wxString typeName = reType.GetMatch(typeString, 1);
wxString strSize = reType.GetMatch(typeString, 2);
typeName.MakeUpper();
type = this->GetDbTypeByName(typeName);
if(type) {
strSize.Trim().Trim(false);
if(strSize.StartsWith(wxT("("))) { strSize.Remove(0, 1); }
if(strSize.EndsWith(wxT(")"))) { strSize.RemoveLast(); }
long size = 0;
if(strSize.ToLong(&size)){
type->SetSize(size);
}
}
}
return type;
}
示例15: OnButtonOK
void AddIncludeFileDlg::OnButtonOK(wxCommandEvent &e)
{
wxUnusedVar(e);
//get the include file to add
wxString fullpath = m_textCtrlFullPath->GetValue();
static wxRegEx reIncludeFile(wxT("include *[\\\"\\<]{1}([a-zA-Z0-9_/\\.]*)"));
wxString relativePath;
if (reIncludeFile.Matches(m_textCtrlLineToAdd->GetValue())) {
relativePath = reIncludeFile.GetMatch(m_textCtrlLineToAdd->GetValue(), 1);
}
fullpath.Replace(wxT("\\"), wxT("/"));
relativePath.Replace(wxT("\\"), wxT("/"));
wxFileName fn(fullpath);
wxString inclPath;
if (fullpath.EndsWith(relativePath, &inclPath) &&
fullpath != relativePath && //dont save the '.' path this is done by default
fn.GetFullName() != relativePath) { //if the relative path is only file name, nothing to cache
m_includePath.Add(inclPath);
}
EndModal(wxID_OK);
}