| 135 | StringPiece substr(size_type pos = 0, size_type n = npos) const; |
| 136 | |
| 137 | int compare(const StringPiece& x) const { |
| 138 | size_type min_size = std::min(size(), x.size()); |
| 139 | if (min_size > 0) { |
| 140 | int r = memcmp(data(), x.data(), min_size); |
| 141 | if (r < 0) return -1; |
| 142 | if (r > 0) return 1; |
| 143 | } |
| 144 | if (size() < x.size()) return -1; |
| 145 | if (size() > x.size()) return 1; |
| 146 | return 0; |
| 147 | } |
| 148 | |
| 149 | // Does "this" start with "x"? |
| 150 | bool starts_with(const StringPiece& x) const { |