コード例 #1
0
        public PcreDfaMatchResult DfaMatch(string subject, PcreDfaMatchSettings settings, int startIndex, uint additionalOptions)
        {
            var input = new Native.dfa_match_input();

            settings.FillMatchInput(ref input);

            var oVector = new uint[2 * Math.Max(1, settings.MaxResults)];

            Native.match_result result;
            CalloutInterop.CalloutInteropInfo calloutInterop;

            fixed(char *pSubject = subject)
            fixed(uint *pOVec = &oVector[0])
            {
                input.code               = _code;
                input.subject            = pSubject;
                input.subject_length     = (uint)subject.Length;
                input.output_vector      = pOVec;
                input.start_index        = (uint)startIndex;
                input.additional_options = additionalOptions;

                CalloutInterop.Prepare(subject, this, ref input, out calloutInterop, settings.Callout);

                Native.dfa_match(ref input, out result);
            }

            AfterMatch(result, ref calloutInterop);

            return(new PcreDfaMatchResult(subject, ref result, oVector));
        }
コード例 #2
0
        public static void Prepare(string subject, InternalRegex regex, ref Native.dfa_match_input input, out CalloutInteropInfo interopInfo, Func <PcreCallout, PcreCalloutResult> callout)
        {
            if (callout != null)
            {
                interopInfo = new CalloutInteropInfo(subject, regex, callout);

                input.callout      = _calloutHandlerFnPtr;
                input.callout_data = interopInfo.ToPointer();
            }
            else
            {
                interopInfo   = default;
                input.callout = null;
            }
        }