diff options
author | Eva Hasler <evahasler@gmail.com> | 2012-03-27 00:17:10 +0400 |
---|---|---|
committer | Eva Hasler <evahasler@gmail.com> | 2012-03-27 00:17:10 +0400 |
commit | 614c98e6825ac5286c42dee259a63a23531e8ca9 (patch) | |
tree | a5db03ed9553b59152c2b9a77eb2072483f3b8b0 /util/tokenize_piece.hh | |
parent | 67588813570dc2ab762f4c5e0fffc041983d09ba (diff) |
fix feature name splitting to split on last colon
Diffstat (limited to 'util/tokenize_piece.hh')
-rw-r--r-- | util/tokenize_piece.hh | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/util/tokenize_piece.hh b/util/tokenize_piece.hh index 413bda0b9..7234ed0c6 100644 --- a/util/tokenize_piece.hh +++ b/util/tokenize_piece.hh @@ -87,6 +87,22 @@ class AnyCharacter { return StringPiece(std::find_first_of(in.data(), in.data() + in.size(), chars_.data(), chars_.data() + chars_.size()), 1); } + StringPiece FindLast(const StringPiece &in) const { + return StringPiece(std::find_end(in.data(), in.data() + in.size(), chars_.data(), chars_.data() + chars_.size()), 1); + } + + private: + StringPiece chars_; +}; + +class AnyCharacterLast { + public: + explicit AnyCharacterLast(const StringPiece &chars) : chars_(chars) {} + + StringPiece Find(const StringPiece &in) const { + return StringPiece(std::find_end(in.data(), in.data() + in.size(), chars_.data(), chars_.data() + chars_.size()), 1); + } + private: StringPiece chars_; }; |