susumu.yata
null+****@clear*****
Tue Dec 16 10:45:45 JST 2014
susumu.yata 2014-11-25 19:02:24 +0900 (Tue, 25 Nov 2014) New Revision: 2995daa9c4217e647dd363b2bf709279849010f7 https://github.com/groonga/grnxx/commit/2995daa9c4217e647dd363b2bf709279849010f7 Message: Add Text::contains(). (#118) Modified files: include/grnxx/data_types/scalar/text.hpp Modified: include/grnxx/data_types/scalar/text.hpp (+14 -0) =================================================================== --- include/grnxx/data_types/scalar/text.hpp 2014-11-25 18:35:38 +0900 (52af5ef) +++ include/grnxx/data_types/scalar/text.hpp 2014-11-25 19:02:24 +0900 (c45d440) @@ -105,6 +105,20 @@ class Text { return has_greater_or_equal_size; } + Bool contains(const Text &rhs) const { + Bool has_greater_or_equal_size = (size_ >= rhs.size_); + if (has_greater_or_equal_size.is_true()) { + size_t end_offset = raw_size() - rhs.raw_size() + 1; + for (size_t offset = 0; offset < end_offset; ++offset) { + if (std::memcmp(data_ + offset, rhs.data_, rhs.raw_size()) == 0) { + return Bool(true); + } + } + return Bool(false); + } + return has_greater_or_equal_size; + } + bool match(const Text &rhs) const { if (size_.unmatch(rhs.size_)) { return false; -------------- next part -------------- HTML����������������������������... 下載