Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Search/ISearchStrategy.cs @ 17932

Last change on this file since 17932 was 11700, checked in by jkarder, 10 years ago

#2077: created branch and added first version

File size: 3.3 KB
Line 
1// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy of this
4// software and associated documentation files (the "Software"), to deal in the Software
5// without restriction, including without limitation the rights to use, copy, modify, merge,
6// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7// to whom the Software is furnished to do so, subject to the following conditions:
8//
9// The above copyright notice and this permission notice shall be included in all copies or
10// substantial portions of the Software.
11//
12// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17// DEALINGS IN THE SOFTWARE.
18
19using System;
20using System.Collections.Generic;
21using System.Runtime.Serialization;
22using ICSharpCode.NRefactory.Editor;
23using ICSharpCode.AvalonEdit.Document;
24
25namespace ICSharpCode.AvalonEdit.Search
26{
27  /// <summary>
28  /// Basic interface for search algorithms.
29  /// </summary>
30  public interface ISearchStrategy : IEquatable<ISearchStrategy>
31  {
32    /// <summary>
33    /// Finds all matches in the given ITextSource and the given range.
34    /// </summary>
35    /// <remarks>
36    /// This method must be implemented thread-safe.
37    /// All segments in the result must be within the given range, and they must be returned in order
38    /// (e.g. if two results are returned, EndOffset of first result must be less than or equal StartOffset of second result).
39    /// </remarks>
40    IEnumerable<ISearchResult> FindAll(ITextSource document, int offset, int length);
41   
42    /// <summary>
43    /// Finds the next match in the given ITextSource and the given range.
44    /// </summary>
45    /// <remarks>This method must be implemented thread-safe.</remarks>
46    ISearchResult FindNext(ITextSource document, int offset, int length);
47  }
48 
49  /// <summary>
50  /// Represents a search result.
51  /// </summary>
52  public interface ISearchResult : ISegment
53  {
54    /// <summary>
55    /// Replaces parts of the replacement string with parts from the match. (e.g. $1)
56    /// </summary>
57    string ReplaceWith(string replacement);
58  }
59 
60  /// <summary>
61  /// Defines supported search modes.
62  /// </summary>
63  public enum SearchMode
64  {
65    /// <summary>
66    /// Standard search
67    /// </summary>
68    Normal,
69    /// <summary>
70    /// RegEx search
71    /// </summary>
72    RegEx,
73    /// <summary>
74    /// Wildcard search
75    /// </summary>
76    Wildcard
77  }
78 
79  /// <inheritdoc/>
80  public class SearchPatternException : Exception, ISerializable
81  {
82    /// <inheritdoc/>
83    public SearchPatternException()
84    {
85    }
86   
87    /// <inheritdoc/>
88    public SearchPatternException(string message) : base(message)
89    {
90    }
91   
92    /// <inheritdoc/>
93    public SearchPatternException(string message, Exception innerException) : base(message, innerException)
94    {
95    }
96
97    // This constructor is needed for serialization.
98    /// <inheritdoc/>
99    protected SearchPatternException(SerializationInfo info, StreamingContext context) : base(info, context)
100    {
101    }
102  }
103}
Note: See TracBrowser for help on using the repository browser.