bool SearchWithAnchoring()

in rapidjson/internal/regex.h [607:639]


    bool SearchWithAnchoring(InputStream& is, bool anchorBegin, bool anchorEnd) const {
        RAPIDJSON_ASSERT(IsValid());
        DecodedStream<InputStream> ds(is);

        state0_.Clear();
        Stack<Allocator> *current = &state0_, *next = &state1_;
        const size_t stateSetSize = GetStateSetSize();
        std::memset(stateSet_, 0, stateSetSize);

        bool matched = AddState(*current, root_);
        unsigned codepoint;
        while (!current->Empty() && (codepoint = ds.Take()) != 0) {
            std::memset(stateSet_, 0, stateSetSize);
            next->Clear();
            matched = false;
            for (const SizeType* s = current->template Bottom<SizeType>(); s != current->template End<SizeType>(); ++s) {
                const State& sr = GetState(*s);
                if (sr.codepoint == codepoint ||
                    sr.codepoint == kAnyCharacterClass || 
                    (sr.codepoint == kRangeCharacterClass && MatchRange(sr.rangeStart, codepoint)))
                {
                    matched = AddState(*next, sr.out) || matched;
                    if (!anchorEnd && matched)
                        return true;
                }
                if (!anchorBegin)
                    AddState(*next, root_);
            }
            internal::Swap(current, next);
        }

        return matched;
    }