| 280 | }; // End class cripts::StringViewMixin |
| 281 | |
| 282 | class string : public std::string |
| 283 | { |
| 284 | using super_type = std::string; |
| 285 | using self_type = string; |
| 286 | |
| 287 | public: |
| 288 | using std::string::string; |
| 289 | |
| 290 | // ToDo: This broke when switching to swoc::TextView |
| 291 | // using std::string::operator cripts::string_view; |
| 292 | using super_type::operator+=; |
| 293 | using super_type::operator[]; |
| 294 | |
| 295 | self_type & |
| 296 | operator=(const self_type &str) |
| 297 | { |
| 298 | super_type::operator=(str); |
| 299 | return *this; |
| 300 | } |
| 301 | |
| 302 | self_type & |
| 303 | operator=(const cripts::string_view &str) |
| 304 | { |
| 305 | super_type::operator=(str); |
| 306 | return *this; |
| 307 | } |
| 308 | |
| 309 | self_type & |
| 310 | operator=(const char *str) |
| 311 | { |
| 312 | super_type::operator=(str); |
| 313 | return *this; |
| 314 | } |
| 315 | |
| 316 | string(const self_type &that) : super_type(that) {} |
| 317 | |
| 318 | // This allows for a std::string to be moved to a cripts::string |
| 319 | string(super_type &&that) : super_type(std::move(that)) {} |
| 320 | string(self_type &&that) noexcept : super_type(that) {} |
| 321 | |
| 322 | operator cripts::string_view() const { return {this->c_str(), this->size()}; } |
| 323 | |
| 324 | // Make sure to keep these updated with C++20 ... |
| 325 | self_type & |
| 326 | ltrim(char c = ' ') |
| 327 | { |
| 328 | this->erase(0, this->find_first_not_of(c)); |
| 329 | return *this; |
| 330 | } |
| 331 | |
| 332 | self_type & |
| 333 | rtrim(char c = ' ') |
| 334 | { |
| 335 | this->erase(this->find_last_not_of(c) + 1); |
| 336 | return *this; |
| 337 | } |
| 338 | |
| 339 | self_type & |