| LEFT | RIGHT |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 return false; | 133 return false; |
| 134 | 134 |
| 135 return std::memcmp(mBuf, other.mBuf, sizeof(value_type) * length()) == 0; | 135 return std::memcmp(mBuf, other.mBuf, sizeof(value_type) * length()) == 0; |
| 136 } | 136 } |
| 137 | 137 |
| 138 constexpr bool operator==(const String& other) const | 138 constexpr bool operator==(const String& other) const |
| 139 { | 139 { |
| 140 return equals(other); | 140 return equals(other); |
| 141 } | 141 } |
| 142 | 142 |
| 143 bool operator!=(const String& other) const | 143 constexpr bool operator!=(const String& other) const |
| 144 { | 144 { |
| 145 return !equals(other); | 145 return !equals(other); |
| 146 } | 146 } |
| 147 | 147 |
| 148 size_type find(value_type c, size_type pos = 0) const | 148 constexpr size_type find(value_type c, size_type pos = 0) const |
| 149 { | 149 { |
| 150 for (size_type i = pos; i < length(); ++i) | 150 for (size_type i = pos; i < length(); ++i) |
| 151 if (mBuf[i] == c) | 151 if (mBuf[i] == c) |
| 152 return i; | 152 return i; |
| 153 return npos; | 153 return npos; |
| 154 } | 154 } |
| 155 | 155 |
| 156 size_type find(const String& str, size_type pos = 0) const | 156 constexpr size_type find(const String& str, size_type pos = 0) const |
| 157 { | 157 { |
| 158 return find(str.mBuf, pos, str.length()); | 158 return find(str.mBuf, pos, str.length()); |
| 159 } | 159 } |
| 160 | 160 |
| 161 size_type find(const value_type* str, size_type pos, size_type count) const | 161 constexpr size_type find(const value_type* str, size_type pos, size_type count
) const |
| 162 { | 162 { |
| 163 if (pos > LENGTH_MASK || pos + count > length()) | 163 if (pos > LENGTH_MASK || pos + count > length()) |
| 164 return npos; | 164 return npos; |
| 165 | 165 |
| 166 if (!count) | 166 if (!count) |
| 167 return pos; | 167 return pos; |
| 168 | 168 |
| 169 for (; pos + count <= length(); ++pos) | 169 for (; pos + count <= length(); ++pos) |
| 170 { | 170 { |
| 171 if (mBuf[pos] == str[0] && | 171 if (mBuf[pos] == str[0] && |
| 172 std::memcmp(mBuf + pos, str, sizeof(value_type) * count) == 0) | 172 std::memcmp(mBuf + pos, str, sizeof(value_type) * count) == 0) |
| 173 { | 173 { |
| 174 return pos; | 174 return pos; |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 | 177 |
| 178 return npos; | 178 return npos; |
| 179 } | 179 } |
| 180 | 180 |
| 181 size_type rfind(value_type c, size_type pos = npos) const | 181 constexpr size_type rfind(value_type c, size_type pos = npos) const |
| 182 { | 182 { |
| 183 if (length() == 0) | 183 if (length() == 0) |
| 184 return npos; | 184 return npos; |
| 185 | 185 |
| 186 if (pos >= length()) | 186 if (pos >= length()) |
| 187 pos = length() - 1; | 187 pos = length() - 1; |
| 188 | 188 |
| 189 for (int i = pos; i >= 0; --i) | 189 for (int i = pos; i >= 0; --i) |
| 190 if (mBuf[i] == c) | 190 if (mBuf[i] == c) |
| 191 return i; | 191 return i; |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 return OwnedString{value}; | 562 return OwnedString{value}; |
| 563 } | 563 } |
| 564 | 564 |
| 565 DependentString TrimSpaces(const String& value); | 565 DependentString TrimSpaces(const String& value); |
| 566 | 566 |
| 567 // Splits the `value` string into two `DependentString`s excluding the character
staying at `separatorPos`. | 567 // Splits the `value` string into two `DependentString`s excluding the character
staying at `separatorPos`. |
| 568 // Useful for parsing. | 568 // Useful for parsing. |
| 569 std::pair<DependentString, DependentString> SplitString(const String& value, Str
ing::size_type separatorPos); | 569 std::pair<DependentString, DependentString> SplitString(const String& value, Str
ing::size_type separatorPos); |
| 570 | 570 |
| 571 ABP_NS_END | 571 ABP_NS_END |
| LEFT | RIGHT |