示例#1
0
        public SearchingParser(
            IPositionedMessagesReader owner,
            CreateSearchingParserParams p,
            TextStreamPositioningParams textStreamPositioningParams,
            DejitteringParams?dejitteringParams,
            Stream rawStream,
            Encoding streamEncoding,
            bool allowPlainTextSearchOptimization,
            LoadedRegex headerRe,
            ILogSourceThreads threads,
            ITraceSourceFactory traceSourceFactory,
            RegularExpressions.IRegexFactory regexFactory
            )
        {
            this.owner        = owner;
            this.parserParams = p;
            this.plainTextSearchOptimizationAllowed = allowPlainTextSearchOptimization && ((p.Flags & MessagesParserFlag.DisablePlainTextSearchOptimization) == 0);
            this.threads        = threads;
            this.requestedRange = p.Range;
            this.textStreamPositioningParams = textStreamPositioningParams;
            this.dejitteringParams           = dejitteringParams;
            this.rawStream      = rawStream;
            this.streamEncoding = streamEncoding;
            this.regexFactory   = regexFactory;
            this.trace          = traceSourceFactory.CreateTraceSource("LogSource", "srchp." + GetHashCode().ToString("x"));
            this.dummyFilter    = new Filter(FilterAction.Include, "", true, new Search.Options(), null, regexFactory);
            var continuationToken = p.ContinuationToken as ContinuationToken;

            if (continuationToken != null)
            {
                this.requestedRange = new FileRange.Range(continuationToken.NextPosition, requestedRange.End);
            }
            this.aligmentTextAccess      = new StreamTextAccess(rawStream, streamEncoding, textStreamPositioningParams);
            this.aligmentSplitter        = new MessagesSplitter(aligmentTextAccess, headerRe.Clone().Regex, headerRe.GetHeaderReSplitterFlags());
            this.aligmentCapture         = new TextMessageCapture();
            this.progressAndCancellation = new ProgressAndCancellation()
            {
                progressHandler   = p.ProgressHandler,
                cancellationToken = p.Cancellation,
                continuationToken = new ContinuationToken()
                {
                    NextPosition = requestedRange.Begin
                }
            };
            this.impl = Enum();
        }
示例#2
0
        protected static LoadedRegex ReadRe(XElement root, string name, ReOptions opts)
        {
            LoadedRegex ret = new LoadedRegex();
            var         n   = root.Element(name);

            if (n == null)
            {
                return(ret);
            }
            string pattern = n.Value;

            if (string.IsNullOrEmpty(pattern))
            {
                return(ret);
            }
            ret.Regex = RegexFactory.Instance.Create(pattern, opts);
            XAttribute attr;

            ret.SuffersFromPartialMatchProblem =
                (attr = n.Attribute("suffers-from-partial-match-problem")) != null &&
                attr.Value == "yes";
            return(ret);
        }
 protected static LoadedRegex CloneRegex(LoadedRegex re, ReOptions optionsToAdd = ReOptions.None)
 {
     return(re.Clone(optionsToAdd));
 }