wxMaxima
Loading...
Searching...
No Matches
RegexSearch.h
Go to the documentation of this file.
1// -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
2//
3// Copyright (C) 2004-2015 Andrej Vodopivec <andrej.vodopivec@gmail.com>
4// (C) 2012-2013 Doug Ilijev <doug.ilijev@gmail.com>
5// (C) 2015 Gunter Königsmann <wxMaxima@physikbuch.de>
6//
7// This program is free software; you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation; either version 2 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17//
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21//
22// SPDX-License-Identifier: GPL-2.0+
23
30#ifndef REGEXSEARCH_H
31#define REGEXSEARCH_H
32
33#include "precomp.h"
34#include <wx/regex.h>
35
38class RegexSearch : public wxRegEx
39{
40public:
41 class Match
42 {
43 public:
44 Match(){m_start=wxNOT_FOUND;m_length = 0;}
45 void SetStart(std::size_t start){m_start = start; m_found = true;}
46 void SetNotFound(){m_found = false;}
47 bool Found() const {return m_found;}
48 void SetLength(std::size_t length){m_length = length;}
49 long long GetStart() const {return m_start;}
50 std::size_t GetLength() const {return m_length;}
51 std::size_t GetEnd() const {return m_start + m_length;}
52 private:
53 std::size_t m_start = 0;
54 std::size_t m_length = 0;
55 bool m_found = false;
56 };
57 explicit RegexSearch(const wxString &regex);
58 virtual ~RegexSearch();
59 Match FindNext(const wxString &string, std::size_t start);
60 Match FindNext_Reverse(const wxString &string, std::size_t start);
61 Match Replace(wxString *string, std::size_t start, const wxString &replacement);
62 Match Replace_Reverse(wxString *string, std::size_t start, const wxString &replacement);
63};
64
65#endif // REGEXSEARCH_H
Definition: RegexSearch.h:42
The find+replace dialog.
Definition: RegexSearch.h:39