OSDN Git Service

Add some predicated searching functions to StringRef.
authorZachary Turner <zturner@google.com>
Sun, 25 Sep 2016 03:27:29 +0000 (03:27 +0000)
committerZachary Turner <zturner@google.com>
Sun, 25 Sep 2016 03:27:29 +0000 (03:27 +0000)
commit568a8f4a4de56dd51a118dd7559b497cee8f8b96
treef711e05a8143a4027a5fc787f129934aef4aca74
parent386ab19245cb9b6bcb73a0209ac76e730125faf8
Add some predicated searching functions to StringRef.

This adds 4 new functions to StringRef, which can be used to
take or drop characters while a certain condition is met, or
until a certain condition is met.  They are:

take_while - Return characters until a condition is not met.
take_until - Return characters until a condition is met.
drop_while - Remove characters until a condition is not met.
drop_until - Remove characters until a condition is met.

Internally, all of these functions delegate to two additional
helper functions which can be used to search for the position
of a character meeting or not meeting a condition, which are:

find_if - Find the first character matching a predicate.
find_if_not - Find the first character not matching a predicate.

Differential Revision: https://reviews.llvm.org/D24842

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282346 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/ADT/StringRef.h
unittests/ADT/StringRefTest.cpp